use of org.hl7.fhir.r4.model.Questionnaire in project org.hl7.fhir.core by hapifhir.
the class Params method loadCliContext.
/**
* TODO Don't do this all in one for loop. Use the above methods.
*/
public static CliContext loadCliContext(String[] args) throws Exception {
CliContext cliContext = new CliContext();
// load the parameters - so order doesn't matter
for (int i = 0; i < args.length; i++) {
if (args[i].equals(VERSION)) {
cliContext.setSv(VersionUtilities.getCurrentPackageVersion(args[++i]));
} else if (args[i].equals(OUTPUT)) {
if (i + 1 == args.length)
throw new Error("Specified -output without indicating output file");
else
cliContext.setOutput(args[++i]);
} else if (args[i].equals(HTML_OUTPUT)) {
if (i + 1 == args.length)
throw new Error("Specified -html-output without indicating output file");
else
cliContext.setHtmlOutput(args[++i]);
} else if (args[i].equals(PROXY)) {
// ignore next parameter
i++;
} else if (args[i].equals(PROXY_AUTH)) {
i++;
} else if (args[i].equals(PROFILE)) {
String p = null;
if (i + 1 == args.length) {
throw new Error("Specified -profile without indicating profile source");
} else {
p = args[++i];
cliContext.addProfile(p);
}
} else if (args[i].equals(BUNDLE)) {
String p = null;
String r = null;
if (i + 1 == args.length) {
throw new Error("Specified -profile without indicating bundle rule ");
} else {
r = args[++i];
}
if (i + 1 == args.length) {
throw new Error("Specified -profile without indicating profile source");
} else {
p = args[++i];
}
cliContext.getBundleValidationRules().add(new BundleValidationRule(r, p));
} else if (args[i].equals(QUESTIONNAIRE)) {
if (i + 1 == args.length)
throw new Error("Specified -questionnaire without indicating questionnaire mode");
else {
String q = args[++i];
cliContext.setQuestionnaireMode(QuestionnaireMode.fromCode(q));
}
} else if (args[i].equals(LEVEL)) {
if (i + 1 == args.length)
throw new Error("Specified -level without indicating level mode");
else {
String q = args[++i];
cliContext.setLevel(ValidationLevel.fromCode(q));
}
} else if (args[i].equals(NATIVE)) {
cliContext.setDoNative(true);
} else if (args[i].equals(ASSUME_VALID_REST_REF)) {
cliContext.setAssumeValidRestReferences(true);
} else if (args[i].equals(DEBUG)) {
cliContext.setDoDebug(true);
} else if (args[i].equals(SCT)) {
cliContext.setSnomedCT(args[++i]);
} else if (args[i].equals(RECURSE)) {
cliContext.setRecursive(true);
} else if (args[i].equals(SHOW_MESSAGES_FROM_REFERENCES)) {
cliContext.setShowMessagesFromReferences(true);
} else if (args[i].equals(LOCALE)) {
if (i + 1 == args.length) {
throw new Error("Specified -locale without indicating locale");
} else {
cliContext.setLocale(new Locale(args[++i]));
}
} else if (args[i].equals(EXTENSIONS)) {
cliContext.getExtensions().add(args[++i]);
} else if (args[i].equals(NO_INTERNAL_CACHING)) {
cliContext.setNoInternalCaching(true);
} else if (args[i].equals(NO_EXTENSIBLE_BINDING_WARNINGS)) {
cliContext.setNoExtensibleBindingMessages(true);
} else if (args[i].equals(NO_UNICODE_BIDI_CONTROL_CHARS)) {
cliContext.setNoUnicodeBiDiControlChars(true);
} else if (args[i].equals(NO_INVARIANTS)) {
cliContext.setNoInvariants(true);
} else if (args[i].equals(WANT_INVARIANTS_IN_MESSAGES)) {
cliContext.setWantInvariantsInMessages(true);
} else if (args[i].equals(HINT_ABOUT_NON_MUST_SUPPORT)) {
cliContext.setHintAboutNonMustSupport(true);
} else if (args[i].equals(TO_VERSION)) {
cliContext.setTargetVer(args[++i]);
cliContext.setMode(EngineMode.VERSION);
} else if (args[i].equals(DO_NATIVE)) {
cliContext.setCanDoNative(true);
} else if (args[i].equals(NO_NATIVE)) {
cliContext.setCanDoNative(false);
} else if (args[i].equals(TRANSFORM)) {
cliContext.setMap(args[++i]);
cliContext.setMode(EngineMode.TRANSFORM);
} else if (args[i].equals(COMPILE)) {
cliContext.setMap(args[++i]);
cliContext.setMode(EngineMode.COMPILE);
} else if (args[i].equals(NARRATIVE)) {
cliContext.setMode(EngineMode.NARRATIVE);
} else if (args[i].equals(SPREADSHEET)) {
cliContext.setMode(EngineMode.SPREADSHEET);
} else if (args[i].equals(SNAPSHOT)) {
cliContext.setMode(EngineMode.SNAPSHOT);
} else if (args[i].equals(SECURITY_CHECKS)) {
cliContext.setSecurityChecks(true);
} else if (args[i].equals(CRUMB_TRAIL)) {
cliContext.setCrumbTrails(true);
} else if (args[i].equals(VERBOSE)) {
cliContext.setCrumbTrails(true);
} else if (args[i].equals(ALLOW_EXAMPLE_URLS)) {
String bl = args[++i];
if ("true".equals(bl)) {
cliContext.setAllowExampleUrls(true);
} else if ("false".equals(bl)) {
cliContext.setAllowExampleUrls(false);
} else {
throw new Error("Value for " + ALLOW_EXAMPLE_URLS + " not understood: " + bl);
}
} else if (args[i].equals(SHOW_TIMES)) {
cliContext.setShowTimes(true);
} else if (args[i].equals(OUTPUT_STYLE)) {
cliContext.setOutputStyle(args[++i]);
} else if (args[i].equals(SCAN)) {
cliContext.setMode(EngineMode.SCAN);
} else if (args[i].equals(TERMINOLOGY)) {
if (i + 1 == args.length)
throw new Error("Specified -tx without indicating terminology server");
else
cliContext.setTxServer("n/a".equals(args[++i]) ? null : args[i]);
} else if (args[i].equals(TERMINOLOGY_LOG)) {
if (i + 1 == args.length)
throw new Error("Specified -txLog without indicating file");
else
cliContext.setTxLog(args[++i]);
} else if (args[i].equals(TERMINOLOGY_CACHE)) {
if (i + 1 == args.length)
throw new Error("Specified -txCache without indicating file");
else
cliContext.setTxCache(args[++i]);
} else if (args[i].equals(LOG)) {
if (i + 1 == args.length)
throw new Error("Specified -log without indicating file");
else
cliContext.setMapLog(args[++i]);
} else if (args[i].equals(LANGUAGE)) {
if (i + 1 == args.length)
throw new Error("Specified -language without indicating language");
else
cliContext.setLang(args[++i]);
} else if (args[i].equals(IMPLEMENTATION_GUIDE) || args[i].equals(DEFINITION)) {
if (i + 1 == args.length)
throw new Error("Specified " + args[i] + " without indicating ig file");
else {
String s = args[++i];
String version = Common.getVersionFromIGName(null, s);
if (version == null) {
cliContext.addIg(s);
} else {
cliContext.setSv(version);
}
}
} else if (args[i].equals(MAP)) {
if (cliContext.getMap() == null) {
if (i + 1 == args.length)
throw new Error("Specified -map without indicating map file");
else
cliContext.setMap(args[++i]);
} else {
throw new Exception("Can only nominate a single -map parameter");
}
} else if (args[i].startsWith(X)) {
i++;
} else if (args[i].equals(CONVERT)) {
cliContext.setMode(EngineMode.CONVERT);
} else if (args[i].equals(FHIRPATH)) {
cliContext.setMode(EngineMode.FHIRPATH);
if (cliContext.getFhirpath() == null)
if (i + 1 == args.length)
throw new Error("Specified -fhirpath without indicating a FHIRPath expression");
else
cliContext.setFhirpath(args[++i]);
else
throw new Exception("Can only nominate a single -fhirpath parameter");
} else {
cliContext.addSource(args[i]);
}
}
return cliContext;
}
use of org.hl7.fhir.r4.model.Questionnaire in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeQuestionnaireQuestionnaireItemAnswerOptionComponent.
protected void composeQuestionnaireQuestionnaireItemAnswerOptionComponent(Complex parent, String parentType, String name, Questionnaire.QuestionnaireItemAnswerOptionComponent element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeBackboneElement(t, "answerOption", name, element, index);
if (element.hasValue())
composeType(t, "Questionnaire", "value", element.getValue(), -1);
if (element.hasInitialSelectedElement())
composeBoolean(t, "Questionnaire", "initialSelected", element.getInitialSelectedElement(), -1);
}
use of org.hl7.fhir.r4.model.Questionnaire in project org.hl7.fhir.core by hapifhir.
the class QuestionnaireRenderer method renderDefinition.
private boolean renderDefinition(XhtmlNode tbl, Questionnaire q, QuestionnaireItemComponent qi, List<QuestionnaireItemComponent> parents) throws IOException {
boolean ext = false;
XhtmlNode td = tbl.tr().td("structure").colspan("2").span(null, null).attribute("class", "self-link-parent");
td.an("item." + qi.getLinkId());
for (QuestionnaireItemComponent p : parents) {
td.ah("#item." + p.getLinkId()).img(Utilities.path(context.getLocalPrefix(), "icon_q_item.png"));
td.tx(" > ");
}
td.img(Utilities.path(context.getLocalPrefix(), "icon_q_item.png"));
td.tx(" Item ");
td.b().tx(qi.getLinkId());
// general information
defn(tbl, "Link Id", qi.getLinkId());
defn(tbl, "Prefix", qi.getPrefix());
defn(tbl, "Text", qi.getText());
defn(tbl, "Type", qi.getType().getDisplay());
defn(tbl, "Required", qi.getRequired(), true);
defn(tbl, "Repeats", qi.getRepeats(), true);
defn(tbl, "Read Only", qi.getReadOnly(), false);
if (ToolingExtensions.readBoolExtension(qi, "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-isSubject")) {
defn(tbl, "Subject", "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-isSubject", "This element changes who the subject of the question is", null);
}
// content control
defn(tbl, "Max Length", qi.getMaxLength());
if (qi.hasAnswerValueSet()) {
defn(tbl, "Value Set", qi.getDefinition(), context.getWorker().fetchResource(ValueSet.class, qi.getAnswerValueSet()));
}
if (qi.hasAnswerOption()) {
XhtmlNode tr = tbl.tr();
tr.td().tx("Allowed Answers");
XhtmlNode ul = tr.td().ul();
for (QuestionnaireItemAnswerOptionComponent ans : qi.getAnswerOption()) {
XhtmlNode li = ul.li();
render(li, ans.getValue());
if (ans.getInitialSelected()) {
li.tx(" (initially selected)");
}
}
}
if (qi.hasInitial()) {
XhtmlNode tr = tbl.tr();
tr.td().tx(Utilities.pluralize("Initial Answer", qi.getInitial().size()));
if (qi.getInitial().size() == 1) {
render(tr.td(), qi.getInitialFirstRep().getValue());
} else {
XhtmlNode ul = tr.td().ul();
for (QuestionnaireItemInitialComponent ans : qi.getInitial()) {
XhtmlNode li = ul.li();
render(li, ans.getValue());
}
}
}
// appearance
if (qi.hasExtension("http://hl7.org/fhir/StructureDefinition/questionnaire-displayCategory")) {
XhtmlNode tr = tbl.tr();
tr.td().ah("http://hl7.org/fhir/StructureDefinition/questionnaire-displayCategory").tx("Display Category");
render(tr.td(), qi.getExtensionByUrl("http://hl7.org/fhir/StructureDefinition/questionnaire-displayCategory").getValue());
}
if (ToolingExtensions.readBoolExtension(qi, "http://hl7.org/fhir/StructureDefinition/questionnaire-hidden")) {
defn(tbl, "Hidden Item", "http://hl7.org/fhir/StructureDefinition/questionnaire-displayCategory", "This item is a hidden question", null);
}
if (ToolingExtensions.readBoolExtension(qi, "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-optionalDisplay")) {
defn(tbl, "Hidden Item", "http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-optionalDisplay", "This item is optional to display", null);
}
// formal definitions
if (qi.hasDefinition()) {
genDefinitionLink(defn(tbl, "Definition"), qi);
}
if (qi.hasCode()) {
XhtmlNode tr = tbl.tr();
tr.td().tx(Utilities.pluralize("Code", qi.getCode().size()));
XhtmlNode ul = tr.td().ul();
for (Coding c : qi.getCode()) {
renderCodingWithDetails(ul.li(), c);
}
}
if (qi.hasExtension("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-observationLinkPeriod")) {
XhtmlNode tr = tbl.tr();
tr.td().ah("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-observationLinkPeriod").tx("Observation Link Period");
render(tr.td(), qi.getExtensionByUrl("http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire-observationLinkPeriod").getValue());
}
// dynamic management
if (qi.hasEnableWhen()) {
XhtmlNode tr = tbl.tr();
tr.td().tx("Enable When");
td = tr.td();
if (qi.getEnableWhen().size() == 1) {
renderEnableWhen(td, qi.getEnableWhen().get(0));
} else {
td.tx(qi.getEnableBehavior().getDisplay() + " are true:");
XhtmlNode ul = td.ul();
for (QuestionnaireItemEnableWhenComponent ew : qi.getEnableWhen()) {
renderEnableWhen(ul.li(), ew);
}
}
}
// other stuff
List<QuestionnaireItemComponent> curr = new ArrayList<>();
curr.addAll(parents);
curr.add(qi);
for (QuestionnaireItemComponent qic : qi.getItem()) {
ext = renderDefinition(tbl, q, qic, curr) || ext;
}
return ext;
}
use of org.hl7.fhir.r4.model.Questionnaire in project org.hl7.fhir.core by hapifhir.
the class QuestionnaireRenderer method listOptions.
private void listOptions(Questionnaire q, QuestionnaireItemComponent i, XhtmlNode select) {
if (i.hasAnswerValueSet()) {
ValueSet vs = null;
if (!Utilities.noString(i.getAnswerValueSet()) && i.getAnswerValueSet().startsWith("#")) {
vs = (ValueSet) q.getContained(i.getAnswerValueSet().substring(1));
if (vs != null && !vs.hasUrl()) {
vs = vs.copy();
vs.setUrl(q.getUrl() + "--" + q.getContained(i.getAnswerValueSet().substring(1)));
}
} else {
vs = context.getContext().fetchResource(ValueSet.class, i.getAnswerValueSet());
}
if (vs != null) {
ValueSetExpansionOutcome exp = context.getContext().expandVS(vs, true, false);
if (exp.getValueset() != null) {
for (ValueSetExpansionContainsComponent cc : exp.getValueset().getExpansion().getContains()) {
select.option(cc.getCode(), cc.hasDisplay() ? cc.getDisplay() : cc.getCode(), false);
}
return;
}
}
} else if (i.hasAnswerOption()) {
renderItemOptions(select, i);
}
select.option("a", "??", false);
}
use of org.hl7.fhir.r4.model.Questionnaire in project org.hl7.fhir.core by hapifhir.
the class QuestionnaireRenderer method renderDefns.
private boolean renderDefns(XhtmlNode x, Questionnaire q) throws IOException {
XhtmlNode tbl = x.table("dict");
boolean ext = false;
ext = renderRootDefinition(tbl, q, new ArrayList<>()) || ext;
for (QuestionnaireItemComponent qi : q.getItem()) {
ext = renderDefinition(tbl, q, qi, new ArrayList<>()) || ext;
}
return ext;
}
Aggregations