Search in sources :

Example 31 with PractitionerRole

use of org.hl7.fhir.r4.model.PractitionerRole 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 32 with PractitionerRole

use of org.hl7.fhir.r4.model.PractitionerRole in project summary-care-record-api by NHSDigital.

the class ParticipantAgentMapper method mapAuthor1.

public static Participant.Author1 mapAuthor1(Bundle bundle, EncounterParticipantComponent encounterParticipant) {
    var author = new Participant.Author1();
    author.setTime(formatDateToHl7(encounterParticipant.getPeriod().getStartElement()));
    var practitionerRoleReference = encounterParticipant.getIndividual().getReference();
    var practitionerRole = getResourceByReference(bundle, practitionerRoleReference, PractitionerRole.class).orElseThrow(() -> new FhirValidationException(String.format("Bundle is missing PractitionerRole %s that is linked to Encounter", practitionerRoleReference)));
    if (StringUtils.isNotBlank(practitionerRole.getOrganization().getReference())) {
        setAgentDevice(bundle, practitionerRole.getOrganization(), author);
    } else if (StringUtils.isNotBlank(practitionerRole.getPractitioner().getReference())) {
        setParticipantAgents(bundle, practitionerRole.getPractitioner(), author);
    }
    return author;
}
Also used : PractitionerRole(org.hl7.fhir.r4.model.PractitionerRole) FhirValidationException(uk.nhs.adaptors.scr.exceptions.FhirValidationException)

Example 33 with PractitionerRole

use of org.hl7.fhir.r4.model.PractitionerRole in project summary-care-record-api by NHSDigital.

the class AgentPersonMapper method mapPractitionerRole.

private PractitionerRole mapPractitionerRole(Node agentPerson) {
    var code = xmlUtils.getValueByXPath(agentPerson, CODE_XPATH);
    var display = xmlUtils.getValueByXPath(agentPerson, CODE_DISPLAY_XPATH);
    var role = new PractitionerRole().addCode(new CodeableConcept(new Coding().setSystem(JOB_ROLE_NAME_SYSTEM).setCode(code).setDisplay(display)));
    role.setId(randomUUID());
    return role;
}
Also used : Coding(org.hl7.fhir.r4.model.Coding) PractitionerRole(org.hl7.fhir.r4.model.PractitionerRole) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 34 with PractitionerRole

use of org.hl7.fhir.r4.model.PractitionerRole in project summary-care-record-api by NHSDigital.

the class AgentPersonMapper method mapPerson.

private void mapPerson(Node agentPerson, PractitionerRole role, List<Resource> resources) {
    xmlUtils.detachOptionalNodeByXPath(agentPerson, PERSON_XPATH).ifPresent(person -> {
        var practitioner = new Practitioner();
        practitioner.setId(randomUUID());
        practitioner.addName().setText(xmlUtils.getNodeText(person, PERSON_NAME_XPATH));
        role.setPractitioner(new Reference(practitioner));
        resources.add(practitioner);
    });
}
Also used : Practitioner(org.hl7.fhir.r4.model.Practitioner) Reference(org.hl7.fhir.r4.model.Reference)

Example 35 with PractitionerRole

use of org.hl7.fhir.r4.model.PractitionerRole in project summary-care-record-api by NHSDigital.

the class AgentPersonSdsMapper method map.

@Override
public List<? extends Resource> map(Node agentPersonSds) {
    List<Resource> resources = new ArrayList<>();
    PractitionerRole role = mapPractitionerRole(agentPersonSds);
    var personSds = xmlUtils.getNodeByXpath(agentPersonSds, PERSON_SDS_XPATH);
    var practitioner = personSdsMapper.mapPractitioner(personSds);
    role.setPractitioner(new Reference(practitioner));
    resources.add(role);
    resources.add(practitioner);
    return resources;
}
Also used : Reference(org.hl7.fhir.r4.model.Reference) Resource(org.hl7.fhir.r4.model.Resource) ArrayList(java.util.ArrayList) PractitionerRole(org.hl7.fhir.r4.model.PractitionerRole)

Aggregations

PractitionerRole (org.hl7.fhir.r4.model.PractitionerRole)26 Reference (org.hl7.fhir.r4.model.Reference)19 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)16 Coding (org.hl7.fhir.r4.model.Coding)15 Identifier (org.hl7.fhir.r4.model.Identifier)13 ArrayList (java.util.ArrayList)12 Practitioner (org.hl7.fhir.r4.model.Practitioner)12 Resource (org.hl7.fhir.r4.model.Resource)12 List (java.util.List)11 PractitionerRole (org.hl7.fhir.dstu3.model.PractitionerRole)11 RelatedPerson (org.hl7.fhir.r4.model.RelatedPerson)10 Optional (java.util.Optional)9 DateTimeType (org.hl7.fhir.r4.model.DateTimeType)7 EncounterParticipantComponent (org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent)7 Period (org.hl7.fhir.r4.model.Period)7 Test (org.junit.jupiter.api.Test)7 Identifiable (org.openehealth.ipf.commons.ihe.xds.core.metadata.Identifiable)7 Component (org.springframework.stereotype.Component)7 ContactPoint (org.hl7.fhir.r4.model.ContactPoint)6 RequiredArgsConstructor (lombok.RequiredArgsConstructor)5