Search in sources :

Example 56 with DomainResource

use of org.hl7.fhir.r4b.model.DomainResource in project org.hl7.fhir.core by hapifhir.

the class NarrativeRemover method execute.

private static void execute(File folder) {
    for (File f : folder.listFiles()) {
        if (f.isDirectory())
            execute(f);
        else {
            System.out.println(f.getAbsolutePath());
            try {
                Resource r = new JsonParser().parse(new FileInputStream(f));
                if (r instanceof DomainResource) {
                    DomainResource d = (DomainResource) r;
                    d.setText(null);
                    new JsonParser().compose(new FileOutputStream(f), d);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
Also used : DomainResource(org.hl7.fhir.r4.model.DomainResource) FileOutputStream(java.io.FileOutputStream) Resource(org.hl7.fhir.r4.model.Resource) DomainResource(org.hl7.fhir.r4.model.DomainResource) File(java.io.File) FileInputStream(java.io.FileInputStream) JsonParser(org.hl7.fhir.r4.formats.JsonParser)

Example 57 with DomainResource

use of org.hl7.fhir.r4b.model.DomainResource in project org.hl7.fhir.core by hapifhir.

the class XmlParserBase method parseDomainResourceContained.

protected DomainResource parseDomainResourceContained(XmlPullParser xpp) throws IOException, FHIRFormatError, XmlPullParserException {
    next(xpp);
    int eventType = nextNoWhitespace(xpp);
    if (eventType == XmlPullParser.START_TAG) {
        DomainResource dr = (DomainResource) parseResource(xpp);
        nextNoWhitespace(xpp);
        next(xpp);
        return dr;
    } else {
        unknownContent(xpp);
        return null;
    }
}
Also used : DomainResource(org.hl7.fhir.r5.model.DomainResource)

Example 58 with DomainResource

use of org.hl7.fhir.r4b.model.DomainResource in project org.hl7.fhir.core by hapifhir.

the class ResourceRenderer method render.

/**
 * given a resource, update it's narrative with the best rendering available
 *
 * @param r - the domain resource in question
 *
 * @throws IOException
 * @throws EOperationOutcome
 * @throws FHIRException
 */
public void render(DomainResource r) throws IOException, FHIRException, EOperationOutcome {
    XhtmlNode x = new XhtmlNode(NodeType.Element, "div");
    boolean ofr = forResource;
    boolean hasExtensions;
    try {
        forResource = true;
        hasExtensions = render(x, r);
    } finally {
        forResource = ofr;
    }
    inject(r, x, hasExtensions ? NarrativeStatus.EXTENSIONS : NarrativeStatus.GENERATED);
}
Also used : XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 59 with DomainResource

use of org.hl7.fhir.r4b.model.DomainResource in project odm2fhir by num-codex.

the class Subject method map.

public Stream<DomainResource> map(SubjectData subjectData) {
    var value = getIdentifierAssigner();
    if (!ENVIRONMENT.containsProperty("debug")) {
        value = sha256Hex(value);
    }
    var organizationIdentifier = new Identifier().setSystem(getIdentifierSystem(ORGANIZATION)).setValue(value);
    var organization = (Organization) new Organization().setName(getIdentifierAssigner()).addIdentifier(organizationIdentifier).setId(sha256Hex(organizationIdentifier.getSystem() + organizationIdentifier.getValue()));
    organizationReference = new Reference(format("%s/%s", ORGANIZATION.toCode(), organization.getId()));
    value = subjectData.getSubjectKey();
    if (!ENVIRONMENT.containsProperty("debug")) {
        value = sha256Hex(value);
    }
    var patientIdentifier = new Identifier().setSystem(getIdentifierSystem(PATIENT)).setValue(value).setType(new CodeableConcept(new Coding().setSystem(IDENTIFIER_TYPE_CODES.getUrl()).setCode(MR.toCode()))).setAssigner(organizationReference);
    patient = (Patient) new Patient().addIdentifier(patientIdentifier).setId(sha256Hex(patientIdentifier.getSystem() + patientIdentifier.getValue())).setMeta(new Meta().addProfile(NUMStructureDefinition.PATIENT.getUrl()));
    patientReference = new Reference(format("%s/%s", PATIENT.toCode(), patient.getId()));
    return Stream.concat(Stream.of(patient, organization), subjectData.getMergedStudyEventData().stream().flatMap(studyEventData -> new StudyEvent().map(this, studyEventData)).peek(this::setId).peek(this::setPatientSubject));
}
Also used : NUMStructureDefinition(de.difuture.uds.odm2fhir.fhir.util.NUMStructureDefinition) Getter(lombok.Getter) Consent(org.hl7.fhir.r4.model.Consent) Identifier(org.hl7.fhir.r4.model.Identifier) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Reference(org.hl7.fhir.r4.model.Reference) ENVIRONMENT(de.difuture.uds.odm2fhir.util.EnvironmentProvider.ENVIRONMENT) ReflectionUtils.invokeMethod(org.springframework.util.ReflectionUtils.invokeMethod) IdentifierHelper.getIdentifierAssigner(de.difuture.uds.odm2fhir.fhir.util.IdentifierHelper.getIdentifierAssigner) ORGANIZATION(org.hl7.fhir.r4.model.codesystems.ResourceTypes.ORGANIZATION) PATIENT(org.hl7.fhir.r4.model.codesystems.ResourceTypes.PATIENT) Meta(org.hl7.fhir.r4.model.Meta) Patient(org.hl7.fhir.r4.model.Patient) MR(org.hl7.fhir.r4.model.codesystems.V3Hl7PublishingDomain.MR) IdentifierHelper.getIdentifierSystem(de.difuture.uds.odm2fhir.fhir.util.IdentifierHelper.getIdentifierSystem) ReflectionUtils.findMethod(org.springframework.util.ReflectionUtils.findMethod) SubjectData(de.difuture.uds.odm2fhir.odm.model.SubjectData) DomainResource(org.hl7.fhir.r4.model.DomainResource) String.format(java.lang.String.format) Organization(org.hl7.fhir.r4.model.Organization) Immunization(org.hl7.fhir.r4.model.Immunization) Stream(java.util.stream.Stream) DigestUtils.sha256Hex(org.apache.commons.codec.digest.DigestUtils.sha256Hex) Coding(org.hl7.fhir.r4.model.Coding) StringUtils.equalsAny(org.apache.commons.lang3.StringUtils.equalsAny) IDENTIFIER_TYPE_CODES(de.difuture.uds.odm2fhir.fhir.util.CommonCodeSystem.IDENTIFIER_TYPE_CODES) Meta(org.hl7.fhir.r4.model.Meta) Identifier(org.hl7.fhir.r4.model.Identifier) Organization(org.hl7.fhir.r4.model.Organization) Coding(org.hl7.fhir.r4.model.Coding) Reference(org.hl7.fhir.r4.model.Reference) Patient(org.hl7.fhir.r4.model.Patient) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 60 with DomainResource

use of org.hl7.fhir.r4b.model.DomainResource in project odm2fhir by num-codex.

the class ImagingProcedures method map.

protected Stream<DomainResource> map(FormData formData) {
    var techniqueGroup = formData.getItemGroupData("bildgebung.bildgebende_verfahren_ct");
    var befundGroup = formData.getItemGroupData("bildgebung.befund_bildgebender_verfahren_ct");
    var generalCoding = formData.getItemData("bildgebende_verfahren");
    if (!"1".equals(generalCoding.getValue())) {
        return Stream.empty();
    }
    var itemDatas = Stream.of(techniqueGroup.getItemData(), befundGroup.getItemData()).flatMap(List::stream).collect(toMap(ItemData::getItemOID, identity()));
    return Stream.of("ct", "roentgen", "us").filter(type -> contains(itemDatas.get("bildgebende_verfahren_" + type).getValue(), "410605003")).filter(type -> !(itemDatas.get("befund_bildgebender_verfahren_" + type).isEmpty())).flatMap(type -> {
        var diagnosticReport = createDiagnosticReport(itemDatas.get("befund_bildgebender_verfahren_" + type));
        var procedure = createProcedure(itemDatas.get("bildgebende_verfahren_" + type)).addReport(new Reference(format("%s/%s", DIAGNOSTICREPORT.toCode(), diagnosticReport.getId())));
        return Stream.of(diagnosticReport, procedure);
    });
}
Also used : FormData(de.difuture.uds.odm2fhir.odm.model.FormData) Item(de.difuture.uds.odm2fhir.fhir.mapper.Item) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) DiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport) PROCEDURE(org.hl7.fhir.r4.model.codesystems.ResourceTypes.PROCEDURE) Reference(org.hl7.fhir.r4.model.Reference) LOINC(de.difuture.uds.odm2fhir.fhir.util.CommonCodeSystem.LOINC) Procedure(org.hl7.fhir.r4.model.Procedure) StringUtils.contains(org.apache.commons.lang3.StringUtils.contains) Collectors.toMap(java.util.stream.Collectors.toMap) COMPLETED(org.hl7.fhir.r4.model.Procedure.ProcedureStatus.COMPLETED) ItemData(de.difuture.uds.odm2fhir.odm.model.ItemData) DIAGNOSTICREPORT(org.hl7.fhir.r4.model.codesystems.ResourceTypes.DIAGNOSTICREPORT) DomainResource(org.hl7.fhir.r4.model.DomainResource) SNOMED_CT(de.difuture.uds.odm2fhir.fhir.util.CommonCodeSystem.SNOMED_CT) DIAGNOSTIC_REPORT_RADIOLOGY(de.difuture.uds.odm2fhir.fhir.util.NUMStructureDefinition.DIAGNOSTIC_REPORT_RADIOLOGY) String.format(java.lang.String.format) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Stream(java.util.stream.Stream) RADIOLOGY_PROCEDURES(de.difuture.uds.odm2fhir.fhir.util.NUMStructureDefinition.RADIOLOGY_PROCEDURES) DigestUtils.sha256Hex(org.apache.commons.codec.digest.DigestUtils.sha256Hex) StringUtils.equalsAny(org.apache.commons.lang3.StringUtils.equalsAny) Function.identity(java.util.function.Function.identity) DIAGNOSTIC_SERVICE_SECTION_ID(de.difuture.uds.odm2fhir.fhir.util.CommonCodeSystem.DIAGNOSTIC_SERVICE_SECTION_ID) FINAL(org.hl7.fhir.r4.model.DiagnosticReport.DiagnosticReportStatus.FINAL) Reference(org.hl7.fhir.r4.model.Reference)

Aggregations

XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)24 FHIRException (org.hl7.fhir.exceptions.FHIRException)22 DomainResource (org.hl7.fhir.r4.model.DomainResource)21 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)16 IOException (java.io.IOException)15 DomainResource (org.hl7.fhir.dstu3.model.DomainResource)15 FileOutputStream (java.io.FileOutputStream)12 ArrayList (java.util.ArrayList)11 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)11 Test (org.junit.jupiter.api.Test)11 Resource (org.hl7.fhir.r4.model.Resource)10 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)9 FileNotFoundException (java.io.FileNotFoundException)8 List (java.util.List)8 NotImplementedException (org.apache.commons.lang3.NotImplementedException)8 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)8 SystemRequestDetails (ca.uhn.fhir.jpa.partition.SystemRequestDetails)7 File (java.io.File)7 ElementDefn (org.hl7.fhir.definitions.model.ElementDefn)7 RestIntegrationTest (org.opencds.cqf.ruler.test.RestIntegrationTest)7