Search in sources :

Example 11 with II

use of org.hl7.v3.II in project webcert by sklintyg.

the class ConvertToFKTypesTest method testToIIExtNull.

@Test
public void testToIIExtNull() {
    II res = ConvertToFKTypes.toII("root", null);
    assertNull(res);
}
Also used : II(iso.v21090.dt.v1.II) Test(org.junit.Test)

Example 12 with II

use of org.hl7.v3.II 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 13 with II

use of org.hl7.v3.II 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 14 with II

use of org.hl7.v3.II in project MobileAccessGateway by i4mi.

the class Iti104AddRequestConverter method doCreate.

/**
 * add a new patient
 * @param header
 * @param entriesByReference
 * @return
 * @throws JAXBException
 */
public String doCreate(Patient in, Identifier identifier) 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"));
    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);
    patient.addId(patientIdentifier(identifier));
    // 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
    if (managingOrg != null) {
        for (Identifier id : managingOrg.getIdentifier()) {
            orgIds.add(new II(getScheme(id.getSystem()), null));
        }
    } else {
        Reference org = in.getManagingOrganization();
        if (org != null && org.getIdentifier() != null) {
            orgIds.add(new II(getScheme(org.getIdentifier().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 != null && managingOrg.hasName()) {
        name = new ON();
        name.setMixed(Collections.singletonList(managingOrg.getName()));
        providerOrganization.setName(Collections.singletonList(name));
    }
    if (managingOrg != null) {
        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 : 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) 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) AD(net.ihe.gazelle.hl7v3.datatypes.AD) Reference(org.hl7.fhir.r4.model.Reference) COCTMT090003UV01Organization(net.ihe.gazelle.hl7v3.coctmt090003UV01.COCTMT090003UV01Organization) 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) 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 15 with II

use of org.hl7.v3.II in project integration-adaptor-111 by nhsconnect.

the class ListMapperTest method setUp.

@BeforeEach
public void setUp() {
    effectiveTime.setValue(EFFECTIVE_DATE);
    HealthcareService healthcareService = new HealthcareService();
    healthcareService.setId("123456");
    QuestionnaireResponse questionnaireResponse = new QuestionnaireResponse();
    questionnaireResponse.setId("654321");
    resourcesCreated = asList(healthcareService, questionnaireResponse);
    when(clinicalDocument.getSetId()).thenReturn(ii);
    when(ii.getRoot()).thenReturn("411910CF-1A76-4330-98FE-C345DDEE5553");
    when(resourceUtil.newRandomUuid()).thenReturn(new IdType(RANDOM_UUID));
    when(clinicalDocument.getEffectiveTime()).thenReturn(effectiveTime);
}
Also used : HealthcareService(org.hl7.fhir.dstu3.model.HealthcareService) QuestionnaireResponse(org.hl7.fhir.dstu3.model.QuestionnaireResponse) IdType(org.hl7.fhir.dstu3.model.IdType) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

ArrayList (java.util.ArrayList)10 II (net.ihe.gazelle.hl7v3.datatypes.II)9 CS (net.ihe.gazelle.hl7v3.datatypes.CS)8 TS (net.ihe.gazelle.hl7v3.datatypes.TS)8 Identifier (org.hl7.fhir.r4.model.Identifier)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 BL (net.ihe.gazelle.hl7v3.datatypes.BL)7 CD (net.ihe.gazelle.hl7v3.datatypes.CD)7 CE (net.ihe.gazelle.hl7v3.datatypes.CE)7 INT (net.ihe.gazelle.hl7v3.datatypes.INT)7 MCCIMT000100UV01Device (net.ihe.gazelle.hl7v3.mccimt000100UV01.MCCIMT000100UV01Device)7 MCCIMT000100UV01Receiver (net.ihe.gazelle.hl7v3.mccimt000100UV01.MCCIMT000100UV01Receiver)7 MCCIMT000100UV01Sender (net.ihe.gazelle.hl7v3.mccimt000100UV01.MCCIMT000100UV01Sender)7 HumanName (org.hl7.fhir.r4.model.HumanName)7 PatientCommunicationComponent (org.hl7.fhir.r4.model.Patient.PatientCommunicationComponent)7 II (iso.v21090.dt.v1.II)6 COCTMT090003UV01AssignedEntity (net.ihe.gazelle.hl7v3.coctmt090003UV01.COCTMT090003UV01AssignedEntity)6 COCTMT090003UV01Organization (net.ihe.gazelle.hl7v3.coctmt090003UV01.COCTMT090003UV01Organization)6 COCTMT150003UV03ContactParty (net.ihe.gazelle.hl7v3.coctmt150003UV03.COCTMT150003UV03ContactParty)6 COCTMT150003UV03Organization (net.ihe.gazelle.hl7v3.coctmt150003UV03.COCTMT150003UV03Organization)6