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();
}
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();
}
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;
}
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);
}
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);
}
Aggregations