use of org.hl7.fhir.r4b.model.ImplementationGuide in project kindling by HL7.
the class PageProcessor method genNSList.
private String genNSList() throws Exception {
StringBuilder b = new StringBuilder();
b.append("<p>Redirects on this page:</p>\r\n");
b.append("<ul>\r\n");
b.append(" <li>Resources</li>\r\n");
b.append(" <li>Data Types</li>\r\n");
b.append(" <li>Code Systems</li>\r\n");
b.append(" <li>Value Sets</li>\r\n");
b.append(" <li>Extensions</li>\r\n");
b.append(" <li>Profiles</li>\r\n");
b.append(" <li>Naming Systems</li>\r\n");
b.append(" <li>Examples</li>\r\n");
b.append(" <li>Compartments</li>\r\n");
b.append(" <li>Data Elements</li>\r\n");
b.append(" <li>Search Parameters</li>\r\n");
b.append(" <li>Implementation Guides</li>\r\n");
b.append(" <li>SIDs</li>\r\n");
b.append(" <li>Others From publish.ini</li>\r\n");
b.append("</ul>\r\n");
b.append("<table class=\"grid\">\r\n");
b.append(" <tr><td><b>URL</b></td><td><b>Thing</b></td><td><b>Page</b></td></tr>");
for (String n : definitions.sortedResourceNames()) definitions.addNs("http://hl7.org/fhir/" + n, n + " Resource", n.toLowerCase() + ".html");
for (String n : definitions.getTypes().keySet()) definitions.addNs("http://hl7.org/fhir/" + n, "Data Type " + n, definitions.getSrcFile(n) + ".html#" + n);
for (String n : definitions.getPrimitives().keySet()) definitions.addNs("http://hl7.org/fhir/" + n, "Primitive Data Type " + n, definitions.getSrcFile(n) + ".html#" + n);
for (String n : definitions.getConstraints().keySet()) definitions.addNs("http://hl7.org/fhir/" + n, "Data Type Profile " + n, definitions.getSrcFile(n) + ".html#" + n);
for (String n : definitions.getInfrastructure().keySet()) definitions.addNs("http://hl7.org/fhir/" + n, "Data Type " + n, definitions.getSrcFile(n) + ".html#" + n);
for (CodeSystem cs : getCodeSystems().getList()) if (cs != null && cs.getUrl().startsWith("http://hl7.org/fhir"))
definitions.addNs(cs.getUrl(), "CodeSystem " + cs.getName(), cs.getUserString("path"));
for (ValueSet vs : getValueSets().getList()) if (vs.getUrl().startsWith("http://hl7.org/fhir"))
definitions.addNs(vs.getUrl(), "ValueSet " + vs.present(), vs.getUserString("path"));
for (ConceptMap cm : getConceptMaps().getList()) if (cm.getUrl().startsWith("http://hl7.org/fhir"))
definitions.addNs(cm.getUrl(), "Concept Map" + cm.getName(), cm.getUserString("path"));
for (StructureDefinition sd : profiles.getList()) if (sd.getUrl().startsWith("http://hl7.org/fhir") && !definitions.getResourceTemplates().containsKey(sd.getName()))
definitions.addNs(sd.getUrl(), "Profile " + sd.getName(), sd.getUserString("path"));
for (StructureDefinition sd : workerContext.getExtensionDefinitions()) if (sd.getUrl().startsWith("http://hl7.org/fhir"))
definitions.addNs(sd.getUrl(), "Profile " + sd.getName(), sd.getUserString("path"));
for (NamingSystem nss : definitions.getNamingSystems()) {
String url = null;
definitions.addNs("http://hl7.org/fhir/NamingSystem/" + nss.getId(), "System " + nss.getName(), nss.getUserString("path"));
for (NamingSystemUniqueIdComponent t : nss.getUniqueId()) {
if (t.getType() == NamingSystemIdentifierType.URI)
url = t.getValue();
}
if (url != null && url.startsWith("http://hl7.org/fhir"))
definitions.addNs(url, "System " + nss.getName(), nss.getUserString("path"));
}
for (String n : ini.getPropertyNames("redirects")) {
String[] parts = ini.getStringProperty("redirects", n).split("\\;");
definitions.addNs(n, "System " + parts[0], parts[1]);
}
for (ImplementationGuideDefn ig : definitions.getIgs().values()) {
if (!ig.isCore()) {
definitions.addNs("http://hl7.org/fhir/ImplementationGuide/" + ig.getCode(), ig.getName(), ig.getHomePage());
definitions.addNs("http://hl7.org/fhir/" + ig.getCode(), ig.getName(), ig.getHomePage());
}
}
for (Compartment t : definitions.getCompartments()) {
definitions.addNs(t.getUri(), t.getName(), "compartmentdefinition.html#" + t.getName());
}
List<String> list = new ArrayList<String>();
list.addAll(definitions.getRedirectList().keySet());
Collections.sort(list);
for (String url : list) {
NamespacePair p = definitions.getRedirectList().get(url);
b.append(" <tr><td>" + Utilities.escapeXml(url) + "</td><td>" + hsplt(Utilities.escapeXml(p.desc)) + "</td><td><a href=\"" + p.page + "\">" + hsplt(Utilities.escapeXml(p.page)) + "</a></td></tr>\r\n");
}
b.append("</table>\r\n");
b.append("<p>" + Integer.toString(list.size()) + " Entries</p>\r\n");
return b.toString();
}
use of org.hl7.fhir.r4b.model.ImplementationGuide in project kindling by HL7.
the class SpreadSheetReloader method processPack.
private void processPack(XSSFSheet src, String ref) throws FHIRFormatError, FileNotFoundException, IOException {
ImplementationGuide ig = (ImplementationGuide) parseXml(fnIG(resourceName + "-" + ref));
ig.getDefinition().getResource().clear();
XSSFRow cols = src.getRow(0);
for (int i = 1; i <= src.getLastRowNum(); i++) {
XSSFRow row = src.getRow(i);
String n = getValue(row, cols, CN_NAME);
String v = getValue(row, cols, CN_VALUE);
if (Utilities.noString(v)) {
v = null;
}
switch(n) {
case CN_ID:
ig.setId(v);
break;
case CN_CODE:
readExt(ig, v, BuildExtensions.EXT_CODE, ExtensionType.Code);
case CN_NAME:
ig.setName(v);
break;
case CN_TITLE:
ig.setTitle(v);
break;
case CN_VERSION:
ig.setVersion(v);
break;
case CN_DESCRIPTION:
ig.setDescription(v);
break;
case CN_PUBLISHER:
ig.setPublisher(v);
break;
case CN_STATUS:
ig.setStatus(PublicationStatus.fromCode(v));
break;
case CN_EXPERIMENTAL:
ig.getExperimentalElement().setValueAsString(v);
break;
case CN_DATE:
ig.getDateElement().setValueAsString(v);
break;
case CN_FMM:
readExt(ig, v, BuildExtensions.EXT_FMM_LEVEL, ExtensionType.Integer);
break;
case CN_WORK_GROUP:
readExt(ig, v, BuildExtensions.EXT_WORKGROUP, ExtensionType.Code);
break;
case CN_INTRODUCTION:
readExt(ig, v, BuildExtensions.EXT_INTRODUCTION, ExtensionType.String);
break;
case CN_NOTES:
readExt(ig, v, BuildExtensions.EXT_NOTES, ExtensionType.String);
break;
case CN_EXTENSION:
if (v != null) {
ig.getDefinition().addResource().getReference().setReference("StructureDefinition/" + v);
}
break;
case CN_PROFILE:
if (v != null) {
ig.getDefinition().addResource().getReference().setReference("StructureDefinition/" + v);
}
break;
case CN_EXAMPLE:
if (v != null) {
ig.getDefinition().addResource().getReference().setReference(v);
}
break;
case CN_SEARCH_PARAMETER:
if (v != null) {
ig.getDefinition().addResource().getReference().setReference("SearchParameter/" + v);
}
break;
}
}
saveXml(fnIG(resourceName + "-" + ref), ig);
}
use of org.hl7.fhir.r4b.model.ImplementationGuide in project kindling by HL7.
the class SpreadSheetReloader method processPacks.
private void processPacks(XSSFWorkbook excel) throws FHIRFormatError, FileNotFoundException, IOException {
ListResource list = (ListResource) parseXml(fnPacks());
list.getEntry().clear();
for (int i = 0; i < excel.getNumberOfSheets(); i++) {
XSSFSheet sheet = excel.getSheetAt(i);
if (sheet.getSheetName().startsWith("Pack ")) {
String n = sheet.getSheetName().substring(5);
list.addEntry().getItem().setReference("ImplementationGuide/" + resourceName + "-" + n);
processPack(sheet, n);
}
}
saveXml(fnPacks(), list);
}
use of org.hl7.fhir.r4b.model.ImplementationGuide in project kindling by HL7.
the class Regenerator method generateCP.
private void generateCP(String root, ResourceDefn r, Profile p) throws IOException {
ImplementationGuide ig = new ImplementationGuide();
ig.setId(r.getName() + "-" + p.getCategory());
ig.setTitle(p.getTitle());
ig.setStatus(PublicationStatus.ACTIVE);
ig.setDate(new Date(r.getTimestamp()));
for (String s : p.getMetadata().keySet()) {
List<String> vl = p.getMetadata().get(s);
for (String v : vl) {
if (!Utilities.noString(v)) {
switch(s) {
// case "id": ig.setId(v); break;
case "name":
ig.setName(v);
break;
case "author.name":
ig.setPublisher(v);
break;
case "code":
ig.addExtension(BuildExtensions.EXT_CODE, new CodeType(v));
break;
case "fmm":
ig.addExtension(ToolingExtensions.EXT_FMM_LEVEL, new CodeType(v));
break;
case "description":
ig.setDescription(v);
break;
case "status":
ig.setStatus(PublicationStatus.fromCode(v));
break;
case "publication.status":
break;
case "version":
ig.setVersion(v);
break;
case "display":
ig.setTitle(v);
break;
case "workgroup":
ig.addExtension(ToolingExtensions.EXT_WORKGROUP, new CodeType(v));
break;
case "date":
ig.getDateElement().setValueAsString(v);
break;
case "Experimental":
ig.setExperimental(Utilities.existsInList(v.toLowerCase(), "y", "yes", "1", "true"));
break;
default:
if (s.startsWith("fmm-") || Utilities.existsInList(s, "extension.uri", "author.reference", "published.structure", "notes", "introduction") || s.startsWith("!")) {
// ignore these
} else if (s.startsWith("summary-")) {
String n = s.substring(8);
for (ConstraintStructure cs : p.getProfiles()) {
if (n.equals(cs.getTitle()) || n.equals(cs.getId())) {
cs.setSummary(v);
}
}
} else {
System.out.println("Unknown metadata item: " + s + "=" + v);
}
}
}
}
}
if (!Utilities.noString(p.getIntroduction())) {
ig.addExtension(BuildExtensions.EXT_INTRODUCTION, new StringType(p.getIntroduction()));
}
if (!Utilities.noString(p.getNotes())) {
ig.addExtension(BuildExtensions.EXT_NOTES, new StringType(p.getNotes()));
}
for (ConstraintStructure cs : p.getProfiles()) {
CanonicalResource cr = generateProfile(root, r, p, cs);
ImplementationGuideDefinitionResourceComponent res = ig.getDefinition().addResource();
res.getReference().setReference(cr.fhirType() + "/" + cr.getId());
}
for (StructureDefinition cs : p.getExtensions()) {
CanonicalResource cr = generateExtension(root, r, p, cs.copy());
ImplementationGuideDefinitionResourceComponent res = ig.getDefinition().addResource();
res.getReference().setReference(cr.fhirType() + "/" + cr.getId());
}
for (SearchParameter cs : p.getSearchParameters()) {
CanonicalResource cr = generateSearchParameter(root, r, p, cs);
ImplementationGuideDefinitionResourceComponent res = ig.getDefinition().addResource();
res.getReference().setReference(cr.fhirType() + "/" + cr.getId());
}
for (Example cs : p.getExamples()) {
ImplementationGuideDefinitionResourceComponent res = ig.getDefinition().addResource();
generateExample(root, r, p, cs, res);
}
File fn = new File(Utilities.path(root, ig.fhirType().toLowerCase() + "-" + ig.getId() + ".gen.xml"));
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(fn), ig);
fn.setLastModified(r.getTimestamp());
}
use of org.hl7.fhir.r4b.model.ImplementationGuide in project kindling by HL7.
the class ResourceParser method parsePacks.
private void parsePacks(ResourceDefn r, String n, String t) throws Exception {
Set<String> codes = new HashSet<>();
ListResource list = (ListResource) parseXml("list-" + t + "-packs.xml");
for (ListResourceEntryComponent le : list.getEntry()) {
String id = le.getItem().getReference().substring(le.getItem().getReference().indexOf("/") + 1);
if (codes.contains(id)) {
throw new FHIRException("Duplicate code " + id + " for resource " + n);
}
codes.add(id);
ImplementationGuide ig = (ImplementationGuide) parseXml("implementationguide-" + id + ".xml");
if (!id.startsWith(r.getName() + "-")) {
throw new FHIRException("Illegal ig name " + id + " - should start with " + r.getName() + "-");
}
id = id.substring(t.length() + 1);
r.getConformancePackages().add(convertPack(ig, id, r.getWg()));
}
}
Aggregations