Search in sources :

Example 6 with Questionnaire

use of org.hl7.fhir.dstu2.model.Questionnaire in project cqf-ruler by DBCG.

the class CanonicalsTest method canonicalParts.

@Test
public void canonicalParts() {
    CanonicalType testUrl = new CanonicalType("http://fhir.acme.com/Questionnaire/example|1.0#vs1");
    CanonicalParts parts = Canonicals.getParts(testUrl);
    assertEquals("http://fhir.acme.com/Questionnaire/example", parts.url());
    assertEquals("Questionnaire", parts.resourceType());
    assertEquals("example", parts.idPart());
    assertEquals("1.0", parts.version());
    assertEquals("vs1", parts.fragment());
}
Also used : CanonicalType(org.hl7.fhir.r4.model.CanonicalType) Test(org.junit.jupiter.api.Test)

Example 7 with Questionnaire

use of org.hl7.fhir.dstu2.model.Questionnaire 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 8 with Questionnaire

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

the class ConditionBundleToDtoConverterBase method conditionInfoToDto.

protected T conditionInfoToDto(ConditionInfoBundleExtractor.ConditionInfoHolder conditionInfo) {
    T conditionDto = newConditionDtoImpl();
    Condition condition = conditionInfo.getCondition();
    conditionDto.setId(condition.getIdElement().getIdPart());
    conditionDto.setName(codeableConceptToStringConverter.convert(condition.getCode()));
    Coding categoryCoding = FhirUtil.findCoding(condition.getCategory(), SDOHMappings.getInstance().getSystem());
    // TODO remove this in future. Fow now two different categories might be used before discussed.
    if (categoryCoding == null) {
        categoryCoding = FhirUtil.findCoding(condition.getCategory(), "http://hl7.org/fhir/us/sdoh-clinicalcare/CodeSystem/SDOHCC-CodeSystemTemporaryCodes");
    }
    if (categoryCoding == null) {
        conditionDto.getErrors().add("SDOH category is not found.");
    } else {
        conditionDto.setCategory(new CodingDto(categoryCoding.getCode(), categoryCoding.getDisplay()));
    }
    Optional<Coding> icdCodeCodingOptional = findCode(condition.getCode(), System.ICD_10);
    if (icdCodeCodingOptional.isPresent()) {
        Coding icdCodeCoding = icdCodeCodingOptional.get();
        conditionDto.setIcdCode(new CodingDto(icdCodeCoding.getCode(), icdCodeCoding.getDisplay()));
    } else {
        conditionDto.getErrors().add("ICD-10 code is not found.");
    }
    Optional<Coding> snomedCodeCodingOptional = findCode(condition.getCode(), System.SNOMED);
    if (snomedCodeCodingOptional.isPresent()) {
        Coding snomedCodeCoding = snomedCodeCodingOptional.get();
        conditionDto.setSnomedCode(new CodingDto(snomedCodeCoding.getCode(), snomedCodeCoding.getDisplay()));
    } else {
        conditionDto.getErrors().add("SNOMED-CT code is not found.");
    }
    QuestionnaireResponse questionnaireResponse = conditionInfo.getQuestionnaireResponse();
    if (questionnaireResponse != null) {
        conditionDto.setAssessmentDate(FhirUtil.toLocalDateTime(questionnaireResponse.getAuthoredElement()));
        Questionnaire questionnaire = conditionInfo.getQuestionnaire();
        if (questionnaire != null) {
            conditionDto.setBasedOn(new ReferenceDto(questionnaireResponse.getIdElement().getIdPart(), questionnaire.getTitle()));
        } else {
            conditionDto.setBasedOn(new ReferenceDto(questionnaireResponse.getIdElement().getIdPart(), questionnaireResponse.getQuestionnaire()));
            conditionDto.getErrors().add("Based on QuestionnaireResponse doesn't have a matching Questionnaire to get a title from. Using URL " + "instead.");
        }
    } else {
        conditionDto.setBasedOn(new StringTypeDto(condition.getEvidenceFirstRep().getCodeFirstRep().getText()));
        Reference recorder = condition.getRecorder();
        conditionDto.setAuthoredBy(new ReferenceDto(recorder.getReferenceElement().getIdPart(), recorder.getDisplay()));
    }
    // abatement must be available for all resolved condition
    if (ConditionClinicalStatusCodes.RESOLVED.toCode().equals(condition.getClinicalStatus().getCodingFirstRep().getCode())) {
        if (condition.getAbatement() instanceof DateTimeType) {
            conditionDto.setResolutionDate(FhirUtil.toLocalDateTime((DateTimeType) condition.getAbatement()));
        } else {
            conditionDto.getErrors().add("Condition is resolved but an abatement property is missing or not of a DateTimeType type.");
        }
    }
    return conditionDto;
}
Also used : Condition(org.hl7.fhir.r4.model.Condition) CodingDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.CodingDto) ReferenceDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.ReferenceDto) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) Questionnaire(org.hl7.fhir.r4.model.Questionnaire) StringTypeDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.StringTypeDto) Coding(org.hl7.fhir.r4.model.Coding) Reference(org.hl7.fhir.r4.model.Reference) QuestionnaireResponse(org.hl7.fhir.r4.model.QuestionnaireResponse)

Example 9 with Questionnaire

use of org.hl7.fhir.dstu2.model.Questionnaire 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 10 with Questionnaire

use of org.hl7.fhir.dstu2.model.Questionnaire in project integration-adaptor-111 by nhsconnect.

the class QuestionnaireMapperTest method shouldMapQuestionnaireResponseFromPathways.

@Test
public void shouldMapQuestionnaireResponseFromPathways() {
    when(pathwaysCase.getPathwayDetails().getPathwayTriageDetails().getPathwayTriageArray(0).getUser()).thenReturn(user);
    Questionnaire questionnaire = questionnaireMapper.mapQuestionnaire(pathwaysCase, triageLine);
    assertThat(questionnaire.getIdentifier().get(0).getValue()).isEqualTo(CASE_ID);
    assertThat(questionnaire.getSubjectType().get(0).getValue()).isEqualTo("Patient");
    assertThat(questionnaire.getExperimental()).isEqualTo(false);
    assertThat(questionnaire.getStatus()).isEqualTo(Enumerations.PublicationStatus.ACTIVE);
    assertThat(toIsoDateTimeString(questionnaire.getDate())).isEqualTo(DATE);
    assertThat(questionnaire.getPublisher()).isEqualTo("N/A");
    assertThat(questionnaire.getIdElement().getValue()).isEqualTo(RANDOM_UUID);
    assertThat(questionnaire.getContactFirstRep().getTelecomFirstRep().getValue()).isEqualTo(PHONE_NUMBER);
    assertThat(questionnaire.getContactFirstRep().getTelecomFirstRep().getSystem()).isEqualTo(PHONE);
    assertThat(questionnaire.getItem().get(0).getPrefix()).isEqualTo(ORDER_NUMBER);
}
Also used : Questionnaire(org.hl7.fhir.dstu3.model.Questionnaire) Test(org.junit.jupiter.api.Test)

Aggregations

XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)18 ArrayList (java.util.ArrayList)15 Questionnaire (org.hl7.fhir.r4.model.Questionnaire)14 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)13 QuestionnaireResponse (org.hl7.fhir.r4.model.QuestionnaireResponse)12 QuestionnaireItemComponent (org.hl7.fhir.r4b.model.Questionnaire.QuestionnaireItemComponent)11 QuestionnaireItemComponent (org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemComponent)11 File (java.io.File)10 TextFile (org.hl7.fhir.utilities.TextFile)10 Test (org.junit.jupiter.api.Test)10 FileOutputStream (java.io.FileOutputStream)9 Questionnaire (org.hl7.fhir.dstu3.model.Questionnaire)9 FHIRException (org.hl7.fhir.exceptions.FHIRException)8 QuestionnaireItemComponent (org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent)8 IOException (java.io.IOException)7 Bundle (org.hl7.fhir.r4.model.Bundle)7 CanonicalType (org.hl7.fhir.r4.model.CanonicalType)7 ValueSet (org.hl7.fhir.r5.model.ValueSet)7 FileNotFoundException (java.io.FileNotFoundException)6 Extension (org.hl7.fhir.r4.model.Extension)6