Search in sources :

Example 6 with Goal

use of org.hl7.fhir.r4.model.Goal in project Gravity-SDOH-Exchange-RI by FHIR.

the class GoalService method remove.

public void remove(String id) {
    Assert.notNull(SmartOnFhirContext.get().getPatient(), "Patient id cannot be null.");
    Bundle responseBundle = searchGoalQuery(Goal.GoalLifecycleStatus.ACTIVE).where(Condition.RES_ID.exactly().code(id)).returnBundle(Bundle.class).execute();
    Goal goal = Optional.ofNullable(FhirUtil.getFirstFromBundle(responseBundle, Goal.class)).orElseThrow(() -> new ResourceNotFoundException(new IdType(Goal.class.getSimpleName(), id)));
    goal.setLifecycleStatus(Goal.GoalLifecycleStatus.CANCELLED);
    goal.setStatusDate(new Date());
    ehrClient.update().resource(goal).execute();
}
Also used : Goal(org.hl7.fhir.r4.model.Goal) IBaseBundle(org.hl7.fhir.instance.model.api.IBaseBundle) Bundle(org.hl7.fhir.r4.model.Bundle) ResourceNotFoundException(ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException) Date(java.util.Date) IdType(org.hl7.fhir.r4.model.IdType)

Example 7 with Goal

use of org.hl7.fhir.r4.model.Goal in project Gravity-SDOH-Exchange-RI by FHIR.

the class GoalService method complete.

// TODO forbid close for goals WITH active tasks!
public void complete(String id, CompleteGoalRequestDto dto) {
    Assert.notNull(SmartOnFhirContext.get().getPatient(), "Patient id cannot be null.");
    Bundle responseBundle = searchGoalQuery(Goal.GoalLifecycleStatus.ACTIVE).where(Condition.RES_ID.exactly().code(id)).returnBundle(Bundle.class).execute();
    Goal goal = Optional.ofNullable(FhirUtil.getFirstFromBundle(responseBundle, Goal.class)).orElseThrow(() -> new ResourceNotFoundException(new IdType(Goal.class.getSimpleName(), id)));
    goal.setLifecycleStatus(Goal.GoalLifecycleStatus.COMPLETED);
    // Is this really an endDate?
    goal.setStatusDateElement(dto.getEnd());
    ehrClient.update().resource(goal).execute();
}
Also used : Goal(org.hl7.fhir.r4.model.Goal) IBaseBundle(org.hl7.fhir.instance.model.api.IBaseBundle) Bundle(org.hl7.fhir.r4.model.Bundle) ResourceNotFoundException(ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException) IdType(org.hl7.fhir.r4.model.IdType)

Example 8 with Goal

use of org.hl7.fhir.r4.model.Goal in project Gravity-SDOH-Exchange-RI by FHIR.

the class GoalBundleFactory method createGoal.

private Goal createGoal() {
    Goal goal = new Goal();
    goal.getMeta().addProfile(SDOHProfiles.GOAL);
    goal.setLifecycleStatus(Goal.GoalLifecycleStatus.ACTIVE);
    goal.setStatusDate(new Date());
    goal.setAchievementStatus(new CodeableConcept().addCoding(new Coding(achievementStatus.getSystem(), achievementStatus.toCode(), achievementStatus.getDisplay())));
    goal.addCategory().addCoding(category);
    goal.setDescription(new CodeableConcept().addCoding(snomedCode));
    goal.getDescription().setText(name);
    goal.setSubject(getPatientReference());
    goal.setStart(startDate);
    goal.setExpressedBy(FhirUtil.toReference(Patient.class, practitioner.getIdElement().getIdPart(), practitioner.getNameFirstRep().getNameAsSingleString()));
    if (!Strings.isNullOrEmpty(comment)) {
        goal.addNote().setText(comment).setTimeElement(DateTimeType.now()).setAuthor(new Reference(new IdType(user.getUserType(), user.getId())).setDisplay(user.getName()));
    }
    if (problems != null) {
        problems.forEach(problem -> goal.addAddresses(FhirUtil.toReference(Condition.class, problem.getIdElement().getIdPart(), problem.getCode().getCodingFirstRep().getDisplay())));
    }
    return goal;
}
Also used : Goal(org.hl7.fhir.r4.model.Goal) Coding(org.hl7.fhir.r4.model.Coding) Reference(org.hl7.fhir.r4.model.Reference) Patient(org.hl7.fhir.r4.model.Patient) Date(java.util.Date) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) IdType(org.hl7.fhir.r4.model.IdType)

Example 9 with Goal

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

the class RdfParser method composePlanDefinitionPlanDefinitionGoalComponent.

protected void composePlanDefinitionPlanDefinitionGoalComponent(Complex parent, String parentType, String name, PlanDefinition.PlanDefinitionGoalComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "goal", name, element, index);
    if (element.hasCategory())
        composeCodeableConcept(t, "PlanDefinition", "category", element.getCategory(), -1);
    if (element.hasDescription())
        composeCodeableConcept(t, "PlanDefinition", "description", element.getDescription(), -1);
    if (element.hasPriority())
        composeCodeableConcept(t, "PlanDefinition", "priority", element.getPriority(), -1);
    if (element.hasStart())
        composeCodeableConcept(t, "PlanDefinition", "start", element.getStart(), -1);
    for (int i = 0; i < element.getAddresses().size(); i++) composeCodeableConcept(t, "PlanDefinition", "addresses", element.getAddresses().get(i), i);
    for (int i = 0; i < element.getDocumentation().size(); i++) composeRelatedArtifact(t, "PlanDefinition", "documentation", element.getDocumentation().get(i), i);
    for (int i = 0; i < element.getTarget().size(); i++) composePlanDefinitionPlanDefinitionGoalTargetComponent(t, "PlanDefinition", "target", element.getTarget().get(i), i);
}
Also used : Complex(org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)

Example 10 with Goal

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

the class RdfParser method composeGoal.

protected void composeGoal(Complex parent, String parentType, String name, Goal element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "Goal", name, element, index);
    for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "Goal", "identifier", element.getIdentifier().get(i), i);
    if (element.hasStatusElement())
        composeEnum(t, "Goal", "status", element.getStatusElement(), -1);
    for (int i = 0; i < element.getCategory().size(); i++) composeCodeableConcept(t, "Goal", "category", element.getCategory().get(i), i);
    if (element.hasPriority())
        composeCodeableConcept(t, "Goal", "priority", element.getPriority(), -1);
    if (element.hasDescription())
        composeCodeableConcept(t, "Goal", "description", element.getDescription(), -1);
    if (element.hasSubject())
        composeReference(t, "Goal", "subject", element.getSubject(), -1);
    if (element.hasStart())
        composeType(t, "Goal", "start", element.getStart(), -1);
    if (element.hasTarget())
        composeGoalGoalTargetComponent(t, "Goal", "target", element.getTarget(), -1);
    if (element.hasStatusDateElement())
        composeDate(t, "Goal", "statusDate", element.getStatusDateElement(), -1);
    if (element.hasStatusReasonElement())
        composeString(t, "Goal", "statusReason", element.getStatusReasonElement(), -1);
    if (element.hasExpressedBy())
        composeReference(t, "Goal", "expressedBy", element.getExpressedBy(), -1);
    for (int i = 0; i < element.getAddresses().size(); i++) composeReference(t, "Goal", "addresses", element.getAddresses().get(i), i);
    for (int i = 0; i < element.getNote().size(); i++) composeAnnotation(t, "Goal", "note", element.getNote().get(i), i);
    for (int i = 0; i < element.getOutcomeCode().size(); i++) composeCodeableConcept(t, "Goal", "outcomeCode", element.getOutcomeCode().get(i), i);
    for (int i = 0; i < element.getOutcomeReference().size(); i++) composeReference(t, "Goal", "outcomeReference", element.getOutcomeReference().get(i), i);
}
Also used : Complex(org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)

Aggregations

Goal (org.hl7.fhir.r4.model.Goal)11 Bundle (org.hl7.fhir.r4.model.Bundle)8 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)6 Condition (org.hl7.fhir.r4.model.Condition)6 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)6 Date (java.util.Date)5 IBaseBundle (org.hl7.fhir.instance.model.api.IBaseBundle)5 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)5 JsonObject (com.google.gson.JsonObject)4 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)4 IdType (org.hl7.fhir.r4.model.IdType)4 Reference (org.hl7.fhir.r4.model.Reference)4 List (java.util.List)3 Coding (org.hl7.fhir.r4.model.Coding)3 ServiceRequest (org.hl7.fhir.r4.model.ServiceRequest)3 ResourceNotFoundException (ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException)2 JsonElement (com.google.gson.JsonElement)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2