Search in sources :

Example 1 with PRPAMT201304UV02Person

use of net.ihe.gazelle.hl7v3.prpamt201304UV02.PRPAMT201304UV02Person 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)

Aggregations

COCTMT090003UV01AssignedEntity (net.ihe.gazelle.hl7v3.coctmt090003UV01.COCTMT090003UV01AssignedEntity)1 MFMIMT700711UV01Custodian (net.ihe.gazelle.hl7v3.mfmimt700711UV01.MFMIMT700711UV01Custodian)1 MFMIMT700711UV01QueryAck (net.ihe.gazelle.hl7v3.mfmimt700711UV01.MFMIMT700711UV01QueryAck)1 PRPAMT201304UV02Patient (net.ihe.gazelle.hl7v3.prpamt201304UV02.PRPAMT201304UV02Patient)1 PRPAMT201304UV02Person (net.ihe.gazelle.hl7v3.prpamt201304UV02.PRPAMT201304UV02Person)1 PRPAMT201307UV02DataSource (net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02DataSource)1 PRPAMT201307UV02ParameterList (net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02ParameterList)1 PRPAMT201307UV02PatientIdentifier (net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02PatientIdentifier)1 PRPAMT201307UV02QueryByParameter (net.ihe.gazelle.hl7v3.prpamt201307UV02.PRPAMT201307UV02QueryByParameter)1