Search in sources :

Example 1 with PatientTaskItemInfoHolder

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

Aggregations

Lists (com.google.common.collect.Lists)1 List (java.util.List)1 Map (java.util.Map)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 Getter (lombok.Getter)1 Bundle (org.hl7.fhir.r4.model.Bundle)1 QuestionnaireResponse (org.hl7.fhir.r4.model.QuestionnaireResponse)1 Reference (org.hl7.fhir.r4.model.Reference)1 Task (org.hl7.fhir.r4.model.Task)1 SDCTemporaryCode (org.hl7.gravity.refimpl.sdohexchange.codes.SDCTemporaryCode)1 BundleExtractor (org.hl7.gravity.refimpl.sdohexchange.fhir.extract.BundleExtractor)1 PatientTaskInfoHolder (org.hl7.gravity.refimpl.sdohexchange.fhir.extract.patienttask.PatientTaskInfoBundleExtractor.PatientTaskInfoHolder)1 PatientTaskItemInfoHolder (org.hl7.gravity.refimpl.sdohexchange.fhir.extract.patienttask.PatientTaskItemInfoBundleExtractor.PatientTaskItemInfoHolder)1 FhirUtil (org.hl7.gravity.refimpl.sdohexchange.util.FhirUtil)1