/** * Get an openmrs Concept object out of the given hl7 coded with exceptions element * * @param codedElement cwe to pull from * @param uid unique string for this message for any error reporting purposes * @return new Concept object * @throws HL7Exception if parsing errors occur */ private Concept getConcept(CWE codedElement, String uid) throws HL7Exception { String hl7ConceptId = codedElement.getIdentifier().getValue(); String codingSystem = codedElement.getNameOfCodingSystem().getValue(); return getConcept(hl7ConceptId, codingSystem, uid); }
/** * Get an openmrs Concept object out of the given hl7 coded element * * @param codedElement ce to pull from * @param uid unique string for this message for any error reporting purposes * @return new Concept object * @throws HL7Exception if parsing errors occur */ private Concept getConcept(CE codedElement, String uid) throws HL7Exception { String hl7ConceptId = codedElement.getIdentifier().getValue(); String codingSystem = codedElement.getNameOfCodingSystem().getValue(); return getConcept(hl7ConceptId, codingSystem, uid); }
/** * Return a java date object for the given TS * * @param ts TS to parse * @return date object or null * @throws HL7Exception */ private Date getDatetime(TS ts) throws HL7Exception { Date datetime = null; DTM value = ts.getTime(); if (value.getYear() == 0 || value.getValue() == null) { return null; } try { datetime = getDate(value.getYear(), value.getMonth(), value.getDay(), value.getHour(), value.getMinute(), value .getSecond()); } catch (DataTypeException e) { } return datetime; }
for (CX id : idList) { String assigningAuthority = id.getAssigningAuthority().getNamespaceID().getValue(); String hl7PatientId = id.getIDNumber().getValue(); 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"); if (dateOfBirth == null || dateOfBirth.getTime() == null || dateOfBirth.getTime().getValue() == null) { throw new HL7Exception("Missing birth date in the PID segment"); ID precisionTemp = dateOfBirth.getDegreeOfPrecision(); if (precisionTemp != null && precisionTemp.getValue() != null) { String precision = precisionTemp.getValue().toUpperCase(); log.debug("The birthdate is estimated: " + precision);
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#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; }
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)) {
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.");
@Transactional(readOnly = true) public Integer resolvePersonId(XCN xcn) throws HL7Exception { String idNumber = xcn.getIDNumber().getValue(); String familyName = xcn.getFamilyName().getSurname().getValue(); String givenName = xcn.getGivenName().getValue();
String pointOfCare = pl.getPointOfCare().getValue(); String facility = pl.getFacility().getUniversalID().getValue();
/** * Derive a concept name from the CWE component of an hl7 message. * * @param altIdentifier * @param altCodingSystem * @return */ private ConceptName getConceptName(ST altIdentifier, ID altCodingSystem) throws HL7Exception { if (altIdentifier != null && HL7Constants.HL7_LOCAL_CONCEPT_NAME.equals(altCodingSystem.getValue())) { String hl7ConceptNameId = altIdentifier.getValue(); return getConceptName(hl7ConceptNameId); } return null; }
} else if ( ack instanceof ca.uhn.hl7v2.model.v25.message.ACK ) { ca.uhn.hl7v2.model.v25.message.ACK mod = (ca.uhn.hl7v2.model.v25.message.ACK) ack; mod.getMSH().getSendingApplication().getNamespaceID().setValue( APPNAME ); mod.getMSH().getSendingFacility().getNamespaceID().setValue( APPNAME ); ackMessage = mod.encode(); } else if ( ack instanceof ca.uhn.hl7v2.model.v251.message.ACK ) {
public final class Cooking extends SystemOfUnits { private static HashSet<Unit<?>> UNITS = new HashSet<Unit<?>>(); private Cooking() { } public static Cooking getInstance() { return INSTANCE; } private static final Cooking INSTANCE = new SI(); public static final BaseUnit<CookingVolume> TABLESPOON = si(new BaseUnit<CookingVolume>("Tbsp")); ... public static final Unit<CookingVolume> GRAM = TABLESPOON.divide(1000); } public interface CookingVolume extends Quantity { public final static Unit<CookingVolume> UNIT = Cooking.TABLESPOON; }
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);
} else if ( structure instanceof ca.uhn.hl7v2.model.v25.segment.MSH ) { messageType = ( (ca.uhn.hl7v2.model.v25.segment.MSH) structure ).getMessageType().getMessageStructure().getValue(); } else if ( structure instanceof ca.uhn.hl7v2.model.v251.segment.MSH ) { messageType =
private Date tsToDate(TS ts) throws HL7Exception { // need to handle timezone String dtm = ts.getTime().getValue(); int year = Integer.parseInt(dtm.substring(0, 4)); int month = (dtm.length() >= 6 ? Integer.parseInt(dtm.substring(4, 6)) - 1 : 0); int day = (dtm.length() >= 8 ? Integer.parseInt(dtm.substring(6, 8)) : 1); int hour = (dtm.length() >= 10 ? Integer.parseInt(dtm.substring(8, 10)) : 0); int min = (dtm.length() >= 12 ? Integer.parseInt(dtm.substring(10, 12)) : 0); int sec = (dtm.length() >= 14 ? Integer.parseInt(dtm.substring(12, 14)) : 0); Calendar cal = Calendar.getInstance(); cal.set(year, month, day, hour, min, sec); return cal.getTime(); }
/** * Derive a concept name from the CWE component of an hl7 message. * * @param cwe * @return * @throws HL7Exception */ private ConceptName getConceptName(CWE cwe) throws HL7Exception { ST altIdentifier = cwe.getAlternateIdentifier(); ID altCodingSystem = cwe.getNameOfAlternateCodingSystem(); return getConceptName(altIdentifier, altCodingSystem); }
/** * Derive a concept name from the CE component of an hl7 message. * * @param ce * @return * @throws HL7Exception */ private ConceptName getConceptName(CE ce) throws HL7Exception { ST altIdentifier = ce.getAlternateIdentifier(); ID altCodingSystem = ce.getNameOfAlternateCodingSystem(); return getConceptName(altIdentifier, altCodingSystem); }
for (CX id : identifiers) { String assigningAuthority = id.getAssigningAuthority().getNamespaceID().getValue(); String hl7PatientId = id.getIDNumber().getValue(); name.setFamilyName(patientNameX.getFamilyName().getSurname().getValue()); name.setGivenName(patientNameX.getGivenName().getValue()); name.setMiddleName(patientNameX.getSecondAndFurtherGivenNamesOrInitialsThereof().getValue()); person.addName(name); String gender = nk1.getAdministrativeSex().getValue(); if (gender == null) { throw new HL7Exception("Missing gender in an NK1 segment"); if (dateOfBirth == null || dateOfBirth.getTime() == null || dateOfBirth.getTime().getValue() == null) { throw new HL7Exception("Missing birth date in an NK1 segment"); person.setBirthdate(HL7Util.parseHL7Timestamp(dateOfBirth.getTime().getValue())); ID precisionTemp = dateOfBirth.getDegreeOfPrecision(); if (precisionTemp != null && precisionTemp.getValue() != null) { String precision = precisionTemp.getValue().toUpperCase(); log.debug("The birthdate is estimated: " + precision);
private Date tsToDate(TS ts) throws HL7Exception { // need to handle timezone String dtm = ts.getTime().getValue(); int year = Integer.parseInt(dtm.substring(0, 4)); int month = (dtm.length() >= 6 ? Integer.parseInt(dtm.substring(4, 6)) - 1 : 0); int day = (dtm.length() >= 8 ? Integer.parseInt(dtm.substring(6, 8)) : 1); int hour = (dtm.length() >= 10 ? Integer.parseInt(dtm.substring(8, 10)) : 0); int min = (dtm.length() >= 12 ? Integer.parseInt(dtm.substring(10, 12)) : 0); int sec = (dtm.length() >= 14 ? Integer.parseInt(dtm.substring(12, 14)) : 0); Calendar cal = Calendar.getInstance(); cal.set(year, month, day, hour, min, sec); return cal.getTime(); } }