Search in sources :

Example 36 with Meta

use of org.hl7.fhir.r4b.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.r5.model.Meta) Bundle(org.hl7.fhir.r5.model.Bundle)

Example 37 with Meta

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

the class NarrativeGenerationTests method test.

@ParameterizedTest(name = "{index}: file {0}")
@MethodSource("data")
public void test(String id, TestDetails test) throws Exception {
    RenderingContext rc = new RenderingContext(context, null, null, "http://hl7.org/fhir", "", null, ResourceRendererMode.END_USER);
    rc.setDestDir("");
    rc.setHeader(test.isHeader());
    rc.setDefinitionsTarget("test.html");
    rc.setTerminologyServiceOptions(TerminologyServiceOptions.defaults());
    rc.setParser(new TestTypeParser());
    // getting timezones correct (well, at least consistent, so tests pass on any computer)
    rc.setLocale(new java.util.Locale("en", "AU"));
    rc.setTimeZoneId(ZoneId.of("Australia/Sydney"));
    rc.setDateTimeFormatString("yyyy-MM-dd'T'HH:mm:ssZZZZZ");
    rc.setDateFormatString("yyyy-MM-dd");
    rc.setMode(test.technical ? ResourceRendererMode.TECHNICAL : ResourceRendererMode.END_USER);
    Resource source;
    if (TestingUtilities.findTestResource("r5", "narrative", test.getId() + ".json")) {
        source = (Resource) new JsonParser().parse(TestingUtilities.loadTestResourceStream("r5", "narrative", test.getId() + ".json"));
    } else {
        source = (Resource) new XmlParser().parse(TestingUtilities.loadTestResourceStream("r5", "narrative", test.getId() + ".xml"));
    }
    XhtmlNode x = RendererFactory.factory(source, rc).build(source);
    String expected = TextFile.streamToString(TestingUtilities.loadTestResourceStream("r5", "narrative", test.getId() + ".html"));
    String actual = HEADER + new XhtmlComposer(true, true).compose(x) + FOOTER;
    String expectedFileName = CompareUtilities.tempFile("narrative", test.getId() + ".expected.html");
    String actualFileName = CompareUtilities.tempFile("narrative", test.getId() + ".actual.html");
    TextFile.stringToFile(expected, expectedFileName);
    TextFile.stringToFile(actual, actualFileName);
    String msg = CompareUtilities.checkXMLIsSame(expectedFileName, actualFileName);
    Assertions.assertTrue(msg == null, "Output does not match expected: " + msg);
    if (test.isMeta()) {
        org.hl7.fhir.r5.elementmodel.Element e = Manager.parseSingle(context, TestingUtilities.loadTestResourceStream("r5", "narrative", test.getId() + ".xml"), FhirFormat.XML);
        x = RendererFactory.factory(source, rc).render(new ElementWrappers.ResourceWrapperMetaElement(rc, e));
        expected = TextFile.streamToString(TestingUtilities.loadTestResourceStream("r5", "narrative", test.getId() + "-meta.html"));
        actual = HEADER + new XhtmlComposer(true, true).compose(x) + FOOTER;
        actualFileName = CompareUtilities.tempFile("narrative", test.getId() + "-meta.actual.html");
        TextFile.stringToFile(actual, actualFileName);
        msg = CompareUtilities.checkXMLIsSame(expectedFileName, actualFileName);
        Assertions.assertTrue(msg == null, "Meta output does not match expected: " + msg);
    }
}
Also used : RenderingContext(org.hl7.fhir.r5.renderers.utils.RenderingContext) XmlParser(org.hl7.fhir.r5.formats.XmlParser) Resource(org.hl7.fhir.r5.model.Resource) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) XhtmlComposer(org.hl7.fhir.utilities.xhtml.XhtmlComposer) JsonParser(org.hl7.fhir.r5.formats.JsonParser) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 38 with Meta

use of org.hl7.fhir.r4b.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.r5.model.Meta) Coding(org.hl7.fhir.r5.model.Coding) Test(org.junit.jupiter.api.Test)

Example 39 with Meta

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

the class InstanceValidator method validateResourceRules.

private void validateResourceRules(List<ValidationMessage> errors, Element element, NodeStack stack) {
    String lang = element.getNamedChildValue("language");
    Element text = element.getNamedChild("text");
    if (text != null) {
        Element div = text.getNamedChild("div");
        if (lang != null && div != null) {
            XhtmlNode xhtml = div.getXhtml();
            String l = xhtml.getAttribute("lang");
            String xl = xhtml.getAttribute("xml:lang");
            if (l == null && xl == null) {
                warning(errors, IssueType.BUSINESSRULE, div.line(), div.col(), stack.getLiteralPath(), false, I18nConstants.LANGUAGE_XHTML_LANG_MISSING1);
            } else {
                if (l == null) {
                    warning(errors, IssueType.BUSINESSRULE, div.line(), div.col(), stack.getLiteralPath(), false, I18nConstants.LANGUAGE_XHTML_LANG_MISSING2);
                } else if (!l.equals(lang)) {
                    warning(errors, IssueType.BUSINESSRULE, div.line(), div.col(), stack.getLiteralPath(), false, I18nConstants.LANGUAGE_XHTML_LANG_DIFFERENT1, lang, l);
                }
                if (xl == null) {
                    warning(errors, IssueType.BUSINESSRULE, div.line(), div.col(), stack.getLiteralPath(), false, I18nConstants.LANGUAGE_XHTML_LANG_MISSING3);
                } else if (!xl.equals(lang)) {
                    warning(errors, IssueType.BUSINESSRULE, div.line(), div.col(), stack.getLiteralPath(), false, I18nConstants.LANGUAGE_XHTML_LANG_DIFFERENT2, lang, xl);
                }
            }
        }
    }
    // security tags are a set (system|code)
    Element meta = element.getNamedChild(META);
    if (meta != null) {
        Set<String> tags = new HashSet<>();
        List<Element> list = new ArrayList<>();
        meta.getNamedChildren("security", list);
        int i = 0;
        for (Element e : list) {
            String s = e.getNamedChildValue("system") + "#" + e.getNamedChildValue("code");
            rule(errors, IssueType.BUSINESSRULE, e.line(), e.col(), stack.getLiteralPath() + ".meta.profile[" + Integer.toString(i) + "]", !tags.contains(s), I18nConstants.META_RES_SECURITY_DUPLICATE, s);
            tags.add(s);
            i++;
        }
    }
}
Also used : NamedElement(org.hl7.fhir.r5.elementmodel.ParserBase.NamedElement) IndexedElement(org.hl7.fhir.validation.instance.utils.IndexedElement) SpecialElement(org.hl7.fhir.r5.elementmodel.Element.SpecialElement) Element(org.hl7.fhir.r5.elementmodel.Element) ArrayList(java.util.ArrayList) ContactPoint(org.hl7.fhir.r5.model.ContactPoint) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) HashSet(java.util.HashSet)

Example 40 with Meta

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

the class RdfParser method composeMeta.

protected void composeMeta(Complex parent, String parentType, String name, Meta element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeElement(t, "Meta", name, element, index);
    if (element.hasVersionIdElement())
        composeId(t, "Meta", "versionId", element.getVersionIdElement(), -1);
    if (element.hasLastUpdatedElement())
        composeInstant(t, "Meta", "lastUpdated", element.getLastUpdatedElement(), -1);
    if (element.hasSourceElement())
        composeUri(t, "Meta", "source", element.getSourceElement(), -1);
    for (int i = 0; i < element.getProfile().size(); i++) composeCanonical(t, "Meta", "profile", element.getProfile().get(i), i);
    for (int i = 0; i < element.getSecurity().size(); i++) composeCoding(t, "Meta", "security", element.getSecurity().get(i), i);
    for (int i = 0; i < element.getTag().size(); i++) composeCoding(t, "Meta", "tag", element.getTag().get(i), i);
}
Also used : Complex(org.hl7.fhir.r4.utils.formats.Turtle.Complex)

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