Search in sources :

Example 1 with PRPAMT201307UV02QueryByParameter

use of net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02QueryByParameter in project ipf by oehf.

the class PixV3QueryRequestTransformer method toPrpa.

/**
 * Transforms a simplified query into the full PRPA model.
 *
 * @param simpleQuery The simplified query to transform.
 * @return the PRPA model query or {@code null} if the input was {@code null}.
 */
public PRPAIN201309UV02Type toPrpa(final PixV3QueryRequest simpleQuery) {
    if (simpleQuery == null) {
        return null;
    }
    // Prepare query with fixed values
    final PRPAIN201309UV02Type query = new PRPAIN201309UV02Type();
    query.setITSVersion("XML_1.0");
    query.setInteractionId(new II("2.16.840.1.113883.1.6", "PRPA_IN201309UV02"));
    query.setProcessingCode(new CS("P", null, null));
    query.setProcessingModeCode(new CS("T", null, null));
    query.setAcceptAckCode(new CS("AL", null, null));
    final PRPAIN201309UV02QUQIMT021001UV01ControlActProcess controlActProcess = new PRPAIN201309UV02QUQIMT021001UV01ControlActProcess();
    controlActProcess.setClassCode(ActClassControlAct.CACT);
    controlActProcess.setMoodCode(XActMoodIntentEvent.EVN);
    controlActProcess.setCode(new CD("PRPA_TE201309UV02", null, null));
    query.setControlActProcess(controlActProcess);
    final PRPAMT201307UV02QueryByParameter queryByParameter = new PRPAMT201307UV02QueryByParameter();
    queryByParameter.setStatusCode(new CS("new", null, null));
    queryByParameter.setResponsePriorityCode(new CS("I", null, null));
    queryByParameter.setParameterList(new PRPAMT201307UV02ParameterList());
    controlActProcess.setQueryByParameter(queryByParameter);
    // Fill query with given data
    query.setCreationTime(new TS());
    query.getCreationTime().setValue(HL7DTM.toSimpleString(simpleQuery.getCreationTime()));
    query.setId(simpleQuery.getMessageId());
    query.setReceiver(List.of(this.toReceiver(simpleQuery.getReceiver())));
    query.setSender(this.toSender(simpleQuery.getSender()));
    queryByParameter.setQueryId(simpleQuery.getQueryId());
    final PRPAMT201307UV02PatientIdentifier patientIdentifier = new PRPAMT201307UV02PatientIdentifier();
    patientIdentifier.setValue(List.of(simpleQuery.getQueryPatientId()));
    patientIdentifier.setSemanticsText(new ST());
    patientIdentifier.getSemanticsText().mixed = List.of("Patient.id");
    queryByParameter.getParameterList().setPatientIdentifier(List.of(patientIdentifier));
    for (final String dataSourceOid : simpleQuery.getDataSourceOids()) {
        final PRPAMT201307UV02DataSource dataSource = new PRPAMT201307UV02DataSource();
        dataSource.setValue(List.of(new II(dataSourceOid, null)));
        dataSource.setSemanticsText(new ST());
        dataSource.getSemanticsText().mixed = List.of("DataSource.id");
        queryByParameter.getParameterList().getDataSource().add(dataSource);
    }
    return query;
}
Also used : 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) PRPAIN201309UV02Type(net.ihe.gazelle.hl7v3.prpain201309UV02.PRPAIN201309UV02Type) PRPAMT201307UV02PatientIdentifier(net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02PatientIdentifier)

Example 2 with PRPAMT201307UV02QueryByParameter

use of net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02QueryByParameter in project MobileAccessGateway by i4mi.

the class Iti83RequestConverter method iti83ToIti45Converter.

public String iti83ToIti45Converter(Parameters parameters) throws JAXBException {
    List<Type> targetSystemList = (List<Type>) parameters.getParameters("targetSystem");
    Identifier sourceIdentifier = (Identifier) parameters.getParameter("sourceIdentifier");
    PRPAIN201309UV02Type resultMsg = new PRPAIN201309UV02Type();
    resultMsg.setITSVersion("XML_1.0");
    // String UUID.randomUUID().toString();
    resultMsg.setId(new II(config.getPixQueryOid(), uniqueId()));
    // Now
    resultMsg.setCreationTime(new TS(Timestamp.now().toHL7()));
    resultMsg.setProcessingCode(new CS("T", null, null));
    resultMsg.setProcessingModeCode(new CS("T", null, null));
    resultMsg.setInteractionId(new II("2.16.840.1.113883.1.18", "PRPA_IN201309UV02"));
    resultMsg.setAcceptAckCode(new CS("AL", null, null));
    MCCIMT000100UV01Receiver receiver = new MCCIMT000100UV01Receiver();
    resultMsg.addReceiver(receiver);
    receiver.setTypeCode(CommunicationFunctionType.RCV);
    MCCIMT000100UV01Device receiverDevice = new MCCIMT000100UV01Device();
    receiver.setDevice(receiverDevice);
    receiverDevice.setClassCode(EntityClassDevice.DEV);
    receiverDevice.setDeterminerCode(EntityDeterminer.INSTANCE);
    receiverDevice.setId(Collections.singletonList(new II(config.getPixReceiverOid(), null)));
    MCCIMT000100UV01Sender sender = new MCCIMT000100UV01Sender();
    resultMsg.setSender(sender);
    sender.setTypeCode(CommunicationFunctionType.SND);
    MCCIMT000100UV01Device senderDevice = new MCCIMT000100UV01Device();
    sender.setDevice(senderDevice);
    senderDevice.setClassCode(EntityClassDevice.DEV);
    senderDevice.setDeterminerCode(EntityDeterminer.INSTANCE);
    senderDevice.setId(Collections.singletonList(new II(config.getPixMySenderOid(), null)));
    PRPAIN201309UV02QUQIMT021001UV01ControlActProcess controlActProcess = new PRPAIN201309UV02QUQIMT021001UV01ControlActProcess();
    resultMsg.setControlActProcess(controlActProcess);
    controlActProcess.setClassCode(ActClassControlAct.CACT);
    controlActProcess.setMoodCode(XActMoodIntentEvent.EVN);
    controlActProcess.setCode(new CD("PRPA_TE201309UV02", "2.16.840.1.113883.1.18", null));
    PRPAMT201307UV02QueryByParameter queryByParameter = new PRPAMT201307UV02QueryByParameter();
    controlActProcess.setQueryByParameter(queryByParameter);
    queryByParameter.setQueryId(new II(config.getPixQueryOid(), uniqueId()));
    queryByParameter.setStatusCode(new CS("new", null, null));
    queryByParameter.setResponsePriorityCode(new CS("I", null, null));
    PRPAMT201307UV02ParameterList parameterList = new PRPAMT201307UV02ParameterList();
    queryByParameter.setParameterList(parameterList);
    PRPAMT201307UV02PatientIdentifier patientIdentifier = new PRPAMT201307UV02PatientIdentifier();
    parameterList.addPatientIdentifier(patientIdentifier);
    String system = getScheme(sourceIdentifier.getSystem());
    patientIdentifier.setValue(Collections.singletonList(new II(system, sourceIdentifier.getValue())));
    patientIdentifier.setSemanticsText(ST("Patient.id"));
    if (targetSystemList != null && (targetSystemList.size() > 0)) {
        for (Type targetSystemType : targetSystemList) {
            UriType targetSystem = (UriType) targetSystemType;
            String sourceSystem = getScheme(targetSystem.getValue());
            PRPAMT201307UV02DataSource dataSource = new PRPAMT201307UV02DataSource();
            parameterList.addDataSource(dataSource);
            dataSource.setValue(Collections.singletonList(new II(sourceSystem, null, null)));
            dataSource.setSemanticsText(ST("DataSource.id"));
        }
    }
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    log.debug("PRE CONVERT");
    HL7V3Transformer.marshallMessage(PRPAIN201309UV02Type.class, out, resultMsg);
    log.debug("POST CONVERT");
    String outArray = new String(out.toByteArray());
    log.debug(outArray);
    return outArray;
}
Also used : II(net.ihe.gazelle.hl7v3.datatypes.II) CD(net.ihe.gazelle.hl7v3.datatypes.CD) PRPAMT201307UV02ParameterList(net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02ParameterList) ByteArrayOutputStream(java.io.ByteArrayOutputStream) PRPAIN201309UV02Type(net.ihe.gazelle.hl7v3.prpain201309UV02.PRPAIN201309UV02Type) MCCIMT000100UV01Sender(net.ihe.gazelle.hl7v3.mccimt000100UV01.MCCIMT000100UV01Sender) UriType(org.hl7.fhir.r4.model.UriType) CS(net.ihe.gazelle.hl7v3.datatypes.CS) Type(org.hl7.fhir.r4.model.Type) CommunicationFunctionType(net.ihe.gazelle.hl7v3.voc.CommunicationFunctionType) PRPAIN201309UV02Type(net.ihe.gazelle.hl7v3.prpain201309UV02.PRPAIN201309UV02Type) UriType(org.hl7.fhir.r4.model.UriType) Identifier(org.hl7.fhir.r4.model.Identifier) PRPAMT201307UV02PatientIdentifier(net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02PatientIdentifier) PRPAMT201307UV02DataSource(net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02DataSource) PRPAIN201309UV02QUQIMT021001UV01ControlActProcess(net.ihe.gazelle.hl7v3.prpain201309UV02.PRPAIN201309UV02QUQIMT021001UV01ControlActProcess) PRPAMT201307UV02QueryByParameter(net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02QueryByParameter) PRPAMT201307UV02ParameterList(net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02ParameterList) List(java.util.List) MCCIMT000100UV01Receiver(net.ihe.gazelle.hl7v3.mccimt000100UV01.MCCIMT000100UV01Receiver) PRPAMT201307UV02PatientIdentifier(net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02PatientIdentifier) MCCIMT000100UV01Device(net.ihe.gazelle.hl7v3.mccimt000100UV01.MCCIMT000100UV01Device) TS(net.ihe.gazelle.hl7v3.datatypes.TS)

Example 3 with PRPAMT201307UV02QueryByParameter

use of net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02QueryByParameter in project ipf by oehf.

the class PixV3QueryResponseTransformer method fromPrpa.

/**
 * Transforms a full PRPA response into the simplified model. Data loss can occur, as the simplified model is not
 * complete.
 *
 * @param response The full PRPA response to transform.
 * @return the simplified response or {@code null} if the input was {@code null}.
 */
public PixV3QueryResponse fromPrpa(final PRPAIN201310UV02Type response) {
    if (response == null) {
        return null;
    }
    final PixV3QueryResponse simpleResponse = new PixV3QueryResponse();
    simpleResponse.setMessageId(response.getId());
    simpleResponse.setSender(this.fromSender(response.getSender()));
    if (!response.getReceiver().isEmpty()) {
        simpleResponse.setReceiver(this.fromReceiver(response.getReceiver().get(0)));
    }
    simpleResponse.setCreationTime(Optional.ofNullable(response.getCreationTime()).map(TS::getValue).map(value -> {
        try {
            return HL7DTM.toZonedDateTime(value);
        } catch (final DataTypeException e) {
            return null;
        }
    }).orElse(null));
    if (!response.getAcknowledgement().isEmpty()) {
        final MCCIMT000300UV01Acknowledgement acknowledgement = response.getAcknowledgement().get(0);
        simpleResponse.setAcknowledgementTypeCode(acknowledgement.getTypeCode().getCode());
        if (acknowledgement.getTargetMessage() != null) {
            simpleResponse.setTargetMessageId(acknowledgement.getTargetMessage().getId());
        }
        simpleResponse.getAcknowledgementDetails().addAll(acknowledgement.getAcknowledgementDetail());
    }
    if (response.getControlActProcess() == null) {
        return simpleResponse;
    }
    final PRPAIN201310UV02MFMIMT700711UV01ControlActProcess controlActProcess = response.getControlActProcess();
    if (controlActProcess.getQueryByParameter() == null) {
        return simpleResponse;
    }
    final PRPAMT201307UV02QueryByParameter queryByParameter = controlActProcess.getQueryByParameter();
    simpleResponse.setQueryId(queryByParameter.getQueryId());
    if (queryByParameter.getParameterList() == null) {
        return simpleResponse;
    }
    final PRPAMT201307UV02ParameterList parameterList = queryByParameter.getParameterList();
    if (!parameterList.getPatientIdentifier().isEmpty()) {
        final List<II> patientIds = parameterList.getPatientIdentifier().get(0).getValue();
        if (!patientIds.isEmpty()) {
            simpleResponse.setQueryPatientId(patientIds.get(0));
        }
    }
    for (final PRPAMT201307UV02DataSource dataSource : parameterList.getDataSource()) {
        if (!dataSource.getValue().isEmpty()) {
            simpleResponse.getDataSourceOids().add(dataSource.getValue().get(0).getRoot());
        }
    }
    final MFMIMT700711UV01QueryAck queryAck = controlActProcess.getQueryAck();
    if (queryAck != null) {
        simpleResponse.setQueryResponseCode(queryAck.getQueryResponseCode().getCode());
    }
    if (controlActProcess.getSubject().isEmpty()) {
        return simpleResponse;
    }
    final PRPAIN201310UV02MFMIMT700711UV01RegistrationEvent registrationEvent = Optional.ofNullable(controlActProcess.getSubject().get(0).getRegistrationEvent()).orElse(null);
    if (registrationEvent == null) {
        return simpleResponse;
    }
    simpleResponse.setCustodianOid(Optional.ofNullable(registrationEvent.getCustodian()).map(MFMIMT700711UV01Custodian::getAssignedEntity).map(COCTMT090003UV01AssignedEntity::getId).map(list -> list.isEmpty() ? null : list.get(0)).map(II::getRoot).orElse(null));
    final PRPAMT201304UV02Patient patient = Optional.ofNullable(registrationEvent.getSubject1()).map(PRPAIN201310UV02MFMIMT700711UV01Subject2::getPatient).orElse(null);
    if (patient == null) {
        return simpleResponse;
    }
    simpleResponse.setProviderOrganization(Optional.ofNullable(patient.getProviderOrganization()).orElse(null));
    if (!patient.getId().isEmpty()) {
        simpleResponse.getPatientIds().addAll(patient.getId());
    }
    if (patient.getPatientPerson() != null) {
        if (!patient.getPatientPerson().getName().isEmpty()) {
            simpleResponse.setPersonName(patient.getPatientPerson().getName().get(0));
        }
        simpleResponse.getPersonIds().addAll(patient.getPatientPerson().getId());
        simpleResponse.getAsOtherIDs().addAll(patient.getPatientPerson().getAsOtherIDs());
    }
    return simpleResponse;
}
Also used : net.ihe.gazelle.hl7v3.datatypes(net.ihe.gazelle.hl7v3.datatypes) Device(org.openehealth.ipf.commons.ihe.hl7v3.core.metadata.Device) COCTMT090003UV01AssignedEntity(net.ihe.gazelle.hl7v3.coctmt090003UV01.COCTMT090003UV01AssignedEntity) net.ihe.gazelle.hl7v3.voc(net.ihe.gazelle.hl7v3.voc) PRPAMT201304UV02Patient(net.ihe.gazelle.hl7v3.prpamt201304UV02.PRPAMT201304UV02Patient) PRPAMT201307UV02QueryByParameter(net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02QueryByParameter) net.ihe.gazelle.hl7v3.mccimt000300UV01(net.ihe.gazelle.hl7v3.mccimt000300UV01) HL7DTM(org.openehealth.ipf.commons.ihe.core.HL7DTM) PixV3QueryResponse(org.openehealth.ipf.commons.ihe.hl7v3.core.responses.PixV3QueryResponse) MFMIMT700711UV01Custodian(net.ihe.gazelle.hl7v3.mfmimt700711UV01.MFMIMT700711UV01Custodian) List(java.util.List) PRPAMT201307UV02ParameterList(net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02ParameterList) PRPAMT201307UV02PatientIdentifier(net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02PatientIdentifier) net.ihe.gazelle.hl7v3.prpain201310UV02(net.ihe.gazelle.hl7v3.prpain201310UV02) PRPAMT201307UV02DataSource(net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02DataSource) Optional(java.util.Optional) DataTypeException(ca.uhn.hl7v2.model.DataTypeException) MFMIMT700711UV01QueryAck(net.ihe.gazelle.hl7v3.mfmimt700711UV01.MFMIMT700711UV01QueryAck) PRPAMT201304UV02Person(net.ihe.gazelle.hl7v3.prpamt201304UV02.PRPAMT201304UV02Person) PRPAMT201307UV02ParameterList(net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02ParameterList) PixV3QueryResponse(org.openehealth.ipf.commons.ihe.hl7v3.core.responses.PixV3QueryResponse) PRPAMT201304UV02Patient(net.ihe.gazelle.hl7v3.prpamt201304UV02.PRPAMT201304UV02Patient) DataTypeException(ca.uhn.hl7v2.model.DataTypeException) PRPAMT201307UV02DataSource(net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02DataSource) MFMIMT700711UV01QueryAck(net.ihe.gazelle.hl7v3.mfmimt700711UV01.MFMIMT700711UV01QueryAck) COCTMT090003UV01AssignedEntity(net.ihe.gazelle.hl7v3.coctmt090003UV01.COCTMT090003UV01AssignedEntity) PRPAMT201307UV02QueryByParameter(net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02QueryByParameter)

Example 4 with PRPAMT201307UV02QueryByParameter

use of net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02QueryByParameter in project ipf by oehf.

the class PixV3QueryResponseTransformer method toPrpa.

/**
 * Transforms a simplified response into the full PRPA model.
 *
 * @param simpleResponse The simplified response to transform.
 * @return the PRPA model response or {@code null} if the input was {@code null}.
 */
public PRPAIN201310UV02Type toPrpa(final PixV3QueryResponse simpleResponse) {
    if (simpleResponse == null) {
        return null;
    }
    // Prepare response with fixed values
    final PRPAIN201310UV02Type response = new PRPAIN201310UV02Type();
    response.setITSVersion("XML_1.0");
    response.setInteractionId(new II("2.16.840.1.113883.1.6", "PRPA_IN201310UV02"));
    response.setProcessingCode(new CS("P", null, null));
    response.setProcessingModeCode(new CS("T", null, null));
    response.setAcceptAckCode(new CS("NE", null, null));
    final MCCIMT000300UV01Acknowledgement acknowledgement = new MCCIMT000300UV01Acknowledgement();
    response.getAcknowledgement().add(acknowledgement);
    final PRPAIN201310UV02MFMIMT700711UV01ControlActProcess controlActProcess = new PRPAIN201310UV02MFMIMT700711UV01ControlActProcess();
    controlActProcess.setClassCode(ActClassControlAct.CACT);
    controlActProcess.setMoodCode(XActMoodIntentEvent.EVN);
    controlActProcess.setCode(new CD("PRPA_TE201310UV02", null, null));
    response.setControlActProcess(controlActProcess);
    final MFMIMT700711UV01QueryAck queryAck = new MFMIMT700711UV01QueryAck();
    controlActProcess.setQueryAck(queryAck);
    final PRPAMT201307UV02QueryByParameter queryByParameter = new PRPAMT201307UV02QueryByParameter();
    queryByParameter.setStatusCode(new CS("new", null, null));
    queryByParameter.setResponsePriorityCode(new CS("I", null, null));
    queryByParameter.setParameterList(new PRPAMT201307UV02ParameterList());
    controlActProcess.setQueryByParameter(queryByParameter);
    // Fill response with given data
    response.setCreationTime(new TS());
    response.getCreationTime().setValue(HL7DTM.toSimpleString(simpleResponse.getCreationTime()));
    response.setId(simpleResponse.getMessageId());
    response.setReceiver(List.of(toReceiver(simpleResponse.getReceiver())));
    response.setSender(toSender(simpleResponse.getSender()));
    queryByParameter.setQueryId(simpleResponse.getQueryId());
    final PRPAMT201307UV02PatientIdentifier patientIdentifier = new PRPAMT201307UV02PatientIdentifier();
    patientIdentifier.setValue(List.of(simpleResponse.getQueryPatientId()));
    patientIdentifier.setSemanticsText(new ST());
    patientIdentifier.getSemanticsText().mixed = List.of("Patient.id");
    queryByParameter.getParameterList().setPatientIdentifier(List.of(patientIdentifier));
    for (final String dataSourceOid : simpleResponse.getDataSourceOids()) {
        final PRPAMT201307UV02DataSource dataSource = new PRPAMT201307UV02DataSource();
        dataSource.setValue(List.of(new II(dataSourceOid, null)));
        dataSource.setSemanticsText(new ST());
        dataSource.getSemanticsText().mixed = List.of("DataSource.id");
        queryByParameter.getParameterList().getDataSource().add(dataSource);
    }
    acknowledgement.setTypeCode(new CS(simpleResponse.getAcknowledgementTypeCode(), null, null));
    acknowledgement.setTargetMessage(new MCCIMT000300UV01TargetMessage());
    acknowledgement.getTargetMessage().setId(simpleResponse.getTargetMessageId());
    acknowledgement.getAcknowledgementDetail().addAll(simpleResponse.getAcknowledgementDetails());
    queryAck.setQueryId(simpleResponse.getQueryId());
    queryAck.setQueryResponseCode(new CS(simpleResponse.getQueryResponseCode(), null, null));
    queryAck.setStatusCode(new CS("deliveredResponse", null, null));
    if (!"OK".equals(simpleResponse.getQueryResponseCode())) {
        // If the query response code is not OK, no RegistrationEvent shall be returned
        return response;
    }
    final PRPAIN201310UV02MFMIMT700711UV01Subject1 subject = new PRPAIN201310UV02MFMIMT700711UV01Subject1();
    subject.setTypeCode("SUBJ");
    controlActProcess.getSubject().add(subject);
    final PRPAIN201310UV02MFMIMT700711UV01RegistrationEvent registrationEvent = new PRPAIN201310UV02MFMIMT700711UV01RegistrationEvent();
    registrationEvent.setStatusCode(new CS("ACTIVE", null, null));
    registrationEvent.setClassCode(ActClass.REG);
    registrationEvent.setMoodCode(ActMood.EVN);
    subject.setRegistrationEvent(registrationEvent);
    final PRPAIN201310UV02MFMIMT700711UV01Subject2 subject1 = new PRPAIN201310UV02MFMIMT700711UV01Subject2();
    subject1.setTypeCode(ParticipationTargetSubject.SBJ);
    registrationEvent.setSubject1(subject1);
    final PRPAMT201304UV02Patient patient = new PRPAMT201304UV02Patient();
    patient.setClassCode("PAT");
    patient.setStatusCode(new CS("ACTIVE", null, null));
    patient.setId(simpleResponse.getPatientIds());
    patient.setProviderOrganization(simpleResponse.getProviderOrganization());
    subject1.setPatient(patient);
    final PRPAMT201304UV02Person person = new PRPAMT201304UV02Person();
    person.setClassCode(EntityClass.PSN);
    person.setDeterminerCode(EntityDeterminer.INSTANCE);
    if (simpleResponse.getPersonName() != null) {
        person.getName().add(simpleResponse.getPersonName());
    }
    person.getId().addAll(simpleResponse.getPersonIds());
    person.getAsOtherIDs().addAll(simpleResponse.getAsOtherIDs());
    patient.setPatientPerson(person);
    final MFMIMT700711UV01Custodian custodian = new MFMIMT700711UV01Custodian();
    custodian.setTypeCode(ParticipationType.CST);
    registrationEvent.setCustodian(custodian);
    final COCTMT090003UV01AssignedEntity assignedEntity = new COCTMT090003UV01AssignedEntity();
    assignedEntity.setClassCode(RoleClassAssignedEntity.ASSIGNED);
    assignedEntity.getId().add(new II(simpleResponse.getCustodianOid(), null));
    custodian.setAssignedEntity(assignedEntity);
    return response;
}
Also used : MFMIMT700711UV01Custodian(net.ihe.gazelle.hl7v3.mfmimt700711UV01.MFMIMT700711UV01Custodian) PRPAMT201307UV02ParameterList(net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02ParameterList) PRPAMT201304UV02Patient(net.ihe.gazelle.hl7v3.prpamt201304UV02.PRPAMT201304UV02Patient) PRPAMT201304UV02Person(net.ihe.gazelle.hl7v3.prpamt201304UV02.PRPAMT201304UV02Person) PRPAMT201307UV02DataSource(net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02DataSource) MFMIMT700711UV01QueryAck(net.ihe.gazelle.hl7v3.mfmimt700711UV01.MFMIMT700711UV01QueryAck) COCTMT090003UV01AssignedEntity(net.ihe.gazelle.hl7v3.coctmt090003UV01.COCTMT090003UV01AssignedEntity) PRPAMT201307UV02QueryByParameter(net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02QueryByParameter) PRPAMT201307UV02PatientIdentifier(net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02PatientIdentifier)

Example 5 with PRPAMT201307UV02QueryByParameter

use of net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02QueryByParameter 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

PRPAMT201307UV02DataSource (net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02DataSource)5 PRPAMT201307UV02ParameterList (net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02ParameterList)5 PRPAMT201307UV02QueryByParameter (net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02QueryByParameter)5 PRPAMT201307UV02PatientIdentifier (net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02PatientIdentifier)4 PRPAIN201309UV02QUQIMT021001UV01ControlActProcess (net.ihe.gazelle.hl7v3.prpain201309UV02.PRPAIN201309UV02QUQIMT021001UV01ControlActProcess)3 DataTypeException (ca.uhn.hl7v2.model.DataTypeException)2 List (java.util.List)2 COCTMT090003UV01AssignedEntity (net.ihe.gazelle.hl7v3.coctmt090003UV01.COCTMT090003UV01AssignedEntity)2 MFMIMT700711UV01Custodian (net.ihe.gazelle.hl7v3.mfmimt700711UV01.MFMIMT700711UV01Custodian)2 MFMIMT700711UV01QueryAck (net.ihe.gazelle.hl7v3.mfmimt700711UV01.MFMIMT700711UV01QueryAck)2 PRPAIN201309UV02Type (net.ihe.gazelle.hl7v3.prpain201309UV02.PRPAIN201309UV02Type)2 PRPAMT201304UV02Patient (net.ihe.gazelle.hl7v3.prpamt201304UV02.PRPAMT201304UV02Patient)2 PRPAMT201304UV02Person (net.ihe.gazelle.hl7v3.prpamt201304UV02.PRPAMT201304UV02Person)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 Optional (java.util.Optional)1 net.ihe.gazelle.hl7v3.datatypes (net.ihe.gazelle.hl7v3.datatypes)1 CD (net.ihe.gazelle.hl7v3.datatypes.CD)1 CS (net.ihe.gazelle.hl7v3.datatypes.CS)1 II (net.ihe.gazelle.hl7v3.datatypes.II)1 TS (net.ihe.gazelle.hl7v3.datatypes.TS)1