use of org.hl7.fhir.dstu2016may.model.Narrative in project kindling by HL7.
the class Publisher method fixExampleReferences.
private String fixExampleReferences(String path, String narrative) throws Exception {
if (narrative == null)
return "";
XhtmlNode node = new XhtmlParser().parseFragment(narrative);
checkExampleLinks(path, node);
return new XhtmlComposer(XhtmlComposer.HTML).compose(node);
}
use of org.hl7.fhir.dstu2016may.model.Narrative in project kindling by HL7.
the class Publisher method addToResourceFeed.
private void addToResourceFeed(CapabilityStatement cs, Bundle dest) throws Exception {
if (cs.getId() == null)
throw new Exception("Resource has no id");
if (ResourceUtilities.getById(dest, ResourceType.ValueSet, cs.getId()) != null)
throw new Exception("Attempt to add duplicate Conformance " + cs.getId());
if (!cs.hasText() || !cs.getText().hasDiv()) {
RendererFactory.factory(cs, page.getRc().copy()).render(cs);
}
if (!cs.hasText() || cs.getText().getDiv() == null)
System.out.println("WARNING: Example CapabilityStatement " + cs.getId() + " does not have any narrative");
// Changed this from an exception to a warning because generateConformanceStatement doesn't produce narrative if
// "register" is 'false'
ResourceUtilities.meta(cs).setLastUpdated(page.getGenDate().getTime());
if (!cs.getUrl().equals("http://hl7.org/fhir/" + cs.getResourceType().toString() + "/" + cs.getId()))
throw new Exception("URL mismatch on CapabilityStatement");
dest.getEntry().add(new BundleEntryComponent().setResource(cs).setFullUrl("http://hl7.org/fhir/" + cs.fhirType() + "/" + cs.getId()));
}
use of org.hl7.fhir.dstu2016may.model.Narrative in project kindling by HL7.
the class ProfileGenerator method generateLogicalModel.
public StructureDefinition generateLogicalModel(ImplementationGuideDefn igd, ResourceDefn r) throws Exception {
StructureDefinition p = new StructureDefinition();
p.setId(r.getRoot().getName());
p.setUrl("http://hl7.org/fhir/StructureDefinition/" + r.getRoot().getName());
p.setKind(StructureDefinitionKind.LOGICAL);
p.setAbstract(false);
p.setUserData("filename", r.getName().toLowerCase());
p.setUserData("path", igd.getPrefix() + r.getName().toLowerCase() + ".html");
p.setTitle(r.getName());
p.setFhirVersion(version);
p.setVersion(version.toCode());
p.setType(r.getRoot().getName());
ToolingExtensions.setStandardsStatus(p, r.getStatus(), null);
ToolResourceUtilities.updateUsage(p, igd.getCode());
p.setName(r.getRoot().getName());
p.setPublisher("Health Level Seven International" + (r.getWg() == null ? " " + igd.getCommittee() : " (" + r.getWg().getName() + ")"));
p.addContact().getTelecom().add(Factory.newContactPoint(ContactPointSystem.URL, "http://hl7.org/fhir"));
if (r.getWg() != null) {
p.addContact().getTelecom().add(Factory.newContactPoint(ContactPointSystem.URL, r.getWg().getUrl()));
ToolingExtensions.setCodeExtension(p, ToolingExtensions.EXT_WORKGROUP, r.getWg().getCode());
}
p.setDescription("Logical Model: " + r.getDefinition());
p.setPurpose(r.getRoot().getRequirements());
if (!p.hasPurpose())
p.setPurpose(r.getRoot().getRequirements());
p.setDate(genDate.getTime());
// DSTU
p.setStatus(PublicationStatus.fromCode("draft"));
Set<String> containedSlices = new HashSet<String>();
// first, the differential
p.setSnapshot(new StructureDefinitionSnapshotComponent());
defineElement(null, p, p.getSnapshot().getElement(), r.getRoot(), r.getRoot().getName(), containedSlices, new ArrayList<ProfileGenerator.SliceHandle>(), SnapShotMode.None, true, "Element", "Element", true);
addElementConstraintToSnapshot(p);
XhtmlNode div = new XhtmlNode(NodeType.Element, "div");
div.addText("to do");
p.setText(new Narrative());
p.getText().setStatus(NarrativeStatus.GENERATED);
p.getText().setDiv(div);
return p;
}
use of org.hl7.fhir.dstu2016may.model.Narrative in project kindling by HL7.
the class ProfileGenerator method generate.
public StructureDefinition generate(TypeDefn t) throws Exception {
genUml(t);
StructureDefinition p = new StructureDefinition();
p.setId(t.getName());
p.setUrl("http://hl7.org/fhir/StructureDefinition/" + t.getName());
p.setKind(StructureDefinitionKind.COMPLEXTYPE);
p.setAbstract(t.isAbstractType());
p.setUserData("filename", t.getName().toLowerCase());
p.setUserData("path", definitions.getSrcFile(t.getName()) + ".html#" + t.getName());
assert !Utilities.noString(t.typeCode());
String b = (t.typeCode().equals("Type") ? "Element" : t.typeCode().equals("Structure") ? "BackboneElement" : t.typeCode());
if (!Utilities.noString(b)) {
p.setBaseDefinition("http://hl7.org/fhir/StructureDefinition/" + b);
p.setDerivation(TypeDerivationRule.SPECIALIZATION);
}
p.setType(t.getName());
p.setFhirVersion(version);
p.setVersion(version.toCode());
ToolingExtensions.setStandardsStatus(p, t.getStandardsStatus(), t.getNormativeVersion());
ToolResourceUtilities.updateUsage(p, "core");
p.setName(t.getName());
p.setPublisher("HL7 FHIR Standard");
p.addContact().getTelecom().add(Factory.newContactPoint(ContactPointSystem.URL, "http://hl7.org/fhir"));
p.setDescription("Base StructureDefinition for " + t.getName() + " Type: " + t.getDefinition());
p.setPurpose(t.getRequirements());
p.setDate(genDate.getTime());
p.setStatus(t.getStandardsStatus() == StandardsStatus.NORMATIVE ? PublicationStatus.fromCode("active") : PublicationStatus.fromCode("draft"));
Set<String> containedSlices = new HashSet<String>();
// first, the differential
p.setDifferential(new StructureDefinitionDifferentialComponent());
defineElement(null, p, p.getDifferential().getElement(), t, t.getName(), containedSlices, new ArrayList<ProfileGenerator.SliceHandle>(), SnapShotMode.None, true, "Element", b, false);
p.getDifferential().getElement().get(0).setIsSummaryElement(null);
reset();
// now. the snapshot
p.setSnapshot(new StructureDefinitionSnapshotComponent());
defineElement(null, p, p.getSnapshot().getElement(), t, t.getName(), containedSlices, new ArrayList<ProfileGenerator.SliceHandle>(), SnapShotMode.DataType, true, "Element", b, true);
for (ElementDefinition ed : p.getSnapshot().getElement()) if (ed.getBase().getPath().equals(ed.getPath()) && ed.getPath().contains("."))
generateElementDefinition(p, ed, getParent(ed, p.getSnapshot().getElement()));
containedSlices.clear();
addElementConstraintToSnapshot(p);
p.getDifferential().getElement().get(0).getType().clear();
p.getSnapshot().getElement().get(0).getType().clear();
p.getSnapshot().getElement().get(0).setIsSummaryElement(null);
XhtmlNode div = new XhtmlNode(NodeType.Element, "div");
div.addText("to do");
p.setText(new Narrative());
p.getText().setStatus(NarrativeStatus.GENERATED);
p.getText().setDiv(div);
checkHasTypes(p);
return p;
}
use of org.hl7.fhir.dstu2016may.model.Narrative in project kindling by HL7.
the class ProfileGenerator method generate.
public StructureDefinition generate(DefinedStringPattern type) throws Exception {
genUml(type);
StructureDefinition p = new StructureDefinition();
p.setId(type.getCode());
p.setUrl("http://hl7.org/fhir/StructureDefinition/" + type.getCode());
p.setBaseDefinition("http://hl7.org/fhir/StructureDefinition/" + type.getBase());
p.setType(type.getCode());
p.setDerivation(TypeDerivationRule.SPECIALIZATION);
p.setKind(StructureDefinitionKind.PRIMITIVETYPE);
p.setAbstract(false);
p.setUserData("filename", type.getCode().toLowerCase());
p.setUserData("path", "datatypes.html#" + type.getCode());
p.setFhirVersion(version);
p.setVersion(version.toCode());
ToolingExtensions.setStandardsStatus(p, StandardsStatus.NORMATIVE, "4.0.0");
ToolResourceUtilities.updateUsage(p, "core");
p.setName(type.getCode());
p.setPublisher("HL7 FHIR Standard");
p.addContact().getTelecom().add(Factory.newContactPoint(ContactPointSystem.URL, "http://hl7.org/fhir"));
p.setDescription("Base StructureDefinition for " + type.getCode() + " type: " + type.getDefinition());
p.setDate(genDate.getTime());
p.setStatus(PublicationStatus.fromCode("active"));
Set<String> containedSlices = new HashSet<String>();
// first, the differential
p.setDifferential(new StructureDefinitionDifferentialComponent());
ElementDefinition ec1 = new ElementDefinition();
p.getDifferential().getElement().add(ec1);
ec1.setId(type.getCode());
ec1.setPath(type.getCode());
ec1.setShort("Primitive Type " + type.getCode());
ec1.setDefinition(type.getDefinition());
ec1.setComment(type.getComment());
ec1.setMin(0);
ec1.setMax("*");
ElementDefinition ec2 = new ElementDefinition();
p.getDifferential().getElement().add(ec2);
ec2.setId(type.getCode() + ".value");
ec2.setPath(type.getCode() + ".value");
ec2.addRepresentation(PropertyRepresentation.XMLATTR);
ec2.setShort("Primitive value for " + type.getCode());
ec2.setDefinition("Primitive value for " + type.getCode());
ec2.setMin(0);
ec2.setMax("1");
TypeRefComponent t = ec2.addType();
t.setCodeElement(new UriType());
t.getFormatCommentsPre().add("Note: special primitive values have a FHIRPath system type. e.g. this is compiler magic (g)");
t.setCode(Constants.NS_SYSTEM_TYPE + type.getFHIRPathType());
ToolingExtensions.addUriExtension(t, ToolingExtensions.EXT_FHIR_TYPE, type.getCode());
if (!Utilities.noString(type.getRegex())) {
ToolingExtensions.addStringExtension(t, ToolingExtensions.EXT_REGEX, type.getRegex());
}
reset();
// now. the snapshot
p.setSnapshot(new StructureDefinitionSnapshotComponent());
ElementDefinition ecA = new ElementDefinition(true, ElementDefinition.NOT_MODIFIER, ElementDefinition.NOT_IN_SUMMARY);
p.getSnapshot().getElement().add(ecA);
ecA.setId(type.getCode());
ecA.setPath(type.getCode());
ecA.setShort("Primitive Type " + type.getCode());
ecA.setDefinition(type.getDefinition());
ecA.setComment(type.getComment());
ecA.setMin(0);
ecA.setMax("*");
ecA.makeBase(type.getCode(), 0, "*");
addElementConstraints("Element", ecA);
ElementDefinition ecid = new ElementDefinition(true, ElementDefinition.NOT_MODIFIER, ElementDefinition.NOT_IN_SUMMARY);
p.getSnapshot().getElement().add(ecid);
ecid.setId(type.getCode() + ".id");
ecid.setPath(type.getCode() + ".id");
ecid.addRepresentation(PropertyRepresentation.XMLATTR);
ecid.setDefinition("unique id for the element within a resource (for internal references)");
ecid.setMin(0);
ecid.setMax("1");
ecid.setShort("xml:id (or equivalent in JSON)");
TypeRefComponent tr = ecid.addType();
tr.getFormatCommentsPre().add("Note: special primitive values have a FHIRPath system type. e.g. this is compiler magic (h)");
tr.setCode(Constants.NS_SYSTEM_TYPE + "String");
ToolingExtensions.addUriExtension(tr, ToolingExtensions.EXT_FHIR_TYPE, "string");
ecid.makeBase("Element.id", 0, "1");
makeExtensionSlice("extension", p, p.getSnapshot(), null, type.getCode());
ElementDefinition ecB = new ElementDefinition(true, ElementDefinition.NOT_MODIFIER, ElementDefinition.NOT_IN_SUMMARY);
p.getSnapshot().getElement().add(ecB);
ecB.setPath(type.getCode() + ".value");
ecB.setId(type.getCode() + ".value");
ecB.addRepresentation(PropertyRepresentation.XMLATTR);
ecB.setDefinition("Primitive value for " + type.getCode());
ecB.setShort("Primitive value for " + type.getCode());
ecB.setMin(0);
ecB.setMax("1");
ecB.makeBase(type.getBase() + ".value", 0, "1");
t = ecB.addType();
t.getFormatCommentsPre().add("Note: special primitive values have a FHIRPath system type. e.g. this is compiler magic (i)");
t.setCode(Constants.NS_SYSTEM_TYPE + "String");
ToolingExtensions.addUriExtension(t, ToolingExtensions.EXT_FHIR_TYPE, "string");
if (!Utilities.noString(type.getRegex()))
ToolingExtensions.addStringExtension(t, ToolingExtensions.EXT_REGEX, type.getRegex());
// generateElementDefinition(ecB, ecA);
containedSlices.clear();
addElementConstraintToSnapshot(p);
XhtmlNode div = new XhtmlNode(NodeType.Element, "div");
div.addText("to do");
p.setText(new Narrative());
p.getText().setStatus(NarrativeStatus.GENERATED);
p.getText().setDiv(div);
checkHasTypes(p);
return p;
}
Aggregations