use of org.hl7.fhir.r4.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;
}
use of org.hl7.fhir.r4.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);
}
}
use of org.hl7.fhir.r4.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));
}
use of org.hl7.fhir.r4.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++;
}
}
}
use of org.hl7.fhir.r4.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);
}
Aggregations