Search in sources :

Example 11 with CareTeam

use of org.hl7.fhir.r4.model.CareTeam 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);
}
Also used : Meta(org.hl7.fhir.r4.model.Meta) CareTeam(org.hl7.fhir.r4.model.CareTeam) Reference(org.hl7.fhir.r4.model.Reference) DocumentReference(org.hl7.fhir.r4.model.DocumentReference) Period(org.hl7.fhir.r4.model.Period) Patient(org.hl7.fhir.r4.model.Patient) Code(org.mitre.synthea.world.concepts.HealthRecord.Code) Date(java.util.Date) CareTeamParticipantComponent(org.hl7.fhir.r4.model.CareTeam.CareTeamParticipantComponent) Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter)

Example 12 with CareTeam

use of org.hl7.fhir.r4.model.CareTeam in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeCareTeamCareTeamParticipantComponent.

protected void composeCareTeamCareTeamParticipantComponent(Complex parent, String parentType, String name, CareTeam.CareTeamParticipantComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "participant", name, element, index);
    if (element.hasRole())
        composeCodeableConcept(t, "CareTeam", "role", element.getRole(), -1);
    if (element.hasMember())
        composeReference(t, "CareTeam", "member", element.getMember(), -1);
    if (element.hasPeriod())
        composePeriod(t, "CareTeam", "period", element.getPeriod(), -1);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 13 with CareTeam

use of org.hl7.fhir.r4.model.CareTeam in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeCareTeam.

protected void composeCareTeam(Complex parent, String parentType, String name, CareTeam element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "CareTeam", name, element, index);
    for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "CareTeam", "identifier", element.getIdentifier().get(i), i);
    if (element.hasStatus())
        composeCodeableConcept(t, "CareTeam", "status", element.getStatus(), -1);
    for (int i = 0; i < element.getType().size(); i++) composeCodeableConcept(t, "CareTeam", "type", element.getType().get(i), i);
    if (element.hasNameElement())
        composeString(t, "CareTeam", "name", element.getNameElement(), -1);
    if (element.hasSubject())
        composeReference(t, "CareTeam", "subject", element.getSubject(), -1);
    if (element.hasPeriod())
        composePeriod(t, "CareTeam", "period", element.getPeriod(), -1);
    for (int i = 0; i < element.getParticipant().size(); i++) composeCareTeamCareTeamParticipantComponent(t, "CareTeam", "participant", element.getParticipant().get(i), i);
    if (element.hasManagingOrganization())
        composeReference(t, "CareTeam", "managingOrganization", element.getManagingOrganization(), -1);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 14 with CareTeam

use of org.hl7.fhir.r4.model.CareTeam in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeClaim.

protected void composeClaim(Complex parent, String parentType, String name, Claim element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "Claim", name, element, index);
    for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "Claim", "identifier", element.getIdentifier().get(i), i);
    if (element.hasStatusElement())
        composeEnum(t, "Claim", "status", element.getStatusElement(), -1);
    if (element.hasType())
        composeCodeableConcept(t, "Claim", "type", element.getType(), -1);
    for (int i = 0; i < element.getSubType().size(); i++) composeCodeableConcept(t, "Claim", "subType", element.getSubType().get(i), i);
    if (element.hasUseElement())
        composeEnum(t, "Claim", "use", element.getUseElement(), -1);
    if (element.hasPatient())
        composeReference(t, "Claim", "patient", element.getPatient(), -1);
    if (element.hasBillablePeriod())
        composePeriod(t, "Claim", "billablePeriod", element.getBillablePeriod(), -1);
    if (element.hasCreatedElement())
        composeDateTime(t, "Claim", "created", element.getCreatedElement(), -1);
    if (element.hasEnterer())
        composeReference(t, "Claim", "enterer", element.getEnterer(), -1);
    if (element.hasInsurer())
        composeReference(t, "Claim", "insurer", element.getInsurer(), -1);
    if (element.hasProvider())
        composeReference(t, "Claim", "provider", element.getProvider(), -1);
    if (element.hasOrganization())
        composeReference(t, "Claim", "organization", element.getOrganization(), -1);
    if (element.hasPriority())
        composeCodeableConcept(t, "Claim", "priority", element.getPriority(), -1);
    if (element.hasFundsReserve())
        composeCodeableConcept(t, "Claim", "fundsReserve", element.getFundsReserve(), -1);
    for (int i = 0; i < element.getRelated().size(); i++) composeClaimRelatedClaimComponent(t, "Claim", "related", element.getRelated().get(i), i);
    if (element.hasPrescription())
        composeReference(t, "Claim", "prescription", element.getPrescription(), -1);
    if (element.hasOriginalPrescription())
        composeReference(t, "Claim", "originalPrescription", element.getOriginalPrescription(), -1);
    if (element.hasPayee())
        composeClaimPayeeComponent(t, "Claim", "payee", element.getPayee(), -1);
    if (element.hasReferral())
        composeReference(t, "Claim", "referral", element.getReferral(), -1);
    if (element.hasFacility())
        composeReference(t, "Claim", "facility", element.getFacility(), -1);
    for (int i = 0; i < element.getCareTeam().size(); i++) composeClaimCareTeamComponent(t, "Claim", "careTeam", element.getCareTeam().get(i), i);
    for (int i = 0; i < element.getInformation().size(); i++) composeClaimSpecialConditionComponent(t, "Claim", "information", element.getInformation().get(i), i);
    for (int i = 0; i < element.getDiagnosis().size(); i++) composeClaimDiagnosisComponent(t, "Claim", "diagnosis", element.getDiagnosis().get(i), i);
    for (int i = 0; i < element.getProcedure().size(); i++) composeClaimProcedureComponent(t, "Claim", "procedure", element.getProcedure().get(i), i);
    for (int i = 0; i < element.getInsurance().size(); i++) composeClaimInsuranceComponent(t, "Claim", "insurance", element.getInsurance().get(i), i);
    if (element.hasAccident())
        composeClaimAccidentComponent(t, "Claim", "accident", element.getAccident(), -1);
    if (element.hasEmploymentImpacted())
        composePeriod(t, "Claim", "employmentImpacted", element.getEmploymentImpacted(), -1);
    if (element.hasHospitalization())
        composePeriod(t, "Claim", "hospitalization", element.getHospitalization(), -1);
    for (int i = 0; i < element.getItem().size(); i++) composeClaimItemComponent(t, "Claim", "item", element.getItem().get(i), i);
    if (element.hasTotal())
        composeMoney(t, "Claim", "total", element.getTotal(), -1);
}
Also used : Complex(org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)

Example 15 with CareTeam

use of org.hl7.fhir.r4.model.CareTeam in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeCarePlan.

protected void composeCarePlan(Complex parent, String parentType, String name, CarePlan element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "CarePlan", name, element, index);
    for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "CarePlan", "identifier", element.getIdentifier().get(i), i);
    for (int i = 0; i < element.getDefinition().size(); i++) composeReference(t, "CarePlan", "definition", element.getDefinition().get(i), i);
    for (int i = 0; i < element.getBasedOn().size(); i++) composeReference(t, "CarePlan", "basedOn", element.getBasedOn().get(i), i);
    for (int i = 0; i < element.getReplaces().size(); i++) composeReference(t, "CarePlan", "replaces", element.getReplaces().get(i), i);
    for (int i = 0; i < element.getPartOf().size(); i++) composeReference(t, "CarePlan", "partOf", element.getPartOf().get(i), i);
    if (element.hasStatusElement())
        composeEnum(t, "CarePlan", "status", element.getStatusElement(), -1);
    if (element.hasIntentElement())
        composeEnum(t, "CarePlan", "intent", element.getIntentElement(), -1);
    for (int i = 0; i < element.getCategory().size(); i++) composeCodeableConcept(t, "CarePlan", "category", element.getCategory().get(i), i);
    if (element.hasTitleElement())
        composeString(t, "CarePlan", "title", element.getTitleElement(), -1);
    if (element.hasDescriptionElement())
        composeString(t, "CarePlan", "description", element.getDescriptionElement(), -1);
    if (element.hasSubject())
        composeReference(t, "CarePlan", "subject", element.getSubject(), -1);
    if (element.hasContext())
        composeReference(t, "CarePlan", "context", element.getContext(), -1);
    if (element.hasPeriod())
        composePeriod(t, "CarePlan", "period", element.getPeriod(), -1);
    for (int i = 0; i < element.getAuthor().size(); i++) composeReference(t, "CarePlan", "author", element.getAuthor().get(i), i);
    for (int i = 0; i < element.getCareTeam().size(); i++) composeReference(t, "CarePlan", "careTeam", element.getCareTeam().get(i), i);
    for (int i = 0; i < element.getAddresses().size(); i++) composeReference(t, "CarePlan", "addresses", element.getAddresses().get(i), i);
    for (int i = 0; i < element.getSupportingInfo().size(); i++) composeReference(t, "CarePlan", "supportingInfo", element.getSupportingInfo().get(i), i);
    for (int i = 0; i < element.getGoal().size(); i++) composeReference(t, "CarePlan", "goal", element.getGoal().get(i), i);
    for (int i = 0; i < element.getActivity().size(); i++) composeCarePlanCarePlanActivityComponent(t, "CarePlan", "activity", element.getActivity().get(i), i);
    for (int i = 0; i < element.getNote().size(); i++) composeAnnotation(t, "CarePlan", "note", element.getNote().get(i), i);
}
Also used : Complex(org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)

Aggregations

Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)7 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)7 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)2 Encounter (org.mitre.synthea.world.concepts.HealthRecord.Encounter)2 Date (java.util.Date)1 Turtle (org.hl7.fhir.dstu3.utils.formats.Turtle)1 Bundle (org.hl7.fhir.r4.model.Bundle)1 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)1 CareTeam (org.hl7.fhir.r4.model.CareTeam)1 CareTeamParticipantComponent (org.hl7.fhir.r4.model.CareTeam.CareTeamParticipantComponent)1 DiagnosticReport (org.hl7.fhir.r4.model.DiagnosticReport)1 DocumentReference (org.hl7.fhir.r4.model.DocumentReference)1 Meta (org.hl7.fhir.r4.model.Meta)1 MetadataResource (org.hl7.fhir.r4.model.MetadataResource)1 Patient (org.hl7.fhir.r4.model.Patient)1 Period (org.hl7.fhir.r4.model.Period)1 Reference (org.hl7.fhir.r4.model.Reference)1 Resource (org.hl7.fhir.r4.model.Resource)1 Test (org.junit.jupiter.api.Test)1 Attachment (org.mitre.synthea.engine.Components.Attachment)1