Search in sources :

Example 76 with HumanName

use of org.hl7.fhir.r5.model.HumanName in project MobileAccessGateway by i4mi.

the class Iti65RequestConverter method transformAuthor.

/**
 * FHIR Reference to Author -> XDS Author
 * @param author
 * @param contained
 * @return
 */
public Author transformAuthor(Reference author, List<Resource> contained, Identifiable authorRole) {
    if (author == null || author.getReference() == null) {
        if (authorRole != null) {
            Author result = new Author();
            Person person = new Person();
            // CARA PMP
            // At least an authorPerson, authorTelecommunication, or authorInstitution sub-attribute must be present
            // Either authorPerson, authorInstitution or authorTelecom shall be specified in the SubmissionSet [IHE ITI Technical Framework Volume 3 (4.2.3.1.4)].
            person.setName(transform(new HumanName().setFamily("---")));
            result.setAuthorPerson(person);
            result.getAuthorRole().add(authorRole);
            return result;
        }
        return null;
    }
    Resource authorObj = findResource(author, contained);
    if (authorObj instanceof Practitioner) {
        Practitioner practitioner = (Practitioner) authorObj;
        Author result = new Author();
        result.setAuthorPerson(transform((Practitioner) authorObj));
        for (ContactPoint contactPoint : practitioner.getTelecom()) result.getAuthorTelecom().add(transform(contactPoint));
        if (authorRole == null) {
            authorRole = new Identifiable("HCP", new AssigningAuthority("2.16.756.5.30.1.127.3.10.1.41"));
        }
        result.getAuthorRole().add(authorRole);
        return result;
    } else if (authorObj instanceof Patient) {
        Patient patient = (Patient) authorObj;
        Author result = new Author();
        result.setAuthorPerson(transform(patient));
        for (ContactPoint contactPoint : patient.getTelecom()) result.getAuthorTelecom().add(transform(contactPoint));
        if (authorRole == null) {
            authorRole = new Identifiable("PAT", new AssigningAuthority("2.16.756.5.30.1.127.3.10.1.41"));
        }
        result.getAuthorRole().add(authorRole);
        return result;
    } else if (authorObj instanceof PractitionerRole) {
        Author result = new Author();
        PractitionerRole role = (PractitionerRole) authorObj;
        Practitioner practitioner = (Practitioner) findResource(role.getPractitioner(), contained);
        if (practitioner != null)
            result.setAuthorPerson(transform(practitioner));
        Organization org = (Organization) findResource(role.getOrganization(), contained);
        if (org != null)
            result.getAuthorInstitution().add(transform(org));
        for (CodeableConcept code : role.getCode()) result.getAuthorRole().add(transformToIdentifiable(code));
        for (CodeableConcept speciality : role.getSpecialty()) result.getAuthorSpecialty().add(transformToIdentifiable(speciality));
        for (ContactPoint contactPoint : role.getTelecom()) result.getAuthorTelecom().add(transform(contactPoint));
        return result;
    } else
        throw new InvalidRequestException("Author role not supported.");
// return null;
}
Also used : Organization(org.hl7.fhir.r4.model.Organization) Resource(org.hl7.fhir.r4.model.Resource) ListResource(org.hl7.fhir.r4.model.ListResource) DomainResource(org.hl7.fhir.r4.model.DomainResource) Patient(org.hl7.fhir.r4.model.Patient) AssigningAuthority(org.openehealth.ipf.commons.ihe.xds.core.metadata.AssigningAuthority) CXiAssigningAuthority(org.openehealth.ipf.commons.ihe.xds.core.metadata.CXiAssigningAuthority) PractitionerRole(org.hl7.fhir.r4.model.PractitionerRole) Identifiable(org.openehealth.ipf.commons.ihe.xds.core.metadata.Identifiable) Practitioner(org.hl7.fhir.r4.model.Practitioner) HumanName(org.hl7.fhir.r4.model.HumanName) ContactPoint(org.hl7.fhir.r4.model.ContactPoint) Author(org.openehealth.ipf.commons.ihe.xds.core.metadata.Author) InvalidRequestException(ca.uhn.fhir.rest.server.exceptions.InvalidRequestException) RelatedPerson(org.hl7.fhir.r4.model.RelatedPerson) Person(org.openehealth.ipf.commons.ihe.xds.core.metadata.Person) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 77 with HumanName

use of org.hl7.fhir.r5.model.HumanName in project MobileAccessGateway by i4mi.

the class Iti65RequestConverter method transform.

/**
 * FHIR HumanName -> XDS Name
 * @param name
 * @return
 */
public Name transform(HumanName name) {
    Name targetName = new XpnName();
    if (name.hasPrefix())
        targetName.setPrefix(name.getPrefixAsSingleString());
    if (name.hasSuffix())
        targetName.setSuffix(name.getSuffixAsSingleString());
    targetName.setFamilyName(name.getFamily());
    List<StringType> given = name.getGiven();
    if (given != null && !given.isEmpty()) {
        targetName.setGivenName(given.get(0).getValue());
        if (given.size() > 1) {
            StringBuffer restOfName = new StringBuffer();
            for (int part = 1; part < given.size(); part++) {
                if (part > 1)
                    restOfName.append(" ");
                restOfName.append(given.get(part).getValue());
            }
            targetName.setSecondAndFurtherGivenNames(restOfName.toString());
        }
    }
    return targetName;
}
Also used : StringType(org.hl7.fhir.r4.model.StringType) XpnName(org.openehealth.ipf.commons.ihe.xds.core.metadata.XpnName) ContactPoint(org.hl7.fhir.r4.model.ContactPoint) HumanName(org.hl7.fhir.r4.model.HumanName) Name(org.openehealth.ipf.commons.ihe.xds.core.metadata.Name) XpnName(org.openehealth.ipf.commons.ihe.xds.core.metadata.XpnName)

Example 78 with HumanName

use of org.hl7.fhir.r5.model.HumanName 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 79 with HumanName

use of org.hl7.fhir.r5.model.HumanName in project camel-quarkus by apache.

the class FhirDstu2Hl7OrgResource method createTransactionBundle.

private Bundle createTransactionBundle() {
    Bundle input = new Bundle();
    input.setType(Bundle.BundleType.TRANSACTION);
    input.addEntry().setResource(new Patient().addName(new HumanName().addGiven("Art").addFamily("Tatum"))).getRequest().setMethod(Bundle.HTTPVerb.POST);
    return input;
}
Also used : HumanName(org.hl7.fhir.dstu2.model.HumanName) Bundle(org.hl7.fhir.dstu2.model.Bundle) IBaseBundle(org.hl7.fhir.instance.model.api.IBaseBundle) Patient(org.hl7.fhir.dstu2.model.Patient)

Example 80 with HumanName

use of org.hl7.fhir.r5.model.HumanName in project camel-quarkus by apache.

the class FhirR4Resource method validateResourceAsString.

@Path("/validate/resourceAsString")
@GET
@Produces(MediaType.TEXT_PLAIN)
public String validateResourceAsString() {
    Patient patient = new Patient().addName(new HumanName().addGiven(PATIENT_FIRST_NAME).setFamily(PATIENT_LAST_NAME));
    patient.getText().setStatus(NarrativeStatus.GENERATED);
    patient.getText().setDivAsString("<div>This is the narrative text</div>");
    String body = this.fhirContextInstance.get().newXmlParser().encodeResourceToString(patient);
    MethodOutcome result = producerTemplate.requestBody("direct:validateResourceAsString-r4", body, MethodOutcome.class);
    OperationOutcome operationOutcome = (OperationOutcome) result.getOperationOutcome();
    return operationOutcome.getIssue().get(0).getDiagnostics();
}
Also used : HumanName(org.hl7.fhir.r4.model.HumanName) IBaseOperationOutcome(org.hl7.fhir.instance.model.api.IBaseOperationOutcome) OperationOutcome(org.hl7.fhir.r4.model.OperationOutcome) Patient(org.hl7.fhir.r4.model.Patient) MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

HumanName (org.hl7.fhir.r4.model.HumanName)84 HumanName (org.hl7.fhir.dstu3.model.HumanName)37 Patient (org.hl7.fhir.r4.model.Patient)37 Test (org.junit.jupiter.api.Test)29 ArrayList (java.util.ArrayList)27 Patient (org.hl7.fhir.dstu3.model.Patient)27 Test (org.junit.Test)26 MethodOutcome (ca.uhn.fhir.rest.api.MethodOutcome)23 Address (org.hl7.fhir.r4.model.Address)20 Identifier (org.hl7.fhir.r4.model.Identifier)20 PersonName (org.openmrs.PersonName)17 CamelSpringBootTest (org.apache.camel.test.spring.junit5.CamelSpringBootTest)16 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)16 GET (javax.ws.rs.GET)15 Path (javax.ws.rs.Path)15 Produces (javax.ws.rs.Produces)15 ContactPoint (org.hl7.fhir.r4.model.ContactPoint)15 NotImplementedException (org.apache.commons.lang3.NotImplementedException)14 StringType (org.hl7.fhir.r4.model.StringType)14 Date (java.util.Date)13