use of org.hl7.gravity.refimpl.sdohexchange.dto.response.AssessmentDto in project Gravity-SDOH-Exchange-RI by FHIR.
the class AssessmentInfoToDtoConverter method convert.
@Override
public AssessmentDto convert(AssessmentInfoHolder infoHolder) {
AssessmentDto assessmentDto = new AssessmentDto();
QuestionnaireResponse questionnaireResponse = infoHolder.getQuestionnaireResponse();
assessmentDto.setId(questionnaireResponse.getIdElement().getIdPart());
if (infoHolder.getQuestionnaire() != null) {
assessmentDto.setName(infoHolder.getQuestionnaire().getTitle());
} else {
assessmentDto.setName(questionnaireResponse.getQuestionnaire());
assessmentDto.getErrors().add("QuestionnaireResponse references a Questionnaire by the URL which does not exist. Using the URL as a " + "name instead.");
}
assessmentDto.setQuestionnaireUrl(questionnaireResponse.getQuestionnaire());
assessmentDto.setDate(FhirUtil.toLocalDateTime(questionnaireResponse.getAuthoredElement()));
assessmentDto.setAssessmentResponse(assessmentResponseToDtoConverter.convert(infoHolder));
assessmentDto.setHealthConcerns(infoHolder.getConditions().stream().map(condition -> new ReferenceDto(condition.getIdElement().getIdPart(), codeableConceptToStringConverter.convert(condition.getCode()))).collect(Collectors.toList()));
return assessmentDto;
}
use of org.hl7.gravity.refimpl.sdohexchange.dto.response.AssessmentDto in project Gravity-SDOH-Exchange-RI by FHIR.
the class AssessmentService method search.
public AssessmentDto search(String questionnaireUrl) {
Assert.notNull(SmartOnFhirContext.get().getPatient(), "Patient id cannot be null.");
Bundle responseBundle = searchAssessmentQuery().where(QuestionnaireResponse.QUESTIONNAIRE.hasId(questionnaireUrl)).returnBundle(Bundle.class).execute();
responseBundle = addQuestionnairesToAssessmentBundle(responseBundle);
return new AssessmentBundleToDtoConverter().convert(responseBundle).stream().findFirst().orElseThrow(() -> new ResourceNotFoundException(String.format("Resource of type QuestionnaireResponse with " + "questionnaire url '%s' is not known", questionnaireUrl)));
}
use of org.hl7.gravity.refimpl.sdohexchange.dto.response.AssessmentDto in project Gravity-SDOH-Exchange-RI by FHIR.
the class AssessmentService method listCompleted.
public List<AssessmentDto> listCompleted() {
Assert.notNull(SmartOnFhirContext.get().getPatient(), "Patient id cannot be null.");
Bundle responseBundle = searchAssessmentQuery().where(QuestionnaireResponse.STATUS.exactly().code(QuestionnaireResponseStatus.COMPLETED.toCode())).returnBundle(Bundle.class).execute();
responseBundle = addQuestionnairesToAssessmentBundle(responseBundle);
return new AssessmentBundleToDtoConverter().convert(responseBundle);
}
Aggregations