use of org.hl7.fhir.r4.model.OperationDefinition in project kindling by HL7.
the class PageProcessor method genOperationInner.
public void genOperationInner(String n, String id, boolean mixed, StandardsStatus resStatus, String prefix, String np, StringBuilder b, Operation op, boolean header) throws Exception {
if (header)
b.append("<h3>").append(Utilities.escapeXml(op.getTitle())).append("<a name=\"").append(op.getName()).append("\"> </a></h3>\r\n");
if (mixed)
b.append(opStandardsStatusNotice(n, op.getStandardsStatus(), resStatus, np, prefix) + "\r\n");
b.append(processMarkdown(n, op.getDoco(), prefix, true) + "\r\n");
b.append("<p>The official URL for this operation definition is</p>\r\n<pre> http://hl7.org/fhir/OperationDefinition/" + n + "-" + op.getName() + "</pre>\r\n");
b.append("<p><a href=\"operation-" + id + "-" + op.getName().toLowerCase() + ".html\">Formal Definition</a> (as a <a href=\"" + prefix + "operationdefinition.html\">OperationDefinition</a>).</p>\r\n");
if (op.isSystem())
b.append("<p>URL: [base]/$").append(op.getName()).append("</p>\r\n");
if (op.isType())
b.append("<p>URL: [base]/").append(checkWrap(n)).append("/$").append(op.getName()).append("</p>\r\n");
if (op.isInstance())
b.append("<p>URL: [base]/").append(checkWrap(n)).append("/[id]/$").append(op.getName()).append("</p>\r\n");
if (op.getIdempotent())
b.append("<p>This is an idempotent operation</p>\r\n");
else
b.append("<p>This is <b>not</b> an idempotent operation</p>\r\n");
if (!op.getParameters().isEmpty()) {
b.append("<table class=\"grid\">\r\n");
if (hasParameters(op.getParameters(), "In")) {
genParameterHeader(b, "In");
for (OperationParameter p : op.getParameters()) genOperationParameter(n, "In", "", b, op, p, prefix);
}
if (hasParameters(op.getParameters(), "Out")) {
genParameterHeader(b, "Out");
for (OperationParameter p : op.getParameters()) genOperationParameter(n, "Out", "", b, op, p, prefix);
}
b.append("</table>\r\n");
}
b.append(processMarkdown(n, op.getFooter(), prefix)).append("\r\n");
if (op.getExamples().size() > 0) {
b.append("<a name=\"examples\"> </a>\r\n<h4>Examples</h4>\r\n");
boolean needsHr = false;
boolean hasHr = false;
for (OperationExample ex : op.getExamples()) if (!ex.isResponse()) {
needsHr = true;
renderExample(b, ex, "Request");
}
for (OperationExample ex : op.getExamples()) if (ex.isResponse()) {
if (needsHr && !hasHr) {
hasHr = true;
b.append("<hr/>\r\n");
}
renderExample(b, ex, "Response");
}
}
if (!Utilities.noString(op.getFooter2())) {
b.append(processMarkdown(n, op.getFooter2(), prefix)).append("\r\n");
boolean needsHr = false;
boolean hasHr = false;
if (op.getExamples2().size() > 0) {
for (OperationExample ex : op.getExamples2()) if (!ex.isResponse()) {
needsHr = true;
renderExample(b, ex, "Request");
}
for (OperationExample ex : op.getExamples2()) if (ex.isResponse()) {
if (needsHr && !hasHr) {
hasHr = true;
b.append("<hr/>\r\n");
}
renderExample(b, ex, "Response");
}
}
}
b.append("<p> </p>");
}
use of org.hl7.fhir.r4.model.OperationDefinition in project kindling by HL7.
the class ExampleInspector method fetch.
@Override
public Element fetch(IResourceValidator validator, Object appContext, String url) throws IOException, FHIRException {
String[] parts = url.split("\\/");
if (parts.length == 2 && definitions.hasResource(parts[0])) {
ResourceDefn r = definitions.getResourceByName(parts[0]);
for (Example e : r.getExamples()) {
if (e.getElement() == null && e.hasXml()) {
e.setElement(new org.hl7.fhir.r5.elementmodel.XmlParser(context).parse(e.getXml()));
if (e.getElement().getProperty().getStructure().getBaseDefinition().contains("MetadataResource")) {
String urle = e.getElement().getChildValue("url");
String v = e.getElement().getChildValue("url");
if (urle != null && urle.startsWith("http://hl7.org/fhir") && !version.toCode().equals(v)) {
e.getElement().setChildValue("version", version.toCode());
}
}
}
if (e.getElement() != null) {
if (e.getElement().fhirType().equals("Bundle")) {
for (Base b : e.getElement().listChildrenByName("entry")) {
if (b.getChildByName("resource").hasValues()) {
Element res = (Element) b.getChildByName("resource").getValues().get(0);
if (res.fhirType().equals(parts[0]) && parts[1].equals(res.getChildValue("id"))) {
return res;
}
}
}
} else if (e.getElement().fhirType().equals(parts[0]) && e.getId().equals(parts[1])) {
return e.getElement();
}
}
}
try {
if (parts[0].equals("StructureDefinition"))
return new ObjectConverter(context).convert(context.fetchResourceWithException(StructureDefinition.class, "http://hl7.org/fhir/" + parts[0] + "/" + parts[1]));
if (parts[0].equals("OperationDefinition"))
return new ObjectConverter(context).convert(context.fetchResourceWithException(OperationDefinition.class, "http://hl7.org/fhir/" + parts[0] + "/" + parts[1]));
if (parts[0].equals("SearchParameter"))
return new ObjectConverter(context).convert(context.fetchResourceWithException(SearchParameter.class, "http://hl7.org/fhir/" + parts[0] + "/" + parts[1]));
if (parts[0].equals("ValueSet"))
return new ObjectConverter(context).convert(context.fetchResourceWithException(ValueSet.class, "http://hl7.org/fhir/" + parts[0] + "/" + parts[1]));
if (parts[0].equals("CodeSystem"))
return new ObjectConverter(context).convert(context.fetchResourceWithException(CodeSystem.class, "http://hl7.org/fhir/" + parts[0] + "/" + parts[1]));
} catch (Exception e) {
return null;
}
return null;
} else
return null;
}
use of org.hl7.fhir.r4.model.OperationDefinition in project kindling by HL7.
the class SpreadSheetReloader method processOperations.
private void processOperations(XSSFWorkbook excel) throws IOException {
ListResource list = (ListResource) parseXml(fnOperations());
XSSFSheet src = getSheet(excel, SN_OPERATIONS);
XSSFSheet bindings = getSheet(excel, SN_BINDINGS);
list.getEntry().clear();
XSSFRow cols = src.getRow(0);
OperationDefinition opd = null;
Map<String, OperationDefinitionParameterComponent> params = new HashMap<>();
for (int i = 1; i <= src.getLastRowNum(); i++) {
XSSFRow row = src.getRow(i);
if (row != null && hasValue(row, cols, CN_NAME)) {
String name = getValue(row, cols, CN_NAME);
if (name == null || !name.contains(".")) {
if (opd != null) {
saveXml(fnOpDef(resourceName + "-" + opd.getCode()), opd);
}
opd = processOperation(row, cols, name, list.getEntry());
moveParams(opd, params);
list.addEntry().getItem().setReference("OperationDefinition/" + resourceName + "-" + opd.getCode());
} else {
processOperationParameter(row, cols, name, opd, params, bindings);
}
}
}
if (opd != null) {
saveXml(fnOpDef(resourceName + "-" + opd.getCode()), opd);
}
saveXml(fnOperations(), list);
}
use of org.hl7.fhir.r4.model.OperationDefinition in project kindling by HL7.
the class SpreadSheetReloader method parseType.
private void parseType(ElementDefinition ed, String value, String hierarchy) throws Exception {
ed.getType().clear();
ed.setContentReferenceElement(null);
if (ed.getPath().equals("Resource.id")) {
ed.addType().setCode("http://hl7.org/fhirpath/System.String").addExtension("http://hl7.org/fhir/StructureDefinition/structuredefinition-fhir-type", new UriType("id"));
} else {
if (Utilities.noString(value)) {
if (ed.getPath().contains(".")) {
ed.addType().setCode("BackboneElement");
}
} else if (value.startsWith("#")) {
ed.setContentReference(value);
} else {
List<TypeRef> tl = new TypeParser(version).parse(value, false, null, context, false);
for (TypeRef tr : tl) {
TypeRefComponent t = ed.addType().setCode(tr.getName());
if ("SimpleQuantity".equals(t.getCode())) {
t.setCode("Quantity");
t.addProfile("http://hl7.org/fhir/StructureDefinition/SimpleQuantity");
}
for (String p : tr.getParams()) {
if (p.equals("Definition")) {
t.addExtension(BuildExtensions.EXT_PATTERN, new CanonicalType("http://hl7.org/fhir/StructureDefinition/Definition"));
t.addTargetProfile("http://hl7.org/fhir/StructureDefinition/ActivityDefinition");
t.addTargetProfile("http://hl7.org/fhir/StructureDefinition/EventDefinition");
t.addTargetProfile("http://hl7.org/fhir/StructureDefinition/EvidenceVariable");
t.addTargetProfile("http://hl7.org/fhir/StructureDefinition/Measure");
t.addTargetProfile("http://hl7.org/fhir/StructureDefinition/OperationDefinition");
t.addTargetProfile("http://hl7.org/fhir/StructureDefinition/PlanDefinition");
t.addTargetProfile("http://hl7.org/fhir/StructureDefinition/Questionnaire");
t.addTargetProfile("http://hl7.org/fhir/StructureDefinition/SubscriptionTopic");
} else {
t.addTargetProfile("http://hl7.org/fhir/StructureDefinition/" + p);
}
}
if (Utilities.existsInList(tr.getName(), "canonical", "Reference") && !Utilities.noString(hierarchy)) {
t.addExtension(BuildExtensions.EXT_HIERARCHY, new BooleanType(Utilities.existsInList(hierarchy, "true", "True", "TRUE", "1", "y", "Y")));
}
}
}
}
}
use of org.hl7.fhir.r4.model.OperationDefinition in project kindling by HL7.
the class SpreadSheetCreator method addOperations.
private void addOperations(XSSFWorkbook excel, XSSFSheet bindings) throws FHIRFormatError, FileNotFoundException, IOException {
ListResource list = (ListResource) parseXml(fnOperations());
list.setText(null);
XSSFSheet sheet = excel.createSheet(SN_OPERATIONS);
addOperationColumns(sheet);
int rowCount = 1;
for (ListResourceEntryComponent li : list.getEntry()) {
String ref = li.getItem().getReference();
ref = ref.substring(ref.indexOf("/") + 1);
OperationDefinition opd = (OperationDefinition) parseXml(fnOpDef(ref));
opd.setText(null);
rowCount = addOperation(sheet, bindings, opd, rowCount);
}
}
Aggregations