ChatGPT to create message transformations for you?
Tags: ai, chatgpt, programming, beginners
Published: 2023-11-23 18:50:07

<h2>A "big" or "small" ask for ChatGPT?</h2>
<p><br><a href="https://community.intersystems.com/post/gpts-implications-healthcare-interoperability-protocols" target="_blank">I tried OpenAI GPT's coding model a couple of weeks ago, to see whether it can do&nbsp;e.g. some&nbsp;message transformations&nbsp;</a>between healthcare protocols. It surely "can", to a seemingly&nbsp;fair degree.&nbsp;<br><br>It has been nearly 3&nbsp;weeks, and it's a long, long time for ChatGPT, so I am wondering how quickly it grows up by now, and whether it could do some of integration&nbsp;engineer jobs for us, e.g. can it&nbsp;create an InterSystems COS DTL tool to turn the HL7 into FHIR message?&nbsp;</p>
<p>Immediately I got some quick answers, in less than one&nbsp;minute or two.</p>
<h2><br>Test</h2>
<p>First I want to test I am talking to the right "guy" behind it.</p>
<hr>
<p><strong>Question 1:&nbsp;&nbsp;how to convert HL7 V2.4 messages to FHIR STU3?</strong></p>
<hr>
<p><strong>ChatGPT</strong>:</p>
<p style="margin-left: 40px;">Converting HL7 V2.4 messages to FHIR STU3 involves several steps, as the two standards have different data models and structures. Here is a high-level overview of the process:</p>

<ol style="margin-left: 40px;">
<li>Identify the relevant data elements in the HL7 message that need to be mapped to FHIR resources. This will depend on the specific use case and data being exchanged.</li>
<li>Define the mapping rules for each data element. This involves identifying the equivalent FHIR resource and element that corresponds to the HL7 data element, and any necessary transformations or translations.</li>
<li>Write a program or script that can extract the data from the HL7 message, apply the mapping rules, and create the corresponding FHIR resources. This may involve using a combination of regular expressions, parsing libraries, and FHIR resource creation libraries.</li>
<li>Validate the FHIR resources against the STU3 specification to ensure they conform to the standard and contain all required elements.</li>
</ol>
<p style="margin-left: 40px;">Here is an example of how this process might look for converting an HL7 V2.4 observation message to a FHIR STU3 Observation resource:</p>

<ol style="margin-left: 40px;">
<li>Identify the relevant data elements in the HL7 message, such as the observation code, value, and units.</li>
<li>Define the mapping rules for each data element, such as mapping the HL7 observation code to a FHIR CodeableConcept and the value and units to a FHIR Quantity.</li>
<li>Write a program or script that can extract the data from the HL7 message, apply the mapping rules, and create a FHIR Observation resource with the appropriate elements.</li>
<li>Validate the FHIR Observation resource against the STU3 specification to ensure it contains all required elements and is valid.</li>
</ol>
<p style="margin-left: 40px;">The specific implementation details will depend on the programming language and libraries used, as well as the specific HL7 message and FHIR resource being mapped. It's recommended to consult the HL7 and FHIR specifications and seek expert advice if needed.</p>

<hr>
<p>Well, it not just sounds about right - it actually answers more comprehensively than most human&nbsp;would do. It gets my attention now, so let's jump into it.&nbsp;&nbsp;&nbsp;<br>&nbsp;</p>
<hr>
<p><strong>Question 2:&nbsp;Can you create a sample transformation in Python to convert HL7 to FHIR <span>&nbsp;</span></strong></p>
<hr>
<p><strong>ChatGPT</strong>:</p>
<p style="margin-left: 40px;">Sure! Here's a sample Python code snippet that demonstrates how to convert an HL7 message into a FHIR STU3 Observation resource:</p>

<pre class="codeblock-container" idlang="8" lang="Python" tabsize="4"><code class="language-css hljs"><span class="hljs-selector-tag">from</span> <span class="hljs-selector-tag">hl7apy</span> <span class="hljs-selector-tag">import</span> <span class="hljs-selector-tag">core</span>
<span class="hljs-selector-tag">from</span> <span class="hljs-selector-tag">fhir</span><span class="hljs-selector-class">.resources</span><span class="hljs-selector-class">.observation</span> <span class="hljs-selector-tag">import</span> <span class="hljs-selector-tag">Observation</span>
# <span class="hljs-selector-tag">Parse</span> <span class="hljs-selector-tag">the</span> <span class="hljs-selector-tag">HL7</span> <span class="hljs-selector-tag">message</span>
<span class="hljs-selector-tag">hl7_message</span> = '<span class="hljs-selector-tag">MSH</span>|^~\&amp;|<span class="hljs-selector-tag">SENDING_APP</span>|<span class="hljs-selector-tag">SENDING_FACILITY</span>|<span class="hljs-selector-tag">RECEIVING_APP</span>|<span class="hljs-selector-tag">RECEIVING_FACILITY</span>|20220527120512||<span class="hljs-selector-tag">ORU</span>^<span class="hljs-selector-tag">R01</span>|<span class="hljs-selector-tag">MSGID12345</span>|<span class="hljs-selector-tag">P</span>|2<span class="hljs-selector-class">.4</span>\<span class="hljs-selector-tag">r</span>' \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '<span class="hljs-selector-tag">OBX</span>|1|<span class="hljs-selector-tag">NM</span>|<span class="hljs-selector-tag">GLU</span>^<span class="hljs-selector-tag">Glucose</span>||100|<span class="hljs-selector-tag">mg</span>/<span class="hljs-selector-tag">dL</span>||<span class="hljs-selector-tag">N</span>|||<span class="hljs-selector-tag">F</span>|||20220527120512\<span class="hljs-selector-tag">r</span>'
<span class="hljs-selector-tag">hl7_parsed</span> = <span class="hljs-selector-tag">core</span><span class="hljs-selector-class">.parse_message</span>(<span class="hljs-selector-tag">hl7_message</span>)

# <span class="hljs-selector-tag">Map</span> <span class="hljs-selector-tag">HL7</span> <span class="hljs-selector-tag">elements</span> <span class="hljs-selector-tag">to</span> <span class="hljs-selector-tag">FHIR</span> <span class="hljs-selector-tag">elements</span>
<span class="hljs-selector-tag">observation</span> = <span class="hljs-selector-tag">Observation</span>()

<span class="hljs-selector-tag">observation</span><span class="hljs-selector-class">.code</span> = {
&nbsp; &nbsp; "coding": [{
&nbsp; &nbsp; &nbsp; &nbsp; "system": "<span class="hljs-attribute">http</span>://loinc.org<span class="hljs-string">",
&nbsp; &nbsp; &nbsp; &nbsp; "</span>code<span class="hljs-string">": hl7_parsed.obx[0].observation_id.value,
&nbsp; &nbsp; &nbsp; &nbsp; "</span>display<span class="hljs-string">": hl7_parsed.obx[0].observation_id.value
&nbsp; &nbsp; }]
}

observation.valueQuantity = {
&nbsp; &nbsp; "</span>value<span class="hljs-string">": hl7_parsed.obx[0].value.value,
&nbsp; &nbsp; "</span>unit<span class="hljs-string">": hl7_parsed.obx[0].units.value,
&nbsp; &nbsp; "</span>system<span class="hljs-string">": "</span>http://unitsofmeasure.org<span class="hljs-string">",
&nbsp; &nbsp; "</span>code<span class="hljs-string">": hl7_parsed.obx[0].units.value
}

# Serialize the FHIR resource as JSON
observation_json = observation.json()

# Print the serialized FHIR resource
print(observation_json)



</span></code></pre>
<p style="margin-left: 40px;">This code uses the <code>hl7apy</code> library to parse the HL7 message and extract the relevant data elements, and the <code>fhir.resources.observation</code> class from the <code>fhir.resources</code> module to create a FHIR Observation resource.</p>
<p style="margin-left: 40px;">In this example, the code maps the HL7 observation ID to the FHIR code element, and the HL7 value and units to the FHIR valueQuantity element. The FHIR resource is then serialized as JSON using the <code>json()</code> method.</p>
<p style="margin-left: 40px;">Note that this is a simple example and you may need to map more data elements depending on your specific use case. Additionally, you will need to install the <code>hl7apy</code> and <code>fhir.resources</code> libraries to run this code.</p>

<hr>
<p>&nbsp;</p>
<p>It's not a bad answer&nbsp;at all - gives a decent boilerplate code. Let's give it a bit specific challenge now:&nbsp;</p>
<hr>
<p><strong>Questions 3:&nbsp;Can you give a sample transformation from HL7 V2 to FHIR Stu3 in Intersystems COS DTL</strong></p>
<hr>
<p><strong>ChatGPT</strong>:</p>
<p style="margin-left: 40px;"><br>Certainly! Here's an example of how to transform an HL7 V2 message to a FHIR STU3 Observation resource in InterSystems COS DTL (Data Transformation Language):</p>

<pre class="codeblock-container" idlang="0" lang="ObjectScript" tabsize="4"><code class="language-cls hljs cos"><span class="hljs-keyword">Class</span> DTL.HL7toFHIR <span class="hljs-keyword">Extends</span> <span class="hljs-built_in">%RegisteredObject</span>
{

<span class="hljs-keyword">ClassMethod</span> TransformHL7ToObservation(hl7Message <span class="hljs-keyword">As</span> <span class="hljs-built_in">%String</span>) <span class="hljs-keyword">As</span> <span class="hljs-built_in">%String</span> [ CodeMode = expression, DDLAllowed = <span class="hljs-number">0</span> ]
{
&nbsp; &nbsp; <span class="hljs-keyword">set</span> src = <span class="hljs-keyword">##class</span>(EnsLib.HL7.Message).<span class="hljs-built_in">%New</span>()
&nbsp; &nbsp; <span class="hljs-keyword">set</span> src.DocType = <span class="hljs-string">"2.4"</span>
&nbsp; &nbsp; <span class="hljs-keyword">set</span> src.Parse(hl7Message)

&nbsp; &nbsp; <span class="hljs-keyword">set</span> obs = <span class="hljs-keyword">##class</span>(FHIR.Resource.Observation).<span class="hljs-built_in">%New</span>()
&nbsp; &nbsp; <span class="hljs-keyword">set</span> obs.subject = { <span class="hljs-string">"reference"</span>: <span class="hljs-string">"Patient/"</span>_src.MSH.GetSendingApplication() }
&nbsp; &nbsp; <span class="hljs-keyword">set</span> obs.status = <span class="hljs-string">"final"</span>
&nbsp; &nbsp; <span class="hljs-keyword">set</span> loincCode = src.GetSegment(<span class="hljs-string">"OBX"</span>, <span class="hljs-number">1</span>).GetField(<span class="hljs-number">3</span>).GetField(<span class="hljs-number">1</span>)
&nbsp; &nbsp; <span class="hljs-keyword">set</span> obs.code = {&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; <span class="hljs-string">"coding"</span>: [&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="hljs-string">"system"</span>: <span class="hljs-string">"http://loinc.org"</span>,&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="hljs-string">"code"</span>: loincCode,&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="hljs-string">"display"</span>: loincCode&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp; &nbsp; &nbsp; &nbsp; ]
&nbsp; &nbsp; }

&nbsp; &nbsp; <span class="hljs-keyword">set</span> value = src.GetSegment(<span class="hljs-string">"OBX"</span>, <span class="hljs-number">1</span>).GetField(<span class="hljs-number">5</span>).GetField(<span class="hljs-number">1</span>)
&nbsp; &nbsp; <span class="hljs-keyword">set</span> units = src.GetSegment(<span class="hljs-string">"OBX"</span>, <span class="hljs-number">1</span>).GetField(<span class="hljs-number">6</span>).GetField(<span class="hljs-number">1</span>)
&nbsp; &nbsp; <span class="hljs-keyword">set</span> obs.valueQuantity = {&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; <span class="hljs-string">"value"</span>: value,&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; <span class="hljs-string">"unit"</span>: units,&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; <span class="hljs-string">"system"</span>: <span class="hljs-string">"http://unitsofmeasure.org"</span>,&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; <span class="hljs-string">"code"</span>: units&nbsp;
&nbsp; &nbsp; }

&nbsp; &nbsp; <span class="hljs-keyword">quit</span> obs.<span class="hljs-built_in">%ToJSON</span>()
}

}</code></pre>
<p style="margin-left: 40px;">This code defines a class method called <code>TransformHL7ToObservation</code> that takes an HL7 V2 message as input and returns a FHIR STU3 Observation resource as a JSON string.</p>
<p style="margin-left: 40px;">The method first creates a new <code>EnsLib.HL7.Message</code> object and uses it to parse the input HL7 message. It then creates a new <code>FHIR.Resource.Observation</code> object and sets the <code>subject</code> and <code>status</code> elements.</p>
<p style="margin-left: 40px;">Next, the code extracts the LOINC code, value, and units from the HL7 message and maps them to the corresponding elements in the FHIR resource.</p>
<p style="margin-left: 40px;">Finally, the method serializes the FHIR resource as JSON and returns it.</p>
<p style="margin-left: 40px;">To use this class method, you can call it from another COS method or from an external system using InterSystems' REST API. Here's an example of how to call the method from another COS method:</p>

<pre class="codeblock-container" idlang="0" lang="ObjectScript" tabsize="4"><code class="language-cls hljs cos"><span class="hljs-keyword">set</span> hl7Message = <span class="hljs-string">"MSH|^~\&amp;|SENDING_APP|SENDING_FACILITY|RECEIVING_APP|RECEIVING_FACILITY|20220527120512||ORU^R01|MSGID12345|P|2.4\rOBX|1|NM|GLU^Glucose||100|mg/dL||N|||F|||20220527120512\r"</span>
<span class="hljs-keyword">set</span> fhirObservation = <span class="hljs-keyword">##class</span>(DTL.HL7toFHIR).TransformHL7ToObservation(hl7Message)
<span class="hljs-keyword">write</span> fhirObservation</code></pre>
<p style="margin-left: 40px;">Note that you will need to define the <code>EnsLib.HL7.Message</code> and <code>FHIR.Resource.Observation</code> classes in your InterSystems environment and have the appropriate permissions to run COS code.</p>

<hr>
<p>&nbsp;</p>
<p>Well, that's probably the most effective yet comprehensive&nbsp;answer we&nbsp;could ever have expected within about 25&nbsp;seconds.&nbsp;Right?</p>
<p>(<em>Please note: the above COS sample&nbsp;isn't perfectly accurate. It's only a boilerplate structure, needs more fine-tuning for&nbsp;real-world implementations. As @Tete.Zhang</em><span><em>&nbsp;kindly pointed, Ensemble level HL7 message class uses ImportFromSting() instead of Parse(); DocType should be more specific etc. And apparently it seemed&nbsp;to&nbsp;create&nbsp;a new FHIR class&nbsp;hierarchy on its own from the COS ground up, instead of using existing HealthShare's built-in FHIR STU3 plumbings. Its "thought process" appears to be following the previous answer of Python structure. It's not going to achieve an Ensemble or HealthShare certification for now, and has a lot to learn with more&nbsp;specialist interactions, but as an excuse we&nbsp;might have to pardon it for its&nbsp;first trial in less than 2 minutes so far, by today?&nbsp;</em>&nbsp;)&nbsp;&nbsp;&nbsp;</span><br>&nbsp;&nbsp;</p>
<p>Now that we are here, we need to be fair to other widely used options I have been enjoying too. So I carried on a few more questions with slightly more faith:</p>
<hr>
<p><strong>Question 4:&nbsp;Can you give a sample transformation from HL7 V2 to FHIR Stu3 in Orion Rhapsody</strong></p>
<hr>
<p><strong>ChatGPT</strong>:</p>
<p style="margin-left: 40px;">Certainly! Here's an example of how to transform an HL7 V2 message to a FHIR STU3 Observation resource in Orion Rhapsody:</p>

<ol style="margin-left: 40px;">
<li>First, create a new Rhapsody channel and add an HL7 Connector component to receive the input HL7 V2 message.</li>
<li>Add a new Data Transformation component to the channel and configure it to use a custom script.</li>
<li>In the Data Transformation component, add the following script to transform the HL7 V2 message to a FHIR STU3 Observation resource:</li>
</ol>
<pre class="codeblock-container" idlang="5" lang="JavaScript" tabsize="4"><code class="language-javascript hljs"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">transform</span>(<span class="hljs-params">msg</span>) </span>{

&nbsp; &nbsp; <span class="hljs-keyword">var</span> hl7 = Packages.ca.uhn.hl7v2.model.v24.message.ORU_R01(msg.getRawData());

&nbsp; &nbsp; <span class="hljs-keyword">var</span> observation = <span class="hljs-keyword">new</span> Packages.org.hl7.fhir.dstu3.model.Observation();
&nbsp; &nbsp; observation.setStatus(Packages.org.hl7.fhir.dstu3.model.Observation.ObservationStatus.FINAL);

&nbsp; &nbsp; <span class="hljs-keyword">var</span> codeableConcept = <span class="hljs-keyword">new</span> Packages.org.hl7.fhir.dstu3.model.CodeableConcept();
&nbsp; &nbsp; <span class="hljs-keyword">var</span> coding = <span class="hljs-keyword">new</span> Packages.org.hl7.fhir.dstu3.model.Coding();
&nbsp; &nbsp; coding.setSystem(<span class="hljs-string">"http://loinc.org"</span>);
&nbsp; &nbsp; coding.setCode(hl7.getRESPONSE().getORDER_OBSERVATION()[<span class="hljs-number">0</span>].getOBR().getUniversalServiceIdentifier().getIdentifier().getValue());
&nbsp; &nbsp; coding.setDisplay(hl7.getRESPONSE().getORDER_OBSERVATION()[<span class="hljs-number">0</span>].getOBR().getUniversalServiceIdentifier().getText().getValue());
&nbsp; &nbsp; codeableConcept.addCoding(coding);
&nbsp; &nbsp; observation.setCode(codeableConcept);

&nbsp; &nbsp; <span class="hljs-keyword">var</span> quantity = <span class="hljs-keyword">new</span> Packages.org.hl7.fhir.dstu3.model.Quantity();
&nbsp; &nbsp; quantity.setValue(hl7.getRESPONSE().getORDER_OBSERVATION()[<span class="hljs-number">0</span>].getOBSERVATION()[<span class="hljs-number">0</span>].getOBX().getObservationValue()[<span class="hljs-number">0</span>].getValue().getValue());
&nbsp; &nbsp; quantity.setUnit(hl7.getRESPONSE().getORDER_OBSERVATION()[<span class="hljs-number">0</span>].getOBSERVATION()[<span class="hljs-number">0</span>].getOBX().getUnits().getText().getValue());
&nbsp; &nbsp; observation.setValue(quantity);

&nbsp; &nbsp; <span class="hljs-keyword">var</span> reference = <span class="hljs-keyword">new</span> Packages.org.hl7.fhir.dstu3.model.Reference();
&nbsp; &nbsp; reference.setReference(<span class="hljs-string">"Patient/"</span> + hl7.getPATIENT_RESULT().getPATIENT().getPid3_PatientIdentifierList()[<span class="hljs-number">0</span>].getID().getValue());
&nbsp; &nbsp; observation.setSubject(reference);

&nbsp; &nbsp; <span class="hljs-keyword">return</span> <span class="hljs-built_in">JSON</span>.stringify(observation);
}</code></pre>
<ol start="4" style="margin-left: 40px;">
<li>Save the script and test the transformation by sending an HL7 V2 message to the channel. The transformed FHIR STU3 Observation resource should be output by the Data Transformation component in JSON format.</li>
</ol>
<p style="margin-left: 40px;">This script uses the HAPI FHIR and HAPI HL7 v2 libraries, which are included with Orion Rhapsody. It starts by parsing the input HL7 V2 message using the HAPI HL7 library.</p>
<p style="margin-left: 40px;">Next, the script creates a new FHIR STU3 Observation resource and sets its <code>status</code>, <code>code</code>, <code>value</code>, and <code>subject</code> elements based on the corresponding values in the HL7 message.</p>
<p style="margin-left: 40px;">Finally, the script serializes the FHIR resource as JSON and returns it.</p>
<p style="margin-left: 40px;">Note that this is just a simple example and may not work for all HL7 V2 message types or FHIR resources. You may need to modify the script to handle different message types or map additional fields to the FHIR resource.</p>

<hr>
<p>&nbsp;</p>
<hr>
<p><strong>Questions 5&nbsp;</strong>Can you create a sample transformation converting HL7 v2.4 to FHIR R4 in Mirth integration engine</p>
<hr>
<p><strong>ChatGPT</strong>:&nbsp;</p>
<p style="margin-left: 40px;">Certainly! Here's an example of how to transform an HL7 V2.4 message to a FHIR R4 Observation resource in Mirth:</p>

<ol style="margin-left: 40px;">
<li>First, create a new Mirth channel and add an HL7v2 Listener source connector to receive the input HL7 V2 message.</li>
<li>Add a new JavaScript Writer destination connector to the channel and configure it to use a custom script.</li>
<li>In the JavaScript Writer connector, add the following script to transform the HL7 V2 message to a FHIR R4 Observation resource:</li>
</ol>
<pre class="codeblock-container" idlang="5" lang="JavaScript" tabsize="4"><code class="language-javascript hljs"><span class="hljs-keyword">var</span> hl7msg = msg[<span class="hljs-string">'HL7v2 Message'</span>].toString(); <span class="hljs-comment">// get the HL7 V2 message</span>
<span class="hljs-keyword">var</span> hl7data = Packages.ca.uhn.hl7v2.parser.Parser.parse(hl7msg); <span class="hljs-comment">// parse the message with the HAPI HL7 parser</span>
<span class="hljs-comment">// extract values from the HL7 message and create the FHIR resource</span>
<span class="hljs-keyword">var</span> obs = <span class="hljs-keyword">new</span> Packages.org.hl7.fhir.r4.model.Observation();
obs.setStatus(Packages.org.hl7.fhir.r4.model.Observation.ObservationStatus.FINAL);

<span class="hljs-keyword">var</span> code = <span class="hljs-keyword">new</span> Packages.org.hl7.fhir.r4.model.CodeableConcept();
code.addCoding()
&nbsp; .setSystem(<span class="hljs-string">"http://loinc.org"</span>)
&nbsp; .setCode(hl7data.get(<span class="hljs-string">"OBR-4-1"</span>).getValue())
&nbsp; .setDisplay(hl7data.get(<span class="hljs-string">"OBR-4-2"</span>).getValue());
obs.setCode(code);

<span class="hljs-keyword">var</span> value = <span class="hljs-keyword">new</span> Packages.org.hl7.fhir.r4.model.Quantity();
value.setValue(hl7data.get(<span class="hljs-string">"OBX-5-1"</span>).getValue());
value.setUnit(hl7data.get(<span class="hljs-string">"OBX-6"</span>).getValue());
obs.setValue(value);

<span class="hljs-keyword">var</span> subject = <span class="hljs-keyword">new</span> Packages.org.hl7.fhir.r4.model.Reference();
subject.setReference(<span class="hljs-string">"Patient/"</span> + hl7data.get(<span class="hljs-string">"PID-3-1"</span>).getValue());
obs.setSubject(subject);

<span class="hljs-comment">// output the FHIR resource as JSON</span>
<span class="hljs-keyword">var</span> json = org.hl7.fhir.r4.formats.JsonParser().setPrettyPrint(<span class="hljs-literal">true</span>).encodeResourceToString(obs);
<span class="hljs-keyword">return</span> json;</code></pre>
<ol start="4" style="margin-left: 40px;">
<li>Save the script and test the transformation by sending an HL7 V2 message to the channel. The transformed FHIR R4 Observation resource should be output by the JavaScript Writer connector in JSON format.</li>
</ol>
<p style="margin-left: 40px;">This script uses the HAPI FHIR and HAPI HL7 v2 libraries, which are included with Mirth. It starts by extracting the HL7 V2 message from the Mirth message object and parsing it with the HAPI HL7 parser.</p>
<p style="margin-left: 40px;">Next, the script creates a new FHIR R4 Observation resource and sets its <code>status</code>, <code>code</code>, <code>value</code>, and <code>subject</code> elements based on the corresponding values in the HL7 message.</p>
<p style="margin-left: 40px;">Finally, the script serializes the FHIR resource as JSON and returns it.</p>
<p style="margin-left: 40px;">Note that this is just a simple example and may not work for all HL7 V2 message types or FHIR resources. You may need to modify the script to handle different message types or map additional fields to the FHIR resource.</p>

<hr>
<h2><br>Conclusions?</h2>
<p><br>I don't&nbsp;have any conclusions or next steps anymore, since even my imagination can't catch up with its leaps.&nbsp; It looks as if there were only limited options for me now:&nbsp; either I can spend time in picking out&nbsp;its imperfect coding styles, or I can re-think of what's left on my plate in another few weeks? I need to think carefully more than ever about the&nbsp;potential of this thing. :)<br><br>Joking aside, while I am enjoying posting on this forum (thanks to the hosts),&nbsp;another thought comes to my mind would be, this "could" actually be an important&nbsp;enabler for some competitive niche player to leap forward to mass market, right?&nbsp; &nbsp;It used to take years to be really&nbsp;comfortable with some coding languages and scripts, due to various reasons, but now the landscape is moving, and with ChatGPT it not only offers well-composed documentation, instructions and samples, but it might also be able to automatically manufacture the engineering tools&nbsp;of your choice&nbsp;over the coming months or years, right?&nbsp; It seems to be able to level up the play ground in "languages", and eventually the non-functional side of features such as performance etc service qualities would look more&nbsp;&nbsp;outstanding.&nbsp;&nbsp;</p>