final HapiContext hapiContext = new DefaultHapiContext(); if (!inputVersion.equals("autodetect")) { hapiContext.setModelClassFactory(new CanonicalModelClassFactory(inputVersion)); hapiContext.setValidationContext((ValidationContext) ValidationContextFactory.noValidation()); final PipeParser parser = hapiContext.getPipeParser(); final String hl7Text = new String(buffer, charset); try { final Message message = parser.parse(hl7Text); final Map<String, String> attributes = getAttributes(message, useSegmentNames, parseSegmentFields); flowFile = session.putAllAttributes(flowFile, attributes);
/** * @see org.openmrs.hl7.HL7Service#parseHL7String(String) */ @Override public Message parseHL7String(String hl7Message) throws HL7Exception { // Any pre-parsing for HL7 messages would go here // or a module can use AOP to pre-parse the message // First, try and parse the message Message message; try { message = parser.parse(hl7Message); } catch (EncodingNotSupportedException e) { throw new HL7Exception("HL7 encoding not supported", e); } catch (HL7Exception e) { throw new HL7Exception("Error parsing message", e); } return message; }
final HapiContext hapiContext = new DefaultHapiContext(); hapiContext.setValidationContext((ca.uhn.hl7v2.validation.ValidationContext) ValidationContextFactory.noValidation()); final PipeParser parser = hapiContext.getPipeParser(); final String hl7Text = new String(buffer, charset); final HL7Message message; try { final Message hapiMessage = parser.parse(hl7Text); message = new HapiMessage(hapiMessage); } catch (final Exception e) {
CX[] idList = pid.getPatientIdentifierList(); if (idList == null || idList.length < 1) { throw new HL7Exception("Missing patient identifier in PID segment"); String assigningAuthority = id.getAssigningAuthority().getNamespaceID().getValue(); String hl7PatientId = id.getIDNumber().getValue(); throw new HL7Exception("Cannot find default location"); throw new HL7Exception("PID segment has no recognizable patient identifiers."); XPN patientNameX = pid.getPatientName(0); if (patientNameX == null) { throw new HL7Exception("Missing patient name in the PID segment"); name.setFamilyName(patientNameX.getFamilyName().getSurname().getValue()); name.setGivenName(patientNameX.getGivenName().getValue()); name.setMiddleName(patientNameX.getSecondAndFurtherGivenNamesOrInitialsThereof().getValue()); if (creator != null) { name.setCreator(creator); String gender = pid.getAdministrativeSex().getValue(); if (gender == null) { throw new HL7Exception("Missing gender in the PID segment"); throw new HL7Exception("Unrecognized gender: " + gender); TS dateOfBirth = pid.getDateTimeOfBirth(); if (dateOfBirth == null || dateOfBirth.getTime() == null || dateOfBirth.getTime().getValue() == null) {
throw new HL7Exception("Missing patient identifier in PID segment"); String hl7PersonId = identifier.getIDNumber().getValue(); String assigningAuthority = identifier.getAssigningAuthority().getNamespaceID().getValue(); } else if (assigningAuthority.equals(HL7Constants.HL7_AUTHORITY_LOCAL)) { String idType = identifier.getIdentifierTypeCode().getValue(); try { if (idType.equals(HL7Constants.HL7_ID_PERSON)) {
/** * @see org.openmrs.hl7.HL7Service#processHL7Message(ca.uhn.hl7v2.model.Message) */ @Override public Message processHL7Message(Message message) throws HL7Exception { // Any post-parsing (pre-routing) processing would go here // or a module can use AOP to do the post-parsing Message response; try { if (!router.canProcess(message)) { throw new HL7Exception("No route for hl7 message: " + message.getName() + ". Make sure you have a module installed that registers a hl7handler for this type"); } response = router.processMessage(message); } catch (ApplicationException e) { throw new HL7Exception("Error while processing HL7 message: " + message.getName(), e); } return response; }
private Provider getProvider(PV1 pv1) throws HL7Exception { XCN hl7Provider = pv1.getAttendingDoctor(0); Provider provider = null; String id = hl7Provider.getIDNumber().getValue(); String assignAuth = hl7Provider.getAssigningAuthority().getUniversalID().getValue(); String type = hl7Provider.getAssigningAuthority().getUniversalIDType().getValue(); String errorMessage; if (StringUtils.hasText(id)) { throw new HL7Exception(errorMessage);
String relCodingSystem = nk1.getRelationship().getNameOfCodingSystem().getValue(); if (!relCodingSystem.equals(HL7Constants.HL7_LOCAL_RELATIONSHIP)) { throw new HL7Exception(Context.getMessageSourceService().getMessage("ORUR01.error.relationshipCoding", new Object[] { relCodingSystem }, null)); String relIdentifier = nk1.getRelationship().getIdentifier().getValue(); throw new HL7Exception(Context.getMessageSourceService().getMessage("ORUR01.error.relationshipType", new Object[] { relIdentifier }, null)); throw new HL7Exception(Context.getMessageSourceService().getMessage("ORUR01.error.relationshipType", new Object[] { relIdentifier }, null)); throw new HL7Exception(Context.getMessageSourceService().getMessage("ORUR01.error.relationshipTypeNotFound", new Object[] { relTypeId }, null)); throw new HL7Exception(Context.getMessageSourceService().getMessage("ORUR01.error.relativeNotCreated"));
/** * @see org.openmrs.hl7.HL7Service#getUuidFromIdentifiers(ca.uhn.hl7v2.model.v25.datatype.CX[]) */ @Override public String getUuidFromIdentifiers(CX[] identifiers) throws HL7Exception { Boolean found = false; String uuid = null; for (CX identifier : identifiers) { // check for UUID as the assigning authority if (OpenmrsUtil.nullSafeEquals(identifier.getAssigningAuthority().getNamespaceID().getValue(), "UUID")) { // check for duplicates if (found && !OpenmrsUtil.nullSafeEquals(identifier.getIDNumber().getValue(), uuid)) { throw new HL7Exception("multiple UUID values found"); } uuid = identifier.getIDNumber().getValue(); found = true; } } // returns null if not found return uuid; }
String id = null; for (EI identifier : msh.getMessageProfileIdentifier()) { if (identifier != null && identifier.getNamespaceID() != null) { String identifierType = identifier.getNamespaceID().getValue(); if (OpenmrsUtil.nullSafeEquals(identifierType, HL7Constants.HL7_FORM_UUID)) { uuid = identifier.getEntityIdentifier().getValue(); } else if (OpenmrsUtil.nullSafeEquals(identifierType, HL7Constants.HL7_FORM_ID)) { id = identifier.getEntityIdentifier().getValue(); } else { log.warn("Form identifier type of " + identifierType + " unknown to ORU R01 processor."); form = Context.getFormService().getForm(formId); } catch (NumberFormatException e) { throw new HL7Exception(Context.getMessageSourceService().getMessage("ORUR01.error.parseFormId"), e);
throw new HL7Exception("Invalid time format '" + s + "'"); throw new HL7Exception("Invalid time format '" + s + "'"); } else { timeString.append("."); throw new HL7Exception("Invalid time format: '" + s + "' [" + timeString + "]", e);
String messageControlId = msh.getMessageControlID().getValue(); log.debug("Found HL7 message in inbound queue with control id = " + messageControlId); String sendingApp = msh.getSendingApplication().getComponent(0).toString(); log.debug("SendingApplication = " + sendingApp); Patient patient = createPatient(pid, sendingApp); if (patient == null) { throw new HL7Exception("Couldn't create Patient object from PID");
String pointOfCare = pl.getPointOfCare().getValue(); String facility = pl.getFacility().getUniversalID().getValue(); if (facility == null) { // we have no tricks left up our sleeve, so throw new HL7Exception("Error trying to treat PL.pointOfCare '" + pointOfCare + "' as a location.location_id", ex);
private User getEnterer(ORC orc) throws HL7Exception { XCN hl7Enterer = orc.getEnteredBy(0); Integer entererId = Context.getHL7Service().resolveUserId(hl7Enterer); if (entererId == null) { throw new HL7Exception(Context.getMessageSourceService().getMessage("ORUR01.error.UnresolvedEnterer")); } User enterer = new User(); enterer.setUserId(entererId); return enterer; }
private Location getLocation(PV1 pv1) throws HL7Exception { PL hl7Location = pv1.getAssignedPatientLocation(); Integer locationId = Context.getHL7Service().resolveLocationId(hl7Location); if (locationId == null) { throw new HL7Exception(Context.getMessageSourceService().getMessage("ORUR01.error.UnresolvedLocation")); } return Context.getLocationService().getLocation(locationId); }
throw new HL7Exception("hl7InQueue argument cannot be null"); throw new HL7Exception("The hl7InQueue message with id: " + hl7InQueue.getHL7InQueueId() + " is already processing. " + ",key=" + hl7InQueue.getHL7SourceKey() + ")"); } else { + Context.getAdministrationService().getGlobalProperty( OpenmrsConstants.GLOBAL_PROPERTY_IGNORE_MISSING_NONLOCAL_PATIENTS, "false")); if (e.getCause() != null && "Could not resolve patient".equals(e.getCause().getMessage()) && !"local".equals(hl7InQueue.getHL7Source().getName()) && "true".equals(Context.getAdministrationService().getGlobalProperty(
throw new HL7Exception("Invalid date '" + s + "'"); throw new HL7Exception("Error parsing date: '" + s.substring(0, 8) + "' for time zone offset'" + s + "'", e); throw new HL7Exception("Invalid date format '" + s + "'"); } else { dateString.append("."); throw new HL7Exception("Error parsing date '" + s + "'");
private Patient getPatient(PID pid) throws HL7Exception { Integer patientId = Context.getHL7Service().resolvePatientId(pid); if (patientId == null) { throw new HL7Exception(Context.getMessageSourceService().getMessage("ORUR01.error.UnresolvedPatient")); } return Context.getPatientService().getPatient(patientId); }
throw new HL7Exception(Context.getMessageSourceService().getMessage("ORUR01.error.hl7ConceptId", new Object[] { hl7ConceptId, uid }, null));