use of ca.uhn.hl7v2.app.ApplicationException in project openmrs-core by openmrs.
the class ORUR01Handler method processMessage.
/**
* Processes an ORU R01 event message
*
* @should create encounter and obs from hl7 message
* @should create basic concept proposal
* @should create concept proposal and with obs alongside
* @should not create problem list observation with concept proposals
* @should append to an existing encounter
* @should create obs group for OBRs
* @should create obs valueCodedName
* @should fail on empty concept proposals
* @should fail on empty concept answers
* @should set value_Coded matching a boolean concept for obs if the answer is 0 or 1 and
* Question datatype is coded
* @should set value as boolean for obs if the answer is 0 or 1 and Question datatype is Boolean
* @should set value_Numeric for obs if Question datatype is Numeric and the answer is either 0
* or 1
* @should set value_Numeric for obs if Question datatype is Numeric
* @should fail if question datatype is coded and a boolean is not a valid answer
* @should fail if question datatype is neither Boolean nor numeric nor coded
* @should create an encounter and find the provider by identifier
* @should create an encounter and find the provider by personId
* @should create an encounter and find the provider by uuid
* @should create an encounter and find the provider by providerId
* @should fail if the provider name type code is not specified and is not a personId
* @should understand form uuid if present
* @should prefer form uuid over id if both are present
* @should prefer form id if uuid is not found
* @should set complex data for obs with complex concepts
*/
@Override
public Message processMessage(Message message) throws ApplicationException {
if (!(message instanceof ORU_R01)) {
throw new ApplicationException(Context.getMessageSourceService().getMessage("ORUR01.error.invalidMessage"));
}
log.debug("Processing ORU_R01 message");
Message response;
try {
ORU_R01 oru = (ORU_R01) message;
response = processORU_R01(oru);
} catch (ClassCastException e) {
log.warn("Error casting " + message.getClass().getName() + " to ORU_R01", e);
throw new ApplicationException(Context.getMessageSourceService().getMessage("ORUR01.error.invalidMessageType ", new Object[] { message.getClass().getName() }, null), e);
} catch (HL7Exception e) {
log.warn("Error while processing ORU_R01 message", e);
throw new ApplicationException(Context.getMessageSourceService().getMessage("ORUR01.error.WhileProcessing"), e);
}
log.debug("Finished processing ORU_R01 message");
return response;
}
use of ca.uhn.hl7v2.app.ApplicationException in project openmrs-core by openmrs.
the class HL7ServiceTest method processHL7Message_shouldParseMessageTypeSuppliedByModule.
/**
* @see HL7Service#processHL7Message(Message)
*/
@Test
@Ignore("TRUNK-3945")
public void processHL7Message_shouldParseMessageTypeSuppliedByModule() throws Exception {
Properties props = super.getRuntimeProperties();
props.setProperty(ModuleConstants.RUNTIMEPROPERTY_MODULE_LIST_TO_LOAD, "org/openmrs/hl7/include/examplehl7handlers-0.1.omod");
// the above module provides a handler for messages of type "ADR" with trigger "A19"
ModuleUtil.startup(props);
// the application context cannot restart here to load in the moduleApplicationContext that
// calls the setHL7Handlers method so we're doing it manually here
Class<Application> c = (Class<Application>) Context.loadClass("org.openmrs.module.examplehl7handlers.ADRHandler");
Application classInstance = c.newInstance();
HashMap<String, Application> map = new HashMap<>();
map.put("ADR_A19", classInstance);
HL7ServiceImpl.getInstance().setHL7Handlers(map);
HL7Service hl7service = Context.getHL7Service();
Message message = hl7service.parseHL7String("MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20080226102656||ADR^A19|JqnfhKKtouEz8kzTk6Zo|P|2.5|1||||||||16^AMRS.ELD.FORMID\r" + "PID|||3^^^^||John3^Doe^||\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|1|NM|5497^CD4, BY FACS^99DCT||450|||||||||20080206\r" + "OBX|2|DT|5096^RETURN VISIT DATE^99DCT||20080229|||||||||20080212");
Assert.assertNotNull(message);
try {
hl7service.processHL7Message(message);
Assert.fail("Should not be here. The ADR_A19 parser provided by the module throws an ApplicationException.");
} catch (HL7Exception e) {
if (e.getCause() != null)
Assert.assertEquals("In ADR A19 parser", e.getCause().getMessage());
else {
log.error("unable to parse message", e);
Assert.fail("something bad happened, check the log statement 1 line up");
}
}
ModuleUtil.shutdown();
}
use of ca.uhn.hl7v2.app.ApplicationException in project openmrs-core by openmrs.
the class ADTA28Handler method processMessage.
/**
* Processes an ADT A28 event message
*/
@Override
public Message processMessage(Message message) throws ApplicationException {
log.debug("Processing ADT_A28 message");
if (!(message instanceof ADT_A05)) {
throw new ApplicationException("Invalid message sent to ADT_A28 handler");
}
Message response;
try {
ADT_A05 adt = (ADT_A05) message;
response = processADT_A28(adt);
} catch (ClassCastException e) {
log.error("Error casting " + message.getClass().getName() + " to ADT_A28", e);
throw new ApplicationException("Invalid message type for handler");
} catch (HL7Exception e) {
log.error("Error while processing ADT_A28 message", e);
throw new ApplicationException(e);
}
log.debug("Finished processing ADT_A28 message");
return response;
}
Aggregations