Announcement

Collapse
No announcement yet.

copy an entire segment in JavaScript

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

  • copy an entire segment in JavaScript

    Using a JavaScript response transformer I'm building a HL7 message string. The string will be sent to another channel using router.routeMessage(). What I want to do is build the PID line from the the existing PID line. When I do this through a mapper variable the PID string is XML. Is there a way to do this without creating a mapper variable for each field in the the PID segment?
    Last edited by stephenprouse; 03-22-2016, 05:31 PM.

  • #2
    I'm able to do what I need by creating a mapper variable and using that mapper variable as below.

    Code:
    // If total score is >= 10 then create HL7 message and file queries to Meditech
    if (parseInt($('Total')) >= 10) {
    	var dtNow = DateUtil.getCurrentDate('yyyyMMddHHmmss');
    	var outFile = ""
    	var msh = "MSH|^~\\&|A|A|HIS|A|" + dtNow + "||ORU^R01|" + dtNow + "|P|2.5\r";
    	var pid = SerializerFactory.getSerializer('HL7V2').fromXML($('patientIdentification')) + "\r";
    	var obr = "OBR|||||||" + dtNow + "\r";
    	var obx1 = "OBX|1|NM|A.B||Yes||||||F\r";
    	var obx2 = "OBX|2|NM|A.C||" + $('Total') + "||||||F";
    	outFile = msh + pid + obr + obx1 + obx2;
    	connectorMap.put('outFile', outFile);
    	//router.routeMessage('CHANNEL1', outFile);
    }
    ...but is there a better way to reference the PID segment directly like below

    var pid = SerializerFactory.getSerializer('HL7V2').fromXML(msg['PID']) + "\r";

    Comment


    • #3
      try:

      var pid = SerializerFactory.getSerializer('HL7V2').fromXML(m sg.PID.copy())+ "\r";

      Comment


      • #4
        oops...typo. obviously "msg" not "m sg"

        Comment


        • #5
          thank you very much

          Comment


          • #6
            Code:
            var pid_5 = msg['PID']['PID.5'][0];
            msg['PID']['PID.5']="";
            msg['PID']['PID.5'][0] =  pid_5;

            Comment

            Working...
            X