use of org.hl7.gravity.refimpl.sdohexchange.dto.response.GoalInfoDto in project Gravity-SDOH-Exchange-RI by FHIR.
the class ProblemBundleToDtoConverter method conditionInfoToDto.
@Override
protected ProblemDto conditionInfoToDto(ConditionInfoBundleExtractor.ConditionInfoHolder conditionInfo) {
// TODO refactor this. Avoid manual casting. Refactor the design of a base class instead.
Assert.isInstanceOf(ProblemInfoBundleExtractor.ProblemInfoHolder.class, conditionInfo, "conditionInfo must be a ProblemInfoHolder.");
ProblemInfoBundleExtractor.ProblemInfoHolder probleminfo = (ProblemInfoBundleExtractor.ProblemInfoHolder) conditionInfo;
Condition condition = probleminfo.getCondition();
ProblemDto problemDto = super.conditionInfoToDto(probleminfo);
// Onset must be available for the problem list items.
if (condition.getOnset() != null) {
problemDto.setStartDate(FhirUtil.toLocalDateTime((DateTimeType) condition.getOnset()));
} else {
problemDto.getErrors().add("Condition is a problem-list-item but an onset property is missing or not of a DateTimeType " + "type.");
}
problemDto.getTasks().addAll(probleminfo.getTasks().stream().map(t -> new TaskInfoDto(t.getId(), t.getName(), t.getStatus())).collect(Collectors.toList()));
problemDto.getGoals().addAll(probleminfo.getGoals().stream().map(t -> new GoalInfoDto(t.getId(), t.getName(), t.getStatus())).collect(Collectors.toList()));
return problemDto;
}
use of org.hl7.gravity.refimpl.sdohexchange.dto.response.GoalInfoDto in project Gravity-SDOH-Exchange-RI by FHIR.
the class SupportService method listGoals.
public List<GoalInfoDto> listGoals() {
Assert.notNull(SmartOnFhirContext.get().getPatient(), "Patient id cannot be null.");
Bundle goalsBundle = ehrClient.search().forResource(Goal.class).sort().descending(Constants.PARAM_LASTUPDATED).where(Goal.PATIENT.hasId(SmartOnFhirContext.get().getPatient())).where(new StringClientParam(Constants.PARAM_PROFILE).matches().value(SDOHProfiles.GOAL)).where(Goal.LIFECYCLE_STATUS.exactly().code(Goal.GoalLifecycleStatus.ACTIVE.toCode())).returnBundle(Bundle.class).execute();
return FhirUtil.getFromBundle(goalsBundle, Goal.class).stream().map(goal -> new GoalToInfoDtoConverter().convert(goal)).collect(Collectors.toList());
}
Aggregations