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());
}
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;
}
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);
}
}
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);
}
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);
}
Aggregations