Announcement

Collapse
No announcement yet.

HL7 to XML conversion

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • HL7 to XML conversion

    I am trying to convert an HL7 message to XML using Mirth hl7toXML using Mirth 2.5.2 but the output doesn’t match what I need. I have attached my channel if that helps.

    In the source transformer I have HL7 template as

    Code:
    MSH|^~\&|Test|Test|||20180207113307-05:00||ORU^R31^ORU-R31|17|P|2.6
    PID|1||PID9||Smith1^O^A||19621023|M
    OBR|1|||C8|||20120326103912-04:00||||O||||CORD
    OBX|1|ST|20570-8^HCT^LN||<10|%PCV||L|||F|||||||316366|20120326103912-04:00
    OBX|2|ST|11558-4^PH^LN||7.277||||||F|||||||316366|20120326103912-04:00
    OBX|3|ST|115576^PCO2^LN||49.2|mmHg|||||F|||||||316366|20120326103912-04:00

    And as XML template I have
    Code:
    <OBS.R01>
      <HDR>
        <HDR.message_type V="OBS.R01" />
        <HDR.control_id V="" />
        <HDR.version_id V="POCT1" />
        <HDR.creation_dttm V="2016-03-01T10:38:36.72-05:00" />
      </HDR>
      <SVC>
        <SVC.role_cd V="OBS" DN="" />
        <SVC.observation_dttm V="2013-01-02T17:36:52-05:00" />
        <SVC.apoc_starcode V="NST" DN="" />
        <PT>
          <PT.patient_id V="123405" />
          <PT.birth_date V="" />
          <OBS>
            <OBS.observation_id V=" " DN="" SN="ABT" SV="" />
            <OBS.value V="" U=" " />
            <OBS.apoc_desc V=" " />
            <OBS.method_cd V=" " DN="" />
            <OBS.status_cd V=" " DN="" />
            <OBS.interpretation_cd V=" " DN="" />
            <OBS.apoc_int_qc_l1 V="P" DN="" />
            <OBS.apoc_int_qc_l2 V="P" DN="" />
            <OBS.apoc_int_qc_l3 V="P" DN="" />
          </OBS>
          <ISC>
            <ISC.apoc_channel V="9" />
            <ISC.apoc_config V="AMP" DN="" />
          </ISC>
          <ISC>
            <ISC.apoc_channel V="10" />
            <ISC.apoc_config V="POT" DN="" />  
          </ISC>
        </PT>
        <OPR>
          <OPR.operator_id V="5" />      
        </OPR>
        <RGT>
          <RGT.name V="C8" />      
          <RGT.apoc_validation_code V="X" DN="" />
        </RGT>
        <ENV>
          <ENV.apoc_amb_temperature V=" " />
          <ENV.apoc_calc_pressure V=" " />      
        </ENV>
        <RSN>
          <RSN.apoc_prompt V="Delivery System" />
          <RSN.apoc_entry V="PST" DN="" />
        </RSN>
        <RSN>
          <RSN.apoc_prompt V=" " />      
          <RSN.apoc_entry V="PRE" DN="" />
        </RSN>
        <NTE>
          <NTE.text V="reviewed" />
        </NTE>
      </SVC>
    </OBS.R01>
    After adding iterator to loops throw OBX it creates new segment at the end of my template instead of creating new OBS after the available one.
    Code:
    <OBS.R01>
      <HDR>
        <HDR.message_type V="OBS.R01" />
        <HDR.control_id V="" />
        <HDR.version_id V="POCT1" />
        <HDR.creation_dttm V="2016-03-01T10:38:36.72-05:00" />
      </HDR>
      <SVC>
        <SVC.role_cd V="OBS" DN="" />
        <SVC.observation_dttm V="2013-01-02T17:36:52-05:00" />
        <SVC.apoc_starcode V="NST" DN="" />
        <PT>
          <PT.patient_id V="123405" />
          <PT.birth_date V="" />
          <OBS>
            <OBS.observation_id V=" " DN="" SN="ABT" SV="" />
            <OBS.value V="" U=" " />
            <OBS.apoc_desc V=" " />
            <OBS.method_cd V=" " DN="" />
            <OBS.status_cd V=" " DN="" />
            <OBS.interpretation_cd V=" " DN="" />
            <OBS.apoc_int_qc_l1 V="P" DN="" />
            <OBS.apoc_int_qc_l2 V="P" DN="" />
            <OBS.apoc_int_qc_l3 V="P" DN="" />
          </OBS>
          <ISC>
            <ISC.apoc_channel V="9" />
            <ISC.apoc_config V="AMP" DN="" />
          </ISC>
          <ISC>
            <ISC.apoc_channel V="10" />
            <ISC.apoc_config V="POT" DN="" />  
          </ISC>
        </PT>
        <OPR>
          <OPR.operator_id V="5" />      
        </OPR>
        <RGT>
          <RGT.name V="C8" />      
          <RGT.apoc_validation_code V="X" DN="" />
        </RGT>
        <ENV>
          <ENV.apoc_amb_temperature V=" " />
          <ENV.apoc_calc_pressure V=" " />      
        </ENV>
        <RSN>
          <RSN.apoc_prompt V="Delivery System" />
          <RSN.apoc_entry V="PST" DN="" />
        </RSN>
        <RSN>
          <RSN.apoc_prompt V=" " />      
          <RSN.apoc_entry V="PRE" DN="" />
        </RSN>
        <NTE>
          <NTE.text V="reviewed" />
        </NTE>
      </SVC>
        <SVC>
            <PT>
                <OBS>
                    <OBS.observation_id V="PH"/>
                </OBS>
            </PT>
        </SVC>
        <SVC>
            <PT>
                <OBS>
                    <OBS.observation_id V="PCO2"/>
                </OBS>
            </PT>
        </SVC>
    </OBS.R01>
    Attached Files

  • #2
    Can any one point me to the right direction or just give a hint what i am doing wrong in my channel ?

    Comment


    • #3
      You're using version 3.5.2, not 2.5.2. I initially skipped over this one because I've never used mirth pre-3.0.

      In your iterator, I think you want to change
      Code:
      tmp['SVC'][i]['PT']['OBS']['OBS.observation_id']['@V']
      to
      Code:
      tmp['SVC']['PT']['OBS'][i]['OBS.observation_id']['@V']

      Comment


      • #4
        Thanks @agermano it did work but instead of using the entire OBS blog it only adds value for the mapping. I need to keep same structure and if no value found keep that empty. I do have template copied in my outbound message still no luck.

        I need following format

        Code:
             <OBS>
                <OBS.observation_id V="" DN="" SN="NA" SV="" />
                <OBS.value V="" U="" />
                <OBS.apoc_desc V="" />
                <OBS.method_cd V="" DN="" />
                <OBS.status_cd V="" DN="" />
                <OBS.interpretation_cd V="" DN="" />
                <OBS.apoc_int_qc_l1 V="" DN="" />
                <OBS.apoc_int_qc_l2 V="" DN="" />
                <OBS.apoc_int_qc_l3 V="" DN="" />
              </OBS>
        But if output as below

        Code:
                    <OBS>
                        <OBS.observation_id V="NA"/>
                    </OBS>

        Comment


        • #5
          Try putting this in a javascript step before your iterator. It will make a copy of the entire empty OBS section in your template for every OBX in your inbound message. Then your iterator can fill it in instead of creating a new section.

          I'm assuming what you tried previously did what you wanted for the first OBX, but not the ones after that?

          Code:
          var OBS_template = tmp.SVC.PT.OBS.copy();
          for (var i = 1; i < msg.OBX.length(); i++) {
              tmp.SVC.PT.OBS += OBS_template;
          }

          Comment


          • #6
            You are the best Got the format so now i can modify and move forward. Lot more to learn

            Comment

            Working...
            X