Announcement

Collapse
No announcement yet.

Looping XML Diagnosis to HL7

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

  • Looping XML Diagnosis to HL7

    I need some guidance on looping the diagnosis field in an FT1 segment.
    XML may contain several diagnosis that needs to be iterated through the HL7 message on FT1.19.1/FT1.19.2/FT1.19.3 so on
    Converting XML to HL7.

    Snippet from XML:
    <Diagnoses>
    <Diagnosis>
    <SuperBillDiagnosisCodeID>52775742</SuperBillDiagnosisCodeID>
    <CodeTypeId>1</CodeTypeId>
    <CodeTypeName>ICD9</CodeTypeName>
    <Code>787.03</Code>
    <EHRSuperBillDiagnosisCodeDetailID>34645423</EHRSuperBillDiagnosisCodeDetailID>
    </Diagnosis>
    <Diagnosis>
    <SuperBillDiagnosisCodeID>52775743</SuperBillDiagnosisCodeID>
    <CodeTypeId>2</CodeTypeId>
    <CodeTypeName>ICD10</CodeTypeName>
    <Code>R11.10</Code>
    <EHRSuperBillDiagnosisCodeDetailID>34645423</EHRSuperBillDiagnosisCodeDetailID>
    </Diagnosis>.

    Originally I wrote it as:
    tmp['FT1']['FT1.19'][0]['FT1.19.1'] = validate(msg['Charges']['Charge']['Diagnoses']['Diagnosis'][0]['Code'].toString(), '', new Array());
    tmp['FT1']['FT1.19'][0]['FT1.19.2'] = validate(msg['Charges']['Charge']['Diagnoses']['Diagnosis'][0]['SuperBillDiagnosisCodeID'].toString().toString(), '', new Array());
    tmp['FT1']['FT1.19'][0]['FT1.19.3'] = validate(msg['Charges']['Charge']['Diagnoses']['Diagnosis'][0]['CodeTypeName'].toString(), '', new Array());
    tmp['FT1']['FT1.19'][1]['FT1.19.1'] = validate(msg['Charges']['Charge']['Diagnoses']['Diagnosis'][1]['Code'].toString(), '', new Array());
    tmp['FT1']['FT1.19'][1]['FT1.19.2'] = validate(msg['Charges']['Charge']['Diagnoses']['Diagnosis'][1]['SuperBillDiagnosisCodeID'].toString().toString(), '', new Array());
    tmp['FT1']['FT1.19'][1]['FT1.19.3'] = validate(msg['Charges']['Charge']['Diagnoses']['Diagnosis'][1]['CodeTypeName'].toString(), '', new Array());

    And this worked if we only expect 2 Diagnosis, but there could be more than 2 in each message,

    Created the 'for each' and 'logger.info' statement to pull out the codes:

    for each (seg in msg['Charges']['Charge']['Diagnoses'].children()) {
    //if (seg.name().toString() == "SEG") {
    var icd = seg['Code'].toString();
    var spID = seg['SuperBillDiagnosisCodeID'].toString();
    var icdT = seg['CodeTypeName'].toString();
    //}
    logger.info(icd)
    logger.info(spID)
    logger.info(icdT)

    }

    And the logger populates all of the fields:
    Example - [2017-05-08 13:24:19,429] INFO (transformer:?): 787.03


    How do I take those variables and populate them into their respective FT1.19 fields?

    Thank you.

    Update 5/9/17 found my fix thank you
    Last edited by mmonisky; 05-09-2017, 09:33 AM.

  • #2
    Was able to fix it.

    Comment


    • #3
      what was the fix?
      Best,

      Kirby

      Mirth Certified|Epic Bridges Certified|Cloverleaf Level 2 Certified

      Appliance Version 3.11.4
      Mirth Connect Version 3.8.0
      Java Version 1.6.0_45-b06
      Java (64 bit) Version 1.6.0_45-b06
      Java 7 (64 bit) Version 1.7.0_151-b15
      Java 8 (64 bit) Version 1.8.0_181-b13
      PostgreSQL Version 9.6.8

      Comment


      • #4
        This did the trick for me.

        var countFT1 = 0;
        var countICD = 0;


        //how many FT1 segments do we need?
        for each (seg in msg['Superbill']['Charges']['Charge']) //maps to FT1 segment
        {
        //create FT1 segment
        createSegment('FT1', tmp, countFT1);
        tmp['FT1'][countFT1]['FT1.1']['FT1.1.1'] = countFT1 + 1;
        tmp['FT1'][countFT1]['FT1.2']['FT1.2.1'] = seg['SuperBillDetailId'].toString();
        tmp['FT1'][countFT1]['FT1.4']['FT1.4.1'] = msg['Superbill']['BeginEventDate'].toString();
        tmp['FT1'][countFT1]['FT1.6']['FT1.6.1'] = msg['Superbill']['CompletedStatus']['SuperBillStatusID'].toString();
        tmp['FT1'][countFT1]['FT1.7']['FT1.7.1'] = seg['Procedure']['CodeTypeId'].toString();
        tmp['FT1'][countFT1]['FT1.7']['FT1.7.2'] = seg['Procedure']['Code'].toString();
        tmp['FT1'][countFT1]['FT1.7']['FT1.7.3'] = seg['Procedure']['CodeTypeName'].toString();
        tmp['FT1'][countFT1]['FT1.16']['FT1.16.1'] = msg['Superbill']['Location']['POSCode'].toString();
        tmp['FT1'][countFT1]['FT1.16']['FT1.16.4'] = msg['Superbill']['Location']['FacilityId'].toString();
        tmp['FT1'][countFT1]['FT1.16']['FT1.16.5'] = msg['Superbill']['Location']['LocationType'].toString();
        tmp['FT1'][countFT1]['FT1.16']['FT1.16.8'] = msg['Superbill']['Location']['LocationDescription'].toString();


        //how many diagnosis do we need?
        for each (seg in msg['Superbill']['Charges']['Charge']['Diagnoses'].children())
        {
        tmp['FT1'][countFT1]['FT1.19'][countICD] = seg['Code'].toString() + "^^" + seg['CodeTypeName'].toString();

        var spID = seg['SuperBillDiagnosisCodeID'].toString();
        var icdT = seg['CodeTypeName'].toString();

        //logger.info(icd)
        logger.info(spID)
        logger.info(icdT)

        countICD++;
        //logger.info("Diagnosis : " + seg);
        //logger.info("Diagnosis COUNT: " + countICD);

        }
        //increment FT1 segment counter
        countFT1++;
        logger.debug("countFT1: " + countFT1);


        }

        Comment

        Working...
        X