use of ca.uhn.hl7v2.HL7Exception in project openmrs-core by openmrs.
the class HL7ServiceTest method resolveLocationId_shouldReturnInternalIdentifierOfLocationIfOnlyLocationNameIsSpecified.
/**
* @throws HL7Exception
* @see HL7Service#resolveLocationId(ca.uhn.hl7v2.model.v25.datatype.PL)
*/
@Test
public void resolveLocationId_shouldReturnInternalIdentifierOfLocationIfOnlyLocationNameIsSpecified() throws HL7Exception {
executeDataSet("org/openmrs/hl7/include/ORUTest-initialData.xml");
HL7Service hl7service = Context.getHL7Service();
Message message = hl7service.parseHL7String("MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20080226102656||ORU^R01|JqnfhKKtouEz8kzTk6Zo|P|2.5|1||||||||16^AMRS.ELD.FORMID\r" + "PID|||3^^^^||John3^Doe^||\r" + "NK1|1|Hornblower^Horatio^L|2B^Sibling^99REL||||||||||||M|19410501|||||||||||||||||1000^^^L^PN||||\r" + "PV1||O|99999^0^0^0&Test Location&0||||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");
ORU_R01 oru = (ORU_R01) message;
PV1 pv1 = oru.getPATIENT_RESULT().getPATIENT().getVISIT().getPV1();
Assert.assertNotNull("PV1 parsed as null", pv1);
PL hl7Location = pv1.getAssignedPatientLocation();
Integer locationId = hl7service.resolveLocationId(hl7Location);
Assert.assertEquals("Resolved and given locationId shoud be equals", Integer.valueOf(1), locationId);
}
use of ca.uhn.hl7v2.HL7Exception in project streamsx.health by IBMStreams.
the class HapiMessageHandler method processMessage.
@Override
public Message processMessage(Message theMessage, Map<String, Object> arg1) throws ReceivingApplicationException, HL7Exception {
server.messageArrived(theMessage);
Message ack;
try {
// Always use the default parser to generate an ack
// HAPI seems to get into trouble if the ADT_AXX superstructure
// is used.
// Internally, when it tries to generate an ack message
// the super structure setting in the model class factory causes the ADT_AXX message
// to get created instead of the ACK getting created. This is to override the model
// class factory so that the proper class can be generated.
theMessage.setParser(ackParser);
ack = theMessage.generateACK();
return ack;
} catch (IOException e) {
TRACE.log(TraceLevel.ERROR, "Unable to generate ack message", e);
}
return theMessage;
}
use of ca.uhn.hl7v2.HL7Exception in project streamsx.health by IBMStreams.
the class ObxToSplMapper method parseOBX.
private void parseOBX(ArrayList<Observation> observations, String obxTs, String obxLocation, OBX obx, String sendingApp, String sendingFacility) throws HL7Exception {
Observation observation = new Observation();
observation.setTs(obxTs);
observation.setLocation(obxLocation);
String observationId = obx.getObservationIdentifier().getIdentifier().getValue();
String unit = obx.getUnits().getIdentifier().getValue();
observation.setObservationId(observationId);
observation.setUnit(unit);
observation.setSendingApp(sendingApp);
observation.setSendingFacility(sendingFacility);
Varies[] values = obx.getObservationValue();
for (Varies value : values) {
observation.setObservationValue(value.encode());
observations.add(observation);
}
}
use of ca.uhn.hl7v2.HL7Exception in project tdi-studio-se by Talend.
the class HL7MessageTreeContentProvider method getChildren.
public Object[] getChildren(Object parentElement) {
List values = new ArrayList();
if (parentElement instanceof Message) {
Message messParent = (Message) parentElement;
String[] childNames = messParent.getNames();
if (!values.isEmpty()) {
values.clear();
}
for (int i = 0; i < childNames.length; i++) {
try {
Structure[] childReps = messParent.getAll(childNames[i]);
for (int j = 0; j < childReps.length; j++) {
if (childReps[j] instanceof Message) {
values.add(childReps[j]);
}
if (childReps[j] instanceof Group) {
values.add((Group) childReps[j]);
allSegmentFromGroup.clear();
getAllSegmentsFromGroup((Group) childReps[j]);
}
if (childReps[j] instanceof Segment) {
SegmentModel sModel = new SegmentModel((Segment) childReps[j], messParent, i, j);
if (sModel.getTypes() != null && sModel.getTypes().length > 0) {
values.add(sModel);
if (!allSegmentsForMessage.contains(sModel)) {
allSegmentsForMessage.add(sModel);
}
}
}
}
// values.addAll(Arrays.asList(childReps));
} catch (HL7Exception e) {
e.printStackTrace();
}
}
return values.toArray();
}
if (parentElement instanceof Segment) {
values.clear();
Segment segment = (Segment) parentElement;
SegmentModel sm = new SegmentModel(segment, segment, 0, 0);
return sm.getTypes();
}
if (parentElement instanceof SegmentModel) {
SegmentModel sm = (SegmentModel) parentElement;
return sm.getTypes();
}
if (parentElement instanceof TypeModel) {
TypeModel tm = (TypeModel) parentElement;
return tm.getPrimitives();
}
if (parentElement instanceof Group) {
values.clear();
Group group = (Group) parentElement;
String[] childNames = group.getNames();
for (int i = 0; i < childNames.length; i++) {
try {
Structure[] childReps = group.getAll(childNames[i]);
for (int j = 0; j < childReps.length; j++) {
if (childReps[j] instanceof Segment) {
SegmentModel sm = new SegmentModel((Segment) childReps[j], group, i, j);
if (sm.getTypes() != null && sm.getTypes().length > 0) {
values.add(sm);
}
} else {
values.add(childReps[j]);
}
}
// values.addAll(Arrays.asList(childReps));
} catch (HL7Exception e) {
e.printStackTrace();
}
}
return values.toArray();
}
return new Object[0];
}
use of ca.uhn.hl7v2.HL7Exception in project tdi-studio-se by Talend.
the class HL7PublicUtil method getChildList.
public Object[] getChildList(Object parentElement) {
List values = new ArrayList();
if (parentElement instanceof Message) {
Message messParent = (Message) parentElement;
String[] childNames = messParent.getNames();
if (!values.isEmpty()) {
values.clear();
}
for (int i = 0; i < childNames.length; i++) {
try {
Structure[] childReps = messParent.getAll(childNames[i]);
for (int j = 0; j < childReps.length; j++) {
if (childReps[j] instanceof Message) {
values.add(childReps[j]);
}
if (childReps[j] instanceof Group) {
allSegmentFromGroup.clear();
getAllSegmentsFromGroup((Group) childReps[j]);
if (allSegmentFromGroup.size() > 0) {
values.addAll(Arrays.asList(allSegmentFromGroup.toArray(new SegmentModel[0])));
}
}
if (childReps[j] instanceof Segment) {
SegmentModel sModel = new SegmentModel((Segment) childReps[j], messParent, i, j);
if (sModel.getTypes() != null && sModel.getTypes().length > 0) {
values.add(sModel);
if (!allSegmentsForMessage.contains(sModel)) {
allSegmentsForMessage.add(sModel);
}
}
}
}
// values.addAll(Arrays.asList(childReps));
} catch (HL7Exception e) {
e.printStackTrace();
}
}
return values.toArray();
}
if (parentElement instanceof Segment) {
values.clear();
Segment segment = (Segment) parentElement;
SegmentModel sm = new SegmentModel(segment, segment, 0, 0);
return sm.getTypes();
}
if (parentElement instanceof SegmentModel) {
SegmentModel sm = (SegmentModel) parentElement;
return sm.getTypes();
}
if (parentElement instanceof TypeModel) {
TypeModel tm = (TypeModel) parentElement;
return tm.getPrimitives();
}
if (parentElement instanceof Group) {
values.clear();
Group group = (Group) parentElement;
String[] childNames = group.getNames();
for (int i = 0; i < childNames.length; i++) {
try {
Structure[] childReps = group.getAll(childNames[i]);
for (int j = 0; j < childReps.length; j++) {
if (childReps[j] instanceof Segment) {
SegmentModel sm = new SegmentModel((Segment) childReps[j], group, i, j);
if (sm.getTypes() != null && sm.getTypes().length > 0) {
values.add(sm);
}
} else {
values.add(childReps[j]);
}
}
// values.addAll(Arrays.asList(childReps));
} catch (HL7Exception e) {
e.printStackTrace();
}
}
return values.toArray();
}
return new Object[0];
}
Aggregations