use of org.hl7.fhir.r4b.model.Meta in project synthea by synthetichealth.
the class FhirR4 method observation.
/**
* Map the given Observation into a FHIR Observation resource, and add it to the given Bundle.
*
* @param rand Source of randomness to use when generating ids etc
* @param personEntry The Person Entry
* @param bundle The Bundle to add to
* @param encounterEntry The current Encounter entry
* @param observation The Observation
* @return The added Entry
*/
private static BundleEntryComponent observation(RandomNumberGenerator rand, BundleEntryComponent personEntry, Bundle bundle, BundleEntryComponent encounterEntry, Observation observation) {
org.hl7.fhir.r4.model.Observation observationResource = new org.hl7.fhir.r4.model.Observation();
observationResource.setSubject(new Reference(personEntry.getFullUrl()));
observationResource.setEncounter(new Reference(encounterEntry.getFullUrl()));
observationResource.setStatus(ObservationStatus.FINAL);
Code code = observation.codes.get(0);
observationResource.setCode(mapCodeToCodeableConcept(code, LOINC_URI));
// add extra codes, if there are any...
if (observation.codes.size() > 1) {
for (int i = 1; i < observation.codes.size(); i++) {
code = observation.codes.get(i);
Coding coding = new Coding();
coding.setCode(code.code);
coding.setDisplay(code.display);
coding.setSystem(LOINC_URI);
observationResource.getCode().addCoding(coding);
}
}
observationResource.addCategory().addCoding().setCode(observation.category).setSystem("http://terminology.hl7.org/CodeSystem/observation-category").setDisplay(observation.category);
if (observation.value != null) {
Type value = mapValueToFHIRType(observation.value, observation.unit);
observationResource.setValue(value);
} else if (observation.observations != null && !observation.observations.isEmpty()) {
// multi-observation (ex blood pressure)
for (Observation subObs : observation.observations) {
ObservationComponentComponent comp = new ObservationComponentComponent();
comp.setCode(mapCodeToCodeableConcept(subObs.codes.get(0), LOINC_URI));
Type value = mapValueToFHIRType(subObs.value, subObs.unit);
comp.setValue(value);
observationResource.addComponent(comp);
}
}
observationResource.setEffective(convertFhirDateTime(observation.start, true));
observationResource.setIssued(new Date(observation.start));
if (USE_US_CORE_IG) {
Meta meta = new Meta();
// add the specific profile based on code
String codeMappingUri = US_CORE_MAPPING.get(LOINC_URI, code.code);
if (codeMappingUri != null) {
meta.addProfile(codeMappingUri);
if (!codeMappingUri.contains("/us/core/") && observation.category.equals("vital-signs")) {
meta.addProfile("http://hl7.org/fhir/StructureDefinition/vitalsigns");
}
} else if (observation.report != null && observation.category.equals("laboratory")) {
meta.addProfile("http://hl7.org/fhir/us/core/StructureDefinition/us-core-observation-lab");
}
if (meta.hasProfile()) {
observationResource.setMeta(meta);
}
} else if (USE_SHR_EXTENSIONS) {
Meta meta = new Meta();
// all Observations are Observations
meta.addProfile(SHR_EXT + "shr-finding-Observation");
if ("vital-signs".equals(observation.category)) {
meta.addProfile(SHR_EXT + "shr-vital-VitalSign");
}
// add the specific profile based on code
String codeMappingUri = SHR_MAPPING.get(LOINC_URI, code.code);
if (codeMappingUri != null) {
meta.addProfile(codeMappingUri);
}
observationResource.setMeta(meta);
}
BundleEntryComponent entry = newEntry(rand, bundle, observationResource);
observation.fullUrl = entry.getFullUrl();
return entry;
}
use of org.hl7.fhir.r4b.model.Meta in project synthea by synthetichealth.
the class FhirR4 method basicInfo.
/**
* Map the given Person to a FHIR Patient resource, and add it to the given Bundle.
*
* @param person The Person
* @param bundle The Bundle to add to
* @param stopTime Time the simulation ended
* @return The created Entry
*/
@SuppressWarnings("rawtypes")
private static BundleEntryComponent basicInfo(Person person, Bundle bundle, long stopTime) {
Patient patientResource = new Patient();
patientResource.addIdentifier().setSystem(SYNTHEA_IDENTIFIER).setValue((String) person.attributes.get(Person.ID));
if (USE_US_CORE_IG) {
Meta meta = new Meta();
meta.addProfile("http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient");
patientResource.setMeta(meta);
}
Code mrnCode = new Code("http://terminology.hl7.org/CodeSystem/v2-0203", "MR", "Medical Record Number");
patientResource.addIdentifier().setType(mapCodeToCodeableConcept(mrnCode, "http://terminology.hl7.org/CodeSystem/v2-0203")).setSystem("http://hospital.smarthealthit.org").setValue((String) person.attributes.get(Person.ID));
Code ssnCode = new Code("http://terminology.hl7.org/CodeSystem/v2-0203", "SS", "Social Security Number");
patientResource.addIdentifier().setType(mapCodeToCodeableConcept(ssnCode, "http://terminology.hl7.org/CodeSystem/v2-0203")).setSystem("http://hl7.org/fhir/sid/us-ssn").setValue((String) person.attributes.get(Person.IDENTIFIER_SSN));
if (person.attributes.get(Person.IDENTIFIER_DRIVERS) != null) {
Code driversCode = new Code("http://terminology.hl7.org/CodeSystem/v2-0203", "DL", "Driver's License");
patientResource.addIdentifier().setType(mapCodeToCodeableConcept(driversCode, "http://terminology.hl7.org/CodeSystem/v2-0203")).setSystem("urn:oid:2.16.840.1.113883.4.3.25").setValue((String) person.attributes.get(Person.IDENTIFIER_DRIVERS));
}
if (person.attributes.get(Person.IDENTIFIER_PASSPORT) != null) {
Code passportCode = new Code("http://terminology.hl7.org/CodeSystem/v2-0203", "PPN", "Passport Number");
patientResource.addIdentifier().setType(mapCodeToCodeableConcept(passportCode, "http://terminology.hl7.org/CodeSystem/v2-0203")).setSystem(SHR_EXT + "passportNumber").setValue((String) person.attributes.get(Person.IDENTIFIER_PASSPORT));
}
if (person.attributes.get(Person.CONTACT_EMAIL) != null) {
ContactComponent contact = new ContactComponent();
HumanName contactName = new HumanName();
contactName.setUse(HumanName.NameUse.OFFICIAL);
contactName.addGiven((String) person.attributes.get(Person.CONTACT_GIVEN_NAME));
contactName.setFamily((String) person.attributes.get(Person.CONTACT_FAMILY_NAME));
contact.setName(contactName);
contact.addTelecom().setSystem(ContactPointSystem.EMAIL).setUse(ContactPointUse.HOME).setValue((String) person.attributes.get(Person.CONTACT_EMAIL));
patientResource.addContact(contact);
}
if (USE_US_CORE_IG) {
// We do not yet account for mixed race
Extension raceExtension = new Extension("http://hl7.org/fhir/us/core/StructureDefinition/us-core-race");
String race = (String) person.attributes.get(Person.RACE);
String raceDisplay;
switch(race) {
case "white":
raceDisplay = "White";
break;
case "black":
raceDisplay = "Black or African American";
break;
case "asian":
raceDisplay = "Asian";
break;
case "native":
raceDisplay = "American Indian or Alaska Native";
break;
case "hawaiian":
raceDisplay = "Native Hawaiian or Other Pacific Islander";
break;
default:
raceDisplay = "Other";
break;
}
String raceNum = (String) raceEthnicityCodes.get(race);
Extension raceCodingExtension = new Extension("ombCategory");
Coding raceCoding = new Coding();
if (raceDisplay.equals("Other")) {
raceCoding.setSystem("http://terminology.hl7.org/CodeSystem/v3-NullFlavor");
raceCoding.setCode("UNK");
raceCoding.setDisplay("Unknown");
} else {
raceCoding.setSystem("urn:oid:2.16.840.1.113883.6.238");
raceCoding.setCode(raceNum);
raceCoding.setDisplay(raceDisplay);
}
raceCodingExtension.setValue(raceCoding);
raceExtension.addExtension(raceCodingExtension);
Extension raceTextExtension = new Extension("text");
raceTextExtension.setValue(new StringType(raceDisplay));
raceExtension.addExtension(raceTextExtension);
patientResource.addExtension(raceExtension);
// We do not yet account for mixed ethnicity
Extension ethnicityExtension = new Extension("http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity");
String ethnicity = (String) person.attributes.get(Person.ETHNICITY);
String ethnicityDisplay;
if (ethnicity.equals("hispanic")) {
ethnicity = "hispanic";
ethnicityDisplay = "Hispanic or Latino";
} else {
ethnicity = "nonhispanic";
ethnicityDisplay = "Not Hispanic or Latino";
}
String ethnicityNum = (String) raceEthnicityCodes.get(ethnicity);
Extension ethnicityCodingExtension = new Extension("ombCategory");
Coding ethnicityCoding = new Coding();
ethnicityCoding.setSystem("urn:oid:2.16.840.1.113883.6.238");
ethnicityCoding.setCode(ethnicityNum);
ethnicityCoding.setDisplay(ethnicityDisplay);
ethnicityCodingExtension.setValue(ethnicityCoding);
ethnicityExtension.addExtension(ethnicityCodingExtension);
Extension ethnicityTextExtension = new Extension("text");
ethnicityTextExtension.setValue(new StringType(ethnicityDisplay));
ethnicityExtension.addExtension(ethnicityTextExtension);
patientResource.addExtension(ethnicityExtension);
}
String firstLanguage = (String) person.attributes.get(Person.FIRST_LANGUAGE);
Map languageMap = (Map) languageLookup.get(firstLanguage);
Code languageCode = new Code((String) languageMap.get("system"), (String) languageMap.get("code"), (String) languageMap.get("display"));
List<PatientCommunicationComponent> communication = new ArrayList<PatientCommunicationComponent>();
communication.add(new PatientCommunicationComponent(mapCodeToCodeableConcept(languageCode, (String) languageMap.get("system"))));
patientResource.setCommunication(communication);
HumanName name = patientResource.addName();
name.setUse(HumanName.NameUse.OFFICIAL);
name.addGiven((String) person.attributes.get(Person.FIRST_NAME));
name.setFamily((String) person.attributes.get(Person.LAST_NAME));
if (person.attributes.get(Person.NAME_PREFIX) != null) {
name.addPrefix((String) person.attributes.get(Person.NAME_PREFIX));
}
if (person.attributes.get(Person.NAME_SUFFIX) != null) {
name.addSuffix((String) person.attributes.get(Person.NAME_SUFFIX));
}
if (person.attributes.get(Person.MAIDEN_NAME) != null) {
HumanName maidenName = patientResource.addName();
maidenName.setUse(HumanName.NameUse.MAIDEN);
maidenName.addGiven((String) person.attributes.get(Person.FIRST_NAME));
maidenName.setFamily((String) person.attributes.get(Person.MAIDEN_NAME));
if (person.attributes.get(Person.NAME_PREFIX) != null) {
maidenName.addPrefix((String) person.attributes.get(Person.NAME_PREFIX));
}
if (person.attributes.get(Person.NAME_SUFFIX) != null) {
maidenName.addSuffix((String) person.attributes.get(Person.NAME_SUFFIX));
}
}
Extension mothersMaidenNameExtension = new Extension("http://hl7.org/fhir/StructureDefinition/patient-mothersMaidenName");
String mothersMaidenName = (String) person.attributes.get(Person.NAME_MOTHER);
mothersMaidenNameExtension.setValue(new StringType(mothersMaidenName));
patientResource.addExtension(mothersMaidenNameExtension);
long birthdate = (long) person.attributes.get(Person.BIRTHDATE);
patientResource.setBirthDate(new Date(birthdate));
Extension birthSexExtension = new Extension("http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex");
if (person.attributes.get(Person.GENDER).equals("M")) {
patientResource.setGender(AdministrativeGender.MALE);
birthSexExtension.setValue(new CodeType("M"));
} else if (person.attributes.get(Person.GENDER).equals("F")) {
patientResource.setGender(AdministrativeGender.FEMALE);
birthSexExtension.setValue(new CodeType("F"));
} else if (person.attributes.get(Person.GENDER).equals("UNK")) {
patientResource.setGender(AdministrativeGender.UNKNOWN);
}
if (USE_US_CORE_IG) {
patientResource.addExtension(birthSexExtension);
}
String state = (String) person.attributes.get(Person.STATE);
if (USE_US_CORE_IG) {
state = Location.getAbbreviation(state);
}
Address addrResource = patientResource.addAddress();
addrResource.addLine((String) person.attributes.get(Person.ADDRESS)).setCity((String) person.attributes.get(Person.CITY)).setPostalCode((String) person.attributes.get(Person.ZIP)).setState(state);
if (COUNTRY_CODE != null) {
addrResource.setCountry(COUNTRY_CODE);
}
Address birthplace = new Address();
birthplace.setCity((String) person.attributes.get(Person.BIRTH_CITY)).setState((String) person.attributes.get(Person.BIRTH_STATE)).setCountry((String) person.attributes.get(Person.BIRTH_COUNTRY));
Extension birthplaceExtension = new Extension("http://hl7.org/fhir/StructureDefinition/patient-birthPlace");
birthplaceExtension.setValue(birthplace);
patientResource.addExtension(birthplaceExtension);
if (person.attributes.get(Person.MULTIPLE_BIRTH_STATUS) != null) {
patientResource.setMultipleBirth(new IntegerType((int) person.attributes.get(Person.MULTIPLE_BIRTH_STATUS)));
} else {
patientResource.setMultipleBirth(new BooleanType(false));
}
patientResource.addTelecom().setSystem(ContactPointSystem.PHONE).setUse(ContactPointUse.HOME).setValue((String) person.attributes.get(Person.TELECOM));
String maritalStatus = ((String) person.attributes.get(Person.MARITAL_STATUS));
if (maritalStatus != null) {
Code maritalStatusCode = new Code("http://terminology.hl7.org/CodeSystem/v3-MaritalStatus", maritalStatus, maritalStatus);
patientResource.setMaritalStatus(mapCodeToCodeableConcept(maritalStatusCode, "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus"));
} else {
Code maritalStatusCode = new Code("http://terminology.hl7.org/CodeSystem/v3-MaritalStatus", "S", "Never Married");
patientResource.setMaritalStatus(mapCodeToCodeableConcept(maritalStatusCode, "http://terminology.hl7.org/CodeSystem/v3-MaritalStatus"));
}
Point2D.Double coord = person.getLonLat();
if (coord != null) {
Extension geolocation = addrResource.addExtension();
geolocation.setUrl("http://hl7.org/fhir/StructureDefinition/geolocation");
geolocation.addExtension("latitude", new DecimalType(coord.getY()));
geolocation.addExtension("longitude", new DecimalType(coord.getX()));
}
if (!person.alive(stopTime)) {
patientResource.setDeceased(convertFhirDateTime((Long) person.attributes.get(Person.DEATHDATE), true));
}
String generatedBySynthea = "Generated by <a href=\"https://github.com/synthetichealth/synthea\">Synthea</a>." + "Version identifier: " + Utilities.SYNTHEA_VERSION + " . " + " Person seed: " + person.getSeed() + " Population seed: " + person.populationSeed;
patientResource.setText(new Narrative().setStatus(NarrativeStatus.GENERATED).setDiv(new XhtmlNode(NodeType.Element).setValue(generatedBySynthea)));
if (USE_SHR_EXTENSIONS) {
patientResource.setMeta(new Meta().addProfile(SHR_EXT + "shr-entity-Patient"));
// Patient profile requires race, ethnicity, birthsex,
// MothersMaidenName, FathersName, Person-extension
patientResource.addExtension().setUrl(SHR_EXT + "shr-actor-FictionalPerson-extension").setValue(new BooleanType(true));
String fathersName = (String) person.attributes.get(Person.NAME_FATHER);
Extension fathersNameExtension = new Extension(SHR_EXT + "shr-entity-FathersName-extension", new HumanName().setText(fathersName));
patientResource.addExtension(fathersNameExtension);
String ssn = (String) person.attributes.get(Person.IDENTIFIER_SSN);
Extension ssnExtension = new Extension(SHR_EXT + "shr-demographics-SocialSecurityNumber-extension", new StringType(ssn));
patientResource.addExtension(ssnExtension);
}
// DALY and QALY values
// we only write the last(current) one to the patient record
Double dalyValue = (Double) person.attributes.get("most-recent-daly");
Double qalyValue = (Double) person.attributes.get("most-recent-qaly");
if (dalyValue != null) {
Extension dalyExtension = new Extension(SYNTHEA_EXT + "disability-adjusted-life-years");
DecimalType daly = new DecimalType(dalyValue);
dalyExtension.setValue(daly);
patientResource.addExtension(dalyExtension);
Extension qalyExtension = new Extension(SYNTHEA_EXT + "quality-adjusted-life-years");
DecimalType qaly = new DecimalType(qalyValue);
qalyExtension.setValue(qaly);
patientResource.addExtension(qalyExtension);
}
return newEntry(bundle, patientResource, (String) person.attributes.get(Person.ID));
}
use of org.hl7.fhir.r4b.model.Meta 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;
}
use of org.hl7.fhir.r4b.model.Meta in project synthea by synthetichealth.
the class FhirR4 method report.
/**
* Map the given Report to a FHIR DiagnosticReport 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 Report to
* @param encounterEntry Current Encounter entry
* @param report The Report
* @return The added Entry
*/
private static BundleEntryComponent report(RandomNumberGenerator rand, BundleEntryComponent personEntry, Bundle bundle, BundleEntryComponent encounterEntry, Report report) {
DiagnosticReport reportResource = new DiagnosticReport();
if (USE_US_CORE_IG) {
Meta meta = new Meta();
meta.addProfile("http://hl7.org/fhir/us/core/StructureDefinition/us-core-diagnosticreport-lab");
reportResource.setMeta(meta);
org.hl7.fhir.r4.model.Encounter encounterResource = (org.hl7.fhir.r4.model.Encounter) encounterEntry.getResource();
reportResource.addPerformer(encounterResource.getServiceProvider());
}
reportResource.setStatus(DiagnosticReportStatus.FINAL);
reportResource.addCategory(new CodeableConcept(new Coding("http://terminology.hl7.org/CodeSystem/v2-0074", "LAB", "Laboratory")));
reportResource.setCode(mapCodeToCodeableConcept(report.codes.get(0), LOINC_URI));
reportResource.setSubject(new Reference(personEntry.getFullUrl()));
reportResource.setEncounter(new Reference(encounterEntry.getFullUrl()));
reportResource.setEffective(convertFhirDateTime(report.start, true));
reportResource.setIssued(new Date(report.start));
for (Observation observation : report.observations) {
Reference reference = new Reference(observation.fullUrl);
reference.setDisplay(observation.codes.get(0).display);
reportResource.addResult(reference);
}
return newEntry(rand, bundle, reportResource);
}
use of org.hl7.fhir.r4b.model.Meta 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