Search in sources :

Example 1 with PixV3QueryRequest

use of org.openehealth.ipf.commons.ihe.hl7v3.core.requests.PixV3QueryRequest in project ipf by oehf.

the class PixV3QueryResponseTest method testFromQuery.

@Test
public void testFromQuery() {
    final PixV3QueryRequest query = new PixV3QueryRequest();
    query.getDataSourceOids().add("7.8.9");
    query.setQueryPatientId(new II("123", "1.2.3"));
    query.setQueryId(new II("abc", "4.5.6"));
    query.setReceiver(new Device());
    query.getReceiver().getIds().add(new II("receiver", "1.2"));
    query.setSender(new Device());
    query.getSender().getIds().add(new II("sender", "1.3"));
    query.setMessageId(new II("m1", "1.3.5"));
    final PixV3QueryResponse response = PixV3QueryResponse.fromQuery(query);
    assertEquals(query.getDataSourceOids(), response.getDataSourceOids());
    assertEquals(query.getQueryPatientId(), response.getQueryPatientId());
    assertEquals(query.getQueryId(), response.getQueryId());
    assertEquals(query.getReceiver(), response.getSender());
    assertEquals(query.getSender(), response.getReceiver());
    assertEquals(query.getMessageId(), response.getTargetMessageId());
}
Also used : PixV3QueryRequest(org.openehealth.ipf.commons.ihe.hl7v3.core.requests.PixV3QueryRequest) II(net.ihe.gazelle.hl7v3.datatypes.II) Device(org.openehealth.ipf.commons.ihe.hl7v3.core.metadata.Device) Test(org.junit.jupiter.api.Test)

Example 2 with PixV3QueryRequest

use of org.openehealth.ipf.commons.ihe.hl7v3.core.requests.PixV3QueryRequest in project ipf by oehf.

the class PixV3QueryRequestTransformerTest method testTransform.

@Test
public void testTransform() throws Exception {
    final PixV3QueryRequestTransformer transformer = new PixV3QueryRequestTransformer();
    final JAXBContext jaxbContext = JAXBContext.newInstance(PRPAIN201309UV02Type.class);
    final PixV3QueryRequest query = getSampleQuery();
    // Transform simple query to JAXB model
    final PRPAIN201309UV02Type prpain201309UV02Type = transformer.toPrpa(query);
    // Marshall JAXB model
    final Marshaller marshaller = jaxbContext.createMarshaller();
    marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
    marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
    marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF8");
    final StringWriter stringWriter = new StringWriter();
    marshaller.marshal(prpain201309UV02Type, stringWriter);
    final String xml = stringWriter.toString();
    // Unmarshall JAXB model
    final Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
    final PRPAIN201309UV02Type parsedPrpain201309UV02Type = (PRPAIN201309UV02Type) unmarshaller.unmarshal(new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)));
    // Transform JAXB model to simple query
    final PixV3QueryRequest parsedQuery = transformer.fromPrpa(parsedPrpain201309UV02Type);
    // The two simple queries should be equal
    assertIiEquals(query.getQueryPatientId(), parsedQuery.getQueryPatientId());
    assertEquals(query.getDataSourceOids(), parsedQuery.getDataSourceOids());
    assertIiEquals(query.getMessageId(), parsedQuery.getMessageId());
    assertIiEquals(query.getQueryId(), parsedQuery.getQueryId());
    assertDeviceEquals(query.getReceiver(), parsedQuery.getReceiver());
    assertDeviceEquals(query.getSender(), parsedQuery.getSender());
    assertEquals(HL7DTM.toSimpleString(query.getCreationTime()), HL7DTM.toSimpleString(parsedQuery.getCreationTime()));
}
Also used : PixV3QueryRequest(org.openehealth.ipf.commons.ihe.hl7v3.core.requests.PixV3QueryRequest) Marshaller(javax.xml.bind.Marshaller) StringWriter(java.io.StringWriter) ByteArrayInputStream(java.io.ByteArrayInputStream) JAXBContext(javax.xml.bind.JAXBContext) PRPAIN201309UV02Type(net.ihe.gazelle.hl7v3.prpain201309UV02.PRPAIN201309UV02Type) Unmarshaller(javax.xml.bind.Unmarshaller) Test(org.junit.jupiter.api.Test)

Example 3 with PixV3QueryRequest

use of org.openehealth.ipf.commons.ihe.hl7v3.core.requests.PixV3QueryRequest in project ipf by oehf.

the class PixV3QueryRequestTransformerTest method getSampleQuery.

public static PixV3QueryRequest getSampleQuery() {
    final PixV3QueryRequest query = new PixV3QueryRequest();
    query.setCreationTime(ZonedDateTime.now());
    query.getDataSourceOids().add("1.2.3");
    query.getDataSourceOids().add("7.8.9");
    query.setQueryPatientId(new II("123", "1.2.3"));
    query.setQueryId(new II("queryId", "4.5.6"));
    query.setMessageId(new II("m1", "1.3.5"));
    query.setReceiver(new Device());
    query.getReceiver().setDesc(new ED());
    query.getReceiver().getDesc().mixed = List.of("Description 1");
    query.getReceiver().setTelecom(new TEL());
    query.getReceiver().getTelecom().setValue("123456789");
    query.getReceiver().getIds().add(new II("1.2.840.114350.1.13.99999.4567", null));
    query.getReceiver().setSoftwareName(new SC());
    query.getReceiver().getSoftwareName().mixed = List.of("Software name 1");
    query.getReceiver().setManufacturerModelName(new SC());
    query.getReceiver().getManufacturerModelName().mixed = List.of("Manufacturer model name 1");
    query.getReceiver().getDeviceTelecom().add(new TEL());
    query.getReceiver().getDeviceTelecom().get(0).setValue("https://example.org/PIXQuery");
    query.getReceiver().getNames().add(new EN());
    query.getReceiver().getNames().get(0).mixed = List.of("Receiver");
    query.setSender(new Device());
    query.getSender().setDesc(new ED());
    query.getSender().getDesc().mixed = List.of("Description 2");
    query.getSender().setTelecom(new TEL());
    query.getSender().getTelecom().setValue("987654321");
    query.getSender().getIds().add(new II("1.2.840.114350.1.13.99997.2.7788", null));
    query.getSender().setSoftwareName(new SC());
    query.getSender().getSoftwareName().mixed = List.of("Software name 2");
    query.getSender().setManufacturerModelName(new SC());
    query.getSender().getManufacturerModelName().mixed = List.of("Manufacturer model name 2");
    query.getSender().getDeviceTelecom().add(new TEL());
    query.getSender().getDeviceTelecom().get(0).setValue("https://example.org/");
    query.getSender().getNames().add(new EN());
    query.getSender().getNames().get(0).mixed = List.of("Sender");
    return query;
}
Also used : PixV3QueryRequest(org.openehealth.ipf.commons.ihe.hl7v3.core.requests.PixV3QueryRequest) Device(org.openehealth.ipf.commons.ihe.hl7v3.core.metadata.Device)

Example 4 with PixV3QueryRequest

use of org.openehealth.ipf.commons.ihe.hl7v3.core.requests.PixV3QueryRequest in project ipf by oehf.

the class PixV3QueryRequestTransformer method fromPrpa.

/**
 * Transforms a full PRPA query into the simplified model. Data loss can occur, as the simplified model is not
 * complete.
 *
 * @param query The full PRPA query to transform.
 * @return the simplified query or {@code null} if the input was {@code null}.
 */
public PixV3QueryRequest fromPrpa(final PRPAIN201309UV02Type query) {
    if (query == null) {
        return null;
    }
    final PixV3QueryRequest simpleQuery = new PixV3QueryRequest();
    simpleQuery.setMessageId(query.getId());
    simpleQuery.setSender(this.fromSender(query.getSender()));
    if (!query.getReceiver().isEmpty()) {
        simpleQuery.setReceiver(this.fromReceiver(query.getReceiver().get(0)));
    }
    simpleQuery.setCreationTime(Optional.ofNullable(query.getCreationTime()).map(TS::getValue).map(value -> {
        try {
            return HL7DTM.toZonedDateTime(value);
        } catch (final DataTypeException e) {
            return null;
        }
    }).orElse(null));
    if (query.getControlActProcess() == null) {
        return simpleQuery;
    }
    final PRPAIN201309UV02QUQIMT021001UV01ControlActProcess controlActProcess = query.getControlActProcess();
    if (controlActProcess.getQueryByParameter() == null) {
        return simpleQuery;
    }
    final PRPAMT201307UV02QueryByParameter queryByParameter = controlActProcess.getQueryByParameter();
    simpleQuery.setQueryId(queryByParameter.getQueryId());
    if (queryByParameter.getParameterList() == null) {
        return simpleQuery;
    }
    final PRPAMT201307UV02ParameterList parameterList = queryByParameter.getParameterList();
    if (!parameterList.getPatientIdentifier().isEmpty()) {
        final List<II> patientIds = parameterList.getPatientIdentifier().get(0).getValue();
        if (!patientIds.isEmpty()) {
            simpleQuery.setQueryPatientId(patientIds.get(0));
        }
    }
    for (final PRPAMT201307UV02DataSource dataSource : parameterList.getDataSource()) {
        if (!dataSource.getValue().isEmpty()) {
            simpleQuery.getDataSourceOids().add(dataSource.getValue().get(0).getRoot());
        }
    }
    return simpleQuery;
}
Also used : PixV3QueryRequest(org.openehealth.ipf.commons.ihe.hl7v3.core.requests.PixV3QueryRequest) DataTypeException(ca.uhn.hl7v2.model.DataTypeException) PRPAMT201307UV02DataSource(net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02DataSource) PRPAMT201307UV02ParameterList(net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02ParameterList) PRPAIN201309UV02QUQIMT021001UV01ControlActProcess(net.ihe.gazelle.hl7v3.prpain201309UV02.PRPAIN201309UV02QUQIMT021001UV01ControlActProcess) PRPAMT201307UV02QueryByParameter(net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02QueryByParameter)

Aggregations

PixV3QueryRequest (org.openehealth.ipf.commons.ihe.hl7v3.core.requests.PixV3QueryRequest)4 Test (org.junit.jupiter.api.Test)2 Device (org.openehealth.ipf.commons.ihe.hl7v3.core.metadata.Device)2 DataTypeException (ca.uhn.hl7v2.model.DataTypeException)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 StringWriter (java.io.StringWriter)1 JAXBContext (javax.xml.bind.JAXBContext)1 Marshaller (javax.xml.bind.Marshaller)1 Unmarshaller (javax.xml.bind.Unmarshaller)1 II (net.ihe.gazelle.hl7v3.datatypes.II)1 PRPAIN201309UV02QUQIMT021001UV01ControlActProcess (net.ihe.gazelle.hl7v3.prpain201309UV02.PRPAIN201309UV02QUQIMT021001UV01ControlActProcess)1 PRPAIN201309UV02Type (net.ihe.gazelle.hl7v3.prpain201309UV02.PRPAIN201309UV02Type)1 PRPAMT201307UV02DataSource (net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02DataSource)1 PRPAMT201307UV02ParameterList (net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02ParameterList)1 PRPAMT201307UV02QueryByParameter (net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02QueryByParameter)1