use of org.hl7.fhir.r4.model.CareTeam.CareTeamParticipantComponent in project synthea by synthetichealth.
the class FhirR4 method careTeam.
/**
* Map the given CarePlan to a FHIR CareTeam resource, and add it to the given Bundle.
*
* @param rand Source of randomness to use when generating ids etc
* @param personEntry The Entry for the Person
* @param bundle Bundle to add the CarePlan to
* @param encounterEntry Current Encounter entry
* @param carePlan The CarePlan to map to FHIR and add to the bundle
* @return The added Entry
*/
private static BundleEntryComponent careTeam(RandomNumberGenerator rand, BundleEntryComponent personEntry, Bundle bundle, BundleEntryComponent encounterEntry, CarePlan carePlan) {
CareTeam careTeam = new CareTeam();
if (USE_US_CORE_IG) {
Meta meta = new Meta();
meta.addProfile("http://hl7.org/fhir/us/core/StructureDefinition/us-core-careteam");
careTeam.setMeta(meta);
}
Period period = new Period().setStart(new Date(carePlan.start));
careTeam.setPeriod(period);
if (carePlan.stop != 0L) {
period.setEnd(new Date(carePlan.stop));
careTeam.setStatus(CareTeamStatus.INACTIVE);
} else {
careTeam.setStatus(CareTeamStatus.ACTIVE);
}
careTeam.setSubject(new Reference(personEntry.getFullUrl()));
careTeam.setEncounter(new Reference(encounterEntry.getFullUrl()));
if (carePlan.reasons != null && !carePlan.reasons.isEmpty()) {
for (Code code : carePlan.reasons) {
careTeam.addReasonCode(mapCodeToCodeableConcept(code, SNOMED_URI));
}
}
// The first participant is the patient...
CareTeamParticipantComponent participant = careTeam.addParticipant();
participant.addRole(mapCodeToCodeableConcept(new Code(SNOMED_URI, "116154003", "Patient"), SNOMED_URI));
Patient patient = (Patient) personEntry.getResource();
participant.setMember(new Reference().setReference(personEntry.getFullUrl()).setDisplay(patient.getNameFirstRep().getNameAsSingleString()));
org.hl7.fhir.r4.model.Encounter encounter = (org.hl7.fhir.r4.model.Encounter) encounterEntry.getResource();
// The second participant is the practitioner...
if (encounter.hasParticipant()) {
participant = careTeam.addParticipant();
participant.addRole(mapCodeToCodeableConcept(new Code(SNOMED_URI, "223366009", "Healthcare professional (occupation)"), SNOMED_URI));
participant.setMember(encounter.getParticipantFirstRep().getIndividual());
}
// The last participant is the organization...
participant = careTeam.addParticipant();
participant.addRole(mapCodeToCodeableConcept(new Code(SNOMED_URI, "224891009", "Healthcare services (qualifier value)"), SNOMED_URI));
participant.setMember(encounter.getServiceProvider());
careTeam.addManagingOrganization(encounter.getServiceProvider());
return newEntry(rand, bundle, careTeam);
}
Aggregations