Search in sources :

Example 36 with QuestionnaireResponse

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

the class PatientTaskInfoBundleExtractor method extract.

@Override
public List<PatientTaskInfoHolder> extract(Bundle bundle) {
    List<PatientTaskItemInfoHolder> patientTaskItemInfoHolders = patientTaskItemInfoBundleExtractor.extract(bundle);
    Map<String, QuestionnaireResponse> questionnaireResponsesMap = FhirUtil.getFromBundle(bundle, QuestionnaireResponse.class).stream().collect(Collectors.toMap(qr -> qr.getIdElement().getIdPart(), Function.identity()));
    return patientTaskItemInfoHolders.stream().map(infoHolder -> {
        Task.TaskOutputComponent outputComponent = infoHolder.getTask().getOutput().stream().filter(o -> FhirUtil.findCoding(Lists.newArrayList(o.getType()), SDCTemporaryCode.SYSTEM, SDCTemporaryCode.QUESTIONNAIRE_RESPONSE.getCode()) != null).findAny().orElse(null);
        String questionnaireResponseId = null;
        if (outputComponent != null) {
            questionnaireResponseId = ((Reference) outputComponent.getValue()).getReferenceElement().getIdPart();
        }
        return new PatientTaskInfoHolder(infoHolder, questionnaireResponsesMap.get(questionnaireResponseId));
    }).collect(Collectors.toList());
}
Also used : Getter(lombok.Getter) Reference(org.hl7.fhir.r4.model.Reference) PatientTaskInfoHolder(org.hl7.gravity.refimpl.sdohexchange.fhir.extract.patienttask.PatientTaskInfoBundleExtractor.PatientTaskInfoHolder) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) SDCTemporaryCode(org.hl7.gravity.refimpl.sdohexchange.codes.SDCTemporaryCode) BundleExtractor(org.hl7.gravity.refimpl.sdohexchange.fhir.extract.BundleExtractor) PatientTaskItemInfoHolder(org.hl7.gravity.refimpl.sdohexchange.fhir.extract.patienttask.PatientTaskItemInfoBundleExtractor.PatientTaskItemInfoHolder) Task(org.hl7.fhir.r4.model.Task) QuestionnaireResponse(org.hl7.fhir.r4.model.QuestionnaireResponse) List(java.util.List) Lists(com.google.common.collect.Lists) Map(java.util.Map) Bundle(org.hl7.fhir.r4.model.Bundle) FhirUtil(org.hl7.gravity.refimpl.sdohexchange.util.FhirUtil) PatientTaskInfoHolder(org.hl7.gravity.refimpl.sdohexchange.fhir.extract.patienttask.PatientTaskInfoBundleExtractor.PatientTaskInfoHolder) PatientTaskItemInfoHolder(org.hl7.gravity.refimpl.sdohexchange.fhir.extract.patienttask.PatientTaskItemInfoBundleExtractor.PatientTaskItemInfoHolder) QuestionnaireResponse(org.hl7.fhir.r4.model.QuestionnaireResponse)

Example 37 with QuestionnaireResponse

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

the class ConditionMapper method mapCondition.

public Condition mapCondition(POCDMT000002UK01ClinicalDocument1 clinicalDocument, Encounter encounter, List<QuestionnaireResponse> questionnaireResponseList) {
    Condition condition = new Condition();
    condition.setIdElement(resourceUtil.newRandomUuid());
    condition.setClinicalStatus(Condition.ConditionClinicalStatus.ACTIVE).setVerificationStatus(Condition.ConditionVerificationStatus.UNKNOWN).setSubject(encounter.getSubject()).setContext(resourceUtil.createReference(encounter));
    if (questionnaireResponseList != null) {
        condition.setEvidence(evidenceOf(questionnaireResponseList));
    }
    addConditionReason(clinicalDocument, condition);
    if (clinicalDocument.getComponent().isSetStructuredBody()) {
        for (POCDMT000002UK01Component3 component3 : clinicalDocument.getComponent().getStructuredBody().getComponentArray()) {
            POCDMT000002UK01Section section = component3.getSection();
            for (POCDMT000002UK01Entry entry : section.getEntryArray()) {
                if (entry.isSetEncounter()) {
                    POCDMT000002UK01Encounter itkEncounter = entry.getEncounter();
                    if (itkEncounter.isSetEffectiveTime()) {
                        condition.setAssertedDateElement(DateUtil.parse(itkEncounter.getEffectiveTime().getValue()));
                    }
                    if (itkEncounter.isSetText()) {
                        condition.addCategory(new CodeableConcept().setText(nodeUtil.getAllText(itkEncounter.getText().getDomNode())));
                    }
                }
            }
            for (POCDMT000002UK01Component5 component : section.getComponentArray()) {
                if (component.getSection() != null) {
                    if (component.getSection().isSetLanguageCode()) {
                        if (component.getSection().getLanguageCode().isSetCode()) {
                            condition.setLanguage(component.getSection().getLanguageCode().getCode());
                        }
                    }
                }
            }
        }
    }
    return condition;
}
Also used : Condition(org.hl7.fhir.dstu3.model.Condition) POCDMT000002UK01Component3(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Component3) POCDMT000002UK01Section(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Section) POCDMT000002UK01Entry(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Entry) POCDMT000002UK01Component5(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Component5) POCDMT000002UK01Encounter(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Encounter) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Example 38 with QuestionnaireResponse

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

the class CompositionMapper method addPathwaysToSection.

private void addPathwaysToSection(Composition composition, List<QuestionnaireResponse> questionnaireResponseList) {
    String questionnaireResponseTitle = "QuestionnaireResponse";
    for (QuestionnaireResponse questionnaireResponse : questionnaireResponseList) {
        SectionComponent sectionComponent = new SectionComponent();
        sectionComponent.addEntry(resourceUtil.createReference(questionnaireResponse));
        sectionComponent.setTitle(questionnaireResponseTitle);
        composition.addSection(sectionComponent);
    }
}
Also used : QuestionnaireResponse(org.hl7.fhir.dstu3.model.QuestionnaireResponse) SectionComponent(org.hl7.fhir.dstu3.model.Composition.SectionComponent)

Example 39 with QuestionnaireResponse

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

the class EncounterReportBundleServiceTest method setUp.

@BeforeEach
public void setUp() throws XmlException {
    INT versionNumber = mock(INT.class);
    when(versionNumber.getValue()).thenReturn(VERSION);
    when(document.getVersionNumber()).thenReturn(versionNumber);
    when(document.getEffectiveTime()).thenReturn(ts);
    when(ts.getValue()).thenReturn(EFFECTIVE_TIME);
    List<QuestionnaireResponse> questionnaireResponseList = new ArrayList<>();
    questionnaireResponseList.add(QUESTIONNAIRE_RESPONSE);
    when(deviceMapper.mapDevice()).thenReturn(DEVICE);
    when(encounterMapper.mapEncounter(any(), any(), any(), any())).thenReturn(ENCOUNTER);
    when(conditionMapper.mapCondition(any(), any(), any())).thenReturn(CONDITION);
    when(compositionMapper.mapComposition(any(), any(), any(), any(), any(), any())).thenReturn(COMPOSITION);
    when(listMapper.mapList(any(), any(), any(), any())).thenReturn(LIST_RESOURCE);
    when(carePlanMapper.mapCarePlan(any(), any(), any())).thenReturn(singletonList(CAREPLAN));
    when(healthcareServiceMapper.mapHealthcareService(any())).thenReturn(singletonList(HEALTHCARE_SERVICE));
    when(consentMapper.mapConsent(any(), any())).thenReturn(CONSENT);
    when(pathwayUtil.getQuestionnaireResponses(any(), any(), any())).thenReturn(questionnaireResponseList);
    when(messageHeaderService.createMessageHeader(any(), any(), eq(EFFECTIVE_TIME))).thenReturn(MESSAGE_HEADER);
    when(referralRequestMapper.mapReferralRequest(any(), any(), any(), any(), any())).thenReturn(REFERRAL_REQUEST);
    when(observationMapper.mapObservations(any(), eq(ENCOUNTER))).thenReturn(Arrays.asList(OBSERVATION));
    when(practitionerRoleMapper.mapAuthorRoles(any())).thenReturn(singletonList(AUTHOR_ROLE));
    when(practitionerRoleMapper.mapResponsibleParty(any())).thenReturn(Optional.of(PRACTITIONER_ROLE));
    when(relatedPersonMapper.createEmergencyContactRelatedPerson(eq(document), eq(ENCOUNTER))).thenReturn(RELATED_PERSON);
    when(deviceMapper.mapDevice()).thenReturn(DEVICE);
    Encounter.DiagnosisComponent diagnosisComponent = new Encounter.DiagnosisComponent();
    diagnosisComponent.setCondition(new Reference());
    diagnosisComponent.setRole(new CodeableConcept());
    diagnosisComponent.setRank(1);
    diagnosisComponent.setConditionTarget(CONDITION);
    ENCOUNTER.addDiagnosis(diagnosisComponent);
}
Also used : Reference(org.hl7.fhir.dstu3.model.Reference) ArrayList(java.util.ArrayList) Encounter(org.hl7.fhir.dstu3.model.Encounter) QuestionnaireResponse(org.hl7.fhir.dstu3.model.QuestionnaireResponse) INT(uk.nhs.connect.iucds.cda.ucr.INT) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 40 with QuestionnaireResponse

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

the class QuestionnaireResponseMapperTest method shouldMapQuestionnaireResponseFromPathways.

@Test
public void shouldMapQuestionnaireResponseFromPathways() {
    TriageLine.Question.Answers.Answer[] answerArray = new TriageLine.Question.Answers.Answer[] { answer };
    String caseId = "caseId";
    String questionText = "this is my question";
    String answerText = "this is my answer";
    when(pathwaysCase.getCaseDetails()).thenReturn(caseDetails);
    when(caseDetails.getCaseId()).thenReturn(caseId);
    when(caseDetails.isSetCaseId()).thenReturn(true);
    when(pathwaysCase.isSetCaseReceiveEnd()).thenReturn(true);
    when(pathwaysCase.getCaseReceiveEnd()).thenReturn(calendar);
    when(calendar.toString()).thenReturn("2011-02-17T17:31:14.313Z");
    when(triageLine.getQuestion()).thenReturn(question);
    when(question.getQuestionText()).thenReturn(questionText);
    when(question.getAnswers()).thenReturn(answers);
    when(answers.getAnswerArray()).thenReturn(answerArray);
    when(answer.getSelected()).thenReturn(true);
    when(answer.getText()).thenReturn(answerText);
    when(resourceUtil.newRandomUuid()).thenReturn(new IdType(RANDOM_UUID));
    QuestionnaireResponse questionnaireResponse = questionnaireResponseMapper.mapQuestionnaireResponse(pathwaysCase, patient, encounter, triageLine);
    assertThat(questionnaireResponse.getStatus()).isEqualTo(QuestionnaireResponse.QuestionnaireResponseStatus.COMPLETED);
    assertThat(questionnaireResponse.getSubject()).isEqualTo(patient);
    assertThat(questionnaireResponse.getContext()).isEqualTo(encounter);
    assertThat(questionnaireResponse.getIdentifier().getValue()).isEqualTo(caseId);
    assertThat(toIsoDateTimeString(questionnaireResponse.getAuthored())).isEqualTo("2011-02-17T17:31:14.313Z");
    assertThat(questionnaireResponse.getItemFirstRep().getText()).isEqualTo(questionText);
    assertThat(questionnaireResponse.getItemFirstRep().getAnswer().get(0).getValue().toString()).isEqualTo(answerText);
}
Also used : IsoDateTimeFormatter.toIsoDateTimeString(uk.nhs.adaptors.oneoneone.cda.report.util.IsoDateTimeFormatter.toIsoDateTimeString) QuestionnaireResponse(org.hl7.fhir.dstu3.model.QuestionnaireResponse) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.jupiter.api.Test)

Aggregations

QuestionnaireResponse (org.hl7.fhir.r4.model.QuestionnaireResponse)15 ArrayList (java.util.ArrayList)14 Bundle (org.hl7.fhir.r4.model.Bundle)11 QuestionnaireResponse (org.hl7.fhir.dstu3.model.QuestionnaireResponse)8 Questionnaire (org.hl7.fhir.r4.model.Questionnaire)8 Row (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row)8 Test (org.junit.jupiter.api.Test)8 Reference (org.hl7.fhir.dstu3.model.Reference)7 Reference (org.hl7.fhir.r4.model.Reference)7 List (java.util.List)6 Collectors (java.util.stream.Collectors)6 Cell (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell)6 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)6 Map (java.util.Map)5 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)5 FhirUtil (org.hl7.gravity.refimpl.sdohexchange.util.FhirUtil)5 Coding (org.hl7.fhir.r4.model.Coding)4 Date (java.util.Date)3 Getter (lombok.Getter)3 Bundle (org.hl7.fhir.dstu3.model.Bundle)3