Hi All!
I?ve been playing around with javascript transformers in Mirth 1.4 and trying to figure out how to extract data from a single field in repeating segments in the incoming message (e.g., DG1, IN1, etc.) and place said fields into the outgoing message. I got the javascript to work (cool!) insofar as it can iterate through the repeating segments and extract the selected fields but I?m stumped on how to get those fields into a variable I can use in the template for the outbound message. Please note that I?m NOT talking about repeating values in a single field (i.e., data delimited by ?~?) but regular fields that occur in each of the repeating segments (in this case DG1.1).
What I want to do (and this is just for playing around mind you) is take field DG1.1 from each of the DG1 segments in an incoming ADT message and concatenate those fields into a field in the outgoing message?s PID segment. So if there are, say, 3 DG1 segments in the incoming message I simply want to extract the data from DG1.1 in each of those segments and place all of the data into, say, PID-20 of the outgoing message. I thought that once I figured out how to do this then I?d have a simple example I could use as a model for doing real, more complicated stuff.
Here?s the HL7 message (please note that our admitting system uses non-standard default delimiters but Mirth handles them fine if I turn off strict parsing. Please also note that since one of these delimiters is a colon the Mirth message board seems to replace selected ones with emoticons. Can emoticons be turned off selectively????):
Here?s my javascript:
Here?s my outbound message template:
After running a transaction the mirth.log shows:
In the Mirth Channel Messages Mappings (Admin Console) the variable testResult shows ?Second?. The count variable is 2.0.
So ? I can see in mirth.log that the javascript has obtained each of the DG1.1 values but I?m stumped as to how to get all of them (i.e., both ?First? and ?Second? into the outbound message variables so it can be used in the outbound template. Ideally I?d like to know if there is some way to also have access to each of the repeating values individually ? so if I only wanted to use DG1.1 from the second DG1 segment I?d be able to do that as well. Please also note that I also may be overthinking this.
Thanks in advance!!!!!!
Bob D.
Toledo Ohio
Post edited by: bdilworth, at: 05/03/2007 07:34
Post edited by: chrisl, at: 05/03/2007 16:25
I?ve been playing around with javascript transformers in Mirth 1.4 and trying to figure out how to extract data from a single field in repeating segments in the incoming message (e.g., DG1, IN1, etc.) and place said fields into the outgoing message. I got the javascript to work (cool!) insofar as it can iterate through the repeating segments and extract the selected fields but I?m stumped on how to get those fields into a variable I can use in the template for the outbound message. Please note that I?m NOT talking about repeating values in a single field (i.e., data delimited by ?~?) but regular fields that occur in each of the repeating segments (in this case DG1.1).
What I want to do (and this is just for playing around mind you) is take field DG1.1 from each of the DG1 segments in an incoming ADT message and concatenate those fields into a field in the outgoing message?s PID segment. So if there are, say, 3 DG1 segments in the incoming message I simply want to extract the data from DG1.1 in each of those segments and place all of the data into, say, PID-20 of the outgoing message. I thought that once I figured out how to do this then I?d have a simple example I could use as a model for doing real, more complicated stuff.
Here?s the HL7 message (please note that our admitting system uses non-standard default delimiters but Mirth handles them fine if I turn off strict parsing. Please also note that since one of these delimiters is a colon the Mirth message board seems to replace selected ones with emoticons. Can emoticons be turned off selectively????):
Code:
MSH:;~\\&:HBOC:A:NONPCM:A:200704101456::ADT;A08;42:19377332:«»D:2.2:19377332::AL:: EVN:A08:200704101456:: PID::00691759:00753542;;;A:32000;A115520:THORPE;TEST;;::19121212:M::1:3372 GILBRALTER HTS #C11;;TOLEDO;OH;43614;US;C;LUCAS~;;TOLEDO;OH;43614;US;P;LUCAS:LUCAS:«»(444)111-2222~(222)111-2222::ENGLISH;4;:M:BUD;;:0704700003;;;A:333-22-2222: NK1:1:TEST;OTHER:H;;:300 TEST;;TOLEDO;OH;43614;US:«»(444)111-2222 PV1::I:3AB;3108;01;A;;;3:3:::111111;BUTTHEAD;MEANSHERYL;;;;MD:55555;NO;PHYSICIAN:"":CC::::1:::111111;BUTTHEAD;MEANSHERYL;;;;MD:IA;;A:0704700003;;;A:«»PM:::::::::::::::::::A:OCC;OCCUPIED::::200702161057::::: AL1:::;::: DG1:First:I9::TEST::ADMITTING:::::::: DG1:«»Second:I9::TEST::WORKING:::::::: GT1:1:32000:THORPE;TEST;;::3372 GILBRALTER HTS #C11;;TOLEDO;OH;43614;US;C;LUCAS~;;TOLEDO;OH;43614;US;P;LUCAS:«»(444)111-2222~(222)111-2222::19121212:M::«»S:333-22-2222:::1:UNKNOWN EMPLOYER;UNK::::4 IN1:1:001:851:«»PARAMOUNT:«»PO BOX 928;;TOLEDO;OH;436970928;US;C;:«»PARAMOUNT:«»(419)887-2525:88:::UNKNOWN EMPLOYER;UNK;A:::;;&&:N;;:THORPE;TEST;::19121212::::::::::::;;::::::33322222201::::::4:M:;;;;;: IN2::333-22-2222::::::::::::::::::::;;:::::::: ACC:"":: ZCA:::;;; ZCM:N::5:::::::4:::::::::::G::55555;NO;PHYSICIAN:: ZCV:3::GB7342::::ER:0
Code:
var testResult = "X"; var count = 0; for each (dg in msg..DG1) { logger.info('dg.1: ' + msg['DG1']['DG1.1']['DG1.1.1'][count].toString()); testResult = msg['DG1']['DG1.1']['DG1.1.1'][count].toString(); count++; } logger.info('Count is: ' + count); logger.info('Result is: ' + testResult); connectorMap.put('testResult', testResult); connectorMap.put('count', count);
Code:
MSH|^~\\&|PCM|A|XYZ|A|${msh7}|OkToBundle|${msh9}|${msh10}|P|2.2|||AL|NE${cr}PID|1||${pid3}||${pid5}||${pid7}|${pid8}||||||||||${pid19}|${pid19}|TR ${testResult}|CNT ${count}
Code:
INFO 2007-05-03 10:07:54,988 [552182b8-9834-4759-a9a8-d5e3a5de3436_source_connector._fileEndpoint#1458791753.receiver.1] destination-transformation: dg.1: First INFO 2007-05-03 10:07:54,988 [552182b8-9834-4759-a9a8-d5e3a5de3436_source_connector._fileEndpoint#1458791753.receiver.1] destination-transformation: dg.1: Second INFO 2007-05-03 10:07:54,988 [552182b8-9834-4759-a9a8-d5e3a5de3436_source_connector._fileEndpoint#1458791753.receiver.1] destination-transformation: Count is: 2 INFO 2007-05-03 10:07:54,988 [552182b8-9834-4759-a9a8-d5e3a5de3436_source_connector._fileEndpoint#1458791753.receiver.1] destination-transformation: Result is: Second
So ? I can see in mirth.log that the javascript has obtained each of the DG1.1 values but I?m stumped as to how to get all of them (i.e., both ?First? and ?Second? into the outbound message variables so it can be used in the outbound template. Ideally I?d like to know if there is some way to also have access to each of the repeating values individually ? so if I only wanted to use DG1.1 from the second DG1 segment I?d be able to do that as well. Please also note that I also may be overthinking this.
Thanks in advance!!!!!!
Bob D.
Toledo Ohio
Post edited by: bdilworth, at: 05/03/2007 07:34
Post edited by: chrisl, at: 05/03/2007 16:25
Comment