Search in sources :

Example 71 with ContactPoint

use of org.hl7.fhir.dstu2.model.ContactPoint 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 72 with ContactPoint

use of org.hl7.fhir.dstu2.model.ContactPoint 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 73 with ContactPoint

use of org.hl7.fhir.dstu2.model.ContactPoint in project MobileAccessGateway by i4mi.

the class Iti78ResponseConverter method transform.

public ContactPoint transform(TEL telecom) {
    ContactPoint contactPoint = new ContactPoint();
    String use = telecom.getUse();
    if (use != null) {
        switch(use) {
            case "HP":
                contactPoint.setUse(ContactPoint.ContactPointUse.HOME);
                break;
        }
    }
    contactPoint.setValue(telecom.getValue());
    return contactPoint;
}
Also used : ContactPoint(org.hl7.fhir.r4.model.ContactPoint)

Example 74 with ContactPoint

use of org.hl7.fhir.dstu2.model.ContactPoint in project synthea by synthetichealth.

the class FhirR4 method practitioner.

/**
 * Map the clinician into a FHIR Practitioner resource, and add it to the given Bundle.
 * @param rand   Source of randomness to use when generating ids etc
 * @param bundle The Bundle to add to
 * @param clinician The clinician
 * @return The added Entry
 */
protected static BundleEntryComponent practitioner(RandomNumberGenerator rand, Bundle bundle, Clinician clinician) {
    Practitioner practitionerResource = new Practitioner();
    if (USE_US_CORE_IG) {
        Meta meta = new Meta();
        meta.addProfile("http://hl7.org/fhir/us/core/StructureDefinition/us-core-practitioner");
        practitionerResource.setMeta(meta);
    }
    practitionerResource.addIdentifier().setSystem("http://hl7.org/fhir/sid/us-npi").setValue(clinician.npi);
    practitionerResource.setActive(true);
    practitionerResource.addName().setFamily((String) clinician.attributes.get(Clinician.LAST_NAME)).addGiven((String) clinician.attributes.get(Clinician.FIRST_NAME)).addPrefix((String) clinician.attributes.get(Clinician.NAME_PREFIX));
    String email = (String) clinician.attributes.get(Clinician.FIRST_NAME) + "." + (String) clinician.attributes.get(Clinician.LAST_NAME) + "@example.com";
    practitionerResource.addTelecom().setSystem(ContactPointSystem.EMAIL).setUse(ContactPointUse.WORK).setValue(email);
    if (USE_US_CORE_IG) {
        practitionerResource.getTelecomFirstRep().addExtension().setUrl("http://hl7.org/fhir/us/core/StructureDefinition/us-core-direct").setValue(new BooleanType(true));
    }
    Address address = new Address().addLine((String) clinician.attributes.get(Clinician.ADDRESS)).setCity((String) clinician.attributes.get(Clinician.CITY)).setPostalCode((String) clinician.attributes.get(Clinician.ZIP)).setState((String) clinician.attributes.get(Clinician.STATE));
    if (COUNTRY_CODE != null) {
        address.setCountry(COUNTRY_CODE);
    }
    practitionerResource.addAddress(address);
    if (clinician.attributes.get(Person.GENDER).equals("M")) {
        practitionerResource.setGender(AdministrativeGender.MALE);
    } else if (clinician.attributes.get(Person.GENDER).equals("F")) {
        practitionerResource.setGender(AdministrativeGender.FEMALE);
    }
    BundleEntryComponent practitionerEntry = newEntry(bundle, practitionerResource, clinician.getResourceID());
    if (USE_US_CORE_IG) {
        // generate an accompanying PractitionerRole resource
        PractitionerRole practitionerRole = new PractitionerRole();
        Meta meta = new Meta();
        meta.addProfile("http://hl7.org/fhir/us/core/StructureDefinition/us-core-practitionerrole");
        practitionerRole.setMeta(meta);
        practitionerRole.setPractitioner(new Reference().setIdentifier(new Identifier().setSystem("http://hl7.org/fhir/sid/us-npi").setValue(clinician.npi)).setDisplay(practitionerResource.getNameFirstRep().getNameAsSingleString()));
        practitionerRole.setOrganization(new Reference().setIdentifier(new Identifier().setSystem(SYNTHEA_IDENTIFIER).setValue(clinician.getOrganization().getResourceID())).setDisplay(clinician.getOrganization().name));
        practitionerRole.addCode(mapCodeToCodeableConcept(new Code("http://nucc.org/provider-taxonomy", "208D00000X", "General Practice"), null));
        practitionerRole.addSpecialty(mapCodeToCodeableConcept(new Code("http://nucc.org/provider-taxonomy", "208D00000X", "General Practice"), null));
        practitionerRole.addLocation().setIdentifier(new Identifier().setSystem(SYNTHEA_IDENTIFIER).setValue(clinician.getOrganization().getResourceLocationID())).setDisplay(clinician.getOrganization().name);
        if (clinician.getOrganization().phone != null && !clinician.getOrganization().phone.isEmpty()) {
            practitionerRole.addTelecom(new ContactPoint().setSystem(ContactPointSystem.PHONE).setValue(clinician.getOrganization().phone));
        }
        practitionerRole.addTelecom(practitionerResource.getTelecomFirstRep());
        newEntry(rand, bundle, practitionerRole);
    }
    return practitionerEntry;
}
Also used : Practitioner(org.hl7.fhir.r4.model.Practitioner) Meta(org.hl7.fhir.r4.model.Meta) ContactPoint(org.hl7.fhir.r4.model.ContactPoint) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Identifier(org.hl7.fhir.r4.model.Identifier) Address(org.hl7.fhir.r4.model.Address) Reference(org.hl7.fhir.r4.model.Reference) DocumentReference(org.hl7.fhir.r4.model.DocumentReference) BooleanType(org.hl7.fhir.r4.model.BooleanType) PractitionerRole(org.hl7.fhir.r4.model.PractitionerRole) Code(org.mitre.synthea.world.concepts.HealthRecord.Code)

Example 75 with ContactPoint

use of org.hl7.fhir.dstu2.model.ContactPoint in project synthea by synthetichealth.

the class FhirR4 method providerLocation.

/**
 * Map the Provider into a FHIR Location resource, and add it to the given Bundle.
 *
 * @param rand     Source of randomness to use when generating ids etc
 * @param bundle   The Bundle to add to
 * @param provider The Provider
 * @return The added Entry or null if the bundle already contains this provider location
 */
protected static org.hl7.fhir.r4.model.Location providerLocation(RandomNumberGenerator rand, Bundle bundle, Provider provider) {
    org.hl7.fhir.r4.model.Location location = new org.hl7.fhir.r4.model.Location();
    if (USE_US_CORE_IG) {
        Meta meta = new Meta();
        meta.addProfile("http://hl7.org/fhir/us/core/StructureDefinition/us-core-location");
        location.setMeta(meta);
    }
    location.setStatus(LocationStatus.ACTIVE);
    location.setName(provider.name);
    // set telecom
    if (provider.phone != null && !provider.phone.isEmpty()) {
        ContactPoint contactPoint = new ContactPoint().setSystem(ContactPointSystem.PHONE).setValue(provider.phone);
        location.addTelecom(contactPoint);
    } else if (USE_US_CORE_IG) {
        ContactPoint contactPoint = new ContactPoint().setSystem(ContactPointSystem.PHONE).setValue("(555) 555-5555");
        location.addTelecom(contactPoint);
    }
    // set address
    Address address = new Address().addLine(provider.address).setCity(provider.city).setPostalCode(provider.zip).setState(provider.state);
    if (COUNTRY_CODE != null) {
        address.setCountry(COUNTRY_CODE);
    }
    location.setAddress(address);
    LocationPositionComponent position = new LocationPositionComponent();
    position.setLatitude(provider.getY());
    position.setLongitude(provider.getX());
    location.setPosition(position);
    location.addIdentifier().setSystem(SYNTHEA_IDENTIFIER).setValue(provider.getResourceLocationID());
    Identifier organizationIdentifier = new Identifier().setSystem(SYNTHEA_IDENTIFIER).setValue(provider.getResourceID());
    location.setManagingOrganization(new Reference().setIdentifier(organizationIdentifier).setDisplay(provider.name));
    return location;
}
Also used : Meta(org.hl7.fhir.r4.model.Meta) Address(org.hl7.fhir.r4.model.Address) Reference(org.hl7.fhir.r4.model.Reference) DocumentReference(org.hl7.fhir.r4.model.DocumentReference) LocationPositionComponent(org.hl7.fhir.r4.model.Location.LocationPositionComponent) ContactPoint(org.hl7.fhir.r4.model.ContactPoint) Identifier(org.hl7.fhir.r4.model.Identifier) Location(org.mitre.synthea.world.geography.Location)

Aggregations

ContactPoint (org.hl7.fhir.r4.model.ContactPoint)56 Test (org.junit.Test)28 Address (org.hl7.fhir.r4.model.Address)18 Identifier (org.hl7.fhir.r4.model.Identifier)17 HumanName (org.hl7.fhir.r4.model.HumanName)16 PersonAttribute (org.openmrs.PersonAttribute)15 NotImplementedException (org.apache.commons.lang3.NotImplementedException)14 ContactPoint (org.hl7.fhir.dstu3.model.ContactPoint)14 Test (org.junit.jupiter.api.Test)14 ArrayList (java.util.ArrayList)12 Organization (org.hl7.fhir.r4.model.Organization)12 ProviderAttribute (org.openmrs.ProviderAttribute)11 HashSet (java.util.HashSet)10 IdType (org.hl7.fhir.dstu3.model.IdType)9 Patient (org.hl7.fhir.r4.model.Patient)9 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)7 ContactDetail (org.hl7.fhir.r5.model.ContactDetail)6 ContactPoint (org.hl7.fhir.r5.model.ContactPoint)6 HashMap (java.util.HashMap)5 Base64 (org.apache.commons.codec.binary.Base64)5