Search in sources :

Example 16 with EncounterParticipantComponent

use of org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent in project integration-adaptor-111 by nhsconnect.

the class ParticipantMapper method mapEncounterRelatedPerson.

public Encounter.EncounterParticipantComponent mapEncounterRelatedPerson(POCDMT000002UK01Informant12 informant, Encounter encounter) {
    RelatedPerson relatedPerson = relatedPersonMapper.mapRelatedPerson(informant, encounter);
    Encounter.EncounterParticipantComponent encounterParticipantComponent = new Encounter.EncounterParticipantComponent().setType(Collections.singletonList(new CodeableConcept().setText(PARTICIPANT_TYPE_CODE_MAP.get(informant.getTypeCode())))).setIndividual(resourceUtil.createReference(relatedPerson)).setIndividualTarget(relatedPerson);
    if (informant.isSetRelatedEntity()) {
        if (informant.getRelatedEntity().isSetEffectiveTime()) {
            encounterParticipantComponent.setPeriod(periodMapper.mapPeriod(informant.getRelatedEntity().getEffectiveTime()));
        }
    }
    return encounterParticipantComponent;
}
Also used : Encounter(org.hl7.fhir.dstu3.model.Encounter) RelatedPerson(org.hl7.fhir.dstu3.model.RelatedPerson) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Example 17 with EncounterParticipantComponent

use of org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent in project eCRNow by drajer-health.

the class R4ResourcesData method loadPractitionersLocationAndOrganization.

public void loadPractitionersLocationAndOrganization(FhirContext context, IGenericClient client, LaunchDetails launchDetails, R4FhirData r4FhirData, Encounter encounter, Bundle bundle, Date start, Date end) {
    if (encounter != null) {
        // Load Practitioners
        if (encounter.getParticipant() != null) {
            List<Practitioner> practitionerList = new ArrayList<>();
            Map<String, String> practitionerMap = new HashMap<>();
            List<EncounterParticipantComponent> participants = encounter.getParticipant();
            for (EncounterParticipantComponent participant : participants) {
                if (participant.getIndividual() != null) {
                    Reference practitionerReference = participant.getIndividual();
                    String practitionerID = practitionerReference.getReferenceElement().getIdPart();
                    if (!practitionerMap.containsKey(practitionerID)) {
                        Practitioner practitioner = (Practitioner) fhirContextInitializer.getResouceById(launchDetails, client, context, "Practitioner", practitionerID);
                        if (practitioner != null) {
                            practitionerList.add(practitioner);
                            practitionerMap.put(practitionerID, practitioner.getResourceType().name());
                            BundleEntryComponent practitionerEntry = new BundleEntryComponent().setResource(practitioner);
                            bundle.addEntry(practitionerEntry);
                        }
                    }
                }
            }
            if (!practitionerList.isEmpty()) {
                r4FhirData.setPractitionersList(practitionerList);
            }
        }
        // Load Location
        if (Boolean.TRUE.equals(encounter.hasServiceProvider())) {
            Reference organizationReference = encounter.getServiceProvider();
            if (organizationReference.hasReferenceElement()) {
                Organization organization = (Organization) fhirContextInitializer.getResouceById(launchDetails, client, context, "Organization", organizationReference.getReferenceElement().getIdPart());
                if (organization != null) {
                    BundleEntryComponent organizationEntry = new BundleEntryComponent().setResource(organization);
                    bundle.addEntry(organizationEntry);
                    r4FhirData.setOrganization(organization);
                }
            }
        }
        if (Boolean.TRUE.equals(encounter.hasLocation())) {
            List<Location> locationList = new ArrayList<>();
            List<EncounterLocationComponent> enocunterLocations = encounter.getLocation();
            for (EncounterLocationComponent location : enocunterLocations) {
                if (location.getLocation() != null) {
                    Reference locationReference = location.getLocation();
                    Location locationResource = (Location) fhirContextInitializer.getResouceById(launchDetails, client, context, "Location", locationReference.getReferenceElement().getIdPart());
                    if (locationResource != null) {
                        locationList.add(locationResource);
                        BundleEntryComponent locationEntry = new BundleEntryComponent().setResource(locationResource);
                        bundle.addEntry(locationEntry);
                    }
                }
            }
            r4FhirData.setLocationList(locationList);
        }
    } else {
        logger.debug("Encounter is null, cannot fetch Practitioners");
    }
}
Also used : HashMap(java.util.HashMap) EncounterLocationComponent(org.hl7.fhir.r4.model.Encounter.EncounterLocationComponent) ArrayList(java.util.ArrayList) EncounterParticipantComponent(org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)

Example 18 with EncounterParticipantComponent

use of org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent in project nia-patient-switching-standard-adaptor by NHSDigital.

the class EncounterMapper method getPerformer.

private EncounterParticipantComponent getPerformer(RCMRMT030101UK04Participant2 participant2) {
    var performer = new EncounterParticipantComponent();
    var coding = new Coding();
    coding.setSystem(PERFORMER_SYSTEM).setCode(PERFORMER_CODE).setDisplay(PERFORMER_DISPLAY);
    return performer.addType(new CodeableConcept(coding)).setIndividual(new Reference(PRACTITIONER_REFERENCE_PREFIX + participant2.getAgentRef().getId().getRoot()));
}
Also used : EncounterParticipantComponent(org.hl7.fhir.dstu3.model.Encounter.EncounterParticipantComponent) Coding(org.hl7.fhir.dstu3.model.Coding) Reference(org.hl7.fhir.dstu3.model.Reference) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Example 19 with EncounterParticipantComponent

use of org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent in project nia-patient-switching-standard-adaptor by NHSDigital.

the class EncounterMapper method getRecorder.

private EncounterParticipantComponent getRecorder(RCMRMT030101UK04Author author) {
    var recorder = new EncounterParticipantComponent();
    var coding = new Coding(RECORDER_SYSTEM, RECORDER_CODE, RECORDER_DISPLAY);
    return recorder.addType(new CodeableConcept(coding)).setIndividual(new Reference(PRACTITIONER_REFERENCE_PREFIX + author.getAgentRef().getId().getRoot()));
}
Also used : EncounterParticipantComponent(org.hl7.fhir.dstu3.model.Encounter.EncounterParticipantComponent) Coding(org.hl7.fhir.dstu3.model.Coding) Reference(org.hl7.fhir.dstu3.model.Reference) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Aggregations

EncounterParticipantComponent (org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent)11 Encounter (org.hl7.fhir.r4.model.Encounter)10 ArrayList (java.util.ArrayList)9 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)8 Coding (org.hl7.fhir.r4.model.Coding)8 Reference (org.hl7.fhir.r4.model.Reference)8 List (java.util.List)7 Observation (org.hl7.fhir.r4.model.Observation)7 Period (org.hl7.fhir.r4.model.Period)7 PractitionerRole (org.hl7.fhir.r4.model.PractitionerRole)7 Resource (org.hl7.fhir.r4.model.Resource)7 Optional (java.util.Optional)6 Component (org.springframework.stereotype.Component)6 RequiredArgsConstructor (lombok.RequiredArgsConstructor)5 SneakyThrows (lombok.SneakyThrows)5 DateTimeType (org.hl7.fhir.r4.model.DateTimeType)5 FINISHED (org.hl7.fhir.r4.model.Encounter.EncounterStatus.FINISHED)5 RelatedPerson (org.hl7.fhir.r4.model.RelatedPerson)5 Autowired (org.springframework.beans.factory.annotation.Autowired)5 Node (org.w3c.dom.Node)5