Convert XML to a Request Message which has HL7 segments
Hello,
We would need to convert a message from the following class:
{ Parameter RESPONSECLASSNAME = "Mensajes.Response.Laboratorio.ACKResponse";
Property mensaje As %XML.GlobalCharacterStream(CONTENT = "MIXED");
Property idPeticion As %String(MAXLEN = "");
Property ExpedienteUsuario As %String(MAXLEN = "");
Property MessageId As %String(MAXLEN = ""); Property ContentType As %String(MAXLEN = "");
to a Request message which is composed by hl7 segments:
{ Parameter RESPONSECLASSNAME = "Mensajes.Response.Laboratorio.ServicioRecepcionDatosPruebaResponse";
Property MSH As hl7.MSH.CONTENT; Property NTE As list Of hl7.NTE.CONTENT;
Property ORMO01PATIENT As EsquemasDatos.HUC.hl7.ORMO01.PATIENT.CONTENT;
Property ORMO01ORDER As list Of EsquemasDatos.HUC.hl7.ORMO01.ORDER.CONTENT;
Property SFT As list Of hl7.SFT.CONTENT; Property MSA As hl7.MSA.CONTENT;
Property ERR As list Of hl7.ERR.CONTENT;
We currently send the following message using HTTP via SOAPUI
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<ORM_O01>
<MSH>
<MSH.1>|</MSH.1>
<MSH.2>^~\&</MSH.2>
<MSH.3>
<HD.1>sistemaExterno</HD.1>
</MSH.3>
<MSH.4>
<HD.1>27</HD.1>
<HD.2>PRUEBAS.</HD.2>
</MSH.4>
<MSH.5>
<HD.1>380316</HD.1>
</MSH.5>
<MSH.6>
<HD.1>EXTHL7</HD.1>
</MSH.6>
<MSH.7>
<TS.1>20200429114820</TS.1>
</MSH.7>
<MSH.8>user:pass</MSH.8>
<MSH.9>
<MSG.1>ORM</MSG.1>
<MSG.2>O01</MSG.2>
<MSG.3>ORM_O01</MSG.3>
</MSH.9>
<MSH.10>65636</MSH.10>
<MSH.11>
<PT.1>E</PT.1>
</MSH.11>
<MSH.12>
<VID.1>2.5</VID.1>
</MSH.12>
<MSH.13>1</MSH.13>
<MSH.16>AL</MSH.16>
<MSH.18>ASCII</MSH.18>
</MSH>
<ORM_O01.PATIENT>
<PID>
<PID.1>1</PID.1>
<PID.2>
<CX.1>FCCT540403904019</CX.1>
</PID.2>
<PID.3>
<CX.1>11645069</CX.1>
<CX.4>
<HD.1>MPI</HD.1>
</CX.4>
<CX.5>11645069</CX.5>
</PID.3>
<PID.3>
<CX.1>FCCT540403904019</CX.1>
<CX.4>
<HD.1>TISR</HD.1>
</CX.4>
<CX.5>FCCT540403904019</CX.5>
</PID.3>
<PID.3>
<CX.1>92920000T</CX.1>
<CX.4>
<HD.1>DNI</HD.1>
</CX.4>
<CX.5>92920000T</CX.5>
</PID.3>
<PID.4>
<CX.1>11645069</CX.1>
</PID.4>
<PID.5>
<XPN.1>
<FN.1>CIUDADANO</FN.1>
</XPN.1>
<XPN.2>FICTICIO</XPN.2>
<XPN.3>ACTIVO</XPN.3>
</PID.5>
<PID.7>
<TS.1>19540403000000</TS.1>
</PID.7>
<PID.8>M</PID.8>
<PID.11>
<XAD.1>
<SAD.1>C/</SAD.1>
<SAD.2>ABREU Y GALINDO, 5</SAD.2>
<SAD.3>6</SAD.3>
</XAD.1>
<XAD.2>87</XAD.2>
<XAD.4>28</XAD.4>
<XAD.5>35001</XAD.5>
</PID.11>
<PID.13>
<XTN.1>922000000</XTN.1>
</PID.13>
<PID.19>380000012304</PID.19>
<PID.30>N</PID.30>
<PID.31>N</PID.31>
</PID>
<PD1>
<PD1.1>1</PD1.1>
</PD1>
<ORM_O01.PATIENT_VISIT>
<PV1>
<PV1.1>1</PV1.1>
<PV1.2>1</PV1.2>
<PV1.7>
<XCN.1>DAMIAN ALVAREZ PEREZ</XCN.1>
</PV1.7>
<PV1.8>
<XCN.8>27950104</XCN.8>
</PV1.8>
<PV1.10>APLP</PV1.10>
<PV1.11>
<PL.1>27</PL.1>
</PV1.11>
<PV1.15>27</PV1.15>
<PV1.30>20200429</PV1.30>
<PV1.35>20200429</PV1.35>
<PV1.50>
<CX.1>11645069</CX.1>
<CX.2>LABAP</CX.2>
</PV1.50>
</PV1>
</ORM_O01.PATIENT_VISIT>
</ORM_O01.PATIENT>
<ORM_O01.ORDER>
<ORC>
<ORC.1>HD</ORC.1>
<ORC.3>
<EI.1>11111</EI.1>
</ORC.3>
<ORC.7>
<TQ.6>1</TQ.6>
</ORC.7>
<ORC.8>
<EIP.1>
<EI.1>65639</EI.1>
</EIP.1>
</ORC.8>
<ORC.10>
<XCN.1>43794017Q</XCN.1>
</ORC.10>
<ORC.13>
<PL.1>CON</PL.1>
</ORC.13>
<ORC.16>
<CE.1>PC</CE.1>
<CE.2>V73.89 CRIBADO PARA DETECCIÓN DEL SARS-CoV-2 ( COVID-19 )</CE.2>
</ORC.16>
</ORC>
<ORM_O01.ORDER_DETAIL>
<ORM_O01.OBRRQDRQ1RXOODSODT_SUPPGRP>
<OBR>
<OBR.1>24398 - SARS-CoV-2 (PCR). (Exudado nasofaríngeo)</OBR.1>
<OBR.4>
<CE.1>1113</CE.1>
<CE.2>Coronavirus 2019-nCov (PCR).(Exudado nasofaríngeo)</CE.2>
</OBR.4>
<OBR.18>LAB</OBR.18>
<OBR.19>LAB</OBR.19>
</OBR>
</ORM_O01.OBRRQDRQ1RXOODSODT_SUPPGRP>
<NTE>
<NTE.3>Datos clínicos de interés%%%Cribado COVID-19:
@@@Colectivo%%%PROFESIONAL SANITARIO
@@@Código de residencia - centro sanitario%%%38010
@@@¿Síntomas de infección respiratoria?%%%SI
@@@Fiebre%%%SI
@@@Tos%%%SI
@@@Disnea%%%SI
@@@Toma de muestras para PCR%%%SI
@@@Solicitud de PCR COVID%%%12354
@@@Resultado test rápido Covid19 IgM%%%POSITIVO
@@@Resultado test rápido Covid19 IgG%%%POSITIVO
@@@Resultado PCR COVID%%%pte lab
@@@Observaciones Cribado COVID%%%fdfdfderhekrhkehrkhekwrhkehwrkhe
</NTE.3>
</NTE>
</ORM_O01.ORDER_DETAIL>
</ORM_O01.ORDER>
</ORM_O01>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
In the process we use the following code to get just the ORM, and use the ITB function to try to parse it from XML to HL7:
set context.mensaje = $PIECE($PIECE(context.mensaje,"</SOAP-ENV:Body>"),"<SOAP-ENV:Body>",2)
$$$LOGINFO("mensaje sin cabeceras: "_context.mensaje)
set mensajeXML = ##class(%GlobalCharacterStream).%New()
do mensajeXML.Write(context.mensaje)
while mensajeXML.AtEnd=0 {
set linea = mensajeXML.Read()
}
do mensajeXML.Rewind()
$$$LOGINFO("linea: "_linea)
set context.mensajeHL7 = ##class(EnsLib.HL7.Message).%New()
set context.mensajeHL7 = ##class(ITB.HL7.Util.Convert).XMLToER7(mensajeXML, .status,"2.5")
//$$$LOGINFO("status: "_status)
$$$LOGINFO($system.Status.GetErrorText(status))
$$$LOGINFO("context.mensajeHL7: "_context.mensajeHL7)
In the trace we see:
And the exception:
We have also tried to just copy the entire ORM message directly into the process, with the following code:
set context.mensaje = $PIECE($PIECE(context.mensaje,"</SOAP-ENV:Body>"),"<SOAP-ENV:Body>",2)
$$$LOGINFO("mensaje sin cabeceras: "_context.mensaje)
set mensajeXML = ##class(%GlobalCharacterStream).%New()
do mensajeXML.Write($zcvt("<ORM_O01> <MSH> <MSH.1>|</MSH.1> <MSH.2>^~\&</MSH.2> <MSH.3> <HD.1>sistemaExterno</HD.1> </MSH.3> <MSH.4> <HD.1>27</HD.1> <HD.2>PRUEBAS DRAGO.</HD.2> </MSH.4> <MSH.5> <HD.1>380316</HD.1> </MSH.5> <MSH.6> <HD.1>EXTHL7</HD.1> </MSH.6> <MSH.7> <TS.1>20200429114820</TS.1> </MSH.7> <MSH.8>scsdaeint:VXSn0jEG0Om2MIpyxynHAA==</MSH.8> <MSH.9> <MSG.1>ORM</MSG.1> <MSG.2>O01</MSG.2> <MSG.3>ORM_O01</MSG.3> </MSH.9> <MSH.10>65636</MSH.10> <MSH.11> <PT.1>E</PT.1> </MSH.11> <MSH.12> <VID.1>2.5</VID.1> </MSH.12> <MSH.13>1</MSH.13> <MSH.16>AL</MSH.16> <MSH.18>ASCII</MSH.18> </MSH> <ORM_O01.PATIENT> <PID> <PID.1>1</PID.1> <PID.2> <CX.1>FCCT540403904019</CX.1> </PID.2> <PID.3> <CX.1>11645069</CX.1> <CX.4> <HD.1>MPI</HD.1> </CX.4> <CX.5>11645069</CX.5> </PID.3> <PID.3> <CX.1>FCCT540403904019</CX.1> <CX.4> <HD.1>TISR</HD.1> </CX.4> <CX.5>FCCT540403904019</CX.5> </PID.3> <PID.3> <CX.1>92920000T</CX.1> <CX.4> <HD.1>DNI</HD.1> </CX.4> <CX.5>92920000T</CX.5> </PID.3> <PID.4> <CX.1>11645069</CX.1> </PID.4> <PID.5> <XPN.1> <FN.1>CIUDADANO</FN.1> </XPN.1> <XPN.2>FICTICIO</XPN.2> <XPN.3>ACTIVO</XPN.3> </PID.5> <PID.7> <TS.1>19540403000000</TS.1> </PID.7> <PID.8>M</PID.8> <PID.11> <XAD.1> <SAD.1>C/</SAD.1> <SAD.2>ABREU Y GALINDO, 5</SAD.2> <SAD.3>6</SAD.3> </XAD.1> <XAD.2>87</XAD.2> <XAD.4>28</XAD.4> <XAD.5>35001</XAD.5> </PID.11> <PID.13> <XTN.1>922000000</XTN.1> </PID.13> <PID.19>380000012304</PID.19> <PID.30>N</PID.30> <PID.31>N</PID.31> </PID> <PD1> <PD1.1>1</PD1.1> </PD1> <ORM_O01.PATIENT_VISIT> <PV1> <PV1.1>1</PV1.1> <PV1.2>1</PV1.2> <PV1.7> <XCN.1>DAMIAN ALVAREZ PEREZ</XCN.1> </PV1.7> <PV1.8> <XCN.8>27950104</XCN.8> </PV1.8> <PV1.10>APLP</PV1.10> <PV1.11> <PL.1>27</PL.1> </PV1.11> <PV1.15>27</PV1.15> <PV1.30>20200429</PV1.30> <PV1.35>20200429</PV1.35> <PV1.50> <CX.1>11645069</CX.1> <CX.2>LABAP</CX.2> </PV1.50> </PV1> </ORM_O01.PATIENT_VISIT> </ORM_O01.PATIENT> <ORM_O01.ORDER> <ORC> <ORC.1>HD</ORC.1> <ORC.3> <EI.1>11111</EI.1> </ORC.3> <ORC.7> <TQ.6>1</TQ.6> </ORC.7> <ORC.8> <EIP.1> <EI.1>65639</EI.1> </EIP.1> </ORC.8> <ORC.10> <XCN.1>43794017Q</XCN.1> </ORC.10> <ORC.13> <PL.1>CON</PL.1> </ORC.13> <ORC.16> <CE.1>PC</CE.1> <CE.2>V73.89 CRIBADO PARA DETECCIÓN DEL SARS-CoV-2 ( COVID-19 )</CE.2> </ORC.16> </ORC> <ORM_O01.ORDER_DETAIL> <ORM_O01.OBRRQDRQ1RXOODSODT_SUPPGRP> <OBR> <OBR.1>24398 - SARS-CoV-2 (PCR). (Exudado nasofaríngeo)</OBR.1> <OBR.4> <CE.1>1113</CE.1> <CE.2>Coronavirus 2019-nCov (PCR).(Exudado nasofaríngeo)</CE.2> </OBR.4> <OBR.18>LAB</OBR.18> <OBR.19>LAB</OBR.19> </OBR> </ORM_O01.OBRRQDRQ1RXOODSODT_SUPPGRP> <NTE> <NTE.3>Datos clínicos de interés%%%Cribado COVID-19: @@@Colectivo%%%PROFESIONAL SANITARIO @@@Código de residencia - centro sanitario%%%38010 @@@¿Síntomas de infección respiratoria?%%%SI @@@Fiebre%%%SI @@@Tos%%%SI @@@Disnea%%%SI @@@Toma de muestras para PCR%%%SI @@@Solicitud de PCR COVID%%%12354 @@@Resultado test rápido Covid19 IgM%%%POSITIVO @@@Resultado test rápido Covid19 IgG%%%POSITIVO @@@Resultado PCR COVID%%%pte lab @@@Observaciones Cribado COVID%%%fdfdfderhekrhkehrkhekwrhkehwrkhe </NTE.3> </NTE> </ORM_O01.ORDER_DETAIL> </ORM_O01.ORDER> </ORM_O01>","O","UTF8"))
while mensajeXML.AtEnd=0 {
set linea = mensajeXML.Read()
}
do mensajeXML.Rewind()
$$$LOGINFO("linea: "_linea)
set context.mensajeHL7 = ##class(EnsLib.HL7.Message).%New()
set context.mensajeHL7 = ##class(ITB.HL7.Util.Convert).XMLToER7(mensajeXML, .status,"2.5")
//$$$LOGINFO("status: "_status)
$$$LOGINFO($system.Status.GetErrorText(status))
$$$LOGINFO("context.mensajeHL7: "_context.mensajeHL7)
And we observe in the trace:
And the exception is:
In both cases the mensajeHL7, is empty:
We have also read:
https://community.intersystems.com/post/convert-hl7-xml
https://community.intersystems.com/post/how-work-undefined-value-correla...
How could we parse a XML message and convert it ➡️ into a request message which is composed by hl7 segments?
Hi Yone,
Try to append in the bigginer of you XML Strign the XML declarion:
In the line:
Try:
do mensajeXML.Write($zcvt("<?xml version="1.0" encoding="utf-8"?> <ORM_O01>........
And check if had some character that can cause the <SINTAX > error in the cos.