use of org.hl7.fhir.dstu3.model.OperationDefinition.OperationDefinitionParameterComponent in project kindling by HL7.
the class SpreadSheetReloader method processOperationParameter.
private void processOperationParameter(XSSFRow row, XSSFRow cols, String name, OperationDefinition opd, Map<String, OperationDefinitionParameterComponent> params, XSSFSheet bindings) {
String pname = name.substring(name.lastIndexOf(".") + 1);
String context = name.substring(0, name.lastIndexOf("."));
OperationParameterUse use = OperationParameterUse.fromCode(getValue(row, cols, CN_USE));
OperationDefinitionParameterComponent param = params.get(pname + (use != null ? ":" + use : ""));
if (param == null) {
param = new OperationDefinitionParameterComponent().setName(pname).setUse(use);
}
OperationDefinitionParameterComponent ctxt = findParam(opd, context);
if (ctxt == null) {
opd.getParameter().add(param);
} else {
ctxt.getPart().add(param);
}
param.setMinElement(null);
param.setMaxElement(null);
String[] card = splitValue(row, cols, CN_CARD, "\\.\\.");
if (card.length == 2) {
param.setMin(Integer.parseInt(card[0]));
param.setMax(card[1]);
}
String t = getValue(row, cols, CN_TYPE);
if (!Utilities.noString(t)) {
if (t.contains(" | ")) {
param.setType(FHIRAllTypes.ELEMENT);
for (String s : t.split("\\|")) {
param.addExtension(BuildExtensions.EXT_ALLOWED_TYPE, new UriType(s.trim()));
}
} else {
if (t.contains("/")) {
param.setSearchType(SearchParamType.fromCode(t.substring(t.lastIndexOf("/") + 1).trim()));
t = t.substring(0, t.indexOf("/")).trim();
}
param.setType(FHIRAllTypes.fromCode(t));
}
}
parseBinding(param, getValue(row, cols, CN_BINDING), bindings);
param.setDocumentation(getValue(row, cols, CN_DOCUMENTATION));
parseStatus(param, getValue(row, cols, CN_STATUS));
readExt(param, row, cols, CN_COMMITTEE_NOTES, BuildExtensions.EXT_COMMITTEE_NOTES, ExtensionType.String);
}
use of org.hl7.fhir.dstu3.model.OperationDefinition.OperationDefinitionParameterComponent in project kindling by HL7.
the class SpreadSheetReloader method moveParams.
private void moveParams(OperationDefinition opd, Map<String, OperationDefinitionParameterComponent> params) {
params.clear();
for (OperationDefinitionParameterComponent p : opd.getParameter()) {
String path = p.getName() + (p.hasUse() ? ":" + p.getUse() : "");
params.put(path, p);
moveParts(path, p, params);
p.getPart().clear();
}
opd.getParameter().clear();
}
use of org.hl7.fhir.dstu3.model.OperationDefinition.OperationDefinitionParameterComponent in project kindling by HL7.
the class SpreadSheetReloader method findParam.
private OperationDefinitionParameterComponent findParam(OperationDefinition opd, String context) {
if (opd.getCode().equals(context)) {
return null;
}
for (int i = opd.getParameter().size() - 1; i >= 0; i--) {
OperationDefinitionParameterComponent p = opd.getParameter().get(i);
String path = opd.getCode() + "." + p.getName();
if (path.equals(context)) {
return p;
}
if (context.startsWith(path)) {
return findParam(path, p, context);
}
}
throw new Error("Unable to find parameter " + context);
}
use of org.hl7.fhir.dstu3.model.OperationDefinition.OperationDefinitionParameterComponent in project kindling by HL7.
the class ResourceParser method convertOperation.
private Operation convertOperation(OperationDefinition src) throws FileNotFoundException, FHIRException, IOException, Exception {
List<OperationExample> examples = new ArrayList<>();
List<OperationExample> examples2 = new ArrayList<>();
for (Extension ex : src.getExtensionsByUrl(BuildExtensions.EXT_OP_EXAMPLE)) {
if ("2".equals(ex.getExtensionString(BuildExtensions.EXT_OP_EXAMPLE_LIST))) {
processExample(examples2, ex.getExtensionString(BuildExtensions.EXT_OP_EXAMPLE_CONTENT), "true".equals(ex.getExtensionString(BuildExtensions.EXT_OP_EXAMPLE_RESPONSE)));
} else {
processExample(examples, ex.getExtensionString(BuildExtensions.EXT_OP_EXAMPLE_CONTENT), "true".equals(ex.getExtensionString(BuildExtensions.EXT_OP_EXAMPLE_RESPONSE)));
}
}
Operation op = new Operation(src.getName(), src.getSystem(), src.getType(), src.getInstance(), src.getKind().toCode(), src.getTitle(), src.getDescription(), BuildExtensions.readStringExtension(src, BuildExtensions.EXT_FOOTER), examples, !src.getAffectsState());
op.getExamples2().addAll(examples2);
op.setResource(src);
op.setStandardsStatus(StandardsStatus.fromCode(BuildExtensions.readStringExtension(src, BuildExtensions.EXT_STANDARDS_STATUS)));
op.setFmm(BuildExtensions.readStringExtension(src, BuildExtensions.EXT_FMM_LEVEL));
op.setFooter2(BuildExtensions.readStringExtension(src, BuildExtensions.EXT_FOOTER2));
for (OperationDefinitionParameterComponent psrc : src.getParameter()) {
op.getParameters().add(convertOperationParameter(psrc, false));
}
return op;
}
use of org.hl7.fhir.dstu3.model.OperationDefinition.OperationDefinitionParameterComponent in project org.hl7.fhir.core by hapifhir.
the class NarrativeGenerator method generate.
public void generate(OperationDefinition opd) throws EOperationOutcome, FHIRException, IOException {
XhtmlNode x = new XhtmlNode(NodeType.Element, "div");
x.addTag("h2").addText(opd.getName());
x.addTag("p").addText(Utilities.capitalize(opd.getKind().toString()) + ": " + opd.getName());
addMarkdown(x, opd.getDescription());
if (opd.getSystem())
x.addTag("p").addText("URL: [base]/$" + opd.getCode());
for (CodeType c : opd.getType()) {
x.addTag("p").addText("URL: [base]/" + c.getValue() + "/$" + opd.getCode());
if (opd.getInstance())
x.addTag("p").addText("URL: [base]/" + c.getValue() + "/[id]/$" + opd.getCode());
}
x.addTag("p").addText("Parameters");
XhtmlNode tbl = x.addTag("table").setAttribute("class", "grid");
XhtmlNode tr = tbl.addTag("tr");
tr.addTag("td").addTag("b").addText("Use");
tr.addTag("td").addTag("b").addText("Name");
tr.addTag("td").addTag("b").addText("Cardinality");
tr.addTag("td").addTag("b").addText("Type");
tr.addTag("td").addTag("b").addText("Binding");
tr.addTag("td").addTag("b").addText("Documentation");
for (OperationDefinitionParameterComponent p : opd.getParameter()) {
genOpParam(tbl, "", p);
}
addMarkdown(x, opd.getNotes());
inject(opd, x, NarrativeStatus.GENERATED);
}
Aggregations