How to read from a JSON File and convert to HL7 message
Hi Community,
I am trying to read a JSON file and convert into HL7 message.Please find the example below
Set Jsonobj={"Doctype":"ADT^A01","PatientId":"123","PatientName":"Alex"}
Set Dynjsonobj=
Error :<THROW>%FromJSON+37^%Library.DynamicAbstractObject.1 *%Exception.General READ error while reading input stream 10 Line 1 Offset 0
I am getting this error while reading the file,Can you please tell me where i am doing wrong in converting the file?
Joe
Product version: Ensemble 2018.1
$ZV: Cache for Windows (x86-64) 2018.1.1 (Build 312_1_18937U) Fri Apr 26 2019 17:58:36 EDT
by using {} your Jsonobj is already a %Library.DynamicObject
USER> ZWRITE Jsonobj
Jsonobj=<OBJECT REFERENCE>[1@%Library.DynamicObject]
no need for
Set Dynjsonobj=##class(%Library.DynamicObject).%FromJSON(Jsonobj)
Hi Robert
I have tried by giving Set Dynjsonobj={}.%FromJSON(Jsonobj) it is throwing below error
<THROW>%FromJSON+37^%Library.DynamicAbstractObject.1 *%Exception.General READ error while reading input stream 10 Line 1 Offset 0
Is there any way i can read from the JSON object
if you insist on that line you need
Set Jsonobj="{""Doctype"":""ADT^A01"",""PatientId"":""123"",""PatientName"":""Alex""}"
Thank you Robert, It worked.
Set Jsonobj="{""Doctype"":""ADT^A01"",""PatientId"":""123"",""PatientName"":""Alex""}"
set dynmicobj={}.%FromJSON(Jsonobj)
Set HL7Obj=##Class(EnsLib.HL7.Message).%New(dynmicobj)
---> here i am trying to open an Object trying to Convert JSON to HL7 message
Can you share any ideas how can i proceed from this steps to convert into HL7 message ?
Sorry, HL7 is not my world.
Hi @Joe Jones !
Take a look at the following sample app by @Guillaume Rongier - it contains FHIR to HL7 transformation example, which is in fact JSON to HL7 also.
Thank you for giving the example i will look into it
I created a class for the JSON message and then used a data transformation in Ensemble/IRIS to transform the JSON message to an HL7 message.
Hi , Can you share the class you created.