Search in sources :

Example 46 with Meta

use of org.hl7.fhir.dstu3.model.Meta in project org.hl7.fhir.core by hapifhir.

the class LoincToDEConvertor method process.

public Bundle process(String sourceFile) throws FileNotFoundException, SAXException, IOException, ParserConfigurationException {
    this.definitions = sourceFile;
    log("Begin. Produce Loinc CDEs in " + dest + " from " + definitions);
    loadLoinc();
    log("LOINC loaded");
    now = DateTimeType.now();
    bundle = new Bundle();
    bundle.setType(BundleType.COLLECTION);
    bundle.setId("http://hl7.org/fhir/commondataelement/loinc");
    bundle.setMeta(new Meta().setLastUpdatedElement(InstantType.now()));
    processLoincCodes();
    return bundle;
}
Also used : Meta(org.hl7.fhir.r4b.model.Meta) Bundle(org.hl7.fhir.r4b.model.Bundle)

Example 47 with Meta

use of org.hl7.fhir.dstu3.model.Meta in project org.hl7.fhir.core by hapifhir.

the class MetaTest method testMetaSecurity.

@Test
public void testMetaSecurity() {
    Meta meta = new Meta();
    Coding coding = meta.addSecurity().setSystem(TEST_SYSTEM).setCode(TEST_CODE);
    Assertions.assertTrue(meta.hasSecurity());
    Assertions.assertNotNull(meta.getSecurity());
    Assertions.assertNotNull(meta.getSecurity(TEST_SYSTEM, TEST_CODE));
    Assertions.assertEquals(1, meta.getSecurity().size());
    Assertions.assertEquals(meta.getSecurity().get(0), meta.getSecurity(TEST_SYSTEM, TEST_CODE));
    Assertions.assertEquals(meta.getSecurityFirstRep(), meta.getSecurity(TEST_SYSTEM, TEST_CODE));
    Assertions.assertEquals(coding, meta.getSecurity(TEST_SYSTEM, TEST_CODE));
}
Also used : Meta(org.hl7.fhir.r4b.model.Meta) Coding(org.hl7.fhir.r4b.model.Coding) Test(org.junit.jupiter.api.Test)

Example 48 with Meta

use of org.hl7.fhir.dstu3.model.Meta in project org.hl7.fhir.core by hapifhir.

the class ProfileDrivenRenderer method renderLeaf.

private void renderLeaf(ResourceWrapper res, BaseWrapper ew, ElementDefinition defn, XhtmlNode parent, XhtmlNode x, boolean title, boolean showCodeDetails, Map<String, String> displayHints, String path, int indent) throws FHIRException, UnsupportedEncodingException, IOException, EOperationOutcome {
    if (ew == null)
        return;
    Base e = ew.getBase();
    if (e instanceof StringType)
        x.addText(((StringType) e).getValue());
    else if (e instanceof CodeType)
        x.addText(((CodeType) e).getValue());
    else if (e instanceof IdType)
        x.addText(((IdType) e).getValue());
    else if (e instanceof Extension)
        return;
    else if (e instanceof InstantType)
        x.addText(((InstantType) e).toHumanDisplay());
    else if (e instanceof DateTimeType) {
        renderDateTime(x, e);
    } else if (e instanceof Base64BinaryType)
        x.addText(new Base64().encodeAsString(((Base64BinaryType) e).getValue()));
    else if (e instanceof org.hl7.fhir.r5.model.DateType) {
        org.hl7.fhir.r5.model.DateType dt = ((org.hl7.fhir.r5.model.DateType) e);
        renderDate(x, dt);
    } else if (e instanceof Enumeration) {
        Object ev = ((Enumeration<?>) e).getValue();
        // todo: look up a display name if there is one
        x.addText(ev == null ? "" : ev.toString());
    } else if (e instanceof BooleanType) {
        x.addText(((BooleanType) e).getValue().toString());
    } else if (e instanceof CodeableConcept) {
        renderCodeableConcept(x, (CodeableConcept) e, showCodeDetails);
    } else if (e instanceof Coding) {
        renderCoding(x, (Coding) e, showCodeDetails);
    } else if (e instanceof CodeableReference) {
        renderCodeableReference(x, (CodeableReference) e, showCodeDetails);
    } else if (e instanceof Annotation) {
        renderAnnotation(x, (Annotation) e);
    } else if (e instanceof Identifier) {
        renderIdentifier(x, (Identifier) e);
    } else if (e instanceof org.hl7.fhir.r5.model.IntegerType) {
        if (((org.hl7.fhir.r5.model.IntegerType) e).hasValue()) {
            x.addText(Integer.toString(((org.hl7.fhir.r5.model.IntegerType) e).getValue()));
        } else {
            x.addText("??");
        }
    } else if (e instanceof org.hl7.fhir.r5.model.Integer64Type) {
        if (((org.hl7.fhir.r5.model.Integer64Type) e).hasValue()) {
            x.addText(Long.toString(((org.hl7.fhir.r5.model.Integer64Type) e).getValue()));
        } else {
            x.addText("??");
        }
    } else if (e instanceof org.hl7.fhir.r5.model.DecimalType) {
        x.addText(((org.hl7.fhir.r5.model.DecimalType) e).getValue().toString());
    } else if (e instanceof HumanName) {
        renderHumanName(x, (HumanName) e);
    } else if (e instanceof SampledData) {
        renderSampledData(x, (SampledData) e);
    } else if (e instanceof Address) {
        renderAddress(x, (Address) e);
    } else if (e instanceof ContactPoint) {
        renderContactPoint(x, (ContactPoint) e);
    } else if (e instanceof Expression) {
        renderExpression(x, (Expression) e);
    } else if (e instanceof Money) {
        renderMoney(x, (Money) e);
    } else if (e instanceof ContactDetail) {
        ContactDetail cd = (ContactDetail) e;
        if (cd.hasName()) {
            x.tx(cd.getName() + ": ");
        }
        boolean first = true;
        for (ContactPoint c : cd.getTelecom()) {
            if (first)
                first = false;
            else
                x.tx(",");
            renderContactPoint(x, c);
        }
    } else if (e instanceof UriType) {
        renderUri(x, (UriType) e, defn.getPath(), rcontext != null && rcontext.getResourceResource() != null ? rcontext.getResourceResource().getId() : null);
    } else if (e instanceof Timing) {
        renderTiming(x, (Timing) e);
    } else if (e instanceof Range) {
        renderRange(x, (Range) e);
    } else if (e instanceof Quantity) {
        renderQuantity(x, (Quantity) e, showCodeDetails);
    } else if (e instanceof Ratio) {
        renderQuantity(x, ((Ratio) e).getNumerator(), showCodeDetails);
        x.tx("/");
        renderQuantity(x, ((Ratio) e).getDenominator(), showCodeDetails);
    } else if (e instanceof Period) {
        Period p = (Period) e;
        renderPeriod(x, p);
    } else if (e instanceof Reference) {
        Reference r = (Reference) e;
        if (r.getReference() != null && r.getReference().contains("#")) {
            if (containedIds.contains(r.getReference().substring(1))) {
                x.ah(r.getReference()).tx("See " + r.getReference());
            } else {
                // in this case, we render the resource in line
                ResourceWrapper rw = null;
                for (ResourceWrapper t : res.getContained()) {
                    if (r.getReference().substring(1).equals(t.getId())) {
                        rw = t;
                    }
                }
                if (rw == null) {
                    renderReference(res, x, r);
                } else {
                    x.an(rw.getId());
                    ResourceRenderer rr = RendererFactory.factory(rw, context.copy().setAddGeneratedNarrativeHeader(false));
                    rr.render(parent.blockquote(), rw);
                }
            }
        } else {
            renderReference(res, x, r);
        }
    } else if (e instanceof Resource) {
        return;
    } else if (e instanceof DataRequirement) {
        DataRequirement p = (DataRequirement) e;
        renderDataRequirement(x, p);
    } else if (e instanceof PrimitiveType) {
        x.tx(((PrimitiveType) e).primitiveValue());
    } else if (e instanceof ElementDefinition) {
        x.tx("todo-bundle");
    } else if (e != null && !(e instanceof Attachment) && !(e instanceof Narrative) && !(e instanceof Meta)) {
        throw new NotImplementedException("type " + e.getClass().getName() + " not handled - should not be here");
    }
}
Also used : ResourceWrapper(org.hl7.fhir.r5.renderers.utils.BaseWrappers.ResourceWrapper) Meta(org.hl7.fhir.r5.model.Meta) Address(org.hl7.fhir.r5.model.Address) StringType(org.hl7.fhir.r5.model.StringType) Attachment(org.hl7.fhir.r5.model.Attachment) DataRequirement(org.hl7.fhir.r5.model.DataRequirement) Identifier(org.hl7.fhir.r5.model.Identifier) Coding(org.hl7.fhir.r5.model.Coding) Narrative(org.hl7.fhir.r5.model.Narrative) SampledData(org.hl7.fhir.r5.model.SampledData) PrimitiveType(org.hl7.fhir.r5.model.PrimitiveType) ElementDefinition(org.hl7.fhir.r5.model.ElementDefinition) InstantType(org.hl7.fhir.r5.model.InstantType) Resource(org.hl7.fhir.r5.model.Resource) DomainResource(org.hl7.fhir.r5.model.DomainResource) Period(org.hl7.fhir.r5.model.Period) Range(org.hl7.fhir.r5.model.Range) IdType(org.hl7.fhir.r5.model.IdType) DateTimeType(org.hl7.fhir.r5.model.DateTimeType) Timing(org.hl7.fhir.r5.model.Timing) CodeableConcept(org.hl7.fhir.r5.model.CodeableConcept) Base64(org.apache.commons.codec.binary.Base64) NotImplementedException(org.apache.commons.lang3.NotImplementedException) UriType(org.hl7.fhir.r5.model.UriType) HumanName(org.hl7.fhir.r5.model.HumanName) ContactPoint(org.hl7.fhir.r5.model.ContactPoint) Money(org.hl7.fhir.r5.model.Money) Ratio(org.hl7.fhir.r5.model.Ratio) Enumeration(org.hl7.fhir.r5.model.Enumeration) Reference(org.hl7.fhir.r5.model.Reference) ResourceWithReference(org.hl7.fhir.r5.renderers.utils.Resolver.ResourceWithReference) CodeableReference(org.hl7.fhir.r5.model.CodeableReference) BooleanType(org.hl7.fhir.r5.model.BooleanType) Quantity(org.hl7.fhir.r5.model.Quantity) Base(org.hl7.fhir.r5.model.Base) Annotation(org.hl7.fhir.r5.model.Annotation) Extension(org.hl7.fhir.r5.model.Extension) ContactDetail(org.hl7.fhir.r5.model.ContactDetail) Expression(org.hl7.fhir.r5.model.Expression) CodeableReference(org.hl7.fhir.r5.model.CodeableReference) CodeType(org.hl7.fhir.r5.model.CodeType) Base64BinaryType(org.hl7.fhir.r5.model.Base64BinaryType)

Example 49 with Meta

use of org.hl7.fhir.dstu3.model.Meta 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 50 with Meta

use of org.hl7.fhir.dstu3.model.Meta in project pathling by aehrc.

the class TestData method newConditionWithExtensions.

public static Condition newConditionWithExtensions() {
    // Condition
    // - extension:
    // - url: uuid:ext1
    // - value: ext1
    // - extension:
    // - url: uuid:ext2
    // - value: 2
    // - extension:
    // - url: uuid:ext4
    // - extension
    // - url: uuid:nested
    // - value: nested
    // - identifier
    // - id: uuid:identifier1
    // - extension:
    // - url: uuid:ext10
    // - value: ext10
    // - extension:
    // - url: uuid:ext11
    // - value: 11
    // - stage
    // - type
    // - extension
    // - url: uuid:ext12
    // - value: ext12
    final Condition conditionWithExtension = new Condition();
    conditionWithExtension.setId("someId");
    final Extension nestedExtension = new Extension("uuid:ext4");
    nestedExtension.addExtension(new Extension("uuid:nested", new StringType("nested")));
    conditionWithExtension.setExtension(Arrays.asList(new Extension("uuid:ext1", new StringType("ext1")), new Extension("uuid:ext2", new IntegerType(2)), nestedExtension));
    conditionWithExtension.setMeta(new Meta().setVersionId("MetVersion"));
    conditionWithExtension.setOnset(new Range());
    conditionWithExtension.setSeverity(new CodeableConcept().addCoding(new Coding("sys", "code", "name")));
    final Identifier identifier = conditionWithExtension.getIdentifierFirstRep();
    identifier.setId("uuid:identifier1");
    identifier.setExtension(Arrays.asList(new Extension("uuid:ext10", new StringType("ext10")), new Extension("uuid:ext11", new IntegerType(11))));
    final ConditionStageComponent stage = conditionWithExtension.getStageFirstRep();
    stage.getType().setExtension(Collections.singletonList(new Extension("uuid:ext12", new StringType("ext12"))));
    return conditionWithExtension;
}
Also used : ConditionStageComponent(org.hl7.fhir.r4.model.Condition.ConditionStageComponent)

Aggregations

Meta (org.hl7.fhir.r4.model.Meta)40 HashMap (java.util.HashMap)36 Date (java.util.Date)35 Meta (org.hl7.fhir.dstu3.model.Meta)31 IBaseMetaType (org.hl7.fhir.instance.model.api.IBaseMetaType)28 Reference (org.hl7.fhir.r4.model.Reference)26 JsonObject (javax.json.JsonObject)24 Path (javax.ws.rs.Path)24 Produces (javax.ws.rs.Produces)24 Code (org.mitre.synthea.world.concepts.HealthRecord.Code)20 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)18 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)17 DocumentReference (org.hl7.fhir.r4.model.DocumentReference)17 ArrayList (java.util.ArrayList)16 Coding (org.hl7.fhir.r4.model.Coding)16 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)15 Test (org.junit.jupiter.api.Test)15 Test (org.junit.Test)14 NotImplementedException (org.apache.commons.lang3.NotImplementedException)13 GET (javax.ws.rs.GET)12