I have a HL7 message that contains one MSH segment and multiple PIV segments.
Using Java REGEX, I need to do these:
1) extract the entire MSH segment
2) find each occurence of PV1 segment.
3) extract the entire content/segments that exists between each PV1 segment - including the PV1 segment.
How do I accomplish the above?
Below is the sample HL7 msg:
MSH|^~\&|OADD|${FACILITY}|HELIX||201012010910||ORU^R01|20101720000042|T|2.2
PID|||PX65^^^MRENTR||Mayer^Ronny
PV1||I||2|||9898^Jackson^Burt^T|||||||||||IP||||||||||||||||||||||||||201012010840
OBX|1|NM|NA^Sodium^0|1.1|140^3|mmol/L|137-146||||F|||201012010905|IM^|8035^COX^CATHERINE(IM)
OBX|2|NM|K^Potassium^0|1.1|4.5|mmol/L|3.5-5.0||||F|||201012010905|IM^|8035^COX^CATHERINE
(IM)
OBX|3|CE|CL^Chloride^0|1.1|100|mmol/L|98-109||||F|||201012010905|IM^|8035^COX^CATHERINE(IM)
PV1||I||2|||9898^Jackson^Burt^T|||||||||||IP||||||||||||||||||||||||||201012010840
OBX|1|NM|NA^Sodium^0|1.1|140^3|mmol/L|137-146||||F|||201012010905|IM^|8035^COX^CATHERINE(IM)
PV1||I||2|||9898^Jackson^Burt^T|||||||||||IP||||||||||||||||||||||||||201012010840
OBX|1|NM|NA^Sodium^0|1.1|140^3|mmol/L|137-146||||F|||201012010905|IM^|8035^COX^CATHERINE(IM)
So the final goal is to have a msg like this - to have the extracted MSH segment before each PV1 segment. Then create a new HL7 message object that contains each of such HL7 message. In my example, 3 hl7 message will be created - each ofthem will be passed to HAPI parser.
MSH|^~\&|OADD|${FACILITY}|HELIX||201012010910||ORU^R01|20101720000042|T|2.2
PID|||PX65^^^MRENTR||Mayer^Ronny
PV1||I||2|||9898^Jackson^Burt^T|||||||||||IP||||||||||||||||||||||||||201012010840
OBX|1|NM|NA^Sodium^0|1.1|140^3|mmol/L|137-146||||F|||201012010905|IM^|8035^COX^CATHERINE(IM)
OBX|2|NM|K^Potassium^0|1.1|4.5|mmol/L|3.5-5.0||||F|||201012010905|IM^|8035^COX^CATHERINE
(IM)
OBX|3|CE|CL^Chloride^0|1.1|100|mmol/L|98-109||||F|||201012010905|IM^|8035^COX^CATHERINE(IM)
MSH|^~\&|OADD|${FACILITY}|HELIX||201012010910||ORU^R01|20101720000042|T|2.2
PV1||I||2|||9898^Jackson^Burt^T|||||||||||IP||||||||||||||||||||||||||201012010840
OBX|1|NM|NA^Sodium^0|1.1|140^3|mmol/L|137-146||||F|||201012010905|IM^|8035^COX^CATHERINE(IM)
MSH|^~\&|OADD|${FACILITY}|HELIX||201012010910||ORU^R01|20101720000042|T|2.2
PV1||I||2|||9898^Jackson^Burt^T|||||||||||IP||||||||||||||||||||||||||201012010840
OBX|1|NM|NA^Sodium^0|1.1|140^3|mmol/L|137-146||||F|||201012010905|IM^|8035^COX^CATHERINE(IM)