In order to extract the Patient ID (PATAA000000040) from the SOAP response below using JavaScript and insert it into a Mirth destination, we need to target the value under the livingSubjectId tag. It's important to note that this tag may repeat, but we should only consider the first iteration of livingSubjectId.
How would you implement this in JavaScript?
<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope
xmlns:S="http://www.w3.org/2003/05/soap-envelope">
<S:Body>
<ns3:RespondingGateway_PRPA_IN201306UV02Response
xmlns="urn:gov:hhs:fha:NwHINc:common:NwHINccommon"
xmlns:ns2="http://schemas.xmlsoap.org/ws/2004/08/addressing"
xmlns:ns3="urn:hl7-org:v3"
xmlns:ns4="urn:gov:hhs:fha:NwHINc:common:patientcorrelationfacade">
[SOAP Response Continued...]
This is an attempted solution:
msg = new XML(msg);
logger.info(msg);
var soap = new Namespace('http://www.w3.org/2003/05/soap-envelope');
var edeia = new Namespace('http://schemas.xmlsoap.org/ws/2004/08/addressing');
var PatientID = msg.soap::Body.edeia::controlActProcess.edeia::queryByParameter.edeia::livingSubjectId.toString();
logger.info(PatientID);
channelMap.put('PatientID',PatientID);
However, the following error occurred in Mirth:
Transformer error
ERROR MESSAGE: Error evaluating transformer
com.mirth.connect.server.MirthJavascriptTransformerException:
CHANNEL: Test SOAP Response
CONNECTOR: sourceConnector
SCRIPT SOURCE:
SOURCE CODE:
[Detailed error message continues...]