Search in sources :

Example 1 with AssessmentDto

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;
}
Also used : ReferenceDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.ReferenceDto) AssessmentDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.AssessmentDto) QuestionnaireResponse(org.hl7.fhir.r4.model.QuestionnaireResponse)

Example 2 with 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)));
}
Also used : AssessmentBundleToDtoConverter(org.hl7.gravity.refimpl.sdohexchange.dto.converter.AssessmentBundleToDtoConverter) IBaseBundle(org.hl7.fhir.instance.model.api.IBaseBundle) Bundle(org.hl7.fhir.r4.model.Bundle) ResourceNotFoundException(ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException)

Example 3 with AssessmentDto

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);
}
Also used : AssessmentBundleToDtoConverter(org.hl7.gravity.refimpl.sdohexchange.dto.converter.AssessmentBundleToDtoConverter) IBaseBundle(org.hl7.fhir.instance.model.api.IBaseBundle) Bundle(org.hl7.fhir.r4.model.Bundle)

Aggregations

IBaseBundle (org.hl7.fhir.instance.model.api.IBaseBundle)2 Bundle (org.hl7.fhir.r4.model.Bundle)2 AssessmentBundleToDtoConverter (org.hl7.gravity.refimpl.sdohexchange.dto.converter.AssessmentBundleToDtoConverter)2 ResourceNotFoundException (ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException)1 QuestionnaireResponse (org.hl7.fhir.r4.model.QuestionnaireResponse)1 AssessmentDto (org.hl7.gravity.refimpl.sdohexchange.dto.response.AssessmentDto)1 ReferenceDto (org.hl7.gravity.refimpl.sdohexchange.dto.response.ReferenceDto)1