Json Parsing in Mirth OR Json in Mirth OR HL7 for JSON in Mirth

I want to use JSON as input channel mirth and output as information Save in db or Create HL7.

In short Input as JSON Parse and output it as any format.

+4
source share
4 answers
var object = {};

//Create JSON Object from HL7 Message.
object.mrn = msg['PID']['PID.3']['PID.3.1'].toString();
object.firstName = msg['PID']['PID.5']['PID.5.2'].toString();
object.lastName = msg['PID']['PID.5']['PID.5.1'].toString();
object.dob = msg['PID']['PID.7']['PID.7.1'].toString();
object.ssn = msg['PID']['PID.19']['PID.19.1'].toString();

//Create string from JSON Object.
var objjson = JSON.stringify(object);
logger.info(objjson);

//Create Json Object From JSON string.
var tt = JSON.parse(objjson);

Exit

{"mrn":"1001","firstName":"COLLEEN","lastName":"OHALLAHAN","dob":"19850704","ssn":"123456789"}

Sample HL7Message

MSH|^~\&|ADT1|SHM|SHMADT|SHM|200812091126|SECURITY|ADT^A01^ADT_A01|MSG00001|P|2.5|
EVN|A01|200812091126||
PID|1|1001|1001^5^M11^ADT1^MR^SHM||OHALLAHAN^COLLEEN^^||19850704|F||2106-3|1200 N ELM STREET^^NEWPORT BEACH^CA^92660-1020^US^H|OC|(949) 555-1234|(949) 555-5678||S||PATID1001^2^M10^ADT1^AN^A|123456789|U1234567^CA|
NK1|1|OHALLAHAN^BRITTANY^M|SIS^SISTER||||N^NEXT-OF-KIN
PV1|1|I|2000^2012^01||||001122^ZOIDBERG^JOHN^|||SUR||||1|A0|
+5
source

I parsed this page and found your Rikin patel code. In fact, when you create an object and display it, it can appear in the console as data JSON, when it looks in normal format when viewing your output XML. But instead of an object, when you use msg, as shown below:

msg = JSON.stringify(object); //converting msg into JSON object
logger.info("json data:" + msg); //displaying the JSOn message

You will find the data that will be changed at the output.

+5
source

Per @Debugger, - json /, .

  • Javascript

JavaScript Transformer:

//Create Json Object From JSON string.
var objJson = JSON.parse(messageObject.getRawData());

logger.info(objJson.propertyName);

:

{"mrn":"1001","firstName":"COLLEEN","lastName":"OHALLAHAN","dob":"19850704","ssn":"123456789"}

:

logger.info(objJson.firstName);

COLLEEN

:

connectorMessage.getRawData() messageObject.getRawData() Mirth 3.0+.

+3

JSON mirth, , Json json.

json, , DB writer db. hl7, mirth , createSegment (seg name, index), hl7.

0

Source: https://habr.com/ru/post/1527855/


All Articles