use of org.hl7.fhir.r4b.model.OperationDefinition 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.r4b.model.OperationDefinition 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.r4b.model.OperationDefinition 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.r4b.model.OperationDefinition in project kindling by HL7.
the class SpreadSheetReloader method processOperation.
private OperationDefinition processOperation(XSSFRow row, XSSFRow cols, String name, List<ListResourceEntryComponent> entry) throws IOException {
String fn = fnOpDef(resourceName + "-" + name);
OperationDefinition opd = null;
if (new File(fn).exists()) {
opd = (OperationDefinition) parseXml(fn);
} else {
opd = new OperationDefinition();
opd.setId(name);
opd.setUrl("http://hl7.org/fhir/Operationdefinition/" + name);
opd.setName(name);
opd.setCode(name);
}
opd.setSystem(false);
opd.setType(false);
opd.setInstance(false);
for (String s : splitValue(row, cols, CN_USE, "\\|")) {
String n = s.trim();
switch(n) {
case "System":
opd.setSystem(true);
break;
case "Type":
opd.setType(true);
break;
case "Instance":
opd.setInstance(true);
break;
}
}
opd.setAffectsState(false);
opd.setKind(null);
for (String s : splitValue(row, cols, CN_TYPE, "\\|")) {
String n = s.trim();
if (n.equals("affects-state")) {
opd.setAffectsState(true);
} else {
opd.setKind(OperationKind.fromCode(n));
}
}
opd.setTitle(getValue(row, cols, CN_TITLE));
opd.setDescription(getValue(row, cols, CN_DOCUMENTATION));
opd.setComment(getValue(row, cols, CN_COMMENTS));
readExt(opd, row, cols, CN_FOOTER, BuildExtensions.EXT_FOOTER, ExtensionType.Markdown);
readExt(opd, row, cols, CN_FOOTER2, BuildExtensions.EXT_FOOTER2, ExtensionType.Markdown);
opd.getExtension().removeIf(n -> ("1".equals(n.getExtensionString(BuildExtensions.EXT_OP_EXAMPLE_LIST))));
opd.getExtension().removeIf(n -> ("2".equals(n.getExtensionString(BuildExtensions.EXT_OP_EXAMPLE_LIST))));
for (String s : splitValue(row, cols, CN_EXAMPLE1_REQUEST, "\\|")) {
Extension ext = opd.addExtension().setUrl(BuildExtensions.EXT_OP_EXAMPLE);
ext.addExtension(BuildExtensions.EXT_OP_EXAMPLE_LIST, new StringType("1"));
ext.addExtension(BuildExtensions.EXT_OP_EXAMPLE_RESPONSE, new BooleanType(false));
ext.addExtension(BuildExtensions.EXT_OP_EXAMPLE_CONTENT, new StringType(s));
}
for (String s : splitValue(row, cols, CN_EXAMPLE1_RESPONSE, "\\|")) {
Extension ext = opd.addExtension().setUrl(BuildExtensions.EXT_OP_EXAMPLE);
ext.addExtension(BuildExtensions.EXT_OP_EXAMPLE_LIST, new StringType("1"));
ext.addExtension(BuildExtensions.EXT_OP_EXAMPLE_RESPONSE, new BooleanType(true));
ext.addExtension(BuildExtensions.EXT_OP_EXAMPLE_CONTENT, new StringType(s));
}
for (String s : splitValue(row, cols, CN_EXAMPLE2_REQUEST, "\\|")) {
Extension ext = opd.addExtension().setUrl(BuildExtensions.EXT_OP_EXAMPLE);
ext.addExtension(BuildExtensions.EXT_OP_EXAMPLE_LIST, new StringType("2"));
ext.addExtension(BuildExtensions.EXT_OP_EXAMPLE_RESPONSE, new BooleanType(false));
ext.addExtension(BuildExtensions.EXT_OP_EXAMPLE_CONTENT, new StringType(s));
}
for (String s : splitValue(row, cols, CN_EXAMPLE2_RESPONSE, "\\|")) {
Extension ext = opd.addExtension().setUrl(BuildExtensions.EXT_OP_EXAMPLE);
ext.addExtension(BuildExtensions.EXT_OP_EXAMPLE_LIST, new StringType("2"));
ext.addExtension(BuildExtensions.EXT_OP_EXAMPLE_RESPONSE, new BooleanType(true));
ext.addExtension(BuildExtensions.EXT_OP_EXAMPLE_CONTENT, new StringType(s));
}
parseStatus(opd, getValue(row, cols, CN_STATUS));
readExt(opd, row, cols, CN_COMMITTEE_NOTES, BuildExtensions.EXT_COMMITTEE_NOTES, ExtensionType.String);
return opd;
}
use of org.hl7.fhir.r4b.model.OperationDefinition 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;
}
Aggregations