use of ca.uhn.hl7v2.model.v26.segment.MSH in project openmrs-core by openmrs.
the class ORUR01HandlerTest method processMessage_shouldFailIfQuestionDatatypeIsNeitherBooleanNorNumericNorCoded.
/**
* @see ORUR01Handler#processMessage(Message)
*/
@Test(expected = ApplicationException.class)
public void processMessage_shouldFailIfQuestionDatatypeIsNeitherBooleanNorNumericNorCoded() throws Exception {
String hl7string = "MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20080226102656||ORU^R01|JqnfhKKtouEz8kzTk6Zo|P|2.5|1||||||||16^AMRS.ELD.FORMID\r" + "PID|||7^^^^||Collet^Test^Chebaskwony||\r" + "PV1||O|1^Unknown Location||||1^Super User (1-8)|||||||||||||||||||||||||||||||||||||20080212|||||||V\r" + "ORC|RE||||||||20080226102537|1^Super User\r" + "OBR|1|||1238^MEDICAL RECORD OBSERVATIONS^99DCT\r" + "OBX|2|NM|19^FAVORITE FOOD, NON-CODED^99DCT||1|||||||||20080206";
Assert.assertEquals("Text", Context.getConceptService().getConcept(19).getDatatype().getName());
Message hl7message = parser.parse(hl7string);
router.processMessage(hl7message);
}
use of ca.uhn.hl7v2.model.v26.segment.MSH in project openmrs-core by openmrs.
the class ORUR01HandlerTest method processMessage_shouldCreateConceptProposalAndWithObsAlongside.
/**
* Should create a concept proposal because of the key string in the message
*
* @see ORUR01Handler#processMessage(Message)
*/
@Test
public void processMessage_shouldCreateConceptProposalAndWithObsAlongside() throws Exception {
// remember initial occurrence of proposal's text in the model
int initialOccurrences = Context.getConceptService().getConceptProposals("ASDFASDFASDF").size();
String hl7string = "MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20081006115934||ORU^R01|a1NZBpKqu54QyrWBEUKf|P|2.5|1||||||||3^AMRS.ELD.FORMID\r" + "PID|||7^^^^~asdf^^^^||Joe^ ^Smith||\r" + "PV1||O|1^Bishop Muge||||1^asdf asdf (5-9)|||||||||||||||||||||||||||||||||||||20081003|||||||V\r" + "ORC|RE||||||||20081006115645|1^Super User\r" + "OBR|1|||1238^MEDICAL RECORD OBSERVATIONS^99DCT\r" + "OBX|2|DT|5096^RETURN VISIT DATE^99DCT||20081004|||||||||20081003\r" + "OBR|3|||1284^PROBLEM LIST^99DCT\r" + "OBX|2|CWE|6042^PROBLEM ADDED^99DCT||PROPOSED^ASDFASDFASDF^99DCT|||||||||20081003";
Message hl7message = parser.parse(hl7string);
router.processMessage(hl7message);
// make sure that the proposal was added
Assert.assertEquals("Processing of the HL7 message did not result in the new proposal being added to the model", initialOccurrences + 1, Context.getConceptService().getConceptProposals("ASDFASDFASDF").size());
}
use of ca.uhn.hl7v2.model.v26.segment.MSH in project wildfly-camel by wildfly-extras.
the class HL7IntegrationTest method testMarshalUnmarshal.
@Test
@SuppressWarnings("resource")
public void testMarshalUnmarshal() throws Exception {
final String msg = "MSH|^~\\&|MYSENDER|MYRECEIVER|MYAPPLICATION||200612211200||QRY^A19|1234|P|2.4\r";
final HL7DataFormat format = new HL7DataFormat();
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start").marshal(format).unmarshal(format).to("mock:result");
}
});
camelctx.start();
try {
HapiContext context = new DefaultHapiContext();
Parser p = context.getGenericParser();
Message hapimsg = p.parse(msg);
ProducerTemplate producer = camelctx.createProducerTemplate();
Message result = (Message) producer.requestBody("direct:start", hapimsg);
Assert.assertEquals(hapimsg.toString(), result.toString());
} finally {
camelctx.stop();
}
}
use of ca.uhn.hl7v2.model.v26.segment.MSH in project pentaho-kettle by pentaho.
the class HL7KettleParser method extractValues.
public static List<HL7Value> extractValues(Message message) throws Exception {
Terser terser = new Terser(message);
SegmentFinder finder = terser.getFinder();
List<HL7Value> values = new ArrayList<HL7Value>();
int childNr = 1;
while (finder.hasNextChild()) {
// next group in the message (MSH, PID, EVN and so on)
//
finder.nextChild();
Structure[] structures = finder.getCurrentChildReps();
for (int i = 0; i < structures.length; i++) {
Structure structure = structures[i];
parseStructure(values, message, terser, structure, Integer.toString(childNr));
}
childNr++;
}
return values;
}
Aggregations