use of org.hl7.fhir.r4b.context.IWorkerContext in project org.hl7.fhir.core by hapifhir.
the class Tester method main.
public static void main(String[] args) throws Exception {
IWorkerContext context = SimpleWorkerContext.fromPack(Utilities.path("C:\\work\\org.hl7.fhir\\build\\publish", "validation-min.xml.zip"));
int t = 0;
int ok = 0;
for (String f : new File("C:\\work\\org.hl7.fhir\\build\\publish").list()) {
if (f.endsWith(".xml") && !f.endsWith(".canonical.xml") && !f.contains("profile") && !f.contains("questionnaire") && new File("C:\\work\\org.hl7.fhir\\build\\publish\\" + Utilities.changeFileExt(f, ".ttl")).exists()) {
// if (f.equals("account-questionnaire.xml")) {
System.out.print("convert " + f);
// Manager.convert(context, new FileInputStream("C:\\work\\org.hl7.fhir\\build\\publish\\"+f), FhirFormat.XML,
// new FileOutputStream("C:\\work\\org.hl7.fhir\\build\\publish\\"+Utilities.changeFileExt(f, ".mm.json")), FhirFormat.JSON, OutputStyle.PRETTY);
// String src = normalise(TextFile.fileToString("C:\\work\\org.hl7.fhir\\build\\publish\\"+Utilities.changeFileExt(f, ".mm.json")));
// String tgt = normalise(TextFile.fileToString("C:\\work\\org.hl7.fhir\\build\\publish\\"+Utilities.changeFileExt(f, ".json")));
Element e = Manager.parse(context, new FileInputStream("C:\\work\\org.hl7.fhir\\build\\publish\\" + f), FhirFormat.XML);
Manager.compose(context, e, new FileOutputStream("C:\\work\\org.hl7.fhir\\build\\publish\\" + Utilities.changeFileExt(f, ".mm.ttl")), FhirFormat.TURTLE, OutputStyle.PRETTY, null);
Manager.compose(context, e, new FileOutputStream(Utilities.path("[tmp]", "resource.xml")), FhirFormat.XML, OutputStyle.PRETTY, null);
String src = TextFile.fileToString("C:\\work\\org.hl7.fhir\\build\\publish\\" + Utilities.changeFileExt(f, ".mm.ttl"));
String tgt = TextFile.fileToString("C:\\work\\org.hl7.fhir\\build\\publish\\" + Utilities.changeFileExt(f, ".ttl"));
t++;
if (src.equals(tgt)) {
System.out.println(".. ok");
ok++;
} else
System.out.println(".. fail");
}
// }
}
System.out.println("done - " + Integer.toString(t) + " files, " + Integer.toString(ok) + " ok");
}
use of org.hl7.fhir.r4b.context.IWorkerContext in project org.hl7.fhir.core by hapifhir.
the class ValueSetUtilities method markStatus.
public static void markStatus(ValueSet vs, String wg, StandardsStatus status, String pckage, String fmm, IWorkerContext context, String normativeVersion) throws FHIRException {
if (vs.hasUserData("external.url"))
return;
if (wg != null) {
if (!ToolingExtensions.hasExtension(vs, ToolingExtensions.EXT_WORKGROUP) || (!Utilities.existsInList(ToolingExtensions.readStringExtension(vs, ToolingExtensions.EXT_WORKGROUP), "fhir", "vocab") && Utilities.existsInList(wg, "fhir", "vocab"))) {
ToolingExtensions.setCodeExtension(vs, ToolingExtensions.EXT_WORKGROUP, wg);
}
}
if (status != null) {
StandardsStatus ss = ToolingExtensions.getStandardsStatus(vs);
if (ss == null || ss.isLowerThan(status))
ToolingExtensions.setStandardsStatus(vs, status, normativeVersion);
if (pckage != null) {
if (!vs.hasUserData("ballot.package"))
vs.setUserData("ballot.package", pckage);
else if (!pckage.equals(vs.getUserString("ballot.package")))
if (!"infrastructure".equals(vs.getUserString("ballot.package")))
System.out.println("Value Set " + vs.getUrl() + ": ownership clash " + pckage + " vs " + vs.getUserString("ballot.package"));
}
if (status == StandardsStatus.NORMATIVE) {
vs.setExperimental(false);
vs.setStatus(PublicationStatus.ACTIVE);
}
}
if (fmm != null) {
String sfmm = ToolingExtensions.readStringExtension(vs, ToolingExtensions.EXT_FMM_LEVEL);
if (Utilities.noString(sfmm) || Integer.parseInt(sfmm) < Integer.parseInt(fmm))
ToolingExtensions.setIntegerExtension(vs, ToolingExtensions.EXT_FMM_LEVEL, Integer.parseInt(fmm));
}
if (vs.hasUserData("cs"))
CodeSystemUtilities.markStatus((CodeSystem) vs.getUserData("cs"), wg, status, pckage, fmm, normativeVersion);
else if (status == StandardsStatus.NORMATIVE && context != null) {
for (ConceptSetComponent csc : vs.getCompose().getInclude()) {
if (csc.hasSystem()) {
CodeSystem cs = context.fetchCodeSystem(csc.getSystem());
if (cs != null) {
CodeSystemUtilities.markStatus(cs, wg, status, pckage, fmm, normativeVersion);
}
}
}
}
}
use of org.hl7.fhir.r4b.context.IWorkerContext in project org.hl7.fhir.core by hapifhir.
the class TestingUtilities method context.
public static IWorkerContext context() {
if (fcontext == null) {
FilesystemPackageCacheManager pcm;
try {
pcm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION);
fcontext = SimpleWorkerContext.fromPackage(pcm.loadPackage("hl7.fhir.r4.core", "4.0.1"));
fcontext.setUcumService(new UcumEssenceService(TestingUtilities.resourceNameToFile("ucum", "ucum-essence.xml")));
fcontext.setExpansionProfile(new Parameters());
} catch (Exception e) {
throw new Error(e);
}
}
return fcontext;
}
use of org.hl7.fhir.r4b.context.IWorkerContext in project org.hl7.fhir.core by hapifhir.
the class Manager method build.
public static Element build(IWorkerContext context, StructureDefinition sd) {
Property p = new Property(context, sd.getSnapshot().getElementFirstRep(), sd);
Element e = new Element(null, p);
return e;
}
use of org.hl7.fhir.r4b.context.IWorkerContext in project org.hl7.fhir.core by hapifhir.
the class ValueSetUtilities method markStatus.
public static void markStatus(ValueSet vs, String wg, StandardsStatus status, String pckage, String fmm, IWorkerContext context, String normativeVersion) throws FHIRException {
if (vs.hasUserData("external.url"))
return;
if (wg != null) {
if (!ToolingExtensions.hasExtension(vs, ToolingExtensions.EXT_WORKGROUP) || (!Utilities.existsInList(ToolingExtensions.readStringExtension(vs, ToolingExtensions.EXT_WORKGROUP), "fhir", "vocab") && Utilities.existsInList(wg, "fhir", "vocab"))) {
ToolingExtensions.setCodeExtension(vs, ToolingExtensions.EXT_WORKGROUP, wg);
}
}
if (status != null) {
StandardsStatus ss = ToolingExtensions.getStandardsStatus(vs);
if (ss == null || ss.isLowerThan(status))
ToolingExtensions.setStandardsStatus(vs, status, normativeVersion);
if (pckage != null) {
if (!vs.hasUserData("ballot.package"))
vs.setUserData("ballot.package", pckage);
else if (!pckage.equals(vs.getUserString("ballot.package")))
if (!"infrastructure".equals(vs.getUserString("ballot.package")))
System.out.println("Value Set " + vs.getUrl() + ": ownership clash " + pckage + " vs " + vs.getUserString("ballot.package"));
}
if (status == StandardsStatus.NORMATIVE) {
vs.setExperimental(false);
vs.setStatus(PublicationStatus.ACTIVE);
}
}
if (fmm != null) {
String sfmm = ToolingExtensions.readStringExtension(vs, ToolingExtensions.EXT_FMM_LEVEL);
if (Utilities.noString(sfmm) || Integer.parseInt(sfmm) < Integer.parseInt(fmm)) {
ToolingExtensions.setIntegerExtension(vs, ToolingExtensions.EXT_FMM_LEVEL, Integer.parseInt(fmm));
}
if (Integer.parseInt(fmm) <= 1) {
vs.setExperimental(true);
}
}
if (vs.hasUserData("cs"))
CodeSystemUtilities.markStatus((CodeSystem) vs.getUserData("cs"), wg, status, pckage, fmm, normativeVersion);
else if (status == StandardsStatus.NORMATIVE && context != null) {
for (ConceptSetComponent csc : vs.getCompose().getInclude()) {
if (csc.hasSystem()) {
CodeSystem cs = context.fetchCodeSystem(csc.getSystem());
if (cs != null) {
CodeSystemUtilities.markStatus(cs, wg, status, pckage, fmm, normativeVersion);
}
}
}
}
}
Aggregations