JS Transformer not working properly with multiple occurrences of FT1 #6501
Replies: 7 comments 9 replies
-
|
Please use code formatting, your post (with the bad code) should look like this: for (var i = 0; i < msg['FT1'].length(); i++) {
if (msg['FT1'][i]['FT1.26']['FT1.26.1'].toString().includes("26"))
{
msg['FT1'][i]['FT1.7']['FT1.7.1'] = msg['FT1'][i]['FT1.7']['FT1.7.1'] + "26".toString(),
msg['FT1'][i]['FT1.25']['FT1.25.1'] = msg['FT1'][i]['FT1.25']['FT1.25.1'] + "26".toString();
}
}Sample Inbound Message: |
Beta Was this translation helpful? Give feedback.
-
|
Thanks so much for the reply. However, when I run the code below, I get the same result. The 26 is also getting added to the 2nd occurrence. That didn't seem to happen in your testing though. I even created a brand new channel, added it as the only transformer step, but it's still updating the 2nd and 3rd occurrence of FT1, rather than just the 3rd.
We're on Mirth Connect Server 4.5.2, if that means anything. Any thoughts as to why it my be working differently for me than for you?
I really appreciate your help.
Thanks,
Mark
From: Paul Coyne ***@***.***>
Sent: Wednesday, October 15, 2025 11:03 AM
To: nextgenhealthcare/connect ***@***.***>
Cc: Mark A. Iskander ***@***.***>; Author ***@***.***>
Subject: [EXTERNAL]Re: [nextgenhealthcare/connect] JS Transformer not working properly with multiple occurrences of FT1 (Discussion #6501)
EXTERNAL EMAIL:
Do not click on any links or open any attachments unless you trust the sender or know the content is safe.
And this is what I think you need:
for each (var ft1 in msg.FT1) {
if (ft1['FT1.26']['FT1.26.1'].toString().includes("26")) {
ft1['FT1.7']['FT1.7.1'] = ft1['FT1.7']['FT1.7.1'].toString() + "26"
ft1['FT1.25']['FT1.25.1'] = ft1['FT1.25']['FT1.25.1'].toString() + "26"
}
}
In message:
EVN|P03||20251014210930000669||01
PID|1|
PV1|1||adbb8e23-1f4e-4ca7-be19-fd614f7a0123|1673319|||92512f64-212b-43f5-94b4-db8c4437803a^Doctor^MARK||1578618450^Doctor^MARK||||||||||||||||||||||||||||||||||||||||||
FT1|1|AI582dcaa7f6f84312aa283e6586b6b47d||20251009000000|20251014210930|CG|27829|||1|||OSS_OPERATIVE_NEXTGEN^OSS Surgery NextGen|||adbb8e23-1f4e-4ca7-be19-fd614f7a0123|||S93.02XA^Subluxation of left ankle joint, initial encounter^I10|92512f64-212b-43f5-94b4-db8c4437803a^Doctor^MARK|||||27829|LT
FT1|2|AIcmgr20yaaes1k014bckzxggae||20251009000000|20251014210930|CG|64450|||1|||OSS_OPERATIVE_NEXTGEN^OSS Surgery NextGen|||adbb8e23-1f4e-4ca7-be19-fd614f7a0123|||S93.02XA^Subluxation of left ankle joint, initial encounter^I10|92512f64-212b-43f5-94b4-db8c4437803a^Doctor^MARK|||||64450|59LT
FT1|3|AIcmgr20yaaes1n014b4jnmmrsc||20251009000000|20251014210930|CG|73610|||1|||OSS_OPERATIVE_NEXTGEN^OSS Surgery NextGen|||adbb8e23-1f4e-4ca7-be19-fd614f7a0123|||S93.02XA^Subluxation of left ankle joint, initial encounter^I10|92512f64-212b-43f5-94b4-db8c4437803a^Doctor^MARK|||||73610|26~LT
ZAI|1|^Hill^Jessica||efdf1a94-afe2-431d-a53c-8377bb6d7ae8
Result:
MSH|^&|AIHEALTH^NEXTGEN ROSETTA|0002|MMGI||||DFT^P03|20251014210930000669|T|2.5
EVN|P03||20251014210930000669||01
PID|1|
PV1|1||adbb8e23-1f4e-4ca7-be19-fd614f7a0123|1673319|||92512f64-212b-43f5-94b4-db8c4437803a^Doctor^MARK||1578618450^Doctor^MARK||||||||||||||||||||||||||||||||||||||||||
FT1|1|AI582dcaa7f6f84312aa283e6586b6b47d||20251009000000|20251014210930|CG|27829|||1|||OSS_OPERATIVE_NEXTGEN^OSS Surgery NextGen|||adbb8e23-1f4e-4ca7-be19-fd614f7a0123|||S93.02XA^Subluxation of left ankle joint, initial encounter^I10|92512f64-212b-43f5-94b4-db8c4437803a^Doctor^MARK|||||27829|LT
FT1|2|AIcmgr20yaaes1k014bckzxggae||20251009000000|20251014210930|CG|64450|||1|||OSS_OPERATIVE_NEXTGEN^OSS Surgery NextGen|||adbb8e23-1f4e-4ca7-be19-fd614f7a0123|||S93.02XA^Subluxation of left ankle joint, initial encounter^I10|92512f64-212b-43f5-94b4-db8c4437803a^Doctor^MARK|||||64450|59LT
FT1|3|AIcmgr20yaaes1n014b4jnmmrsc||20251009000000|20251014210930|CG|7361026|||1|||OSS_OPERATIVE_NEXTGEN^OSS Surgery NextGen|||adbb8e23-1f4e-4ca7-be19-fd614f7a0123|||S93.02XA^Subluxation of left ankle joint, initial encounter^I10|92512f64-212b-43f5-94b4-db8c4437803a^Doctor^MARK|||||7361026|26~LT
ZAI|1|^Hill^Jessica||efdf1a94-afe2-431d-a53c-8377bb6d7ae8
-
Reply to this email directly, view it on GitHub<#6501 (reply in thread)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AXJMGQBMXLSVJK43QNY6RED3X2D5PAVCNFSM6AAAAACJJBKMZ2VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTINRZGAZTAMA>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
|
Yeah I've tried multiple times, pasted the transformer exactly how you had it. No idea why it'd be different in our environment.
Anyway, thanks for the help, I do appreciate it.
Cheers,
Mark
From: Paul Coyne ***@***.***>
Sent: Wednesday, October 15, 2025 1:18 PM
To: nextgenhealthcare/connect ***@***.***>
Cc: Mark A. Iskander ***@***.***>; Author ***@***.***>
Subject: [EXTERNAL]Re: [nextgenhealthcare/connect] JS Transformer not working properly with multiple occurrences of FT1 (Discussion #6501)
EXTERNAL EMAIL:
Do not click on any links or open any attachments unless you trust the sender or know the content is safe.
Huh? My code only added it to the third FT1 segment. What are you looking at?
image.png (view on web)<https://github.com/user-attachments/assets/279293b9-70d8-4903-b6c7-509dc1176092>
-
Reply to this email directly, view it on GitHub<#6501 (reply in thread)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AXJMGQGA5TC3YTTYYWC27ED3X2TXDAVCNFSM6AAAAACJJBKMZ2VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTINRZGEZDGMY>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
|
I don't see any outbound template. It's still adding the 26 to the prior line, even though the prior line does not have a 26 in FT1.26.1
Could it be something in the Outbound Properties? Use Strict Parser doesn't do the trick...
***@***.***
PV1|1||adbb8e23-1f4e-4ca7-be19-fd614f7a0123|1673319|||92512f64-212b-43f5-94b4-db8c4437803a^REED^MARK||1578618450^DOCTOR^MARK||||||||||||||||||||||||||||||||||||||||||
FT1|1|AI582dcaa7f6f84312aa283e6586b6b47d||20251009000000|20251014210930|CG|27829|||1|||OSS_OPERATIVE_NEXTGEN^OSS Surgery NextGen|||adbb8e23-1f4e-4ca7-be19-fd614f7a0123|||S93.02XA^Subluxation of left ankle joint, initial encounter^I10|92512f64-212b-43f5-94b4-db8c4437803a^DOCTOR^MARK|||||27829|LT
FT1|2|AIcmgr20yaaes1k014bckzxggae||20251009000000|20251014210930|CG|6445026|||1|||OSS_OPERATIVE_NEXTGEN^OSS Surgery NextGen|||adbb8e23-1f4e-4ca7-be19-fd614f7a0123|||S93.02XA^Subluxation of left ankle joint, initial encounter^I10|92512f64-212b-43f5-94b4-db8c4437803a^DOCTOR^MARK|||||6445026|59~LT
FT1|3|AIcmgr20yaaes1n014b4jnmmrsc||20251009000000|20251014210930|CG|7361026|||1|||OSS_OPERATIVE_NEXTGEN^OSS Surgery NextGen|||adbb8e23-1f4e-4ca7-be19-fd614f7a0123|||S93.02XA^Subluxation of left ankle joint, initial encounter^I10|92512f64-212b-43f5-94b4-db8c4437803a^DOCTOR^MARK|||||7361026|26~LT
ZAI|1|^Hill^Jessica||efdf1a94-afe2-431d-a53c-8377bb6d7ae8
Great thought about the outbound template though. I'm still stumped..
From: Paul Coyne ***@***.***>
Sent: Thursday, October 16, 2025 5:03 PM
To: nextgenhealthcare/connect ***@***.***>
Cc: Mark A. Iskander ***@***.***>; Author ***@***.***>
Subject: [EXTERNAL]Re: [nextgenhealthcare/connect] JS Transformer not working properly with multiple occurrences of FT1 (Discussion #6501)
EXTERNAL EMAIL:
Do not click on any links or open any attachments unless you trust the sender or know the content is safe.
Do you accidentally have an outbound message template overriding what you are creating in the transformer?
-
Reply to this email directly, view it on GitHub<#6501 (reply in thread)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AXJMGQG4Z4ZRG7SEKGPQK5T3YAW2PAVCNFSM6AAAAACJJBKMZ2VHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTINZQGQYDGNY>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
Apologies for the emails, etc., just becoming familiar with Github. Here's the channel. |
Beta Was this translation helpful? Give feedback.
-
|
Not sure how i didn't know that, thanks. The line endings are all \r (you can't see the end of the pertinent rows in the screenshot, but they're all the same). |
Beta Was this translation helpful? Give feedback.



Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
We're trying to build a transformer that looks at each occurrence of FT1.26.1, and if it contains '26' anywhere within, suffix 26 to the end of the value in FT1.7.1 and FT1.25.1
The transformer seems to work, but when there are multiple FT1s, it's adding the 26 to the prior FT1, in addition to the FT1 that had the '26' in FT1.26.1
Here's the transformer:
for(var i=0;i<msg['FT1'].length();i++){
if(msg['FT1'][i]['FT1.26']['FT1.26.1'].toString().includes("26"))
{
msg['FT1'][i]['FT1.7']['FT1.7.1'] = msg['FT1'][i]['FT1.7']['FT1.7.1']+"26".toString(),
}
}
Here's the RAW message. Notice that only 3rd occurrence of FT1 has a '26' in the FT1.26.1:
MSH|^
&|AIHEALTH^NEXTGEN ROSETTA|0002|MMGI||||DFT^P03|20251014210930000669|T|2.5LTEVN|P03||20251014210930000669||01
PID|1|
PV1|1||adbb8e23-1f4e-4ca7-be19-fd614f7a0123|1673319|||92512f64-212b-43f5-94b4-db8c4437803a^Doctor^MARK||1578618450^Doctor^MARK||||||||||||||||||||||||||||||||||||||||||
FT1|1|AI582dcaa7f6f84312aa283e6586b6b47d||20251009000000|20251014210930|CG|27829|||1|||OSS_OPERATIVE_NEXTGEN^OSS Surgery NextGen|||adbb8e23-1f4e-4ca7-be19-fd614f7a0123|||S93.02XA^Subluxation of left ankle joint, initial encounter^I10|92512f64-212b-43f5-94b4-db8c4437803a^Doctor^MARK|||||27829|LT
FT1|2|AIcmgr20yaaes1k014bckzxggae||20251009000000|20251014210930|CG|64450|||1|||OSS_OPERATIVE_NEXTGEN^OSS Surgery NextGen|||adbb8e23-1f4e-4ca7-be19-fd614f7a0123|||S93.02XA^Subluxation of left ankle joint, initial encounter^I10|92512f64-212b-43f5-94b4-db8c4437803a^Doctor^MARK|||||64450|59
FT1|3|AIcmgr20yaaes1n014b4jnmmrsc||20251009000000|20251014210930|CG|73610|||1|||OSS_OPERATIVE_NEXTGEN^OSS Surgery NextGen|||adbb8e23-1f4e-4ca7-be19-fd614f7a0123|||S93.02XA^Subluxation of left ankle joint, initial encounter^I10|92512f64-212b-43f5-94b4-db8c4437803a^Doctor^MARK|||||73610|26~LT
ZAI|1|^Hill^Jessica||efdf1a94-afe2-431d-a53c-8377bb6d7ae8
Here's the encoded message. Notice that both the 2nd and 3rd occurrence of FT1 had the FT1.7 appended with 26, even though the 26 only existed on the third FT1:
MSH|^
&|AIHEALTH^NEXTGEN ROSETTA|0002|MMGI||||DFT^P03|20251014210930000669|T|2.5LTEVN|P03||20251014210930000669||01
PID|1|
PV1|1||adbb8e23-1f4e-4ca7-be19-fd614f7a0123|1673319|||92512f64-212b-43f5-94b4-db8c4437803a^REED^MARK||1578618450^REED^MARK||||||||||||||||||||||||||||||||||||||||||
FT1|1|AI582dcaa7f6f84312aa283e6586b6b47d||20251009000000|20251014210930|CG|27829|||1|||OSS_OPERATIVE_NEXTGEN^OSS Surgery NextGen|||adbb8e23-1f4e-4ca7-be19-fd614f7a0123|||S93.02XA^Subluxation of left ankle joint, initial encounter^I10|92512f64-212b-43f5-94b4-db8c4437803a^REED^MARK|||||27829|LT
FT1|2|AIcmgr20yaaes1k014bckzxggae||20251009000000|20251014210930|CG|6445026|||1|||OSS_OPERATIVE_NEXTGEN^OSS Surgery NextGen|||adbb8e23-1f4e-4ca7-be19-fd614f7a0123|||S93.02XA^Subluxation of left ankle joint, initial encounter^I10|92512f64-212b-43f5-94b4-db8c4437803a^REED^MARK|||||6445026|59
FT1|3|AIcmgr20yaaes1n014b4jnmmrsc||20251009000000|20251014210930|CG|7361026|||1|||OSS_OPERATIVE_NEXTGEN^OSS Surgery NextGen|||adbb8e23-1f4e-4ca7-be19-fd614f7a0123|||S93.02XA^Subluxation of left ankle joint, initial encounter^I10|92512f64-212b-43f5-94b4-db8c4437803a^REED^MARK|||||7361026|26~LT
ZAI|1|^Hill^Jessica||efdf1a94-afe2-431d-a53c-8377bb6d7ae8
How do i get the logic to only work on the FT1 that has the 26 in FT1.26.1?
Beta Was this translation helpful? Give feedback.
All reactions