private PV1 getPV1(ORU_R01 oru) { return oru.getPATIENT_RESULT().getPATIENT().getVISIT().getPV1(); }
private ORC getORC(ORU_R01 oru) { return oru.getPATIENT_RESULT().getORDER_OBSERVATION().getORC(); }
private PID getPID(ORU_R01 oru) { return oru.getPATIENT_RESULT().getPATIENT().getPID(); }
int numObr = patientResult.getORDER_OBSERVATIONReps(); for (int i = 0; i < numObr; i++) { if (log.isDebugEnabled()) { log.debug("Processing OBR (" + i + " of " + numObr + ")"); ORU_R01_ORDER_OBSERVATION orderObs = patientResult.getORDER_OBSERVATION(i); OBR obr = orderObs.getOBR(); int totalNTEs = parent.getNTEReps(); for (int iNTE = 0; iNTE < totalNTEs; iNTE++) { for (FT obxComment : parent.getNTE(iNTE).getComment()) { if (comments.length() > 0) { comments.append(" "); int numObs = orderObs.getOBSERVATIONReps(); HL7Exception errorInHL7Queue = null; for (int j = 0; j < numObs; j++) { OBX obx = orderObs.getOBSERVATION(j).getOBX(); try { log.debug("Parsing observation");
/** * finds NK1 segments in an ORU_R01 message. all HAPI-rendered Messages have at least one NK1 * segment but if the original message truly does not contain an NK1, the setID will be null on * the generated NK1 * * @param oru ORU_R01 message to be parsed for NK1 segments * @return list of not-null NK1 segments * @throws HL7Exception */ public List<NK1> getNK1List(ORU_R01 oru) throws HL7Exception { List<NK1> res = new ArrayList<>(); // there will always be at least one NK1, even if the original message does not contain one for (int i = 0; i < oru.getPATIENT_RESULT().getPATIENT().getNK1Reps(); i++) { // if the setIDNK1 value is null, this NK1 is blank if (oru.getPATIENT_RESULT().getPATIENT().getNK1(i).getSetIDNK1().getValue() != null) { res.add(oru.getPATIENT_RESULT().getPATIENT().getNK1(i)); } } return res; }
/** * Returns a specific repetition of * ROL (Role) - creates it if necessary * * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0) * @throws HL7Exception if the repetition requested is more than one * greater than the number of existing repetitions. */ public ROL getROL(int rep) { ROL retVal = getTyped("ROL", rep, ROL.class); return retVal; }
/** * Returns the number of existing repetitions of ROL */ public int getROLReps() { return getReps("ROL"); }
/** * Returns the number of existing repetitions of ROL */ public int getROLReps() { return getReps("ROL"); }
/** * <p> * Returns a non-modifiable List containing all current existing repetitions of DB1. * <p> * <p> * Note that unlike {@link #getDB1()}, this method will not create any reps * if none are already present, so an empty list may be returned. * </p> */ public java.util.List<DB1> getDB1All() throws HL7Exception { return getAllAsList("DB1", DB1.class); }
/** * Returns a specific repetition of * ROL (Role) - creates it if necessary * * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0) * @throws HL7Exception if the repetition requested is more than one * greater than the number of existing repetitions. */ public ROL getROL(int rep) { ROL retVal = getTyped("ROL", rep, ROL.class); return retVal; }
/** * Returns the number of existing repetitions of ROL */ public int getROLReps() { return getReps("ROL"); }
/** * @throws HL7Exception * @see HL7Service#resolveLocationId(ca.uhn.hl7v2.model.v25.datatype.PL) */ @Test public void resolveLocationId_shouldReturnInternalIdentifierOfLocationIfOnlyLocationIdIsSpecified() 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|1^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); }
/** * @throws HL7Exception * @see HL7Service#resolveUserId(ca.uhn.hl7v2.model.v25.datatype.XCN) */ @Test public void resolveUserId_shouldReturnUserUsingFirstAndLastNameGivenUserIDIsNull() throws HL7Exception { HL7Service hl7service = Context.getHL7Service(); //construct a message such that id Number at ORC is null 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" + "ORC|RE||||||||20080226102537|^Otterbourg^Bruno\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; ORC orc = oru.getPATIENT_RESULT().getORDER_OBSERVATION().getORC(); XCN xcn = orc.getEnteredBy(0); Integer userId = hl7service.resolveUserId(xcn); assertThat(userId, is(501)); }
/** * Returns * the first repetition of * PROCEDURE (a Group object) - creates it if necessary */ public BAR_P01_PROCEDURE getPROCEDURE() { BAR_P01_PROCEDURE retVal = getTyped("PROCEDURE", BAR_P01_PROCEDURE.class); return retVal; }
/** * @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); }
/** * @throws HL7Exception * @see HL7Service#resolveUserId(ca.uhn.hl7v2.model.v25.datatype.XCN) */ @Test public void resolveUserId_shouldReturnUserUsingUsername() throws HL7Exception { HL7Service hl7service = Context.getHL7Service(); //construct a message such that id Number at ORC is null 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" + "ORC|RE||||||||20080226102537|^butch\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; ORC orc = oru.getPATIENT_RESULT().getORDER_OBSERVATION().getORC(); XCN xcn = orc.getEnteredBy(0); Integer userId = hl7service.resolveUserId(xcn); assertThat(userId, is(502)); } }
/** * Returns a specific repetition of * GT1 (Guarantor) - creates it if necessary * * @param rep The repetition index (0-indexed, i.e. the first repetition is at index 0) * @throws HL7Exception if the repetition requested is more than one * greater than the number of existing repetitions. */ public GT1 getGT1(int rep) { GT1 retVal = getTyped("GT1", rep, GT1.class); return retVal; }
/** * @throws HL7Exception * @see HL7Service#resolveLocationId(ca.uhn.hl7v2.model.v25.datatype.PL) */ @Test public void resolveLocationId_shouldReturnNullIfLocationIdAndNameAreIncorrect() 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&Unknown&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.assertNull(locationId); }
/** * @throws HL7Exception * @see HL7Service#resolveUserId(ca.uhn.hl7v2.model.v25.datatype.XCN) */ @Test public void resolveUserId_shouldReturnNullForAmbiguousUsersUsingFirstAndLastNameGivenUserIDIsNull() throws HL7Exception { HL7Service hl7service = Context.getHL7Service(); executeDataSet(XML_FILENAME); //construct a message such that id Number at ORC is null 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&Unknown&0||||^Super User (1-8)|||||||||||||||||||||||||||||||||||||20080212|||||||V\r" + "ORC|RE||||||||20080226102537|^User^Super\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; ORC orc = oru.getPATIENT_RESULT().getORDER_OBSERVATION().getORC(); XCN xcn = orc.getEnteredBy(0); //userId should be null since there exist two ambiguous users that has givename=Super and lastname=User. Integer userId = hl7service.resolveUserId(xcn); Assert.assertNull(userId); }
/** * Returns * the first repetition of * NK1 (Next of Kin / Associated Parties) - creates it if necessary */ public NK1 getNK1() { NK1 retVal = getTyped("NK1", NK1.class); return retVal; }