fix misleading error message + uppate for new release of tests

This commit is contained in:
Grahame Grieve 2020-05-22 08:17:36 +10:00
parent 210864978e
commit 786aa001c5
8 changed files with 132 additions and 5 deletions

View File

@ -532,7 +532,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
return new ValueSetExpansionOutcome(vs.copy()); return new ValueSetExpansionOutcome(vs.copy());
} }
if (!vs.hasUrl()) if (!vs.hasUrl())
throw new Error(formatMessage(I18nConstants.NO_VALUE_SET)); throw new Error(formatMessage(I18nConstants.NO_VALUE_SET_IN_URL));
CacheToken cacheToken = txCache.generateExpandToken(vs, heirarchical); CacheToken cacheToken = txCache.generateExpandToken(vs, heirarchical);
ValueSetExpansionOutcome res; ValueSetExpansionOutcome res;

View File

@ -3,6 +3,7 @@ package org.hl7.fhir.r5.renderers;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.List; import java.util.List;
import java.util.UUID;
import org.hl7.fhir.r5.model.CodeableConcept; import org.hl7.fhir.r5.model.CodeableConcept;
import org.hl7.fhir.r5.model.DomainResource; import org.hl7.fhir.r5.model.DomainResource;
@ -10,9 +11,11 @@ import org.hl7.fhir.r5.model.Expression;
import org.hl7.fhir.r5.model.Extension; import org.hl7.fhir.r5.model.Extension;
import org.hl7.fhir.r5.model.Questionnaire; import org.hl7.fhir.r5.model.Questionnaire;
import org.hl7.fhir.r5.model.ValueSet; import org.hl7.fhir.r5.model.ValueSet;
import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent;
import org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemComponent; import org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemComponent;
import org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemInitialComponent; import org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemInitialComponent;
import org.hl7.fhir.r5.renderers.utils.RenderingContext; import org.hl7.fhir.r5.renderers.utils.RenderingContext;
import org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome;
import org.hl7.fhir.r5.utils.ToolingExtensions; import org.hl7.fhir.r5.utils.ToolingExtensions;
import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator; import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator;
@ -258,7 +261,73 @@ public class QuestionnaireRenderer extends TerminologyRenderer {
p.tx(": "); p.tx(": ");
} }
p.span(null, "linkId: "+i.getLinkId()).tx(i.getText()); p.span(null, "linkId: "+i.getLinkId()).tx(i.getText());
if (i.getRequired()) {
p.span("color: red", "Mandatory").tx(" *");
}
XhtmlNode input = null;
switch (i.getType()) {
case STRING:
p.tx(" ");
input = p.input(i.getLinkId(), "text", i.getType().getDisplay(), 60);
break;
case ATTACHMENT:
break;
case BOOLEAN:
p.tx(" ");
input = p.input(i.getLinkId(), "checkbox", i.getType().getDisplay(), 1);
break;
case CHOICE:
input = p.select(i.getLinkId());
listOptions(q, i, input);
break;
case DATE:
p.tx(" ");
input = p.input(i.getLinkId(), "date", i.getType().getDisplay(), 10);
break;
case DATETIME:
p.tx(" ");
input = p.input(i.getLinkId(), "datetime-local", i.getType().getDisplay(), 25);
break;
case DECIMAL:
p.tx(" ");
input = p.input(i.getLinkId(), "number", i.getType().getDisplay(), 15);
break;
case DISPLAY:
break;
case GROUP:
break;
case INTEGER:
p.tx(" ");
input = p.input(i.getLinkId(), "number", i.getType().getDisplay(), 10);
break;
case OPENCHOICE:
break;
case QUANTITY:
p.tx(" ");
input = p.input(i.getLinkId(), "number", "value", 15);
p.tx(" ");
input = p.input(i.getLinkId(), "unit", "unit", 10);
break;
case QUESTION:
break;
case REFERENCE:
break;
case TEXT:
break;
case TIME:
break;
case URL:
break;
default:
break;
}
if (input != null) {
if (i.getReadOnly()) {
input.attribute("readonly", "1");
}
}
int t = 1; int t = 1;
for (QuestionnaireItemComponent c : i.getItem()) { for (QuestionnaireItemComponent c : i.getItem()) {
hasExt = renderFormItem(d, q, c, pfx == null ? null : pfx+"."+Integer.toString(t), false) || hasExt; hasExt = renderFormItem(d, q, c, pfx == null ? null : pfx+"."+Integer.toString(t), false) || hasExt;
@ -267,6 +336,32 @@ public class QuestionnaireRenderer extends TerminologyRenderer {
return hasExt; return hasExt;
} }
private void listOptions(Questionnaire q, QuestionnaireItemComponent i, XhtmlNode select) {
if (i.hasAnswerValueSet()) {
ValueSet vs = null;
if (i.getAnswerValueSet().startsWith("#")) {
vs = (ValueSet) q.getContained(i.getAnswerValueSet().substring(1)).copy();
if (vs != null && !vs.hasUrl()) {
vs.setUrl("urn:uuid:"+UUID.randomUUID().toString().toLowerCase());
}
} 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()) {
}
select.option("a", "??", false);
}
public String display(DomainResource dr) throws UnsupportedEncodingException, IOException { public String display(DomainResource dr) throws UnsupportedEncodingException, IOException {
return display((Questionnaire) dr); return display((Questionnaire) dr);
} }

View File

@ -19,6 +19,7 @@ import org.fhir.ucum.UcumEssenceService;
import org.hl7.fhir.r5.context.IWorkerContext; import org.hl7.fhir.r5.context.IWorkerContext;
import org.hl7.fhir.r5.context.SimpleWorkerContext; import org.hl7.fhir.r5.context.SimpleWorkerContext;
import org.hl7.fhir.r5.model.Parameters; import org.hl7.fhir.r5.model.Parameters;
import org.hl7.fhir.r5.terminologies.TerminologyClientR5;
import org.hl7.fhir.utilities.CSFile; import org.hl7.fhir.utilities.CSFile;
import org.hl7.fhir.utilities.TextFile; import org.hl7.fhir.utilities.TextFile;
import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.Utilities;
@ -88,6 +89,7 @@ public class TestingUtilities {
IWorkerContext fcontext = SimpleWorkerContext.fromPackage(pcm.loadPackage(VersionUtilities.packageForVersion(version), version)); IWorkerContext fcontext = SimpleWorkerContext.fromPackage(pcm.loadPackage(VersionUtilities.packageForVersion(version), version));
fcontext.setUcumService(new UcumEssenceService(TestingUtilities.loadTestResourceStream("ucum", "ucum-essence.xml"))); fcontext.setUcumService(new UcumEssenceService(TestingUtilities.loadTestResourceStream("ucum", "ucum-essence.xml")));
fcontext.setExpansionProfile(new Parameters()); fcontext.setExpansionProfile(new Parameters());
// ((SimpleWorkerContext) fcontext).connectToTSServer(new TerminologyClientR5("http://tx.fhir.org/r4"), null);
fcontexts.put(v, fcontext); fcontexts.put(v, fcontext);
} catch (Exception e) { } catch (Exception e) {
throw new Error(e); throw new Error(e);

View File

@ -408,7 +408,7 @@ public class I18nConstants {
public final static String CAN_ONLY_SPECIFY_PROFILE_IN_THE_CONTEXT = "Can_only_specify_profile_in_the_context"; public final static String CAN_ONLY_SPECIFY_PROFILE_IN_THE_CONTEXT = "Can_only_specify_profile_in_the_context";
public final static String NO_URL_IN_EXPAND_VALUE_SET_2 = "no_url_in_expand_value_set_2"; public final static String NO_URL_IN_EXPAND_VALUE_SET_2 = "no_url_in_expand_value_set_2";
public final static String NO_URL_IN_EXPAND_VALUE_SET = "no_url_in_expand_value_set"; public final static String NO_URL_IN_EXPAND_VALUE_SET = "no_url_in_expand_value_set";
public final static String NO_VALUE_SET = "no_value_set"; public final static String NO_VALUE_SET_IN_URL = "no_value_set";
public final static String NO_PARAMETERS_PROVIDED_TO_EXPANDVS = "No_Parameters_provided_to_expandVS"; public final static String NO_PARAMETERS_PROVIDED_TO_EXPANDVS = "No_Parameters_provided_to_expandVS";
public final static String NO_EXPANSION_PARAMETERS_PROVIDED = "No_Expansion_Parameters_provided"; public final static String NO_EXPANSION_PARAMETERS_PROVIDED = "No_Expansion_Parameters_provided";
public final static String UNABLE_TO_RESOLVE_VALUE_SET_ = "Unable_to_resolve_value_Set_"; public final static String UNABLE_TO_RESOLVE_VALUE_SET_ = "Unable_to_resolve_value_Set_";

View File

@ -659,4 +659,34 @@ public class XhtmlNode implements IBaseXhtml {
return this; return this;
} }
public XhtmlNode input(String name, String type, String placeholder, int size) {
XhtmlNode p = new XhtmlNode(NodeType.Element, "input");
p.attribute("name", name);
p.attribute("type", type);
p.attribute("placeholder", placeholder);
p.attribute("size", Integer.toString(size));
getChildNodes().add(p);
return p;
}
public XhtmlNode select(String name) {
XhtmlNode p = new XhtmlNode(NodeType.Element, "select");
p.attribute("name", name);
p.attribute("size", "1");
getChildNodes().add(p);
return p;
}
public XhtmlNode option(String value, String text, boolean selected) {
XhtmlNode p = new XhtmlNode(NodeType.Element, "option");
p.attribute("value", value);
p.attribute("selected", Boolean.toString(selected));
p.tx(text);
getChildNodes().add(p);
return p;
}
} }

View File

@ -398,7 +398,7 @@ No_ExpansionProfile_provided = No ExpansionProfile provided
Can_only_specify_profile_in_the_context = Can only specify profile in the context Can_only_specify_profile_in_the_context = Can only specify profile in the context
no_url_in_expand_value_set_2 = no url in expand value set 2 no_url_in_expand_value_set_2 = no url in expand value set 2
no_url_in_expand_value_set = no url in expand value set no_url_in_expand_value_set = no url in expand value set
no_value_set = no value set no_value_set = value set has no url property
No_Parameters_provided_to_expandVS = No Parameters provided to expandVS No_Parameters_provided_to_expandVS = No Parameters provided to expandVS
No_Expansion_Parameters_provided = No Expansion Parameters provided No_Expansion_Parameters_provided = No Expansion Parameters provided
Unable_to_resolve_value_Set_ = Unable to resolve value Set {0} Unable_to_resolve_value_Set_ = Unable to resolve value Set {0}

View File

@ -160,7 +160,7 @@ import com.google.gson.JsonObject;
/** /**
* Thinking of using this in a java program? Don't! * Thinking of using this in a java program? Don't!
* You should use one of the wrappers instead. Either in HAPI, or use ValidationEngine, or NativeHostServices * You should use one of the wrappers instead. Either in HAPI, or use ValidationEngine
* <p> * <p>
* Validation todo: * Validation todo:
* - support @default slices * - support @default slices

View File

@ -17,7 +17,7 @@
<properties> <properties>
<hapi_fhir_version>5.0.0</hapi_fhir_version> <hapi_fhir_version>5.0.0</hapi_fhir_version>
<validator_test_case_version>1.1.14-SNAPSHOT</validator_test_case_version> <validator_test_case_version>1.1.14</validator_test_case_version>
<junit_jupiter_version>5.6.2</junit_jupiter_version> <junit_jupiter_version>5.6.2</junit_jupiter_version>
<maven_surefire_version>3.0.0-M4</maven_surefire_version> <maven_surefire_version>3.0.0-M4</maven_surefire_version>
<jacoco_version>0.8.5</jacoco_version> <jacoco_version>0.8.5</jacoco_version>