use of org.hl7.fhir.r5.model.Enumerations.FHIRVersion in project org.hl7.fhir.core by hapifhir.
the class IgLoader method scanForVersions.
public void scanForVersions(List<String> sources, VersionSourceInformation versions) throws FHIRException, IOException {
List<String> refs = new ArrayList<String>();
ValidatorUtils.parseSources(sources, refs, context);
for (String ref : refs) {
Content cnt = loadContent(ref, "validate", false);
String s = TextFile.bytesToString(cnt.focus);
if (s.contains("http://hl7.org/fhir/3.0")) {
versions.see("3.0", "Profile in " + ref);
}
if (s.contains("http://hl7.org/fhir/1.0")) {
versions.see("1.0", "Profile in " + ref);
}
if (s.contains("http://hl7.org/fhir/4.0")) {
versions.see("4.0", "Profile in " + ref);
}
if (s.contains("http://hl7.org/fhir/1.4")) {
versions.see("1.4", "Profile in " + ref);
}
try {
if (s.startsWith("{")) {
JsonObject json = JsonTrackingParser.parse(s, null);
if (json.has("fhirVersion")) {
versions.see(VersionUtilities.getMajMin(JSONUtil.str(json, "fhirVersion")), "fhirVersion in " + ref);
}
} else {
Document doc = ValidatorUtils.parseXml(cnt.focus);
String v = XMLUtil.getNamedChildValue(doc.getDocumentElement(), "fhirVersion");
if (v != null) {
versions.see(VersionUtilities.getMajMin(v), "fhirVersion in " + ref);
}
}
} catch (Exception e) {
// nothing
}
}
}
use of org.hl7.fhir.r5.model.Enumerations.FHIRVersion in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeCapabilityStatement.
protected void composeCapabilityStatement(Complex parent, String parentType, String name, CapabilityStatement element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeDomainResource(t, "CapabilityStatement", name, element, index);
if (element.hasUrlElement())
composeUri(t, "CapabilityStatement", "url", element.getUrlElement(), -1);
if (element.hasVersionElement())
composeString(t, "CapabilityStatement", "version", element.getVersionElement(), -1);
if (element.hasNameElement())
composeString(t, "CapabilityStatement", "name", element.getNameElement(), -1);
if (element.hasTitleElement())
composeString(t, "CapabilityStatement", "title", element.getTitleElement(), -1);
if (element.hasStatusElement())
composeEnum(t, "CapabilityStatement", "status", element.getStatusElement(), -1);
if (element.hasExperimentalElement())
composeBoolean(t, "CapabilityStatement", "experimental", element.getExperimentalElement(), -1);
if (element.hasDateElement())
composeDateTime(t, "CapabilityStatement", "date", element.getDateElement(), -1);
if (element.hasPublisherElement())
composeString(t, "CapabilityStatement", "publisher", element.getPublisherElement(), -1);
for (int i = 0; i < element.getContact().size(); i++) composeContactDetail(t, "CapabilityStatement", "contact", element.getContact().get(i), i);
if (element.hasDescriptionElement())
composeMarkdown(t, "CapabilityStatement", "description", element.getDescriptionElement(), -1);
for (int i = 0; i < element.getUseContext().size(); i++) composeUsageContext(t, "CapabilityStatement", "useContext", element.getUseContext().get(i), i);
for (int i = 0; i < element.getJurisdiction().size(); i++) composeCodeableConcept(t, "CapabilityStatement", "jurisdiction", element.getJurisdiction().get(i), i);
if (element.hasPurposeElement())
composeMarkdown(t, "CapabilityStatement", "purpose", element.getPurposeElement(), -1);
if (element.hasCopyrightElement())
composeMarkdown(t, "CapabilityStatement", "copyright", element.getCopyrightElement(), -1);
if (element.hasKindElement())
composeEnum(t, "CapabilityStatement", "kind", element.getKindElement(), -1);
for (int i = 0; i < element.getInstantiates().size(); i++) composeCanonical(t, "CapabilityStatement", "instantiates", element.getInstantiates().get(i), i);
for (int i = 0; i < element.getImports().size(); i++) composeCanonical(t, "CapabilityStatement", "imports", element.getImports().get(i), i);
if (element.hasSoftware())
composeCapabilityStatementCapabilityStatementSoftwareComponent(t, "CapabilityStatement", "software", element.getSoftware(), -1);
if (element.hasImplementation())
composeCapabilityStatementCapabilityStatementImplementationComponent(t, "CapabilityStatement", "implementation", element.getImplementation(), -1);
if (element.hasFhirVersionElement())
composeEnum(t, "CapabilityStatement", "fhirVersion", element.getFhirVersionElement(), -1);
for (int i = 0; i < element.getFormat().size(); i++) composeCode(t, "CapabilityStatement", "format", element.getFormat().get(i), i);
for (int i = 0; i < element.getPatchFormat().size(); i++) composeCode(t, "CapabilityStatement", "patchFormat", element.getPatchFormat().get(i), i);
for (int i = 0; i < element.getImplementationGuide().size(); i++) composeCanonical(t, "CapabilityStatement", "implementationGuide", element.getImplementationGuide().get(i), i);
for (int i = 0; i < element.getRest().size(); i++) composeCapabilityStatementCapabilityStatementRestComponent(t, "CapabilityStatement", "rest", element.getRest().get(i), i);
for (int i = 0; i < element.getMessaging().size(); i++) composeCapabilityStatementCapabilityStatementMessagingComponent(t, "CapabilityStatement", "messaging", element.getMessaging().get(i), i);
for (int i = 0; i < element.getDocument().size(); i++) composeCapabilityStatementCapabilityStatementDocumentComponent(t, "CapabilityStatement", "document", element.getDocument().get(i), i);
}
use of org.hl7.fhir.r5.model.Enumerations.FHIRVersion in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeImplementationGuideImplementationGuideDefinitionResourceComponent.
protected void composeImplementationGuideImplementationGuideDefinitionResourceComponent(Complex parent, String parentType, String name, ImplementationGuide.ImplementationGuideDefinitionResourceComponent element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeBackboneElement(t, "resource", name, element, index);
if (element.hasReference())
composeReference(t, "ImplementationGuide", "reference", element.getReference(), -1);
for (int i = 0; i < element.getFhirVersion().size(); i++) composeEnum(t, "ImplementationGuide", "fhirVersion", element.getFhirVersion().get(i), i);
if (element.hasNameElement())
composeString(t, "ImplementationGuide", "name", element.getNameElement(), -1);
if (element.hasDescriptionElement())
composeString(t, "ImplementationGuide", "description", element.getDescriptionElement(), -1);
if (element.hasExample())
composeType(t, "ImplementationGuide", "example", element.getExample(), -1);
if (element.hasGroupingIdElement())
composeId(t, "ImplementationGuide", "groupingId", element.getGroupingIdElement(), -1);
}
use of org.hl7.fhir.r5.model.Enumerations.FHIRVersion in project org.hl7.fhir.core by hapifhir.
the class CapabilityStatementComparer method compare.
public CapabilityStatementComparison compare(CapabilityStatement left, CapabilityStatement right) {
if (left == null)
throw new DefinitionException("No CapabilityStatement provided (left)");
if (right == null)
throw new DefinitionException("No CapabilityStatement provided (right)");
CapabilityStatementComparison res = new CapabilityStatementComparison(left, right);
session.identify(res);
CapabilityStatement cs = new CapabilityStatement();
res.setUnion(cs);
session.identify(cs);
cs.setName("Union" + left.getName() + "And" + right.getName());
cs.setTitle("Union of " + left.getTitle() + " And " + right.getTitle());
cs.setStatus(left.getStatus());
cs.setDate(new Date());
CapabilityStatement cs1 = new CapabilityStatement();
res.setIntersection(cs1);
session.identify(cs1);
cs1.setName("Intersection" + left.getName() + "And" + right.getName());
cs1.setTitle("Intersection of " + left.getTitle() + " And " + right.getTitle());
cs1.setStatus(left.getStatus());
cs1.setDate(new Date());
compareMetadata(left, right, res.getMetadata(), res);
comparePrimitives("kind", left.getKindElement(), right.getKindElement(), res.getMetadata(), IssueSeverity.ERROR, res);
compareCanonicalList("instantiates", left.getInstantiates(), right.getInstantiates(), res.getMetadata(), IssueSeverity.ERROR, res, cs.getInstantiates(), cs1.getInstantiates());
compareCanonicalList("imports", left.getImports(), right.getImports(), res.getMetadata(), IssueSeverity.ERROR, res, cs.getImports(), cs1.getImports());
comparePrimitives("software.name", left.getSoftware().getNameElement(), right.getSoftware().getNameElement(), res.getMetadata(), IssueSeverity.ERROR, res);
comparePrimitives("software.version", left.getSoftware().getVersionElement(), right.getSoftware().getVersionElement(), res.getMetadata(), IssueSeverity.ERROR, res);
comparePrimitives("software.releaseDate", left.getSoftware().getReleaseDateElement(), right.getSoftware().getReleaseDateElement(), res.getMetadata(), IssueSeverity.ERROR, res);
comparePrimitives("implementation.description", left.getImplementation().getDescriptionElement(), right.getImplementation().getDescriptionElement(), res.getMetadata(), IssueSeverity.ERROR, res);
comparePrimitives("implementation.url", left.getImplementation().getUrlElement(), right.getImplementation().getUrlElement(), res.getMetadata(), IssueSeverity.ERROR, res);
comparePrimitives("fhirVersion", left.getFhirVersionElement(), right.getFhirVersionElement(), res.getMetadata(), IssueSeverity.ERROR, res);
compareCodeList("format", left.getFormat(), right.getFormat(), res.getMetadata(), IssueSeverity.ERROR, res, cs.getFormat(), cs1.getFormat());
compareCodeList("patchFormat", left.getPatchFormat(), right.getPatchFormat(), res.getMetadata(), IssueSeverity.ERROR, res, cs.getPatchFormat(), cs1.getPatchFormat());
compareCanonicalList("implementationGuide", left.getImplementationGuide(), right.getImplementationGuide(), res.getMetadata(), IssueSeverity.ERROR, res, cs.getImplementationGuide(), cs1.getImplementationGuide());
compareRests(left.getRest(), right.getRest(), res.getCombined(), res.getUnion().getRest(), res.getIntersection().getRest(), res.getUnion(), res.getIntersection(), res, "CapabilityStatement.rest");
return res;
}
use of org.hl7.fhir.r5.model.Enumerations.FHIRVersion in project org.hl7.fhir.core by hapifhir.
the class NPMPackageGenerator method buildPackageJson.
private void buildPackageJson(String canonical, PackageType kind, String web, Date date, ImplementationGuide ig, List<String> fhirVersion, boolean notForPublication) throws FHIRException, IOException {
String dtHuman = new SimpleDateFormat("EEE, MMM d, yyyy HH:mmZ", new Locale("en", "US")).format(date);
String dt = new SimpleDateFormat("yyyyMMddHHmmss").format(date);
CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
if (!ig.hasPackageId()) {
b.append("packageId");
}
if (!ig.hasVersion()) {
b.append("version");
}
if (!ig.hasFhirVersion()) {
b.append("fhirVersion");
}
if (!ig.hasLicense()) {
b.append("license");
}
for (ImplementationGuideDependsOnComponent d : ig.getDependsOn()) {
if (!d.hasVersion()) {
b.append("dependsOn.version(" + d.getUri() + ")");
}
}
JsonObject npm = new JsonObject();
npm.addProperty("name", ig.getPackageId());
npm.addProperty("version", ig.getVersion());
igVersion = ig.getVersion();
npm.addProperty("tools-version", ToolsVersion.TOOLS_VERSION);
npm.addProperty("type", kind.getCode());
npm.addProperty("date", dt);
if (ig.hasLicense()) {
npm.addProperty("license", ig.getLicense().toCode());
}
npm.addProperty("canonical", canonical);
if (notForPublication) {
npm.addProperty("notForPublication", true);
}
npm.addProperty("url", web);
if (ig.hasTitle()) {
npm.addProperty("title", ig.getTitle());
}
if (ig.hasDescription()) {
npm.addProperty("description", ig.getDescription() + " (built " + dtHuman + timezone() + ")");
}
JsonArray vl = new JsonArray();
npm.add("fhirVersions", vl);
for (String v : fhirVersion) {
vl.add(new JsonPrimitive(v));
}
if (kind != PackageType.CORE) {
JsonObject dep = new JsonObject();
npm.add("dependencies", dep);
for (String v : fhirVersion) {
String vp = packageForVersion(v);
if (vp != null) {
dep.addProperty(vp, v);
}
}
for (ImplementationGuideDependsOnComponent d : ig.getDependsOn()) {
dep.addProperty(d.getPackageId(), d.getVersion());
}
}
if (ig.hasPublisher()) {
npm.addProperty("author", ig.getPublisher());
}
JsonArray m = new JsonArray();
for (ContactDetail t : ig.getContact()) {
String email = email(t.getTelecom());
String url = url(t.getTelecom());
if (t.hasName() & (email != null || url != null)) {
JsonObject md = new JsonObject();
m.add(md);
md.addProperty("name", t.getName());
if (email != null)
md.addProperty("email", email);
if (url != null)
md.addProperty("url", url);
}
}
if (m.size() > 0)
npm.add("maintainers", m);
if (ig.getManifest().hasRendering())
npm.addProperty("homepage", ig.getManifest().getRendering());
JsonObject dir = new JsonObject();
npm.add("directories", dir);
dir.addProperty("lib", "package");
dir.addProperty("example", "example");
Gson gson = new GsonBuilder().setPrettyPrinting().create();
String json = gson.toJson(npm);
try {
addFile(Category.RESOURCE, "package.json", json.getBytes("UTF-8"));
} catch (UnsupportedEncodingException e) {
}
packageJ = npm;
packageManifest = new JsonObject();
packageManifest.addProperty("version", ig.getVersion());
JsonArray fv = new JsonArray();
for (String v : fhirVersion) {
fv.add(v);
}
packageManifest.add("fhirVersion", fv);
packageManifest.addProperty("date", dt);
packageManifest.addProperty("name", ig.getPackageId());
}
Aggregations