use of org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterComponent in project kindling by HL7.
the class SpreadSheetCreator method addOperation.
private int addOperation(XSSFSheet sheet, XSSFSheet bindings, OperationDefinition opd, int rowCount) {
Row row = sheet.createRow(rowCount++);
int columnCount = 0;
addCell(opd.getCode(), row, columnCount++);
addCell(use(opd), row, columnCount++);
addCell("", row, columnCount++);
addCell(type(opd), row, columnCount++);
addCell("", row, columnCount++);
addCell(opd.present(), row, columnCount++);
addCell(opd.getDescription(), row, columnCount++);
addCell(opd.getComment(), row, columnCount++);
addCell(ext(opd, BuildExtensions.EXT_FOOTER), row, columnCount++);
addCell(ext(opd, BuildExtensions.EXT_FOOTER2), row, columnCount++);
addCell(exlist(opd, false, "1"), row, columnCount++);
addCell(exlist(opd, true, "1"), row, columnCount++);
addCell(exlist(opd, false, "2"), row, columnCount++);
addCell(exlist(opd, true, "2"), row, columnCount++);
addCell(status(opd), row, columnCount++);
addCell(ext(opd, BuildExtensions.EXT_COMMITTEE_NOTES), row, columnCount++);
for (OperationDefinitionParameterComponent param : opd.getParameter()) {
rowCount = addOpParam(sheet, bindings, opd.getCode(), param, rowCount);
}
return rowCount;
}
use of org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterComponent 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.r4.model.OperationDefinition.OperationDefinitionParameterComponent in project kindling by HL7.
the class ProfileGenerator method produceOpParam.
private void produceOpParam(String path, List<OperationDefinitionParameterComponent> opd, OperationParameter p, OperationParameterUse defUse) throws Exception {
OperationDefinitionParameterComponent pp = new OperationDefinitionParameterComponent();
pp.setName(p.getName());
if (path.contains("."))
pp.setUse(defUse);
else if (p.getUse().equals("in"))
pp.setUse(OperationParameterUse.IN);
else if (p.getUse().equals("out"))
pp.setUse(OperationParameterUse.OUT);
else
// but this is validated elsewhere
throw new Exception("Unable to determine parameter use: " + p.getUse() + " at " + path + "." + p.getName());
pp.setDocumentation(preProcessMarkdown(p.getDoc(), "Operation Parameter Doco"));
pp.setMin(p.getMin());
pp.setMax(p.getMax());
if (p.getBs() != null) {
if (p.getBs().hasMax())
throw new Error("Max binding not handled yet");
pp.setBinding(new OperationDefinitionParameterBindingComponent().setStrength(p.getBs().getStrength()).setValueSet(buildValueSetReference(p.getBs())));
if (!Utilities.noString(p.getBinding().getName())) {
pp.getBinding().addExtension("http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName", new StringType(p.getBinding().getName()));
}
}
if (!Utilities.noString(p.getProfile())) {
pp.addTargetProfile(p.getProfile());
}
opd.add(pp);
if (p.getFhirType().equals("Tuple")) {
for (OperationParameter part : p.getParts()) {
produceOpParam(path + "." + p.getName(), pp.getPart(), part, pp.getUse());
}
} else {
List<TypeRef> trs = new TypeParser(version.toCode()).parse(p.getFhirType(), false, null, null, false);
if (trs.size() > 1) {
if (p.getSearchType() != null)
pp.setSearchType(SearchParamType.fromCode(p.getSearchType()));
pp.setType(Enumerations.FHIRAllTypes.fromCode("Element"));
for (TypeRef tr : trs) {
pp.addExtension(ToolingExtensions.EXT_ALLOWED_TYPE, new UriType(tr.getName()));
if (tr.getParams().size() > 0)
throw new Error("Multiple types for an operation parameter, where one is a reference, is not supported by the build tools");
}
} else {
TypeRef tr = trs.get(0);
if (definitions.getConstraints().containsKey(tr.getName())) {
ProfiledType pt = definitions.getConstraints().get(tr.getName());
pp.setType(Enumerations.FHIRAllTypes.fromCode(pt.getBaseType().equals("*") ? "Type" : pt.getBaseType()));
pp.addTargetProfile("http://hl7.org/fhir/StructureDefinition/" + pt.getName());
} else {
if (p.getSearchType() != null)
pp.setSearchType(SearchParamType.fromCode(p.getSearchType()));
pp.setType(Enumerations.FHIRAllTypes.fromCode(tr.getName().equals("*") ? "Type" : tr.getName()));
if (tr.getParams().size() == 1 && !tr.getParams().get(0).equals("Any"))
pp.addTargetProfile("http://hl7.org/fhir/StructureDefinition/" + tr.getParams().get(0));
}
}
}
}
use of org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterComponent in project org.hl7.fhir.core by hapifhir.
the class NarrativeGenerator method genOpParam.
private void genOpParam(XhtmlNode tbl, String path, OperationDefinitionParameterComponent p) throws EOperationOutcome, FHIRException, IOException {
XhtmlNode tr;
tr = tbl.addTag("tr");
tr.addTag("td").addText(p.getUse().toString());
tr.addTag("td").addText(path + p.getName());
tr.addTag("td").addText(Integer.toString(p.getMin()) + ".." + p.getMax());
tr.addTag("td").addText(p.hasType() ? p.getType() : "");
XhtmlNode td = tr.addTag("td");
if (p.hasBinding() && p.getBinding().hasValueSet()) {
if (p.getBinding().getValueSet() instanceof Reference)
AddVsRef(p.getBinding().getValueSetReference().getReference(), td);
else
td.addTag("a").setAttribute("href", p.getBinding().getValueSetUriType().getValue()).addText("External Reference");
td.addText(" (" + p.getBinding().getStrength().getDisplay() + ")");
}
addMarkdown(tr.addTag("td"), p.getDocumentation());
if (!p.hasType()) {
for (OperationDefinitionParameterComponent pp : p.getPart()) {
genOpParam(tbl, path + p.getName() + ".", pp);
}
}
}
use of org.hl7.fhir.r4.model.OperationDefinition.OperationDefinitionParameterComponent in project org.hl7.fhir.core by hapifhir.
the class NarrativeGenerator method genOpParam.
private void genOpParam(ResourceContext rcontext, XhtmlNode tbl, String path, OperationDefinitionParameterComponent p) throws EOperationOutcome, FHIRException, IOException {
XhtmlNode tr;
tr = tbl.tr();
tr.td().addText(p.getUse().toString());
tr.td().addText(path + p.getName());
tr.td().addText(Integer.toString(p.getMin()) + ".." + p.getMax());
tr.td().addText(p.hasType() ? p.getType() : "");
XhtmlNode td = tr.td();
if (p.hasBinding() && p.getBinding().hasValueSet()) {
if (p.getBinding().getValueSet() instanceof Reference)
AddVsRef(rcontext, p.getBinding().getValueSetReference().getReference(), td);
else
td.ah(p.getBinding().getValueSetUriType().getValue()).tx("External Reference");
td.tx(" (" + p.getBinding().getStrength().getDisplay() + ")");
}
addMarkdown(tr.td(), p.getDocumentation());
if (!p.hasType()) {
for (OperationDefinitionParameterComponent pp : p.getPart()) {
genOpParam(rcontext, tbl, path + p.getName() + ".", pp);
}
}
}
Aggregations