Java Code Examples for ca.uhn.hl7v2.HL7Exception

The following examples show how to use ca.uhn.hl7v2.HL7Exception. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: micro-integrator   Source File: HL7Codec.java    License: Apache License 2.0 6 votes vote down vote up
public int encode(ByteBuffer outBuf, MLLPContext context) throws HL7Exception, IOException {

        if (this.state < READ_COMPLETE) {
            return 0;
        }

        if (this.state == READ_COMPLETE) {

            if ((context.isAutoAck() || context.isApplicationAck()) && !context.isNackMode()) {
                responseBytes = context.getHl7Message().generateACK().encode().getBytes(charsetDecoder.charset());
                context.setApplicationAck(false);
            } else {
                responseBytes = context.getHl7Message().encode().getBytes(charsetDecoder.charset());
            }

            this.state = WRITE_HEADER;
        }

        if (this.state >= WRITE_HEADER) {
            return fillBuffer(outBuf, responseBytes);
        }

        return 0;
    }
 
Example 2
Source Project: micro-integrator   Source File: HL7MessageUtils.java    License: Apache License 2.0 6 votes vote down vote up
public static MessageContext createErrorMessageContext(String rawMessage, Exception errorMsg,
                                                       InboundProcessorParams params)
        throws AxisFault, HL7Exception {
    MessageContext synCtx = createSynapseMessageContext(
            params.getProperties().getProperty(MLLPConstants.HL7_INBOUND_TENANT_DOMAIN));

    if (params.getProperties().getProperty(Axis2HL7Constants.HL7_VALIDATION_PASSED) != null) {
        synCtx.setProperty(Axis2HL7Constants.HL7_VALIDATION_PASSED,
                           params.getProperties().getProperty(Axis2HL7Constants.HL7_VALIDATION_PASSED));
    }

    try {
        synCtx.setProperty(SynapseConstants.ERROR_CODE, SynapseConstants.RCV_IO_ERROR_RECEIVING);
        synCtx.setProperty(SynapseConstants.ERROR_MESSAGE, errorMsg.getMessage());
        synCtx.setProperty(SynapseConstants.ERROR_DETAIL,
                           (errorMsg.getCause() == null ? "null" : errorMsg.getCause().getMessage()));
        synCtx.setProperty(SynapseConstants.ERROR_EXCEPTION, errorMsg);
        synCtx.setEnvelope(createErrorEnvelope(synCtx, rawMessage, errorMsg.getMessage(), params));
    } catch (Exception e) {
        throw new HL7Exception(e);
    }

    return synCtx;
}
 
Example 3
Source Project: localization_nifi   Source File: HapiMessage.java    License: Apache License 2.0 6 votes vote down vote up
public HapiMessage(final Message message) throws HL7Exception {
    this.message = message;

    allSegments = new ArrayList<>();
    populateSegments(message, allSegments);

    segmentMap = new HashMap<>();
    for (final HL7Segment segment : allSegments) {
        final String segmentName = segment.getName();
        List<HL7Segment> segmentList = segmentMap.get(segmentName);
        if (segmentList == null) {
            segmentList = new ArrayList<>();
            segmentMap.put(segmentName, segmentList);
        }

        segmentList.add(segment);
    }
}
 
Example 4
Source Project: elexis-3-core   Source File: HL7_ORU_R01.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Adds a ORU_R01 observation result
 * 
 * @param oru
 * @param patient
 * @param labItem
 * @param labwert
 * @param initial
 * @return
 */
private String addResultInternal(final ORU_R01 oru, final HL7Patient patient,
	final HL7LaborItem labItem, final HL7LaborWert labwert, int orderObservationIndex)
	throws DataTypeException, HL7Exception{
	
	// Observation
	ORU_R01_ORDER_OBSERVATION orderObservation =
		(ORU_R01_ORDER_OBSERVATION) oru.getPATIENT_RESULT().getORDER_OBSERVATION(
			orderObservationIndex);
	fillOBR(orderObservation.getOBR(), orderObservationIndex, labItem);
	fillOBX(orderObservation.getOBSERVATION().getOBX(), patient, labItem, labwert);
	if (labwert.getKommentar() != null && labwert.getKommentar().length() > 0) {
		fillNTE(orderObservation.getNTE(), labwert);
	}
	// Now, let's encode the message and look at the output
	Parser parser = new PipeParser();
	return parser.encode(oru);
}
 
Example 5
Source Project: localization_nifi   Source File: TestHL7Query.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings({"unchecked", "rawtypes"})
public void testSelectField() throws HL7Exception, IOException {
    final HL7Query query = HL7Query.compile("SELECT PID.5");
    final HL7Message msg = createMessage(new File("src/test/resources/hypoglycemia"));
    final QueryResult result = query.evaluate(msg);
    assertTrue(result.isMatch());
    final List<String> labels = result.getLabels();
    assertEquals(1, labels.size());
    assertEquals(1, result.getHitCount());

    final Object names = result.nextHit().getValue("PID.5");
    assertTrue(names instanceof List);
    final List<Object> nameList = (List) names;
    assertEquals(1, nameList.size());
    final HL7Field nameField = (HL7Field) nameList.get(0);
    assertEquals("SMITH^JOHN", nameField.getValue());
}
 
Example 6
Source Project: elexis-3-core   Source File: HL7_ADT_A08.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates an ORU_R01 message
 * 
 * @param patient
 * @param consultation
 * @param labItem
 * @param labwert
 * 
 * @return
 */
public String createText(final HL7Patient patient, HL7Konsultation consultation)
	throws DataTypeException, HL7Exception{
	
	ADT_A08 adt = new ADT_A08();
	// Message
	fillMSH(adt.getMSH(), "ADT", "A08", mandant, this.uniqueMessageControlID, //$NON-NLS-1$ //$NON-NLS-2$
		"8859/1", patient); //$NON-NLS-1$ //$NON-NLS-2$
	
	fillEVN(adt.getEVN());
	
	// Patient
	fillPID(adt.getPID(), patient);
	
	// Patient Visit
	fillPV1(adt.getPV1(), consultation);
	
	// Now, let's encode the message and look at the output
	HapiContext context = new DefaultHapiContext();
	Parser parser = context.getPipeParser();
	return parser.encode(adt);
}
 
Example 7
Source Project: elexis-3-core   Source File: HL7ReaderV231.java    License: Eclipse Public License 1.0 6 votes vote down vote up
private OrcMessage extractOrc(ORC orc) throws HL7Exception{
	if (orc != null) {
		OrcMessage orcMessage = new OrcMessage();
		XCN[] ops = orc.getOrderingProvider();
		for (XCN op : ops) {
			FN fn = op.getFamilyLastName();
			ST familyName = null;
			if (fn != null) {
				familyName = fn.getFamilyName();
			}
			addNameValuesToOrcMessage(op.getGivenName(), familyName, orcMessage);
		}
		return orcMessage;
	}
	return null;
}
 
Example 8
Source Project: localization_nifi   Source File: TestHL7Query.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testIsNull() throws HL7Exception, IOException {
    HL7Query hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.999 IS NULL");
    QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
    assertTrue(result.isMatch());

    hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.1 IS NULL");
    result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
    assertFalse(result.isMatch());

    hl7Query = HL7Query.compile("SELECT MESSAGE WHERE ZZZ IS NULL");
    result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
    assertTrue(result.isMatch());

    hl7Query = HL7Query.compile("SELECT MESSAGE WHERE OBX IS NULL");
    result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
    assertFalse(result.isMatch());
}
 
Example 9
Source Project: localization_nifi   Source File: TestHL7Query.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testNotNull() throws HL7Exception, IOException {
    HL7Query hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.999 NOT NULL");
    QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
    assertFalse(result.isMatch());

    hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.1 NOT NULL");
    result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
    assertTrue(result.isMatch());

    hl7Query = HL7Query.compile("SELECT MESSAGE WHERE ZZZ NOT NULL");
    result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
    assertFalse(result.isMatch());

    hl7Query = HL7Query.compile("SELECT MESSAGE WHERE OBX NOT NULL");
    result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
    assertTrue(result.isMatch());
}
 
Example 10
Source Project: localization_nifi   Source File: ExtractHL7Attributes.java    License: Apache License 2.0 6 votes vote down vote up
private static Map<String, Type> getAllFields(final String segmentKey, final Segment segment, final boolean useNames) throws HL7Exception {
    final Map<String, Type> fields = new TreeMap<>();
    final String[] segmentNames = segment.getNames();
    for (int i = 1; i <= segment.numFields(); i++) {
        final Type field = segment.getField(i, 0);
        if (!isEmpty(field)) {
            final String fieldName;
            if (useNames) {
                fieldName = WordUtils.capitalize(segmentNames[i-1]).replaceAll("\\W+", "");
            } else {
                fieldName = String.valueOf(i);
            }

            final String fieldKey = new StringBuilder()
                .append(segmentKey)
                .append(".")
                .append(fieldName)
                .toString();

            fields.put(fieldKey, field);
        }
    }
    return fields;
}
 
Example 11
Source Project: product-ei   Source File: SampleApp.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Message processMessage(Message theIn) throws ApplicationException, HL7Exception {

    String encodedMessage = new PipeParser().encode(theIn);
    System.out.println("Received message:\n" + encodedMessage + "\n\n");

    // Now we need to generate a message to return. This will generally be an ACK message.
    Segment msh = (Segment) theIn.get("MSH");
    Message retVal;
    try {
        // This method takes in the MSH segment of an incoming message, and generates an
        // appropriate ACK
        retVal = DefaultApplication.makeACK(msh);
    } catch (IOException e) {
        throw new HL7Exception(e);
    }

    return retVal;
}
 
Example 12
Source Project: elexis-3-core   Source File: HL7_ORU_R01.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Reads an ORU_R01 HL7 file
 * 
 * @param text
 *            ISO-8559-1 String
 * @param readWithValidation
 *            True for parsing with validation, False for parsing without validation
 * @return The ORU_R01 message
 * @throws HL7Exception
 */
public ORU_R01 read(String text, boolean readWithValidation) throws HL7Exception{
	Parser p = new PipeParser();
	if (readWithValidation) {
		p.setValidationContext(new ElexisValidation());
	} else {
		p.setValidationContext(new NoValidation());
	}
	Message hl7Msg = p.parse(text);
	if (hl7Msg instanceof ORU_R01) {
		return (ORU_R01) hl7Msg;
	} else {
		addError(
			MessageFormat.format(Messages.HL7_ORU_R01_Error_WrongMsgType, hl7Msg.getName()));
	}
	return null;
}
 
Example 13
Source Project: elexis-3-core   Source File: HL7Writer.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Fills PID segment
 * 
 * @param pid
 * @param patient
 * @throws DataTypeException
 * @throws HL7Exception
 */
protected void fillPID(final ca.uhn.hl7v2.model.v231.segment.PID pid, final HL7Patient patient)
	throws DataTypeException, HL7Exception{
	String sex = ""; //$NON-NLS-1$
	if (patient.isMale() != null) {
		sex = "M"; //$NON-NLS-1$
		if (!patient.isMale().booleanValue()) {
			sex = "F"; //$NON-NLS-1$
		}
	}
	pid.getPid1_SetIDPID().setValue("1"); //$NON-NLS-1$
	pid.getPid2_PatientID().getID().setValue(patient.getPatCode());
	pid.getPid3_PatientIdentifierList(0).getID().setValue(patient.getPatCode());
	pid.getPid4_AlternatePatientIDPID(0).getID().setValue(patient.getPatCode());
	addKontaktToXPN(pid.getPid5_PatientName(0), patient);
	pid.getPid16_MaritalStatus().getCe1_Identifier().setValue(""); //$NON-NLS-1$
	pid.getPid7_DateTimeOfBirth().getTs1_TimeOfAnEvent()
		.setValue(HL7Helper.dateToString(patient.getBirthdate()));
	
	pid.getPid8_Sex().setValue(sex);
	pid.getPid9_PatientAlias(0).getXpn1_FamilyLastName().getFn1_FamilyName().setValue(""); //$NON-NLS-1$
	pid.getPid10_Race(0).getCe1_Identifier().setValue(""); //$NON-NLS-1$
	addAddressToXAD(pid.getPid11_PatientAddress(0), patient);
	pid.getPid12_CountyCode().setValue(""); //$NON-NLS-1$
	addPhone1ToXTN(pid.getPid13_PhoneNumberHome(0), patient);
}
 
Example 14
Source Project: elexis-3-core   Source File: HL7ReaderV26.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Override
public String getSender() throws ElexisException{
	String sender;
	try {
		MSH msh = (MSH) message.get("MSH");
		sender = msh.getMsh4_SendingFacility().getNamespaceID().getValue();
		if (sender == null) {
			sender = msh.getMsh3_SendingApplication().getNamespaceID().getValue();
			if (sender == null) {
				sender = "";
			}
		}
	} catch (HL7Exception e) {
		throw new ElexisException(e.getMessage(), e);
	}
	return sender;
}
 
Example 15
Source Project: elexis-3-core   Source File: HL7ReaderV26.java    License: Eclipse Public License 1.0 6 votes vote down vote up
private OrcMessage extractOrc(ORC orc) throws HL7Exception{
	if (orc != null) {
		OrcMessage orcMessage = new OrcMessage();
		XCN[] ops = orc.getOrderingProvider();
		for (XCN op : ops) {
			FN fn = op.getFamilyName();
			ST familyName = null;
			if (fn != null) {
				familyName = fn.getSurname();
				if (familyName == null) {
					familyName = fn.getOwnSurname();
				}
			}
			addNameValuesToOrcMessage(op.getGivenName(), familyName, orcMessage);
		}
		return orcMessage;
	}
	return null;
}
 
Example 16
Source Project: elexis-3-core   Source File: HL7ReaderV251.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Override
public ObservationMessage readObservation(HL7PatientResolver patientResolver,
	boolean createIfNotFound) throws ElexisException{
	observation = null;
	
	try {
		this.patientResolver = patientResolver;
		if (message.getName().contains("OUL_R22")) {
			readObservationOulR22(createIfNotFound);
		} else {
			readObservationOruR01(createIfNotFound);
		}
	} catch (HL7Exception | ParseException e) {
		throw new ElexisException(e.getMessage(), e);
	}
	
	return observation;
}
 
Example 17
Source Project: nifi   Source File: HapiSegment.java    License: Apache License 2.0 6 votes vote down vote up
public HapiSegment(final Segment segment) throws HL7Exception {
    this.segment = segment;

    final List<HL7Field> fieldList = new ArrayList<>();
    for (int i = 1; i <= segment.numFields(); i++) {
        final Type[] types = segment.getField(i);

        if (types == null || types.length == 0) {
            fieldList.add(new EmptyField());
            continue;
        }

        for (final Type type : types) {
            fieldList.add(new HapiField(type));
        }
    }

    this.fields = Collections.unmodifiableList(fieldList);
}
 
Example 18
Source Project: nifi   Source File: TestHL7Query.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings({"unchecked", "rawtypes"})
public void testSelectField() throws HL7Exception, IOException {
    final HL7Query query = HL7Query.compile("SELECT PID.5");
    final HL7Message msg = hypoglycemia;
    final QueryResult result = query.evaluate(msg);
    assertTrue(result.isMatch());
    final List<String> labels = result.getLabels();
    assertEquals(1, labels.size());
    assertEquals(1, result.getHitCount());

    final Object names = result.nextHit().getValue("PID.5");
    assertTrue(names instanceof List);
    final List<Object> nameList = (List) names;
    assertEquals(1, nameList.size());
    final HL7Field nameField = (HL7Field) nameList.get(0);
    assertEquals("SMITH^JOHN", nameField.getValue());
}
 
Example 19
Source Project: elexis-3-core   Source File: HL7ReaderV24.java    License: Eclipse Public License 1.0 6 votes vote down vote up
private OrcMessage extractOrc(ORC orc) throws HL7Exception{
	if (orc != null) {
		OrcMessage orcMessage = new OrcMessage();
		XCN[] ops = orc.getOrderingProvider();
		for (XCN op : ops) {
			FN fn = op.getFamilyName();
			ST familyName = null;
			if (fn != null) {
				familyName = fn.getSurname();
				if (familyName == null) {
					familyName = fn.getOwnSurname();
				}
			}
			addNameValuesToOrcMessage(op.getGivenName(), familyName, orcMessage);
		}
		return orcMessage;
	}
	return null;
}
 
Example 20
Source Project: nifi   Source File: TestHL7Query.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testNotNull() throws HL7Exception, IOException {
    HL7Query hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.999 NOT NULL");
    QueryResult result = hl7Query.evaluate(hypoglycemia);
    assertFalse(result.isMatch());

    hl7Query = HL7Query.compile("DECLARE result AS REQUIRED OBX SELECT MESSAGE WHERE result.1 NOT NULL");
    result = hl7Query.evaluate(hypoglycemia);
    assertTrue(result.isMatch());

    hl7Query = HL7Query.compile("SELECT MESSAGE WHERE ZZZ NOT NULL");
    result = hl7Query.evaluate(hypoglycemia);
    assertFalse(result.isMatch());

    hl7Query = HL7Query.compile("SELECT MESSAGE WHERE OBX NOT NULL");
    result = hl7Query.evaluate(hypoglycemia);
    assertTrue(result.isMatch());
}
 
Example 21
Source Project: elexis-3-core   Source File: HL7_OML_O21.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates an OMG_O19 message
 * 
 * @param patient
 * @param kostentraeger
 * @param rechnungsempfaenger
 * @param auftragsNummer
 * @param plan
 *            Abrechnungssystem (MV, UVG, VVG, KVG, usw)
 * @param beginDate
 * @param vnr
 *            Versicherungs-, Fall- oder Unfallnr
 * @return
 */
public String createText(final HL7Patient patient, final HL7Kostentraeger rechnungsempfaenger,
	final HL7Kostentraeger kostentraeger, final String plan, final Date beginDate,
	final String fallNr, final long auftragsNummer) throws DataTypeException, HL7Exception{
	
	OML_O21 omg = new OML_O21();
	fillMSH(omg.getMSH(), "OML", "O21", mandant, this.uniqueMessageControlID, //$NON-NLS-1$ //$NON-NLS-2$
		this.uniqueProcessingID, patient); //$NON-NLS-1$ //$NON-NLS-2$
	fillPID(omg.getPATIENT().getPID(), patient);
	fillNK1(omg.getPATIENT().getNK1(), rechnungsempfaenger);
	fillPV1(omg.getPATIENT().getPATIENT_VISIT().getPV1(), patient, beginDate);
	fillIN1(omg.getPATIENT().getINSURANCE().getIN1(), patient, kostentraeger, plan, fallNr);
	fillORC(omg.getORDER().getORC(), "1", auftragsNummer); //$NON-NLS-1$
	
	// Now, let's encode the message and look at the output
	Parser parser = new PipeParser();
	return parser.encode(omg);
}
 
Example 22
Source Project: elexis-3-core   Source File: HL7ReaderV251.java    License: Eclipse Public License 1.0 6 votes vote down vote up
private OrcMessage extractOrc(ORC orc) throws HL7Exception{
	if (orc != null) {
		OrcMessage orcMessage = new OrcMessage();
		XCN[] ops = orc.getOrderingProvider();
		for (XCN op : ops) {
			FN fn = op.getFamilyName();
			ST familyName = null;
			if (fn != null) {
				familyName = fn.getSurname();
				if (familyName == null) {
					familyName = fn.getOwnSurname();
				}
			}
			addNameValuesToOrcMessage(op.getGivenName(), familyName, orcMessage);
		}
		return orcMessage;
	}
	return null;
}
 
Example 23
Source Project: micro-integrator   Source File: HL7MessageUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static Message parse(String msg, boolean validate) throws HL7Exception {
    if (validate) {
        return pipeParser.parse(msg);
    } else {
        return noValidationPipeParser.parse(msg);
    }
}
 
Example 24
Source Project: elexis-3-core   Source File: HL7ReaderV23.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private OrcMessage extractOrc(ORC orc) throws HL7Exception{
	if (orc != null) {
		OrcMessage orcMessage = new OrcMessage();
		XCN[] ops = orc.getOrderingProvider();
		for (XCN op : ops) {
			addNameValuesToOrcMessage(op.getFamilyName(), op.getGivenName(), orcMessage);
		}
		return orcMessage;
	}
	return null;
}
 
Example 25
Source Project: micro-integrator   Source File: HL7MessageUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static Message createNack(Message hl7Msg, String errorMsg) throws HL7Exception {
    if (errorMsg == null) {
        errorMsg = "";
    }
    if (hl7Msg == null) {
        return createDefaultNackMessage(errorMsg);
    } else {
        try {
            return hl7Msg.generateACK(AcknowledgmentCode.AE, new HL7Exception(errorMsg));
        } catch (IOException e) {
            throw new HL7Exception(e);
        }
    }
}
 
Example 26
Source Project: micro-integrator   Source File: HL7Processor.java    License: Apache License 2.0 5 votes vote down vote up
private void handleException(MLLPContext mllpContext, String msg) {
    if (mllpContext.isAutoAck()) {
        try {
            mllpContext.setNackMode(true);
            mllpContext.setHl7Message(HL7MessageUtils.createNack(mllpContext.getHl7Message(), msg));
            mllpContext.requestOutput();
        } catch (HL7Exception e) {
            log.error("Error while generating NACK response.", e);
        }
    } else {
        processError(mllpContext, new Exception(msg));
    }
}
 
Example 27
Source Project: elexis-3-core   Source File: HL7ReaderV22.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Override
public String getSender() throws ElexisException{
	String sender = "";
	try {
		MSH msh = (MSH) message.get("MSH");
		sender = msh.getMsh4_SendingFacility().getValue();
		if (sender == null) {
			sender = "";
		}
	} catch (HL7Exception e) {
		throw new ElexisException(e.getMessage(), e);
	}
	return sender;
}
 
Example 28
Source Project: localization_nifi   Source File: TestHL7Query.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testSelectMessage() throws HL7Exception, IOException {
    final HL7Query query = HL7Query.compile("SELECT MESSAGE");
    final HL7Message msg = createMessage(new File("src/test/resources/hypoglycemia"));
    final QueryResult result = query.evaluate(msg);
    assertTrue(result.isMatch());
    final List<String> labels = result.getLabels();
    assertEquals(1, labels.size());
    assertEquals("MESSAGE", labels.get(0));

    assertEquals(1, result.getHitCount());
    assertEquals(msg, result.nextHit().getValue("MESSAGE"));
}
 
Example 29
Source Project: localization_nifi   Source File: TestHL7Query.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testSelectAbnormalTestResult() throws HL7Exception, IOException {
    final String query = "DECLARE result AS REQUIRED OBX SELECT result WHERE result.7 != 'N' AND result.1 = 1";

    final HL7Query hl7Query = HL7Query.compile(query);
    final QueryResult result = hl7Query.evaluate(createMessage(new File("src/test/resources/hypoglycemia")));
    assertTrue(result.isMatch());
}
 
Example 30
Source Project: nifi   Source File: ExtractHL7Attributes.java    License: Apache License 2.0 5 votes vote down vote up
private static boolean isTimestamp(final Type field) throws HL7Exception {
    if (isEmpty(field)) {
        return false;
    }
    final String fieldName = field.getName();
    return (fieldName.equals("TS") || fieldName.equals("DT") || fieldName.equals("TM"));
}