use of org.hl7.fhir.r4b.model.Extension in project kindling by HL7.
the class SpreadSheetCreator method exlist.
private String exlist(OperationDefinition opd, boolean isResponse, String lcode) {
sortExtensions(opd);
List<String> tl = new ArrayList<>();
for (Extension ext : opd.getExtensionsByUrl(BuildExtensions.EXT_OP_EXAMPLE)) {
String list = ext.getExtensionString(BuildExtensions.EXT_OP_EXAMPLE_LIST);
String resp = ext.getExtensionString(BuildExtensions.EXT_OP_EXAMPLE_RESPONSE);
if (lcode.equals(list) && ("true".equals(resp)) == isResponse) {
tl.add(ext.getExtensionString(BuildExtensions.EXT_OP_EXAMPLE_CONTENT));
}
}
return String.join(" | ", tl);
}
use of org.hl7.fhir.r4b.model.Extension in project kindling by HL7.
the class ExtensionDefinitionValidator method checkNoValueAndExtensions.
private void checkNoValueAndExtensions(StructureDefinition sd) throws FHIRException {
boolean hasValue = false;
for (ElementDefinition ed : sd.getSnapshot().getElement()) {
if (ed.getPath().startsWith("Extension.value")) {
if (!ed.getMax().equals("0")) {
hasValue = true;
}
}
}
if (hasValue) {
for (ElementDefinition ed : sd.getSnapshot().getElement()) {
if (ed.getPath().equals("Extension.extension")) {
ed.setMax("0");
}
if (ed.getPath().startsWith("Extension.extension.")) {
throw new FHIRException("The extension " + sd.getUrl() + " has both value and extensions");
}
}
boolean found = false;
int ip = 0;
for (ElementDefinition ed : sd.getDifferential().getElement()) {
if (ed.getPath().equals("Extension.extension")) {
ed.setMax("0");
found = true;
}
if (ed.getPath().equals("Extension") || ed.getPath().equals("Extension.id"))
ip++;
}
if (!found) {
ElementDefinition ed = new ElementDefinition();
ed.setPath("Extension.extension");
ed.setMax("0");
sd.getDifferential().getElement().add(ip, ed);
}
}
}
use of org.hl7.fhir.r4b.model.Extension in project kindling by HL7.
the class Regenerator method generateExtension.
private CanonicalResource generateExtension(String root, ResourceDefn r, Profile p, StructureDefinition sd) throws IOException {
File fn = new File(Utilities.path(root, sd.fhirType().toLowerCase() + "-extension-" + sd.getId() + ".gen.xml"));
sd.setSnapshot(null);
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(fn), sd);
fn.setLastModified(r.getTimestamp());
return sd;
}
use of org.hl7.fhir.r4b.model.Extension in project kindling by HL7.
the class ResourceParser method convertOperationParameter.
public OperationParameter convertOperationParameter(OperationDefinitionParameterComponent psrc, boolean part) throws IOException {
List<String> pl = new ArrayList<>();
for (CanonicalType u : psrc.getTargetProfile()) {
pl.add(u.asStringValue().replace("http://hl7.org/fhir/StructureDefinition/", ""));
}
String t;
if (psrc.hasExtension(BuildExtensions.EXT_ALLOWED_TYPE)) {
for (Extension e : psrc.getExtensionsByUrl(BuildExtensions.EXT_ALLOWED_TYPE)) {
pl.add(e.getValue().primitiveValue());
}
t = String.join(" | ", pl);
} else if (psrc.hasType()) {
t = psrc.getType().toCode();
if (pl.size() > 0) {
t = t + "(" + String.join("|", pl) + ")";
}
} else {
t = "Tuple";
}
OperationParameter p = new OperationParameter(psrc.getName(), part ? null : psrc.getUse().toCode(), psrc.getDocumentation(), psrc.getMin(), psrc.getMax(), t, psrc.hasSearchType() ? psrc.getSearchType().toCode() : null, null);
if (psrc.hasBinding()) {
p.setBs(parseBinding(psrc.getBinding()));
}
for (OperationDefinitionParameterComponent pc : psrc.getPart()) {
p.getParts().add(convertOperationParameter(pc, true));
}
return p;
}
use of org.hl7.fhir.r4b.model.Extension in project kindling by HL7.
the class SvgGenerator method determineMetrics.
private Point determineMetrics(String[] classNames) throws Exception {
double width = textWidth("Element") * 1.8;
double height = HEADER_HEIGHT + GAP_HEIGHT * 2;
// if ("true".equals(ini.getStringProperty("diagram", "element-attributes"))) {
// height = height + LINE_HEIGHT + GAP_HEIGHT;
// width = textWidth("extension : Extension 0..*");
// }
Point p = new Point(0, 0, PointKind.unknown);
ClassItem item = new ClassItem(p.x, p.y, width, height, id);
classes.put(null, item);
double x = item.right() + MARGIN_X;
double y = item.bottom() + MARGIN_Y;
if (classNames != null) {
for (String cn : classNames) {
if (definitions.getPrimitives().containsKey(cn)) {
DefinedCode cd = definitions.getPrimitives().get(cn);
ElementDefn fake = new ElementDefn();
fake.setName(cn);
fakes.put(cn, fake);
if (cd instanceof DefinedStringPattern)
p = determineMetrics(fake, classes.get(fakes.get(((DefinedStringPattern) cd).getBase())), cn, false, cd);
else
p = determineMetrics(fake, item, cn, false, cd);
} else if ("xhtml".equals(cn)) {
ElementDefn fake = new ElementDefn();
fake.setName("xhtml");
fakes.put("xhtml", fake);
DefinedCode cd = new DefinedCode("xhtml", "XHTML for resource narrative", null);
p = determineMetrics(fake, item, cn, false, cd);
} else if (definitions.getConstraints().containsKey(cn)) {
ProfiledType cd = definitions.getConstraints().get(cn);
ElementDefn ed = definitions.getElementDefn(cd.getBaseType());
ClassItem parentClss = classes.get(ed);
ElementDefn fake = new ElementDefn();
fake.setName(cn);
fakes.put(cn, fake);
p = determineMetrics(fake, parentClss, cn, false, null);
} else {
ElementDefn c = definitions.getElementDefn(cn);
p = determineMetrics(c, item, c.getName(), false, null);
}
x = Math.max(x, p.x + MARGIN_X);
y = Math.max(y, p.y + MARGIN_Y);
}
}
return new Point(x, y, PointKind.unknown);
}
Aggregations