use of org.hl7.fhir.definitions.model.OperationParameter in project kindling by HL7.
the class ProfileGenerator method generate.
public OperationDefinition generate(String name, String id, String resourceName, Operation op, ResourceDefn rd) throws Exception {
OperationDefinition opd = new OperationDefinition();
op.setResource(opd);
if (Utilities.noString(op.getFmm()))
ToolingExtensions.addIntegerExtension(opd, ToolingExtensions.EXT_FMM_LEVEL, Integer.parseInt(rd.getFmmLevel()));
else
ToolingExtensions.addIntegerExtension(opd, ToolingExtensions.EXT_FMM_LEVEL, Integer.parseInt(op.getFmm()));
ToolingExtensions.setStandardsStatus(opd, op.getStandardsStatus() == null ? rd.getStatus() : op.getStandardsStatus(), op.getNormativeVersion());
opd.setId(FormatUtilities.makeId(id));
opd.setUrl("http://hl7.org/fhir/OperationDefinition/" + id);
opd.setName(op.getName());
opd.setTitle(op.getTitle());
opd.setVersion(version.toCode());
opd.setPublisher("HL7 (FHIR Project)");
opd.addContact().getTelecom().add(org.hl7.fhir.r5.model.Factory.newContactPoint(ContactPointSystem.URL, "http://hl7.org/fhir"));
opd.getContact().get(0).getTelecom().add(org.hl7.fhir.r5.model.Factory.newContactPoint(ContactPointSystem.EMAIL, "fhir@lists.hl7.org"));
opd.setDescription(preProcessMarkdown(op.getDoco(), "Operation Documentation"));
opd.setStatus(op.getStandardsStatus() == StandardsStatus.NORMATIVE ? PublicationStatus.ACTIVE : PublicationStatus.DRAFT);
opd.setDate(genDate.getTime());
if (op.getKind().toLowerCase().equals("operation"))
opd.setKind(OperationKind.OPERATION);
else if (op.getKind().toLowerCase().equals("query"))
opd.setKind(OperationKind.QUERY);
else {
throw new Exception("Unrecognized operation kind: '" + op.getKind() + "' for operation " + name);
}
opd.setCode(op.getName());
opd.setComment(preProcessMarkdown(op.getFooter(), "Operation Comments"));
opd.setSystem(op.isSystem());
opd.addResource(resourceName);
opd.setType(op.isType());
opd.setInstance(op.isInstance());
if (op.getIdempotent() == null) {
throw new Error("Operation " + opd.getId() + " is not marked as Idempotent or not");
} else {
opd.setAffectsState(!op.getIdempotent());
}
for (OperationParameter p : op.getParameters()) {
produceOpParam(op.getName(), opd.getParameter(), p, null);
}
OperationDefinitionRenderer opr = new OperationDefinitionRenderer(rc);
opr.render(opd);
return opd;
}
use of org.hl7.fhir.definitions.model.OperationParameter in project kindling by HL7.
the class PageProcessor method genOperationParameter.
private void genOperationParameter(String resource, String mode, String path, StringBuilder b, Operation op, OperationParameter p, String prefix) throws Exception {
if (!Utilities.noString(p.getUse()) && !mode.equalsIgnoreCase(p.getUse()))
return;
b.append("<tr><td>");
b.append(path + p.getName());
b.append("</td><td>");
b.append(p.describeCardinality());
b.append("</td><td>");
boolean firstt = true;
String tl = p.getFhirType();
boolean isRes = true;
for (String tx : tl.split("\\|")) {
String t = tx.trim();
if (firstt)
firstt = false;
else
b.append(" | ");
String st = p.getSearchType();
if (definitions.hasResource(t)) {
b.append("<a href=\"");
b.append(prefix);
b.append(t.toLowerCase());
b.append(".html\">");
b.append(t);
b.append("</a>");
} else if (definitions.hasPrimitiveType(t)) {
isRes = false;
b.append("<a href=\"" + prefix + "datatypes.html#");
b.append(t);
b.append("\">");
b.append(t);
b.append("</a>");
if (!Utilities.noString(st)) {
b.append("<br/>(<a href=\"" + (prefix == null ? "" : prefix) + "search.html#");
b.append(st);
b.append("\">");
b.append(st);
b.append("</a>)");
}
} else if (definitions.hasElementDefn(t)) {
isRes = false;
b.append("<a href=\"");
b.append(prefix);
b.append(definitions.getSrcFile(t));
b.append(".html#");
b.append(t);
b.append("\">");
b.append(t);
b.append("</a>");
} else if (t.startsWith("Reference(")) {
isRes = false;
b.append("<a href=\"" + prefix + "references.html#Reference\">Reference</a>");
String pn = t.substring(0, t.length() - 1).substring(10);
b.append("(");
boolean first = true;
for (String tn : pn.split("\\|")) {
if (first)
first = false;
else
b.append("|");
b.append("<a href=\"");
b.append(prefix);
if (tn.equals("Any"))
b.append("resourcelist");
else
b.append(tn.toLowerCase());
b.append(".html\">");
b.append(tn);
b.append("</a>");
}
b.append(")");
} else if (!t.equals("Tuple")) {
b.append(t);
}
}
b.append("</td><td>");
if (p.getBs() != null && p.getBs().getBinding() != BindingMethod.Unbound) {
b.append("<a href=\"" + BaseGenerator.getBindingLink(prefix, p.getBs()) + "\">" + (p.getBs().getValueSet() != null ? p.getBs().getValueSet().present() : p.getBs().getName()) + "</a>");
if (p.getBs().hasMax())
throw new Error("Max binding not handled yet");
b.append(" (<a href=\"" + prefix + "terminologies.html#" + p.getBs().getStrength().toCode() + "\">" + p.getBs().getStrength().getDisplay() + "</a>)");
}
b.append("</td><td>");
if (!Utilities.noString(p.getProfile())) {
StructureDefinition sd = profiles.get(p.getProfile());
if (sd != null)
b.append("<a href=\"" + prefix + sd.getUserString("path") + "\">" + sd.getName() + "</a>");
else
b.append(p.getProfile() + " (unknown)");
}
b.append("</td><td>");
b.append(processMarkdown(resource, p.getDoc(), prefix));
if (p.getName().equals("return") && isOnlyOutParameter(op.getParameters(), p) && isRes)
b.append("<p>Note: as this is the only out parameter, it is a resource, and it has the name 'return', the result of this operation is returned directly as a resource</p>");
b.append("</td></tr>");
for (OperationParameter pp : p.getParts()) genOperationParameter(resource, mode, path + p.getName() + ".", b, op, pp, prefix);
}
Aggregations