Announcement

Collapse
No announcement yet.

HL7 query response built with web service response

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

  • HL7 query response built with web service response

    I’m looking for the best practices to create a channel that accepts a HL7 query (TCP) and return the HL7 query result. The response is built after a web service call that returns extra information.

    Query generated by the client software :
    MSH|^~\&|SOFT|||| Date ||QRY^A19|45|P|2.x
    QRD|QueryDate|R|I|GETPAT1454|||1^&RD|800325|DEM^SO FT


    Expected response structure [simplified] (outbound template on “Destination 1”) :

    MSH|^~\&| SOFT || SOFT ||Date||COR^A19|1|P|2.x
    PID|||Number|800325|Name^Firstname^^^ |DoB|M|||Road 12^^City^^ZipCode^Country|||Sex|


    Mirth Connect Channel Configuration
    Source
    Connector Type = TCP Listener / Basic TCP on 6661 (Basic TCP is used because MLLP is not supported by the software => the query message does not start with a VT so we need to customize the message delimiter: <Message Data><FS><CR>)
    - Source Queue = OFF
    - Response = ReturnResponse (variable)
    - Encoding Windows-1252
    - 3 transformers are needed to extract query parameters
    Destination 1
    - Connector Type = Web Service Reader that returns a SOAP response and use the extracted parameters during the source transformation (Two-way without authentication)
    - The Soap response will be converted to an HL7 query response with 3 Response scripts (2 message builders + 1 JavaScript)
    - The script use responseMap.put("ReturnResponse", ResponseFactory.getSentResponse(SerializerFactory. getSerializer('HL7V2').fromXML(tmp)));
    - Return the result on the same connection that used by the query
    Scripts => none

    Q1. Convert Web Service response to HL7 using the Response Script
    - What’s the best practice to do that?
    - I use an outbound template and when I try to change a value with JavaScript Builder, it automatically add a new segment even if it is already present in the outbound template

    For example:
    tmp['PID']['PID.1']['PID.1.1']=$('RequeteValeur'); => will add another PID segment.
    But when I use the message builder BEFORE the JavaScript Response , it works perfectly

    Q2. Add a carriage return after the last line (I check the outbound template and that should be ok)
    - I have unchecked “Convert line breaks” in “Outbound properties” window it works but when I do that the outbound template tree cannot be used

    Thanks for your time !

  • #2
    Originally posted by achtus View Post
    Q1. Convert Web Service response to HL7 using the Response Script
    - What’s the best practice to do that?
    - I use an outbound template and when I try to change a value with JavaScript Builder, it automatically add a new segment even if it is already present in the outbound template

    For example:
    tmp['PID']['PID.1']['PID.1.1']=$('RequeteValeur'); => will add another PID segment.
    But when I use the message builder BEFORE the JavaScript Response , it works perfectly
    If tmp does not contain a PID segment and you set "tmp['PID']... = ...", then yes a PID segment will be automatically appended. That's expected. I have no idea what you're doing in the Message Builder step. If you post your channel it would be easier for people here to troubleshoot.

    Originally posted by achtus View Post
    Q2. Add a carriage return after the last line (I check the outbound template and that should be ok)
    - I have unchecked “Convert line breaks” in “Outbound properties” window it works but when I do that the outbound template tree cannot be used

    Thanks for your time !
    I think you have some misunderstandings about what the data type properties do. The Convert Line Breaks property only applies to the serialization of the outbound template. It is not true that the "tree cannot be used" in that case. Instead, you probably didn't have a valid HL7 message in the template itself (with CRs). When Convert Line Breaks is disabled, only carriage returns are considered to delimit segments, as per the HL7 specifications. In any case, why do you need to disable that in the first place? If you don't have a good reason or you don't know what it does, generally you will want to leave it alone.
    Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

    Nicholas Rupley
    Work: 949-237-6069
    Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


    - How do I foo?
    - You just bar.

    Comment


    • #3
      Thank you for your answer !

      Q1 : I try to set PID and MSH values in Javascript. I'm probably doing something wrong The 2 message builder expressions before the Javascript work perfectly.
      So I assume that :
      - The hl7 outbound template is not valid/correct > Mirth does not recognize it like a valid HL7 and "ignore" it
      - The tmp should be initialized. But how ? I use logger.info(SerializerFactory.getSerializer('HL7V2 ').fromXML(tmp)) just before fixing any values and I got the template in the console.
      - I'm a n00b <= probably the best answer btw

      Part of the Javascript (Response builder)

      Code:
      tmp['MSH']['MSH.7']['MSH.7.1']=dateString.toString();
      tmp['PID']['PID.2']['PID.2.1']=objetResultat.Patient.NumeroPatient.toString();
      tmp['PID']['PID.3']['PID.3.1']=objetResultat.Patient.Niss.toString();
      tmp['PID']['PID.4']['PID.4.1']=objetResultat.Patient.NumeroPatient.toString();
      Response

      Code:
      MSH|^~\&|MirthConnect||MirthConnect||200811111017||ADR^A19|179|P|2.4
      PID|123|456|10000437363|508003|Bremer^Hans^^^||19631101|M|||Mercedesstr 12^^Bergheim^^68123^D|||||M|
      MSH|||||||20140605154921
      PID||24756|123456789|24756|Foo^Bar||1970101|F|||^^^^^|||||U
      Q2 : Yes I made a mistake in the outbound template. I removed CR between segment so the HL7 template was wrong.
      Attached Files

      Comment


      • #4
        Originally posted by achtus View Post
        Q1 : I try to set PID and MSH values in Javascript. I'm probably doing something wrong The 2 message builder expressions before the Javascript work perfectly.
        So I assume that :
        - The hl7 outbound template is not valid/correct > Mirth does not recognize it like a valid HL7 and "ignore" it
        - The tmp should be initialized. But how ? I use logger.info(SerializerFactory.getSerializer('HL7V2 ').fromXML(tmp)) just before fixing any values and I got the template in the console.
        - I'm a n00b <= probably the best answer btw
        Part of the Javascript (Response builder)
        I found this snippet to get around

        var deserializationProperties = SerializerFactory.getDefaultDeserializationPropert ies('HL7V2');
        var templateTempo = SerializerFactory.getSerializer('HL7V2', null, deserializationProperties).fromXML(tmp);
        tmp = new XML(SerializerFactory.getSerializer('HL7V2').toXML (templateTempo));

        Comment

        Working...
        X