use of org.hl7.gravity.refimpl.sdohexchange.fhir.extract.patienttask.PatientTaskItemInfoBundleExtractor.PatientTaskItemInfoHolder 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());
}
Aggregations