Search in sources :

Example 1 with CD

use of net.ihe.gazelle.hl7v3.datatypes.CD 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 CD

use of net.ihe.gazelle.hl7v3.datatypes.CD 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 CD

use of net.ihe.gazelle.hl7v3.datatypes.CD in project MobileAccessGateway by i4mi.

the class Iti93AddRequestConverter method doCreate.

/**
 * add a new patient
 * @param header
 * @param entriesByReference
 * @return
 * @throws JAXBException
 */
public String doCreate(MessageHeader header, Map<String, BundleEntryComponent> entriesByReference) throws JAXBException {
    PRPAIN201301UV02Type resultMsg = new PRPAIN201301UV02Type();
    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_IN201301UV02"));
    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)));
    PRPAIN201301UV02MFMIMT700701UV01ControlActProcess controlActProcess = new PRPAIN201301UV02MFMIMT700701UV01ControlActProcess();
    resultMsg.setControlActProcess(controlActProcess);
    controlActProcess.setClassCode(ActClassControlAct.CACT);
    controlActProcess.setMoodCode(XActMoodIntentEvent.EVN);
    controlActProcess.setCode(new CD("PRPA_TE201301UV02", null, "2.16.840.1.113883.1.18"));
    for (BundleEntryComponent entry : entriesByReference.values()) {
        if (entry.getResource() instanceof Patient) {
            HTTPVerb method = entry.getRequest().getMethod();
            if (method == null)
                throw new InvalidRequestException("HTTP verb missing in Bundle for Patient resource.");
            Patient in = (Patient) entry.getResource();
            PRPAIN201301UV02MFMIMT700701UV01Subject1 subject = new PRPAIN201301UV02MFMIMT700701UV01Subject1();
            controlActProcess.addSubject(subject);
            subject.setTypeCode("SUBJ");
            // ???
            subject.setContextConductionInd(false);
            PRPAIN201301UV02MFMIMT700701UV01RegistrationEvent registrationEvent = new PRPAIN201301UV02MFMIMT700701UV01RegistrationEvent();
            subject.setRegistrationEvent(registrationEvent);
            registrationEvent.setClassCode(ActClass.REG);
            registrationEvent.setMoodCode(ActMood.EVN);
            // ???
            registrationEvent.setStatusCode(new CS("active", null, null));
            PRPAIN201301UV02MFMIMT700701UV01Subject2 subject1 = new PRPAIN201301UV02MFMIMT700701UV01Subject2();
            registrationEvent.setSubject1(subject1);
            subject1.setTypeCode(ParticipationTargetSubject.SBJ);
            PRPAMT201301UV02Patient patient = new PRPAMT201301UV02Patient();
            subject1.setPatient(patient);
            patient.setClassCode("PAT");
            // ???
            patient.setStatusCode(new CS("active", null, null));
            PRPAMT201301UV02Person patientPerson = new PRPAMT201301UV02Person();
            patient.setPatientPerson(patientPerson);
            patientPerson.setClassCode(EntityClass.PSN);
            patientPerson.setDeterminerCode(EntityDeterminer.INSTANCE);
            // TODO How is the correct mapping done?
            for (Identifier id : in.getIdentifier()) {
                patient.addId(patientIdentifier(id));
            }
            for (HumanName name : in.getName()) {
                patientPerson.addName(transform(name));
            }
            patientPerson.setBirthTime(transform(in.getBirthDateElement()));
            if (in.hasGender()) {
                switch(in.getGender()) {
                    case MALE:
                        patientPerson.setAdministrativeGenderCode(new CE("M", "Male", "2.16.840.1.113883.12.1"));
                        break;
                    case FEMALE:
                        patientPerson.setAdministrativeGenderCode(new CE("F", "Female", "2.16.840.1.113883.12.1"));
                        break;
                    case OTHER:
                        patientPerson.setAdministrativeGenderCode(new CE("A", "Ambiguous", "2.16.840.1.113883.12.1"));
                        break;
                    case UNKNOWN:
                        patientPerson.setAdministrativeGenderCode(new CE("U", "Unknown", "2.16.840.1.113883.12.1"));
                        break;
                }
            }
            if (in.hasAddress())
                patientPerson.setAddr(new ArrayList<AD>());
            for (Address address : in.getAddress()) {
                patientPerson.addAddr(transform(address));
            }
            for (ContactPoint contactPoint : in.getTelecom()) {
                patientPerson.addTelecom(transform(contactPoint));
            }
            List<II> orgIds = new ArrayList<II>();
            Organization managingOrg = getManagingOrganization(in);
            // NULL POINTER CHECK
            for (Identifier id : managingOrg.getIdentifier()) {
                orgIds.add(new II(getScheme(id.getSystem()), null));
            }
            if (in.hasDeceasedBooleanType()) {
                patientPerson.setDeceasedInd(new BL(in.getDeceasedBooleanType().getValue()));
            }
            if (in.hasDeceasedDateTimeType()) {
                patientPerson.setDeceasedTime(transform(in.getDeceasedDateTimeType()));
            }
            if (in.hasMultipleBirthBooleanType()) {
                patientPerson.setMultipleBirthInd(new BL(in.getMultipleBirthBooleanType().getValue()));
            }
            if (in.hasMultipleBirthIntegerType()) {
                patientPerson.setMultipleBirthOrderNumber(new INT(in.getMultipleBirthIntegerType().getValue()));
            }
            if (in.hasMaritalStatus()) {
                patientPerson.setMaritalStatusCode(transform(in.getMaritalStatus()));
            }
            if (in.hasCommunication()) {
                for (PatientCommunicationComponent pcc : in.getCommunication()) {
                    PRPAMT201301UV02LanguageCommunication languageCommunication = new PRPAMT201301UV02LanguageCommunication();
                    languageCommunication.setLanguageCode(transform(pcc.getLanguage()));
                    // NULL POINTER EXCEPTION
                    if (pcc.hasPreferred())
                        languageCommunication.setPreferenceInd(new BL(pcc.getPreferred()));
                    patientPerson.addLanguageCommunication(languageCommunication);
                }
            }
            COCTMT150003UV03Organization providerOrganization = new COCTMT150003UV03Organization();
            patient.setProviderOrganization(providerOrganization);
            providerOrganization.setClassCode(EntityClassOrganization.ORG);
            providerOrganization.setDeterminerCode(EntityDeterminer.INSTANCE);
            providerOrganization.setId(orgIds);
            ON name = null;
            if (managingOrg.hasName()) {
                name = new ON();
                name.setMixed(Collections.singletonList(managingOrg.getName()));
                providerOrganization.setName(Collections.singletonList(name));
            }
            COCTMT150003UV03ContactParty contactParty = new COCTMT150003UV03ContactParty();
            contactParty.setClassCode(RoleClassContact.CON);
            for (ContactPoint contactPoint : managingOrg.getTelecom()) {
                contactParty.addTelecom(transform(contactPoint));
            }
            if (managingOrg.hasAddress())
                contactParty.setAddr(new ArrayList<AD>());
            for (Address address : managingOrg.getAddress()) {
                contactParty.addAddr(transform(address));
            }
            if (managingOrg.hasContact()) {
                OrganizationContactComponent occ = managingOrg.getContactFirstRep();
                COCTMT150003UV03Person contactPerson = new COCTMT150003UV03Person();
                contactPerson.setClassCode(EntityClass.PSN);
                contactPerson.setDeterminerCode(EntityDeterminer.INSTANCE);
                if (occ.hasName())
                    contactPerson.setName(Collections.singletonList(transform(occ.getName())));
                contactParty.setContactPerson(contactPerson);
            }
            providerOrganization.setContactParty(Collections.singletonList(contactParty));
            MFMIMT700701UV01Custodian custodian = new MFMIMT700701UV01Custodian();
            registrationEvent.setCustodian(custodian);
            custodian.setTypeCode(ParticipationType.CST);
            COCTMT090003UV01AssignedEntity assignedEntity = new COCTMT090003UV01AssignedEntity();
            custodian.setAssignedEntity(assignedEntity);
            assignedEntity.setClassCode(RoleClassAssignedEntity.ASSIGNED);
            List<II> custIds = new ArrayList<II>();
            custIds.add(new II(getScheme(config.getCustodianOid()), null));
            assignedEntity.setId(custIds);
            // assignedEntity.setId(orgIds);
            COCTMT090003UV01Organization assignedOrganization = new COCTMT090003UV01Organization();
            assignedEntity.setAssignedOrganization(assignedOrganization);
            assignedOrganization.setClassCode(EntityClassOrganization.ORG);
            assignedOrganization.setDeterminerCode(EntityDeterminer.INSTANCE);
            if (managingOrg.hasName()) {
                assignedOrganization.setName(Collections.singletonList(name));
            }
        }
    }
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    HL7V3Transformer.marshallMessage(PRPAIN201301UV02Type.class, out, resultMsg);
    String outArray = new String(out.toByteArray());
    return outArray;
}
Also used : HTTPVerb(org.hl7.fhir.r4.model.Bundle.HTTPVerb) PRPAIN201301UV02MFMIMT700701UV01Subject1(net.ihe.gazelle.hl7v3.prpain201301UV02.PRPAIN201301UV02MFMIMT700701UV01Subject1) PRPAIN201301UV02MFMIMT700701UV01Subject2(net.ihe.gazelle.hl7v3.prpain201301UV02.PRPAIN201301UV02MFMIMT700701UV01Subject2) COCTMT150003UV03Organization(net.ihe.gazelle.hl7v3.coctmt150003UV03.COCTMT150003UV03Organization) EntityClassOrganization(net.ihe.gazelle.hl7v3.voc.EntityClassOrganization) Organization(org.hl7.fhir.r4.model.Organization) COCTMT090003UV01Organization(net.ihe.gazelle.hl7v3.coctmt090003UV01.COCTMT090003UV01Organization) Address(org.hl7.fhir.r4.model.Address) ArrayList(java.util.ArrayList) PRPAMT201301UV02Person(net.ihe.gazelle.hl7v3.prpamt201301UV02.PRPAMT201301UV02Person) BL(net.ihe.gazelle.hl7v3.datatypes.BL) INT(net.ihe.gazelle.hl7v3.datatypes.INT) PRPAMT201301UV02Patient(net.ihe.gazelle.hl7v3.prpamt201301UV02.PRPAMT201301UV02Patient) HumanName(org.hl7.fhir.r4.model.HumanName) ContactPoint(org.hl7.fhir.r4.model.ContactPoint) Identifier(org.hl7.fhir.r4.model.Identifier) PRPAIN201301UV02MFMIMT700701UV01ControlActProcess(net.ihe.gazelle.hl7v3.prpain201301UV02.PRPAIN201301UV02MFMIMT700701UV01ControlActProcess) PatientCommunicationComponent(org.hl7.fhir.r4.model.Patient.PatientCommunicationComponent) InvalidRequestException(ca.uhn.fhir.rest.server.exceptions.InvalidRequestException) MCCIMT000100UV01Device(net.ihe.gazelle.hl7v3.mccimt000100UV01.MCCIMT000100UV01Device) ON(net.ihe.gazelle.hl7v3.datatypes.ON) II(net.ihe.gazelle.hl7v3.datatypes.II) CD(net.ihe.gazelle.hl7v3.datatypes.CD) PRPAMT201301UV02LanguageCommunication(net.ihe.gazelle.hl7v3.prpamt201301UV02.PRPAMT201301UV02LanguageCommunication) CE(net.ihe.gazelle.hl7v3.datatypes.CE) COCTMT090003UV01Organization(net.ihe.gazelle.hl7v3.coctmt090003UV01.COCTMT090003UV01Organization) Patient(org.hl7.fhir.r4.model.Patient) PRPAMT201301UV02Patient(net.ihe.gazelle.hl7v3.prpamt201301UV02.PRPAMT201301UV02Patient) PRPAIN201301UV02MFMIMT700701UV01RegistrationEvent(net.ihe.gazelle.hl7v3.prpain201301UV02.PRPAIN201301UV02MFMIMT700701UV01RegistrationEvent) ByteArrayOutputStream(java.io.ByteArrayOutputStream) MCCIMT000100UV01Sender(net.ihe.gazelle.hl7v3.mccimt000100UV01.MCCIMT000100UV01Sender) CS(net.ihe.gazelle.hl7v3.datatypes.CS) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) COCTMT150003UV03ContactParty(net.ihe.gazelle.hl7v3.coctmt150003UV03.COCTMT150003UV03ContactParty) COCTMT150003UV03Person(net.ihe.gazelle.hl7v3.coctmt150003UV03.COCTMT150003UV03Person) OrganizationContactComponent(org.hl7.fhir.r4.model.Organization.OrganizationContactComponent) COCTMT150003UV03Organization(net.ihe.gazelle.hl7v3.coctmt150003UV03.COCTMT150003UV03Organization) COCTMT090003UV01AssignedEntity(net.ihe.gazelle.hl7v3.coctmt090003UV01.COCTMT090003UV01AssignedEntity) PRPAIN201301UV02Type(net.ihe.gazelle.hl7v3.prpain201301UV02.PRPAIN201301UV02Type) MFMIMT700701UV01Custodian(net.ihe.gazelle.hl7v3.mfmimt700701UV01.MFMIMT700701UV01Custodian) MCCIMT000100UV01Receiver(net.ihe.gazelle.hl7v3.mccimt000100UV01.MCCIMT000100UV01Receiver) TS(net.ihe.gazelle.hl7v3.datatypes.TS)

Example 4 with CD

use of net.ihe.gazelle.hl7v3.datatypes.CD in project MobileAccessGateway by i4mi.

the class Iti78RequestConverter method iti78ToIti47Converter.

public String iti78ToIti47Converter(@Header("FhirRequestParameters") Iti78SearchParameters parameters) throws JAXBException {
    PRPAIN201305UV02Type resultMsg = new PRPAIN201305UV02Type();
    resultMsg.setITSVersion("XML_1.0");
    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.6", "PRPA_IN201305UV02"));
    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)));
    PRPAIN201305UV02QUQIMT021001UV01ControlActProcess controlActProcess = new PRPAIN201305UV02QUQIMT021001UV01ControlActProcess();
    resultMsg.setControlActProcess(controlActProcess);
    controlActProcess.setClassCode(ActClassControlAct.CACT);
    controlActProcess.setMoodCode(XActMoodIntentEvent.EVN);
    controlActProcess.setCode(new CD("PRPA_TE201305UV02", "2.16.840.1.113883.1.6", null));
    PRPAMT201306UV02QueryByParameter queryByParameter = new PRPAMT201306UV02QueryByParameter();
    controlActProcess.setQueryByParameter(queryByParameter);
    queryByParameter.setQueryId(new II(config.getPixQueryOid(), uniqueId()));
    queryByParameter.setStatusCode(new CS("new", null, null));
    queryByParameter.setResponsePriorityCode(new CS("I", null, null));
    queryByParameter.setResponseModalityCode(new CS("R", null, null));
    PRPAMT201306UV02ParameterList parameterList = new PRPAMT201306UV02ParameterList();
    queryByParameter.setParameterList(parameterList);
    TokenParam id = parameters.get_id();
    if (id != null) {
        String v = id.getValue();
        int idx = v.indexOf("-");
        if (idx > 0) {
            PRPAMT201306UV02LivingSubjectId livingSubjectId = new PRPAMT201306UV02LivingSubjectId();
            livingSubjectId.addValue(new II(v.substring(0, idx), v.substring(idx + 1)));
            livingSubjectId.setSemanticsText(ST("LivingSubject.id"));
            parameterList.addLivingSubjectId(livingSubjectId);
        }
    }
    // active -> patientStatusCode
    TokenParam active = parameters.getActive();
    if (active != null) {
        String activeCode = "active";
        PRPAMT201306UV02PatientStatusCode patientStatusCode = new PRPAMT201306UV02PatientStatusCode();
        patientStatusCode.setValue(new CS(activeCode, null, null));
        parameterList.addPatientStatusCode(patientStatusCode);
    }
    // patientAddress
    StringParam postalCode = parameters.getPostalCode();
    StringParam state = parameters.getState();
    StringParam city = parameters.getCity();
    StringParam country = parameters.getCountry();
    StringParam address = parameters.getAddress();
    if (postalCode != null || state != null || city != null || country != null || address != null) {
        PRPAMT201306UV02PatientAddress patientAddress = new PRPAMT201306UV02PatientAddress();
        AD ad = new AD();
        if (postalCode != null)
            ad.addPostalCode(element(AdxpPostalCode.class, postalCode.getValue()));
        if (state != null)
            ad.addState(element(AdxpState.class, state.getValue()));
        if (city != null)
            ad.addCity(element(AdxpCity.class, city.getValue()));
        if (country != null)
            ad.addCountry(element(AdxpCountry.class, country.getValue()));
        // TODO How to support address filter?
        patientAddress.addValue(ad);
        patientAddress.setSemanticsText(ST("Patient.addr"));
        parameterList.addPatientAddress(patientAddress);
    }
    // livingSubjectBirthTime
    DateAndListParam birthdate = parameters.getBirthDate();
    if (birthdate != null) {
        IVLTS ivlts = new IVLTS();
        for (DateOrListParam birthdateOr : birthdate.getValuesAsQueryTokens()) {
            for (DateParam birthdateParam : birthdateOr.getValuesAsQueryTokens()) {
                Date lDate = null;
                Date hDate = null;
                TemporalPrecisionEnum precision = birthdateParam.getPrecision();
                ParamPrefixEnum prefix = birthdateParam.getPrefix();
                if (prefix == null)
                    prefix = ParamPrefixEnum.EQUAL;
                Calendar cal = Calendar.getInstance();
                cal.setTime(birthdateParam.getValue());
                switch(precision) {
                    case SECOND:
                        cal.set(Calendar.MILLISECOND, 0);
                        lDate = cal.getTime();
                        cal.set(Calendar.MILLISECOND, 1000);
                        hDate = cal.getTime();
                        break;
                    case MINUTE:
                        cal.set(Calendar.MILLISECOND, 0);
                        cal.set(Calendar.SECOND, 0);
                        lDate = cal.getTime();
                        cal.add(Calendar.MINUTE, 1);
                        hDate = cal.getTime();
                        break;
                    case DAY:
                        cal.set(Calendar.MILLISECOND, 0);
                        cal.set(Calendar.SECOND, 0);
                        cal.set(Calendar.MINUTE, 0);
                        cal.set(Calendar.HOUR_OF_DAY, 0);
                        lDate = cal.getTime();
                        cal.add(Calendar.DAY_OF_MONTH, 1);
                        hDate = cal.getTime();
                        break;
                    case MONTH:
                        int month = cal.get(Calendar.MONTH);
                        int year = cal.get(Calendar.YEAR);
                        cal.set(year, month, 1, 0, 0, 0);
                        lDate = cal.getTime();
                        cal.add(Calendar.MONTH, 1);
                        hDate = cal.getTime();
                        break;
                    case YEAR:
                        year = cal.get(Calendar.YEAR);
                        cal.set(year, 0, 1, 0, 0, 0);
                        lDate = cal.getTime();
                        cal.add(Calendar.YEAR, 1);
                        hDate = cal.getTime();
                        break;
                    case MILLI:
                    default:
                        lDate = cal.getTime();
                        cal.add(Calendar.MILLISECOND, 1);
                        hDate = cal.getTime();
                        break;
                }
                switch(prefix) {
                    case GREATERTHAN:
                        ivlts.setLow(transform(hDate));
                        break;
                    case LESSTHAN:
                        ivlts.setHigh(transform(lDate));
                        break;
                    case GREATERTHAN_OR_EQUALS:
                        ivlts.setLow(transform(lDate));
                        break;
                    case LESSTHAN_OR_EQUALS:
                        ivlts.setHigh(transform(hDate));
                        break;
                    case STARTS_AFTER:
                        ivlts.setLow(transform(hDate));
                        break;
                    case ENDS_BEFORE:
                        ivlts.setHigh(transform(lDate));
                        break;
                    case EQUAL:
                    case APPROXIMATE:
                        ivlts.setLow(transform(lDate));
                        ivlts.setHigh(transform(hDate));
                        break;
                    // 
                    default:
                        throw new InvalidRequestException("Date operation not supported.");
                }
            }
        }
        PRPAMT201306UV02LivingSubjectBirthTime livingSubjectBirthTime = new PRPAMT201306UV02LivingSubjectBirthTime();
        livingSubjectBirthTime.addValue(ivlts);
        livingSubjectBirthTime.setSemanticsText(ST("LivingSubject.birthTime"));
        parameterList.addLivingSubjectBirthTime(livingSubjectBirthTime);
    }
    // given, family -> livingSubjectName
    StringAndListParam given = parameters.getGiven();
    StringAndListParam family = parameters.getFamily();
    StringParam givenElem = given != null ? given.getValuesAsQueryTokens().get(0).getValuesAsQueryTokens().get(0) : null;
    StringParam familyElem = family != null ? family.getValuesAsQueryTokens().get(0).getValuesAsQueryTokens().get(0) : null;
    if (givenElem != null || familyElem != null) {
        PRPAMT201306UV02LivingSubjectName livingSubjectName = new PRPAMT201306UV02LivingSubjectName();
        livingSubjectName.setSemanticsText(ST("Patient.name"));
        EN name = new EN();
        if (familyElem != null) {
            name.addFamily(element(EnFamily.class, familyElem.getValue()));
            if (!familyElem.isExact())
                name.setUse("SRCH");
        }
        if (givenElem != null) {
            name.addGiven(element(EnGiven.class, givenElem.getValue()));
            if (!givenElem.isExact())
                name.setUse("SRCH");
        }
        livingSubjectName.addValue(name);
        livingSubjectName.setSemanticsText(ST("LivingSubject.name"));
        parameterList.addLivingSubjectName(livingSubjectName);
    }
    // gender -> livingSubjectAdministrativeGender
    TokenParam gender = parameters.getGender();
    if (gender != null) {
        PRPAMT201306UV02LivingSubjectAdministrativeGender livingSubjectAdministrativeGender = new PRPAMT201306UV02LivingSubjectAdministrativeGender();
        switch(gender.getValue().toUpperCase()) {
            case "MALE":
                livingSubjectAdministrativeGender.addValue(new CE("M", "Male", "2.16.840.1.113883.12.1"));
                break;
            case "FEMALE":
                livingSubjectAdministrativeGender.addValue(new CE("F", "Female", "2.16.840.1.113883.12.1"));
                break;
            case "OTHER":
                livingSubjectAdministrativeGender.addValue(new CE("A", "Ambiguous", "2.16.840.1.113883.12.1"));
                break;
            case "UNKNOWN":
                livingSubjectAdministrativeGender.addValue(new CE("U", "Unknown", "2.16.840.1.113883.12.1"));
                break;
            default:
                throw new InvalidRequestException("Unknown gender query parameter value");
        }
        livingSubjectAdministrativeGender.setSemanticsText(ST("LivingSubject.administrativeGender"));
        parameterList.addLivingSubjectAdministrativeGender(livingSubjectAdministrativeGender);
    }
    // identifiers -> livingSubjectId or otherIDsScopingOrganization
    TokenAndListParam identifiers = parameters.getIdentifiers();
    if (identifiers != null) {
        for (TokenOrListParam idOr : identifiers.getValuesAsQueryTokens()) {
            for (TokenParam identifier : idOr.getValuesAsQueryTokens()) {
                if (identifier.getValue() == null || identifier.getValue().length() == 0) {
                    PRPAMT201306UV02OtherIDsScopingOrganization otherIDsScopingOrganization = new PRPAMT201306UV02OtherIDsScopingOrganization();
                    otherIDsScopingOrganization.addValue(new II(getScheme(identifier.getSystem()), null));
                    otherIDsScopingOrganization.setSemanticsText(ST("OtherIDs.scopingOrganization.id"));
                    parameterList.addOtherIDsScopingOrganization(otherIDsScopingOrganization);
                } else {
                    PRPAMT201306UV02LivingSubjectId livingSubjectId = new PRPAMT201306UV02LivingSubjectId();
                    livingSubjectId.addValue(new II(getScheme(identifier.getSystem()), identifier.getValue()));
                    livingSubjectId.setSemanticsText(ST("LivingSubject.id"));
                    parameterList.addLivingSubjectId(livingSubjectId);
                }
            }
        }
    }
    // mothersMaidenName -> mothersMaidenName
    StringParam mmn = parameters.getMothersMaidenName();
    if (mmn != null) {
        PRPAMT201306UV02MothersMaidenName mothersMaidenName = new PRPAMT201306UV02MothersMaidenName();
        PN mothersMaidenNamePN = new PN();
        mothersMaidenNamePN.addGiven(element(EnGiven.class, mmn.getValue()));
        mothersMaidenName.addValue(mothersMaidenNamePN);
        mothersMaidenName.setSemanticsText(ST("Person.MothersMaidenName"));
        parameterList.addMothersMaidenName(mothersMaidenName);
    }
    // telecom -> patientTelecom
    StringParam telecom = parameters.getTelecom();
    if (telecom != null) {
        PRPAMT201306UV02PatientTelecom patientTelecom = new PRPAMT201306UV02PatientTelecom();
        TEL tel = new TEL();
        tel.setValue(telecom.getValue());
        patientTelecom.addValue(tel);
        parameterList.addPatientTelecom(patientTelecom);
    }
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    HL7V3Transformer.marshallMessage(PRPAIN201305UV02Type.class, out, resultMsg);
    String outArray = new String(out.toByteArray());
    return outArray;
}
Also used : PRPAMT201306UV02MothersMaidenName(net.ihe.gazelle.hl7v3.prpamt201306UV02.PRPAMT201306UV02MothersMaidenName) PRPAMT201306UV02PatientStatusCode(net.ihe.gazelle.hl7v3.prpamt201306UV02.PRPAMT201306UV02PatientStatusCode) ParamPrefixEnum(ca.uhn.fhir.rest.param.ParamPrefixEnum) DateOrListParam(ca.uhn.fhir.rest.param.DateOrListParam) IVLTS(net.ihe.gazelle.hl7v3.datatypes.IVLTS) PRPAMT201306UV02QueryByParameter(net.ihe.gazelle.hl7v3.prpamt201306UV02.PRPAMT201306UV02QueryByParameter) PRPAMT201306UV02PatientTelecom(net.ihe.gazelle.hl7v3.prpamt201306UV02.PRPAMT201306UV02PatientTelecom) TemporalPrecisionEnum(ca.uhn.fhir.model.api.TemporalPrecisionEnum) EnFamily(net.ihe.gazelle.hl7v3.datatypes.EnFamily) PRPAMT201306UV02ParameterList(net.ihe.gazelle.hl7v3.prpamt201306UV02.PRPAMT201306UV02ParameterList) PRPAMT201306UV02LivingSubjectBirthTime(net.ihe.gazelle.hl7v3.prpamt201306UV02.PRPAMT201306UV02LivingSubjectBirthTime) InvalidRequestException(ca.uhn.fhir.rest.server.exceptions.InvalidRequestException) PRPAIN201305UV02Type(net.ihe.gazelle.hl7v3.prpain201305UV02.PRPAIN201305UV02Type) StringParam(ca.uhn.fhir.rest.param.StringParam) MCCIMT000100UV01Device(net.ihe.gazelle.hl7v3.mccimt000100UV01.MCCIMT000100UV01Device) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) PRPAIN201305UV02QUQIMT021001UV01ControlActProcess(net.ihe.gazelle.hl7v3.prpain201305UV02.PRPAIN201305UV02QUQIMT021001UV01ControlActProcess) DateParam(ca.uhn.fhir.rest.param.DateParam) II(net.ihe.gazelle.hl7v3.datatypes.II) CD(net.ihe.gazelle.hl7v3.datatypes.CD) PRPAMT201306UV02PatientAddress(net.ihe.gazelle.hl7v3.prpamt201306UV02.PRPAMT201306UV02PatientAddress) CE(net.ihe.gazelle.hl7v3.datatypes.CE) AD(net.ihe.gazelle.hl7v3.datatypes.AD) DateAndListParam(ca.uhn.fhir.rest.param.DateAndListParam) StringAndListParam(ca.uhn.fhir.rest.param.StringAndListParam) Calendar(java.util.Calendar) EN(net.ihe.gazelle.hl7v3.datatypes.EN) EnGiven(net.ihe.gazelle.hl7v3.datatypes.EnGiven) PRPAMT201306UV02OtherIDsScopingOrganization(net.ihe.gazelle.hl7v3.prpamt201306UV02.PRPAMT201306UV02OtherIDsScopingOrganization) ByteArrayOutputStream(java.io.ByteArrayOutputStream) MCCIMT000100UV01Sender(net.ihe.gazelle.hl7v3.mccimt000100UV01.MCCIMT000100UV01Sender) PRPAMT201306UV02LivingSubjectName(net.ihe.gazelle.hl7v3.prpamt201306UV02.PRPAMT201306UV02LivingSubjectName) Date(java.util.Date) PRPAMT201306UV02LivingSubjectAdministrativeGender(net.ihe.gazelle.hl7v3.prpamt201306UV02.PRPAMT201306UV02LivingSubjectAdministrativeGender) CS(net.ihe.gazelle.hl7v3.datatypes.CS) TokenOrListParam(ca.uhn.fhir.rest.param.TokenOrListParam) TokenParam(ca.uhn.fhir.rest.param.TokenParam) PRPAMT201306UV02LivingSubjectId(net.ihe.gazelle.hl7v3.prpamt201306UV02.PRPAMT201306UV02LivingSubjectId) MCCIMT000100UV01Receiver(net.ihe.gazelle.hl7v3.mccimt000100UV01.MCCIMT000100UV01Receiver) TEL(net.ihe.gazelle.hl7v3.datatypes.TEL) PN(net.ihe.gazelle.hl7v3.datatypes.PN) IVXBTS(net.ihe.gazelle.hl7v3.datatypes.IVXBTS) IVLTS(net.ihe.gazelle.hl7v3.datatypes.IVLTS) TS(net.ihe.gazelle.hl7v3.datatypes.TS)

Example 5 with CD

use of net.ihe.gazelle.hl7v3.datatypes.CD in project MobileAccessGateway by i4mi.

the class Iti93MergeRequestConverter method doMerge.

/**
 * merge request for ITI-93 transaction
 * @param header
 * @param entriesByReference
 * @return
 * @throws JAXBException
 */
public String doMerge(MessageHeader header, Map<String, BundleEntryComponent> entriesByReference) throws JAXBException {
    PRPAIN201304UV02Type resultMsg = new PRPAIN201304UV02Type();
    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_IN201304UV02"));
    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)));
    PRPAIN201304UV02MFMIMT700701UV01ControlActProcess controlActProcess = new PRPAIN201304UV02MFMIMT700701UV01ControlActProcess();
    resultMsg.setControlActProcess(controlActProcess);
    // ???
    controlActProcess.setClassCode(ActClassControlAct.CACT);
    // ???
    controlActProcess.setMoodCode(XActMoodIntentEvent.EVN);
    // ???
    controlActProcess.setCode(new CD("PRPA_TE201304UV02", "2.16.840.1.113883.1.18", null));
    for (BundleEntryComponent entry : entriesByReference.values()) {
        // BundleEntryComponent entry = entriesByReference.get(ref.getReference());
        HTTPVerb method = entry.getRequest().getMethod();
        if (method == null)
            throw new InvalidRequestException("HTTP verb missing in Bundle for Patient resource.");
        Patient basePatient = (Patient) entry.getResource();
        Patient in = null;
        List<Patient> replaced = new ArrayList<Patient>();
        for (PatientLinkComponent linked : basePatient.getLink()) {
            if (linked.getType().equals(LinkType.REPLACEDBY)) {
                Reference other = linked.getOther();
                Patient otherPatient = findPatient(other, entriesByReference, basePatient);
                in = otherPatient;
                replaced.add(basePatient);
            } else if (linked.getType().equals(LinkType.REPLACES)) {
                Reference other = linked.getOther();
                Patient otherPatient = findPatient(other, entriesByReference, basePatient);
                in = basePatient;
                replaced.add(otherPatient);
            }
        }
        if (in == null || replaced.isEmpty())
            throw new InvalidRequestException("Cannot determine Patients to merge");
        PRPAIN201304UV02MFMIMT700701UV01Subject1 subject = new PRPAIN201304UV02MFMIMT700701UV01Subject1();
        controlActProcess.addSubject(subject);
        subject.setTypeCode("SUBJ");
        // ???
        subject.setContextConductionInd(false);
        PRPAIN201304UV02MFMIMT700701UV01RegistrationEvent registrationEvent = new PRPAIN201304UV02MFMIMT700701UV01RegistrationEvent();
        subject.setRegistrationEvent(registrationEvent);
        registrationEvent.setClassCode(ActClass.REG);
        registrationEvent.setMoodCode(ActMood.EVN);
        // ???
        registrationEvent.setStatusCode(new CS("active", null, null));
        List<MFMIMT700701UV01ReplacementOf> replacementOfList = new ArrayList<MFMIMT700701UV01ReplacementOf>();
        registrationEvent.setReplacementOf(replacementOfList);
        for (Patient replacedPatient : replaced) {
            MFMIMT700701UV01ReplacementOf replacementOf = new MFMIMT700701UV01ReplacementOf();
            MFMIMT700701UV01PriorRegistration priorRegistration = new MFMIMT700701UV01PriorRegistration();
            replacementOf.setPriorRegistration(priorRegistration);
            replacementOf.setTypeCode("RPLC");
            priorRegistration.setClassCode(ActClass.REG);
            priorRegistration.setMoodCode(ActMood.EVN);
            priorRegistration.setStatusCode(new CS("obsolete", null, null));
            MFMIMT700701UV01Subject3 subject1 = new MFMIMT700701UV01Subject3();
            priorRegistration.setSubject1(subject1);
            subject1.setTypeCode(ParticipationTargetSubject.SBJ);
            MFMIMT700701UV01PriorRegisteredRole priorRegisteredRole = new MFMIMT700701UV01PriorRegisteredRole();
            subject1.setPriorRegisteredRole(priorRegisteredRole);
            priorRegisteredRole.setClassCode("PAT");
            for (Identifier id : replacedPatient.getIdentifier()) {
                priorRegisteredRole.addId(patientIdentifier(id));
            }
            replacementOfList.add(replacementOf);
        }
        PRPAIN201304UV02MFMIMT700701UV01Subject2 subject1 = new PRPAIN201304UV02MFMIMT700701UV01Subject2();
        registrationEvent.setSubject1(subject1);
        subject1.setTypeCode(ParticipationTargetSubject.SBJ);
        PRPAMT201303UV02Patient patient = new PRPAMT201303UV02Patient();
        patient.setClassCode("PAT");
        subject1.setPatient(patient);
        PRPAMT201302UV02PatientStatusCode statusCode = new PRPAMT201302UV02PatientStatusCode("active", null, null);
        // ???
        patient.setStatusCode(statusCode);
        List<II> orgIds = new ArrayList<II>();
        Set<String> mainIds = new HashSet<String>();
        PRPAMT201303UV02Person patientPerson = new PRPAMT201303UV02Person();
        patientPerson.setClassCode(EntityClass.PSN);
        patientPerson.setDeterminerCode(EntityDeterminer.INSTANCE);
        patient.setPatientPerson(patientPerson);
        Organization managingOrg = getManagingOrganization(in, basePatient.getContained());
        for (Identifier id : managingOrg.getIdentifier()) {
            orgIds.add(new II(getScheme(id.getSystem()), null));
            mainIds.add(id.getSystem());
        }
        if (managingOrg == null)
            managingOrg = getManagingOrganization(basePatient, basePatient.getContained());
        if (managingOrg == null)
            throw new InvalidRequestException("Cannot determine managingOrganization");
        // TODO How is the correct mapping done?
        for (Identifier id : in.getIdentifier()) {
            PRPAMT201302UV02PatientId patientId = new PRPAMT201302UV02PatientId(getScheme(id.getSystem()), id.getValue());
            patient.addId(patientId);
        }
        for (HumanName name : in.getName()) {
            patientPerson.addName(transform(name));
        }
        COCTMT150003UV03Organization providerOrganization = new COCTMT150003UV03Organization();
        patient.setProviderOrganization(providerOrganization);
        providerOrganization.setClassCode(EntityClassOrganization.ORG);
        providerOrganization.setDeterminerCode(EntityDeterminer.INSTANCE);
        providerOrganization.setId(orgIds);
        ON name = null;
        if (managingOrg.hasName()) {
            name = new ON();
            name.setMixed(Collections.singletonList(managingOrg.getName()));
            providerOrganization.setName(Collections.singletonList(name));
        }
        COCTMT150003UV03ContactParty contactParty = new COCTMT150003UV03ContactParty();
        contactParty.setClassCode(RoleClassContact.CON);
        for (ContactPoint contactPoint : managingOrg.getTelecom()) {
            contactParty.addTelecom(transform(contactPoint));
        }
        if (managingOrg.hasAddress())
            contactParty.setAddr(new ArrayList<AD>());
        for (Address address : managingOrg.getAddress()) {
            contactParty.addAddr(transform(address));
        }
        if (managingOrg.hasContact()) {
            OrganizationContactComponent occ = managingOrg.getContactFirstRep();
            COCTMT150003UV03Person contactPerson = new COCTMT150003UV03Person();
            contactPerson.setClassCode(EntityClass.PSN);
            contactPerson.setDeterminerCode(EntityDeterminer.INSTANCE);
            if (occ.hasName())
                contactPerson.setName(Collections.singletonList(transform(occ.getName())));
            contactParty.setContactPerson(contactPerson);
        }
        providerOrganization.setContactParty(Collections.singletonList(contactParty));
        patientPerson.setBirthTime(transform(in.getBirthDateElement()));
        if (in.hasGender()) {
            switch(in.getGender()) {
                case MALE:
                    patientPerson.setAdministrativeGenderCode(new CE("M", "Male", "2.16.840.1.113883.12.1"));
                    break;
                case FEMALE:
                    patientPerson.setAdministrativeGenderCode(new CE("F", "Female", "2.16.840.1.113883.12.1"));
                    break;
                case OTHER:
                    patientPerson.setAdministrativeGenderCode(new CE("A", "Ambiguous", "2.16.840.1.113883.12.1"));
                    break;
                case UNKNOWN:
                    patientPerson.setAdministrativeGenderCode(new CE("U", "Unknown", "2.16.840.1.113883.12.1"));
                    break;
            }
        }
        if (in.hasAddress())
            patientPerson.setAddr(new ArrayList<AD>());
        for (Address address : in.getAddress()) {
            patientPerson.addAddr(transform(address));
        }
        for (ContactPoint contactPoint : in.getTelecom()) {
            patientPerson.addTelecom(transform(contactPoint));
        }
        if (in.hasDeceasedBooleanType()) {
            patientPerson.setDeceasedInd(new BL(in.getDeceasedBooleanType().getValue()));
        }
        if (in.hasDeceasedDateTimeType()) {
            patientPerson.setDeceasedTime(transform(in.getDeceasedDateTimeType()));
        }
        if (in.hasMultipleBirthBooleanType()) {
            patientPerson.setMultipleBirthInd(new BL(in.getMultipleBirthBooleanType().getValue()));
        }
        if (in.hasMultipleBirthIntegerType()) {
            patientPerson.setMultipleBirthOrderNumber(new INT(in.getMultipleBirthIntegerType().getValue()));
        }
        if (in.hasMaritalStatus()) {
            patientPerson.setMaritalStatusCode(transform(in.getMaritalStatus()));
        }
        if (in.hasCommunication()) {
            for (PatientCommunicationComponent pcc : in.getCommunication()) {
                PRPAMT201303UV02LanguageCommunication languageCommunication = new PRPAMT201303UV02LanguageCommunication();
                languageCommunication.setLanguageCode(transform(pcc.getLanguage()));
                if (pcc.hasPreferred())
                    languageCommunication.setPreferenceInd(new BL(pcc.getPreferred()));
                patientPerson.addLanguageCommunication(languageCommunication);
            }
        }
        MFMIMT700701UV01Custodian custodian = new MFMIMT700701UV01Custodian();
        registrationEvent.setCustodian(custodian);
        custodian.setTypeCode(ParticipationType.CST);
        COCTMT090003UV01AssignedEntity assignedEntity = new COCTMT090003UV01AssignedEntity();
        custodian.setAssignedEntity(assignedEntity);
        assignedEntity.setClassCode(RoleClassAssignedEntity.ASSIGNED);
        List<II> custIds = new ArrayList<II>();
        custIds.add(new II(getScheme(config.getCustodianOid()), null));
        assignedEntity.setId(custIds);
        // assignedEntity.setId(orgIds);
        COCTMT090003UV01Organization assignedOrganization = new COCTMT090003UV01Organization();
        assignedEntity.setAssignedOrganization(assignedOrganization);
        assignedOrganization.setClassCode(EntityClassOrganization.ORG);
        assignedOrganization.setDeterminerCode(EntityDeterminer.INSTANCE);
        if (managingOrg.hasName()) {
            ON onName = new ON();
            onName.setMixed(Collections.singletonList(managingOrg.getName()));
            assignedOrganization.setName(Collections.singletonList(onName));
        }
    }
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    HL7V3Transformer.marshallMessage(PRPAIN201304UV02Type.class, out, resultMsg);
    String outArray = new String(out.toByteArray());
    return outArray;
}
Also used : HTTPVerb(org.hl7.fhir.r4.model.Bundle.HTTPVerb) PRPAIN201304UV02MFMIMT700701UV01RegistrationEvent(net.ihe.gazelle.hl7v3.prpain201304UV02.PRPAIN201304UV02MFMIMT700701UV01RegistrationEvent) Address(org.hl7.fhir.r4.model.Address) ArrayList(java.util.ArrayList) PRPAMT201302UV02PatientId(net.ihe.gazelle.hl7v3.prpamt201302UV02.PRPAMT201302UV02PatientId) Identifier(org.hl7.fhir.r4.model.Identifier) InvalidRequestException(ca.uhn.fhir.rest.server.exceptions.InvalidRequestException) HashSet(java.util.HashSet) II(net.ihe.gazelle.hl7v3.datatypes.II) PRPAIN201304UV02Type(net.ihe.gazelle.hl7v3.prpain201304UV02.PRPAIN201304UV02Type) COCTMT090003UV01Organization(net.ihe.gazelle.hl7v3.coctmt090003UV01.COCTMT090003UV01Organization) PRPAMT201303UV02LanguageCommunication(net.ihe.gazelle.hl7v3.prpamt201303UV02.PRPAMT201303UV02LanguageCommunication) MFMIMT700701UV01PriorRegisteredRole(net.ihe.gazelle.hl7v3.mfmimt700701UV01.MFMIMT700701UV01PriorRegisteredRole) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) COCTMT150003UV03Person(net.ihe.gazelle.hl7v3.coctmt150003UV03.COCTMT150003UV03Person) OrganizationContactComponent(org.hl7.fhir.r4.model.Organization.OrganizationContactComponent) PRPAMT201302UV02PatientStatusCode(net.ihe.gazelle.hl7v3.prpamt201302UV02.PRPAMT201302UV02PatientStatusCode) PRPAMT201303UV02Person(net.ihe.gazelle.hl7v3.prpamt201303UV02.PRPAMT201303UV02Person) COCTMT090003UV01AssignedEntity(net.ihe.gazelle.hl7v3.coctmt090003UV01.COCTMT090003UV01AssignedEntity) MFMIMT700701UV01ReplacementOf(net.ihe.gazelle.hl7v3.mfmimt700701UV01.MFMIMT700701UV01ReplacementOf) MFMIMT700701UV01Custodian(net.ihe.gazelle.hl7v3.mfmimt700701UV01.MFMIMT700701UV01Custodian) MCCIMT000100UV01Receiver(net.ihe.gazelle.hl7v3.mccimt000100UV01.MCCIMT000100UV01Receiver) PRPAMT201303UV02Patient(net.ihe.gazelle.hl7v3.prpamt201303UV02.PRPAMT201303UV02Patient) COCTMT150003UV03Organization(net.ihe.gazelle.hl7v3.coctmt150003UV03.COCTMT150003UV03Organization) COCTMT090003UV01Organization(net.ihe.gazelle.hl7v3.coctmt090003UV01.COCTMT090003UV01Organization) EntityClassOrganization(net.ihe.gazelle.hl7v3.voc.EntityClassOrganization) Organization(org.hl7.fhir.r4.model.Organization) PatientLinkComponent(org.hl7.fhir.r4.model.Patient.PatientLinkComponent) BL(net.ihe.gazelle.hl7v3.datatypes.BL) MFMIMT700701UV01PriorRegistration(net.ihe.gazelle.hl7v3.mfmimt700701UV01.MFMIMT700701UV01PriorRegistration) INT(net.ihe.gazelle.hl7v3.datatypes.INT) HumanName(org.hl7.fhir.r4.model.HumanName) ContactPoint(org.hl7.fhir.r4.model.ContactPoint) PatientCommunicationComponent(org.hl7.fhir.r4.model.Patient.PatientCommunicationComponent) MCCIMT000100UV01Device(net.ihe.gazelle.hl7v3.mccimt000100UV01.MCCIMT000100UV01Device) ON(net.ihe.gazelle.hl7v3.datatypes.ON) CD(net.ihe.gazelle.hl7v3.datatypes.CD) CE(net.ihe.gazelle.hl7v3.datatypes.CE) Reference(org.hl7.fhir.r4.model.Reference) PRPAMT201301UV02Patient(net.ihe.gazelle.hl7v3.prpamt201301UV02.PRPAMT201301UV02Patient) PRPAMT201303UV02Patient(net.ihe.gazelle.hl7v3.prpamt201303UV02.PRPAMT201303UV02Patient) Patient(org.hl7.fhir.r4.model.Patient) PRPAMT201302UV02Patient(net.ihe.gazelle.hl7v3.prpamt201302UV02.PRPAMT201302UV02Patient) PRPAIN201304UV02MFMIMT700701UV01Subject2(net.ihe.gazelle.hl7v3.prpain201304UV02.PRPAIN201304UV02MFMIMT700701UV01Subject2) ByteArrayOutputStream(java.io.ByteArrayOutputStream) PRPAIN201304UV02MFMIMT700701UV01Subject1(net.ihe.gazelle.hl7v3.prpain201304UV02.PRPAIN201304UV02MFMIMT700701UV01Subject1) MCCIMT000100UV01Sender(net.ihe.gazelle.hl7v3.mccimt000100UV01.MCCIMT000100UV01Sender) CS(net.ihe.gazelle.hl7v3.datatypes.CS) MFMIMT700701UV01Subject3(net.ihe.gazelle.hl7v3.mfmimt700701UV01.MFMIMT700701UV01Subject3) COCTMT150003UV03ContactParty(net.ihe.gazelle.hl7v3.coctmt150003UV03.COCTMT150003UV03ContactParty) COCTMT150003UV03Organization(net.ihe.gazelle.hl7v3.coctmt150003UV03.COCTMT150003UV03Organization) TS(net.ihe.gazelle.hl7v3.datatypes.TS) PRPAIN201304UV02MFMIMT700701UV01ControlActProcess(net.ihe.gazelle.hl7v3.prpain201304UV02.PRPAIN201304UV02MFMIMT700701UV01ControlActProcess)

Aggregations

ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 CD (net.ihe.gazelle.hl7v3.datatypes.CD)5 CS (net.ihe.gazelle.hl7v3.datatypes.CS)5 II (net.ihe.gazelle.hl7v3.datatypes.II)5 TS (net.ihe.gazelle.hl7v3.datatypes.TS)5 MCCIMT000100UV01Device (net.ihe.gazelle.hl7v3.mccimt000100UV01.MCCIMT000100UV01Device)5 MCCIMT000100UV01Receiver (net.ihe.gazelle.hl7v3.mccimt000100UV01.MCCIMT000100UV01Receiver)5 MCCIMT000100UV01Sender (net.ihe.gazelle.hl7v3.mccimt000100UV01.MCCIMT000100UV01Sender)5 InvalidRequestException (ca.uhn.fhir.rest.server.exceptions.InvalidRequestException)4 COCTMT090003UV01AssignedEntity (net.ihe.gazelle.hl7v3.coctmt090003UV01.COCTMT090003UV01AssignedEntity)4 CE (net.ihe.gazelle.hl7v3.datatypes.CE)4 Identifier (org.hl7.fhir.r4.model.Identifier)4 ArrayList (java.util.ArrayList)3 COCTMT090003UV01Organization (net.ihe.gazelle.hl7v3.coctmt090003UV01.COCTMT090003UV01Organization)3 COCTMT150003UV03ContactParty (net.ihe.gazelle.hl7v3.coctmt150003UV03.COCTMT150003UV03ContactParty)3 COCTMT150003UV03Organization (net.ihe.gazelle.hl7v3.coctmt150003UV03.COCTMT150003UV03Organization)3 COCTMT150003UV03Person (net.ihe.gazelle.hl7v3.coctmt150003UV03.COCTMT150003UV03Person)3 BL (net.ihe.gazelle.hl7v3.datatypes.BL)3 INT (net.ihe.gazelle.hl7v3.datatypes.INT)3 ON (net.ihe.gazelle.hl7v3.datatypes.ON)3