Search in sources :

Example 31 with Composition

use of org.hl7.fhir.r4b.model.Composition in project cqf-ruler by DBCG.

the class CareGapsProvider method getReports.

// warning for greater than 7 parameters
@SuppressWarnings("squid:S00107")
private List<MeasureReport> getReports(RequestDetails requestDetails, String periodStart, String periodEnd, Patient patient, List<String> status, List<Measure> measures, Composition composition, List<DetectedIssue> detectedIssues, Map<String, Resource> evaluatedResources) {
    List<MeasureReport> reports = new ArrayList<>();
    MeasureReport report = null;
    for (Measure measure : measures) {
        report = measureEvaluateProvider.evaluateMeasure(requestDetails, measure.getIdElement(), periodStart, periodEnd, "patient", Ids.simple(patient), null, null, null, null);
        if (!report.hasGroup()) {
            ourLog.info("Report does not include a group so skipping.\nSubject: {}\nMeasure: {}", Ids.simple(patient), Ids.simplePart(measure));
            continue;
        }
        initializeReport(report);
        CareGapsStatusCode gapStatus = getGapStatus(measure, report);
        if (!status.contains(gapStatus.toString())) {
            continue;
        }
        DetectedIssue detectedIssue = getDetectedIssue(patient, report, gapStatus);
        detectedIssues.add(detectedIssue);
        composition.addSection(getSection(measure, report, detectedIssue, gapStatus));
        getEvaluatedResources(report, evaluatedResources);
        reports.add(report);
    }
    return reports;
}
Also used : DetectedIssue(org.hl7.fhir.r4.model.DetectedIssue) ArrayList(java.util.ArrayList) Measure(org.hl7.fhir.r4.model.Measure) MeasureReport(org.hl7.fhir.r4.model.MeasureReport)

Example 32 with Composition

use of org.hl7.fhir.r4b.model.Composition in project cqf-ruler by DBCG.

the class CompositionBuilder method initializeDstu2_1.

@Override
protected void initializeDstu2_1(T theResource) {
    super.initializeDstu2_1(theResource);
    org.hl7.fhir.dstu2016may.model.Composition composition = (org.hl7.fhir.dstu2016may.model.Composition) theResource;
    composition.setDate(myDate).setIdentifier(new Identifier().setSystem(getIdentifier().getKey()).setValue(getIdentifier().getValue())).setStatus(org.hl7.fhir.dstu2016may.model.Composition.CompositionStatus.valueOf(myStatus)).setSubject(new Reference(mySubject)).setTitle(myTitle).setType(new CodeableConcept().addCoding(new Coding().setSystem(getTypeSetting().getSystem()).setCode(getTypeSetting().getCode()).setDisplay(getTypeSetting().getDisplay()))).addAuthor(new Reference(myAuthor)).setCustodian(new Reference(myCustodian));
}
Also used : Identifier(org.hl7.fhir.dstu2016may.model.Identifier) Coding(org.hl7.fhir.dstu2016may.model.Coding) Reference(org.hl7.fhir.dstu2016may.model.Reference) CodeableConcept(org.hl7.fhir.dstu2016may.model.CodeableConcept)

Example 33 with Composition

use of org.hl7.fhir.r4b.model.Composition in project cqf-ruler by DBCG.

the class MeasureDataProcessProvider method gatherEicrs.

private void gatherEicrs(IVersionSpecificBundleFactory bundleFactory, Map<String, Reference> populationSubjectListReferenceMap) {
    Map<String, Bundle> eicrs = new HashMap<>();
    List<Bundle> documentBundles = search(Bundle.class, Searches.all()).getAllResourcesTyped().stream().filter(x -> x.hasEntry() && DOCUMENT.equals(x.getType())).collect(Collectors.toList());
    for (Bundle bundle : documentBundles) {
        IBaseResource firstResource = bundle.getEntryFirstRep().getResource();
        if (!(firstResource instanceof Composition)) {
            logger.debug("Any bundle of type document must have the first entry of type Composition, but found: {}", firstResource);
            continue;
        }
        Composition composition = (Composition) firstResource;
        Reference compositionSubject = composition.getSubject();
        String[] referenceSplit = compositionSubject.getReference().split("/");
        for (Map.Entry<String, Reference> entry : populationSubjectListReferenceMap.entrySet()) {
            if (compositionSubject.equals(entry.getValue()) || compositionSubject.getReference().equals(entry.getKey()) || (referenceSplit.length > 1 && referenceSplit[1].equals(entry.getKey()))) {
                eicrs.putIfAbsent(entry.getKey(), bundle);
            }
        }
    }
    bundleFactory.addResourcesToBundle(eicrs.values().stream().collect(Collectors.toList()), COLLECTION, null, null, null);
}
Also used : DaoRegistryOperationProvider(org.opencds.cqf.ruler.provider.DaoRegistryOperationProvider) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) Operation(ca.uhn.fhir.rest.annotation.Operation) Reference(org.hl7.fhir.r4.model.Reference) ArrayList(java.util.ArrayList) RequestDetails(ca.uhn.fhir.rest.api.server.RequestDetails) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) MeasureResourceProvider(ca.uhn.fhir.jpa.rp.r4.MeasureResourceProvider) Map(java.util.Map) OperationParam(ca.uhn.fhir.rest.annotation.OperationParam) Group(org.hl7.fhir.r4.model.Group) Logger(org.slf4j.Logger) IVersionSpecificBundleFactory(ca.uhn.fhir.rest.api.IVersionSpecificBundleFactory) COLLECTION(ca.uhn.fhir.model.valueset.BundleTypeEnum.COLLECTION) DOCUMENT(org.hl7.fhir.r4.model.Bundle.BundleType.DOCUMENT) ListResource(org.hl7.fhir.r4.model.ListResource) Composition(org.hl7.fhir.r4.model.Composition) Collectors(java.util.stream.Collectors) IdType(org.hl7.fhir.r4.model.IdType) Searches(org.opencds.cqf.ruler.utility.Searches) ResourceType(org.hl7.fhir.r4.model.ResourceType) List(java.util.List) MeasureReport(org.hl7.fhir.r4.model.MeasureReport) Bundle(org.hl7.fhir.r4.model.Bundle) Composition(org.hl7.fhir.r4.model.Composition) HashMap(java.util.HashMap) Bundle(org.hl7.fhir.r4.model.Bundle) Reference(org.hl7.fhir.r4.model.Reference) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) HashMap(java.util.HashMap) Map(java.util.Map)

Example 34 with Composition

use of org.hl7.fhir.r4b.model.Composition in project summary-care-record-api by NHSDigital.

the class PatientMapper method mapPatient.

public static void mapPatient(GpSummary gpSummary, Bundle bundle) throws FhirMappingException {
    Patient patient = getDomainResource(bundle, Patient.class);
    setPatientIds(gpSummary, patient);
    var composition = getDomainResource(bundle, Composition.class);
    if (!composition.hasSubject() || !patient.getId().contains(composition.getSubject().getReference())) {
        throw new FhirValidationException("Composition.subject reference is missing or invalid");
    }
}
Also used : Patient(org.hl7.fhir.r4.model.Patient) FhirValidationException(uk.nhs.adaptors.scr.exceptions.FhirValidationException)

Example 35 with Composition

use of org.hl7.fhir.r4b.model.Composition in project fhir-bridge by ehrbase.

the class PatientToCompositionConverter method convert.

@Override
public C convert(@NonNull Patient resource) {
    C composition = super.convert(resource);
    Extension extensionAge = resource.getExtensionByUrl("https://www.netzwerk-universitaetsmedizin.de/fhir/StructureDefinition/age");
    composition.setStartTimeValue(TimeConverter.convertAgeExtensionTime(extensionAge));
    return composition;
}
Also used : Extension(org.hl7.fhir.r4.model.Extension)

Aggregations

ArrayList (java.util.ArrayList)16 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)12 Coding (org.hl7.fhir.r4.model.Coding)8 FHIRException (org.hl7.fhir.exceptions.FHIRException)7 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)7 Composition (org.hl7.fhir.r4.model.Composition)6 IOException (java.io.IOException)5 Composition (org.hl7.fhir.dstu3.model.Composition)5 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)5 Reference (org.hl7.fhir.r4.model.Reference)5 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)5 UnsupportedEncodingException (java.io.UnsupportedEncodingException)4 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)4 HashMap (java.util.HashMap)3 List (java.util.List)3 Encounter (org.hl7.fhir.dstu3.model.Encounter)3 QuestionnaireResponse (org.hl7.fhir.dstu3.model.QuestionnaireResponse)3 Reference (org.hl7.fhir.dstu3.model.Reference)3 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)3 Map (java.util.Map)2