use of org.hl7.fhir.r5.model.CompartmentDefinition.CompartmentDefinitionResourceComponent in project kindling by HL7.
the class Publisher method generateCompartmentDefinition.
private void generateCompartmentDefinition(Compartment c) throws Exception {
CompartmentDefinition cpd = new CompartmentDefinition();
cpd.setId(c.getName());
cpd.setUrl("http://hl7.org/fhir/CompartmentDefinition/" + c.getName());
cpd.setName("Base FHIR compartment definition for " + c.getTitle());
cpd.setStatus(PublicationStatus.DRAFT);
cpd.setDescription(c.getIdentity() + ". " + c.getDescription());
cpd.setExperimental(true);
cpd.setVersion(page.getVersion().toCode());
cpd.setDate(page.getGenDate().getTime());
cpd.setPublisher("FHIR Project Team");
cpd.addContact().getTelecom().add(Factory.newContactPoint(ContactPointSystem.URL, "http://hl7.org/fhir"));
cpd.setCode(CompartmentType.fromCode(c.getTitle()));
cpd.setSearch(true);
for (String rn : page.getDefinitions().sortedResourceNames()) {
ResourceDefn rd = page.getDefinitions().getResourceByName(rn);
String rules = c.getResources().get(rd);
CompartmentDefinitionResourceComponent cc = cpd.addResource().setCode(rd.getName());
if (!Utilities.noString(rules)) {
for (String p : rules.split("\\|")) cc.addParam(p.trim());
}
}
RenderingContext lrc = page.getRc().copy().setLocalPrefix("").setTooCostlyNoteEmpty(PageProcessor.TOO_MANY_CODES_TEXT_EMPTY).setTooCostlyNoteNotEmpty(PageProcessor.TOO_MANY_CODES_TEXT_NOT_EMPTY);
RendererFactory.factory(cpd, lrc).render(cpd);
FileOutputStream s = new FileOutputStream(page.getFolders().dstDir + "compartmentdefinition-" + c.getName().toLowerCase() + ".xml");
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(s, cpd);
s.close();
s = new FileOutputStream(page.getFolders().dstDir + "compartmentdefinition-" + c.getName().toLowerCase() + ".canonical.xml");
new XmlParser().setOutputStyle(OutputStyle.CANONICAL).compose(s, cpd);
s.close();
cloneToXhtml("compartmentdefinition-" + c.getName().toLowerCase(), "Compartment Definition for " + c.getName(), true, "resource-instance:CompartmentDefinition", "Compartment Definition for " + c.getName(), null, wg("fhir"));
s = new FileOutputStream(page.getFolders().dstDir + "compartmentdefinition-" + c.getName().toLowerCase() + ".json");
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(s, cpd);
s.close();
s = new FileOutputStream(page.getFolders().dstDir + "compartmentdefinition-" + c.getName().toLowerCase() + ".canonical.json");
new JsonParser().setOutputStyle(OutputStyle.CANONICAL).compose(s, cpd);
s.close();
jsonToXhtml("compartmentdefinition-" + c.getName().toLowerCase(), "Compartment Definition for " + c.getName(), resource2Json(cpd), "resource-instance:CompartmentDefinition", "Compartment Definition for " + c.getName(), null, wg("fhir"));
s = new FileOutputStream(page.getFolders().dstDir + "compartmentdefinition-" + c.getName().toLowerCase() + ".ttl");
new RdfParser().setOutputStyle(OutputStyle.PRETTY).compose(s, cpd);
s.close();
ttlToXhtml("compartmentdefinition-" + c.getName().toLowerCase(), "Compartment Definition for " + c.getName(), resource2Ttl(cpd), "resource-instance:CompartmentDefinition", "Compartment Definition for " + c.getName(), null, wg("fhir"));
Utilities.copyFile(new CSFile(page.getFolders().dstDir + "compartmentdefinition-" + c.getName().toLowerCase() + ".xml"), new CSFile(page.getFolders().dstDir + "examples" + File.separator + "compartmentdefinition-" + c.getName().toLowerCase() + ".xml"));
addToResourceFeed(cpd, page.getResourceBundle());
}
use of org.hl7.fhir.r5.model.CompartmentDefinition.CompartmentDefinitionResourceComponent in project org.hl7.fhir.core by hapifhir.
the class CompartmentDefinition method setProperty.
@Override
public Base setProperty(String name, Base value) throws FHIRException {
if (name.equals("url")) {
// UriType
this.url = castToUri(value);
} else if (name.equals("name")) {
// StringType
this.name = castToString(value);
} else if (name.equals("title")) {
// StringType
this.title = castToString(value);
} else if (name.equals("status")) {
value = new PublicationStatusEnumFactory().fromType(castToCode(value));
// Enumeration<PublicationStatus>
this.status = (Enumeration) value;
} else if (name.equals("experimental")) {
// BooleanType
this.experimental = castToBoolean(value);
} else if (name.equals("date")) {
// DateTimeType
this.date = castToDateTime(value);
} else if (name.equals("publisher")) {
// StringType
this.publisher = castToString(value);
} else if (name.equals("contact")) {
this.getContact().add(castToContactDetail(value));
} else if (name.equals("description")) {
// MarkdownType
this.description = castToMarkdown(value);
} else if (name.equals("purpose")) {
// MarkdownType
this.purpose = castToMarkdown(value);
} else if (name.equals("useContext")) {
this.getUseContext().add(castToUsageContext(value));
} else if (name.equals("jurisdiction")) {
this.getJurisdiction().add(castToCodeableConcept(value));
} else if (name.equals("code")) {
value = new CompartmentTypeEnumFactory().fromType(castToCode(value));
// Enumeration<CompartmentType>
this.code = (Enumeration) value;
} else if (name.equals("search")) {
// BooleanType
this.search = castToBoolean(value);
} else if (name.equals("resource")) {
this.getResource().add((CompartmentDefinitionResourceComponent) value);
} else
return super.setProperty(name, value);
return value;
}
use of org.hl7.fhir.r5.model.CompartmentDefinition.CompartmentDefinitionResourceComponent in project org.hl7.fhir.core by hapifhir.
the class NarrativeGenerator method generate.
public boolean generate(ResourceContext rcontext, CompartmentDefinition cpd) {
StringBuilder in = new StringBuilder();
StringBuilder out = new StringBuilder();
for (CompartmentDefinitionResourceComponent cc : cpd.getResource()) {
CommaSeparatedStringBuilder rules = new CommaSeparatedStringBuilder();
if (!cc.hasParam()) {
out.append(" <li><a href=\"").append(cc.getCode().toLowerCase()).append(".html\">").append(cc.getCode()).append("</a></li>\r\n");
} else if (!rules.equals("{def}")) {
for (StringType p : cc.getParam()) rules.append(p.asStringValue());
in.append(" <tr><td><a href=\"").append(cc.getCode().toLowerCase()).append(".html\">").append(cc.getCode()).append("</a></td><td>").append(rules.toString()).append("</td></tr>\r\n");
}
}
XhtmlNode x;
try {
x = new XhtmlParser().parseFragment("<div><p>\r\nThe following resources may be in this compartment:\r\n</p>\r\n" + "<table class=\"grid\">\r\n" + " <tr><td><b>Resource</b></td><td><b>Inclusion Criteria</b></td></tr>\r\n" + in.toString() + "</table>\r\n" + "<p>\r\nA resource is in this compartment if the nominated search parameter (or chain) refers to the patient resource that defines the compartment.\r\n</p>\r\n" + "<p>\r\n\r\n</p>\r\n" + "<p>\r\nThe following resources are never in this compartment:\r\n</p>\r\n" + "<ul>\r\n" + out.toString() + "</ul></div>\r\n");
inject(cpd, x, NarrativeStatus.GENERATED);
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
use of org.hl7.fhir.r5.model.CompartmentDefinition.CompartmentDefinitionResourceComponent in project org.hl7.fhir.core by hapifhir.
the class NarrativeGenerator method generate.
public boolean generate(ResourceContext rcontext, CompartmentDefinition cpd) {
StringBuilder in = new StringBuilder();
StringBuilder out = new StringBuilder();
for (CompartmentDefinitionResourceComponent cc : cpd.getResource()) {
CommaSeparatedStringBuilder rules = new CommaSeparatedStringBuilder();
if (!cc.hasParam()) {
out.append(" <li><a href=\"").append(cc.getCode().toLowerCase()).append(".html\">").append(cc.getCode()).append("</a></li>\r\n");
} else if (!rules.equals("{def}")) {
for (StringType p : cc.getParam()) rules.append(p.asStringValue());
in.append(" <tr><td><a href=\"").append(cc.getCode().toLowerCase()).append(".html\">").append(cc.getCode()).append("</a></td><td>").append(rules.toString()).append("</td></tr>\r\n");
}
}
XhtmlNode x;
try {
x = new XhtmlParser().parseFragment("<div><p>\r\nThe following resources may be in this compartment:\r\n</p>\r\n" + "<table class=\"grid\">\r\n" + " <tr><td><b>Resource</b></td><td><b>Inclusion Criteria</b></td></tr>\r\n" + in.toString() + "</table>\r\n" + "<p>\r\nA resource is in this compartment if the nominated search parameter (or chain) refers to the patient resource that defines the compartment.\r\n</p>\r\n" + "<p>\r\n\r\n</p>\r\n" + "<p>\r\nThe following resources are never in this compartment:\r\n</p>\r\n" + "<ul>\r\n" + out.toString() + "</ul></div>\r\n");
inject(cpd, x, NarrativeStatus.GENERATED);
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
Aggregations