Search in sources :

Example 61 with Composition

use of org.hl7.fhir.r5.model.Composition in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeCompositionCompositionRelatesToComponent.

protected void composeCompositionCompositionRelatesToComponent(Complex parent, String parentType, String name, Composition.CompositionRelatesToComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "relatesTo", name, element, index);
    if (element.hasCodeElement())
        composeEnum(t, "Composition", "code", element.getCodeElement(), -1);
    if (element.hasTarget())
        composeType(t, "Composition", "target", element.getTarget(), -1);
}
Also used : Complex(org.hl7.fhir.r4.utils.formats.Turtle.Complex)

Example 62 with Composition

use of org.hl7.fhir.r5.model.Composition in project eCRNow by drajer-health.

the class EicrCompositionGenerator method convertR4FhirBundletoCdaEicr.

public static Composition convertR4FhirBundletoCdaEicr(R4FhirData data) {
    Composition comp = new Composition();
    // Add version number extension.
    comp.addExtension(FhirGeneratorConstants.COMP_CLIN_DOC_VERSION_NUM_URL, new StringType(String.valueOf(FhirGeneratorConstants.VERSION_NUM)));
    // Add Type
    comp.setType(FhirGeneratorUtils.getCodeableConcept(FhirGeneratorConstants.LOINC_CS_URL, FhirGeneratorConstants.COMP_TYPE_CODE, FhirGeneratorConstants.COMP_TYPE_CODE_DISPLAY));
    // Setup Patient.
    comp.getSubject().setResource(data.getPatient());
    // Setup Encounter
    if (data.getEncounter() != null)
        comp.getEncounter().setResource(data.getEncounter());
    // Add Authors.
    List<Reference> auths = new ArrayList<>();
    // Add organization
    if (data.getOrganization() != null)
        auths.add(FhirGeneratorUtils.getReference(data.getOrganization()));
    if (data.getPractitioner() != null)
        auths.add(FhirGeneratorUtils.getReference(data.getPractitioner()));
    comp.setAuthor(auths);
    // Add Reason for Visit Section;
    SectionComponent rvs = FhirGeneratorUtils.getSectionComponent(FhirGeneratorConstants.LOINC_CS_URL, FhirGeneratorConstants.REASON_FOR_VISIT_CODE, FhirGeneratorConstants.REASON_FOR_VISIT_CODE_DISPLAY);
    // Set the Section Code Display to be the narrative text.
    rvs.getCode().setTextElement(new StringType(FhirGeneratorUtils.getReasonForVisitNarrativeText(data.getEncounter())));
    comp.getSection().add(rvs);
    return comp;
}
Also used : Composition(org.hl7.fhir.r4.model.Composition) StringType(org.hl7.fhir.r4.model.StringType) Reference(org.hl7.fhir.r4.model.Reference) ArrayList(java.util.ArrayList) SectionComponent(org.hl7.fhir.r4.model.Composition.SectionComponent)

Example 63 with Composition

use of org.hl7.fhir.r5.model.Composition in project nia-patient-switching-standard-adaptor by NHSDigital.

the class DiagnosticReportMapper method mapResources.

@Override
public List<DiagnosticReport> mapResources(RCMRMT030101UK04EhrExtract ehrExtract, Patient patient, List<Encounter> encounters, String practiseCode) {
    return mapEhrExtractToFhirResource(ehrExtract, (extract, composition, component) -> extractAllCompoundStatements(component).filter(Objects::nonNull).filter(ResourceFilterUtil::isDiagnosticReport).map(compoundStatement -> {
        DiagnosticReport diagnosticReport = createDiagnosticReport(compoundStatement, patient, composition, encounters, practiseCode);
        getIssued(ehrExtract, compoundStatement, composition).ifPresent(diagnosticReport::setIssuedElement);
        return diagnosticReport;
    })).toList();
}
Also used : RCMRMT030101UK04Author(org.hl7.v3.RCMRMT030101UK04Author) Identifier(org.hl7.fhir.dstu3.model.Identifier) IdType(org.hl7.fhir.dstu3.model.IdType) TextUtil.getLastLine(uk.nhs.adaptors.pss.translator.util.TextUtil.getLastLine) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept) RCMRMT030101UK04Component02(org.hl7.v3.RCMRMT030101UK04Component02) ArrayList(java.util.ArrayList) DiagnosticReportStatus(org.hl7.fhir.dstu3.model.DiagnosticReport.DiagnosticReportStatus) Collectors.toCollection(java.util.stream.Collectors.toCollection) DiagnosticReport(org.hl7.fhir.dstu3.model.DiagnosticReport) ResourceType(org.hl7.fhir.dstu3.model.ResourceType) II(org.hl7.v3.II) Service(org.springframework.stereotype.Service) RCMRMT030101UK04EhrExtract(org.hl7.v3.RCMRMT030101UK04EhrExtract) CompoundStatementResourceExtractors.extractAllCompoundStatements(uk.nhs.adaptors.pss.translator.util.CompoundStatementResourceExtractors.extractAllCompoundStatements) RCMRMT030101UK04CompoundStatement(org.hl7.v3.RCMRMT030101UK04CompoundStatement) AbstractMapper(uk.nhs.adaptors.pss.translator.mapper.AbstractMapper) DateFormatUtil.parseToInstantType(uk.nhs.adaptors.pss.translator.util.DateFormatUtil.parseToInstantType) ResourceFilterUtil(uk.nhs.adaptors.pss.translator.util.ResourceFilterUtil) CompoundStatementResourceExtractors(uk.nhs.adaptors.pss.translator.util.CompoundStatementResourceExtractors) Reference(org.hl7.fhir.dstu3.model.Reference) InstantType(org.hl7.fhir.dstu3.model.InstantType) RCMRMT030101UK04EhrComposition(org.hl7.v3.RCMRMT030101UK04EhrComposition) Observation(org.hl7.fhir.dstu3.model.Observation) Objects(java.util.Objects) Encounter(org.hl7.fhir.dstu3.model.Encounter) TS(org.hl7.v3.TS) List(java.util.List) Patient(org.hl7.fhir.dstu3.model.Patient) Optional(java.util.Optional) ResourceUtil.generateMeta(uk.nhs.adaptors.pss.translator.util.ResourceUtil.generateMeta) ResourceUtil.buildIdentifier(uk.nhs.adaptors.pss.translator.util.ResourceUtil.buildIdentifier) Objects(java.util.Objects) DiagnosticReport(org.hl7.fhir.dstu3.model.DiagnosticReport)

Example 64 with Composition

use of org.hl7.fhir.r5.model.Composition in project nia-patient-switching-standard-adaptor by NHSDigital.

the class ConditionMapper method getCondition.

private Condition getCondition(RCMRMT030101UK04EhrExtract ehrExtract, Patient patient, List<Encounter> encounters, RCMRMT030101UK04EhrComposition composition, RCMRMT030101UK04LinkSet linkSet, String practiseCode) {
    String id = linkSet.getId().getRoot();
    Condition condition = (Condition) new Condition().addIdentifier(buildIdentifier(id, practiseCode)).addCategory(generateCategory()).setId(id).setMeta(generateMeta(META_PROFILE));
    buildClinicalStatus(linkSet.getCode()).ifPresentOrElse(condition::setClinicalStatus, () -> {
        condition.setClinicalStatus(ACTIVE);
        condition.addNote(new Annotation(new StringType(DEFAULT_CLINICAL_STATUS)));
    });
    condition.setSubject(new Reference(patient));
    condition.addExtension(buildProblemSignificance(linkSet.getCode()));
    generateAnnotationToMinor(linkSet.getCode()).ifPresent(condition::addNote);
    buildContext(composition, encounters).ifPresent(condition::setContext);
    buildOnsetDateTimeType(linkSet).ifPresent(condition::setOnset);
    buildAbatementDateTimeType(linkSet.getEffectiveTime()).ifPresent(condition::setAbatement);
    buildAssertedDateTimeType(composition).ifPresentOrElse(condition::setAssertedDateElement, () -> condition.setAssertedDateElement(parseToDateTimeType(ehrExtract.getAvailabilityTime().getValue())));
    composition.getParticipant2().stream().findFirst().ifPresent(participant2 -> condition.setAsserter(new Reference(new IdType(ResourceType.Practitioner.name(), participant2.getAgentRef().getId().getRoot()))));
    return condition;
}
Also used : Condition(org.hl7.fhir.dstu3.model.Condition) StringType(org.hl7.fhir.dstu3.model.StringType) Reference(org.hl7.fhir.dstu3.model.Reference) Annotation(org.hl7.fhir.dstu3.model.Annotation) RCMRMT030101UK04Annotation(org.hl7.v3.RCMRMT030101UK04Annotation) IdType(org.hl7.fhir.dstu3.model.IdType)

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