I have an allergy message which I would like to split and create two messages and ultimately send the allergy fields and its reactions to SQL Server. I know how to insert the fields in SQL. I am having trouble splitting the message in two via tcl or xlate. Any help is greately appreciated. In xlate I have a iteration on the group and then on each segment.
Incoming Message:
MSH|^~@|DAMALLGY|HFT|||201109281209||ADT^A60|CHPFDA01||2.3|||||||
ZSH|PHM~ADT|IDX-INFO
PID|||8904355^^^HFT^PN~T90000079^^^HFT^MR~38206^^^HFT^PI||TESTPHYS^NINETEEN^^^^^L||19780909|F||W|X^””^UNIVERSITY OF CT HEALTH CTR^CT^06030|||||U|UNK|8904355|||||||||||||
PV1|0001|I|SURG^7031^A|R|||4075^DOCTOR CONVERSION|||GPE||||RP||N|4075^DOCTOR CONVERSION|I|000000021092|S|||||||||||||||||||SURG|||||201109281209|||||||||
PV2||||||||||||||||||||0||||IA|||||||||||||
IAM||DA|00001085^carbidopa^99ING|||X|||||||||||C^ACTIVE|TRMD09^DOCTOR09^TRAINING^^^^^^H0FT||201107060906|||||||00006358^Sinemet^99DRG
IAR|^Anaphylaxis|SV|AL|
IAR|^Hives|MI|AD|5
IAR|^Eye Irritation|U|SE|
IAR|^Chills||AL|
IAM||DA|00001639^levodopa^99ING|||X|||||||||||C^ACTIVE|TRMD09^DOCTOR09^TRAINING^^^^^^H0FT||201107060906|||||||00006358^Sinemet^99DRG
IAR|^Anaphylaxis|SV|AL|
IAR|^Hives|MI|AD|5
IAR|^Eye Irritation|U|SE|
IAR|^Chills||AL|
Desired Outcome:
MSH|^~@|DAMALLGY|HFT|||201109281209||ADT^A60|CHPFDA01||2.3|||||||
ZSH|PHM~ADT|IDX-INFO
PID|||8904355^^^HFT^PN~T90000079^^^HFT^MR~38206^^^HFT^PI||TESTPHYS^NINETEEN^^^^^L||19780909|F||W|X^””^UNIVERSITY OF CT HEALTH CTR^CT^06030|||||U|UNK|8904355|||||||||||||
PV1|0001|I|SURG^7031^A|R|||4075^DOCTOR CONVERSION|||GPE||||RP||N|4075^DOCTOR CONVERSION|I|000000021092|S|||||||||||||||||||SURG|||||201109281209|||||||||
PV2||||||||||||||||||||0||||IA|||||||||||||
IAM||DA|00001085^carbidopa^99ING|||X|||||||||||C^ACTIVE|TRMD09^DOCTOR09^TRAINING^^^^^^H0FT||201107060906|||||||00006358^Sinemet^99DRG
IAR|^Anaphylaxis|SV|AL|
IAR|^Hives|MI|AD|5
IAR|^Eye Irritation|U|SE|
IAR|^Chills||AL|
MSH|^~@|DAMALLGY|HFT|||201109281209||ADT^A60|CHPFDA01||2.3|||||||
ZSH|PHM~ADT|IDX-INFO
PID|||8904355^^^HFT^PN~T90000079^^^HFT^MR~38206^^^HFT^PI||TESTPHYS^NINETEEN^^^^^L||19780909|F||W|X^””^UNIVERSITY OF CT HEALTH CTR^CT^06030|||||U|UNK|8904355|||||||||||||
PV1|0001|I|SURG^7031^A|R|||4075^DOCTOR CONVERSION|||GPE||||RP||N|4075^DOCTOR CONVERSION|I|000000021092|S|||||||||||||||||||SURG|||||201109281209|||||||||
PV2||||||||||||||||||||0||||IA|||||||||||||
IAM||DA|00001639^levodopa^99ING|||X|||||||||||C^ACTIVE|TRMD09^DOCTOR09^TRAINING^^^^^^H0FT||201107060906|||||||00006358^Sinemet^99DRG
IAR|^Anaphylaxis|SV|AL|
IAR|^Hives|MI|AD|5
IAR|^Eye Irritation|U|SE|
IAR|^Chills||AL|