Announcement

Collapse
No announcement yet.

Combine OBX from matching value

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

  • Combine OBX from matching value

    Hello, I am on Mirth Connect Server 3.2.2.7694.

    I have an interface where I am trying to combine OBX's if a value in OBX.5 matches, and otherwise not combine them. More details below:

    RAW MESSAGE EXAMPLE:

    MSH|^~\&|TEST|TEST|||20160706113515||ORU^R01^ORU_R 01|C0706113515755369a56|P|2.5|||AL|AL
    PID|||B1002091^^^^MR||TEST^TESTFOUR||1989010800000 0|F||||||||||20023960
    PV1||B|---^BR06^BR06^SB||||||||||||||||59587|||||||||||||||| |||||||||||||||b05a94bc-3be7-4988-8b01-e23a7d447529^^^OBTV^EID
    OBR|1||39452^OBTV|NTE046^Event^99POB|||20160620055 745||||||||||||||||||F
    OBX|1|ST|NTE046-1^Event^99POB||Event: Presentation: Cephalic [PRESENTATION]||||||F|||20160620055745||John Doe
    OBR|2||39569^OBTV|NTE046^Event^99POB|||20160620055 745||||||||||||||||||F
    OBX|1|ST|NTE046-1^Event^99POB||Event: Presentation: All information gathered [PRESENTATION]||||||F|||20160620055745||John Doe
    OBR|3||39686^OBTV|NTE046^Event^99POB|||20160620055 745||||||||||||||||||F
    OBX|1|ST|NTE046-1^Event^99POB||Event: Fetal Lie: Longitudinal [FETALLIE]||||||F|||20160620055745||John Doe
    OBR|4||39800^OBTV|NTE046^Event^99POB|||20160620055 745||||||||||||||||||F
    OBX|1|ST|NTE046-1^Event^99POB||Event: Position: OA [POSITION]||||||F|||20160620055745||John Doe
    OBR|5||39903^OBTV|NTE046^Event^99POB|||20160620055 745||||||||||||||||||F
    OBX|1|ST|NTE046-1^Event^99POB||Event: Method: Manual [EXAMMETHOD]||||||F|||20160620055745||John Doe
    OBR|6||40010^OBTV|NTE046^Event^99POB|||20160620055 745||||||||||||||||||F
    OBX|1|ST|NTE046-1^Event^99POB||Event: Method: Completed by JSMITH [EXAMMETHOD]||||||F|||20160620055745||John Doe
    OBR|7||40133^OBTV|NTE046^Event^99POB|||20160620060 120||||||||||||||||||F
    OBX|1|ST|NTE046-1^Event^99POB||Event: Fluid Color: Clear [FLUIDCOLOR]||||||F|||20160620060120||John Doe
    OBR|8||40244^OBTV|NTE046^Event^99POB|||20160620060 120||||||||||||||||||F
    OBX|1|ST|NTE046-1^Event^99POB||Event: Fluid Odor: None [FLUIDODOR]||||||F|||20160620060120||John Doe
    OBR|9||40352^OBTV|NTE046^Event^99POB|||20160620060 120||||||||||||||||||F
    OBX|1|ST|NTE046-1^Event^99POB||Event: Fluid Amount: None [FLUIDAMT]||||||F|||20160620060120||John Doe
    OBR|10||40461^OBTV|NTE046^Event^99POB|||2016062006 0120||||||||||||||||||F
    OBX|1|ST|NTE046-1^Event^99POB||Event: Fluid Amount: Scant [FLUIDAMT]||||||F|||20160620060120||John Doe

    ENCODED MESSAGE:

    MSH|^~\&|TEST|TEST|||20160706113515||ORU^R01^ORU_R 01|C0706113515755369a56|P|2.5|||AL|AL
    PID|||B1002091^^^^MR||TEST^TESTFOUR||1989010800000 0|F||||||||||20023960
    PV1||B|---^BR06^BR06^SB||||||||||||||||59587|||||||||||||||| |||||||||||||||b05a94bc-3be7-4988-8b01-e23a7d447529^^^OBTV^EID
    OBR|1||39452^OBTV|NTE046^Event^99POB|||20160620055 745||||||||||||||||||F
    OBX|1|ST|PRESENTATION||Cephalic||||||F|||201606200 55745||John Doe
    OBR|2||39569^OBTV|NTE046^Event^99POB|||20160620055 745||||||||||||||||||F
    OBX|1|ST|PRESENTATION||All information gathered||||||F|||20160620055745||John Doe
    OBR|3||39686^OBTV|NTE046^Event^99POB|||20160620055 745||||||||||||||||||F
    OBX|1|ST|FETALLIE||Longitudinal||||||F|||201606200 55745||John Doe
    OBR|4||39800^OBTV|NTE046^Event^99POB|||20160620055 745||||||||||||||||||F
    OBX|1|ST|POSITION||OA||||||F|||20160620055745||Joh n Doe
    OBR|5||39903^OBTV|NTE046^Event^99POB|||20160620055 745||||||||||||||||||F
    OBX|1|ST|EXAMMETHOD||Manual||||||F|||2016062005574 5||John Doe
    OBR|6||40010^OBTV|NTE046^Event^99POB|||20160620055 745||||||||||||||||||F
    OBX|1|ST|EXAMMETHOD||Completed by JSMITH||||||F|||20160620055745||John Doe
    OBR|7||40133^OBTV|NTE046^Event^99POB|||20160620060 120||||||||||||||||||F
    OBX|1|ST|FLUIDCOLOR||Clear||||||F|||20160620060120 ||John Doe
    OBR|8||40244^OBTV|NTE046^Event^99POB|||20160620060 120||||||||||||||||||F
    OBX|1|ST|FLUIDODOR||None||||||F|||20160620060120|| John Doe
    OBR|9||40352^OBTV|NTE046^Event^99POB|||20160620060 120||||||||||||||||||F
    OBX|1|ST|FLUIDAMT||None||||||F|||20160620060120||J ohn Doe
    OBR|10||40461^OBTV|NTE046^Event^99POB|||2016062006 0120||||||||||||||||||F
    OBX|1|ST|FLUIDAMT||Scant||||||F|||20160620060120|| John Doe

    The problem is that our EMR is unable to process this message correctly because they need:
    - All matching values in OBX.3 to combine into one OBX segment, and to concatenate the values from OBX.5 into a single OBX.5 in the combined OBX segment. There should be a semicolon between (.
    - Note, the value in OBX.3 (Encoded) comes from the raw message in OBX.5 by scraping what is in between the brackets.
    - Note, the value in OBX.3 (Encoded) is a dynamic value that can be any of hundreds of values.
    - Note, when the values in OBX.3 match from one OBX to the next they are always together in OBX order.
    - The OBR segment that proceeds the matching OBR should be kept, and the duplicate OBR's should be removed.
    - The OBX segment in which the values are combined should be kept, and the OBX segments matched from should be removed.
    - Note, if you look at the encoded message you will see there are 3 values in OBX.3 that should each separately be combined (PRESENTATION, EXAMMETHOD, and FLUIDAMT). There are also values that are individual and should not be touched (FETALLIE, POSITION, FLUIDCOLOR, and FLUIDODOR). Again, these are examples of hundreds of possible values, and each may or may not have multiple segments that match.
    - Also, after deleting OBR's, the OBR segments may need to be reordered.

    For the above raw and encoded message, the GOAL would be to have this message come out:

    MSH|^~\&|TEST|TEST|||20160706113515||ORU^R01^ORU_R 01|C0706113515755369a56|P|2.5|||AL|AL
    PID|||B1002091^^^^MR||TEST^TESTFOUR||1989010800000 0|F||||||||||20023960
    PV1||B|---^BR06^BR06^SB||||||||||||||||59587|||||||||||||||| |||||||||||||||b05a94bc-3be7-4988-8b01-e23a7d447529^^^OBTV^EID
    OBR|1||39452^OBTV|NTE046^Event^99POB|||20160620055 745||||||||||||||||||F
    OBX|1|ST|PRESENTATION||Cephalic; All information gathered||||||F|||20160620055745||John Doe
    OBR|2||39686^OBTV|NTE046^Event^99POB|||20160620055 745||||||||||||||||||F
    OBX|1|ST|FETALLIE||Longitudinal||||||F|||201606200 55745||John Doe
    OBR|3||39800^OBTV|NTE046^Event^99POB|||20160620055 745||||||||||||||||||F
    OBX|1|ST|POSITION||OA||||||F|||20160620055745||Joh n Doe
    OBR|4||39903^OBTV|NTE046^Event^99POB|||20160620055 745||||||||||||||||||F
    OBX|1|ST|EXAMMETHOD||Manual;Completed by JSMITH||||||F|||20160620055745||John Doe
    OBR|5||40133^OBTV|NTE046^Event^99POB|||20160620060 120||||||||||||||||||F
    OBX|1|ST|FLUIDCOLOR||Clear||||||F|||20160620060120 ||John Doe
    OBR|6||40244^OBTV|NTE046^Event^99POB|||20160620060 120||||||||||||||||||F
    OBX|1|ST|FLUIDODOR||None||||||F|||20160620060120|| John Doe
    OBR|7||40352^OBTV|NTE046^Event^99POB|||20160620060 120||||||||||||||||||F
    OBX|1|ST|FLUIDAMT||None;Scant||||||F|||20160620060120||John Doe

    Here is the code that is being used to get the message from RAW to ENCODED in examples above. My attempts to get the final outcome are sloppy and therefore unhelpful and not included:

    for each (seg in msg..OBX) {
    if (seg['OBX.3']['OBX.3.2'].toString()=="Event")
    {
    var CodeValue =seg['OBX.5']['OBX.5.1'].toString().match("\\[.*]");
    seg['OBX.3']=CodeValue
    seg['OBX.3']=seg['OBX.3'].toString().replace(/[\[\]']+/g,"")
    seg['OBX.5']['OBX.5.1']=seg['OBX.5']['OBX.5.1'].toString().replace("Event: ","").replace(CodeValue,"");
    seg['OBX.5']['OBX.5.1']=seg['OBX.5']['OBX.5.1'].toString().substring(seg['OBX.5']['OBX.5.1'].indexOf(":") + 1).trim();
    }
    else {
    seg['OBX.3']=seg['OBX.3']['OBX.3.2'].toString()
    }
    if (seg['OBX.3'] == "Remark")
    {
    seg['OBX.5']['OBX.5.1']=seg['OBX.5']['OBX.5.1'].toString().replace("Remarks: ","")
    }
    }


    I understand this is a lot of information, and I hope it makes sense. I appreciate any assistance that anyone is able to provide.

    Thank you,

    Justin
Working...
X