Merge remote-tracking branch 'origin/master' into do-i18n-plurals

This commit is contained in:
dotasek 2022-11-03 13:35:40 -04:00
commit fc7cd56335
28 changed files with 401 additions and 130 deletions

View File

@ -60,52 +60,52 @@ public class ExpansionProfile30_40 {
if (src == null)
return null;
org.hl7.fhir.dstu3.model.ExpansionProfile tgt = new org.hl7.fhir.dstu3.model.ExpansionProfile();
if (src.hasParameter("profile-url"))
tgt.setUrl(src.getParameter("profile-url").primitiveValue());
if (src.hasParameter("profile-version"))
tgt.setVersion(src.getParameter("profile-version").primitiveValue());
if (src.hasParameter("profile-name"))
tgt.setName(src.getParameter("profile-name").primitiveValue());
if (src.hasParameter("profile-status"))
tgt.setStatus(PublicationStatus.fromCode(src.getParameter("profile-status").primitiveValue()));
for (Type t : src.getParameters("system-version")) {
if (src.hasParameterValue("profile-url"))
tgt.setUrl(src.getParameterValue("profile-url").primitiveValue());
if (src.hasParameterValue("profile-version"))
tgt.setVersion(src.getParameterValue("profile-version").primitiveValue());
if (src.hasParameterValue("profile-name"))
tgt.setName(src.getParameterValue("profile-name").primitiveValue());
if (src.hasParameterValue("profile-status"))
tgt.setStatus(PublicationStatus.fromCode(src.getParameterValue("profile-status").primitiveValue()));
for (Type t : src.getParameterValues("system-version")) {
String[] v = t.primitiveValue().split("\\|");
tgt.addFixedVersion().setSystem(v[0]).setVersion(v[1]).setMode(SystemVersionProcessingMode.DEFAULT);
}
for (Type t : src.getParameters("force-system-version")) {
for (Type t : src.getParameterValues("force-system-version")) {
String[] v = t.primitiveValue().split("\\|");
tgt.addFixedVersion().setSystem(v[0]).setVersion(v[1]).setMode(SystemVersionProcessingMode.OVERRIDE);
}
for (Type t : src.getParameters("check-system-version")) {
for (Type t : src.getParameterValues("check-system-version")) {
String[] v = t.primitiveValue().split("\\|");
tgt.addFixedVersion().setSystem(v[0]).setVersion(v[1]).setMode(SystemVersionProcessingMode.CHECK);
}
for (Type t : src.getParameters("exclude-system")) {
for (Type t : src.getParameterValues("exclude-system")) {
String[] v = t.primitiveValue().split("\\|");
tgt.getExcludedSystem().setSystem(v[0]).setVersion(v[1]);
}
if (src.hasParameter("includeDesignations"))
if (src.hasParameterValue("includeDesignations"))
tgt.setIncludeDesignations(src.getParameterBool(""));
for (Type t : src.getParameters("designation")) {
for (Type t : src.getParameterValues("designation")) {
String[] v = t.primitiveValue().split("\\|");
if ("urn:ietf:bcp:47".equals(v[0]))
tgt.getDesignation().getInclude().addDesignation().setLanguage(v[1]);
else
tgt.getDesignation().getInclude().addDesignation().getUse().setSystem(v[0]).setCode(v[1]);
}
if (src.hasParameter("includeDefinition"))
if (src.hasParameterValue("includeDefinition"))
tgt.setIncludeDefinition(src.getParameterBool("includeDefinition"));
if (src.hasParameter("activeOnly"))
if (src.hasParameterValue("activeOnly"))
tgt.setActiveOnly(src.getParameterBool("activeOnly"));
if (src.hasParameter("excludeNested"))
if (src.hasParameterValue("excludeNested"))
tgt.setExcludeNested(src.getParameterBool("excludeNested"));
if (src.hasParameter("excludeNotForUI"))
if (src.hasParameterValue("excludeNotForUI"))
tgt.setExcludeNotForUI(src.getParameterBool("excludeNotForUI"));
if (src.hasParameter("excludeNotForUI"))
if (src.hasParameterValue("excludeNotForUI"))
tgt.setExcludePostCoordinated(src.getParameterBool("excludeNotForUI"));
if (src.hasParameter("displayLanguage"))
tgt.setDisplayLanguage(src.getParameter("displayLanguage").primitiveValue());
if (src.hasParameter("limitedExpansion"))
if (src.hasParameterValue("displayLanguage"))
tgt.setDisplayLanguage(src.getParameterValue("displayLanguage").primitiveValue());
if (src.hasParameterValue("limitedExpansion"))
tgt.setLimitedExpansion(src.getParameterBool("getParameterBool"));
return tgt;
}

View File

@ -214,7 +214,7 @@ public class Resource30_40 {
public org.hl7.fhir.dstu3.model.Resource convertResource(org.hl7.fhir.r4.model.Resource src, BaseAdvisor_30_40 advisor) throws FHIRException {
if (src == null) return null;
if (src instanceof org.hl7.fhir.r4.model.Parameters) {
if (((org.hl7.fhir.r4.model.Parameters) src).hasParameter("profile-url"))
if (((org.hl7.fhir.r4.model.Parameters) src).hasParameterValue("profile-url"))
return ExpansionProfile30_40.convertExpansionProfile((org.hl7.fhir.r4.model.Parameters) src);
else return Parameters30_40.convertParameters((org.hl7.fhir.r4.model.Parameters) src);
}

View File

@ -285,7 +285,7 @@ public class Resource30_50 {
public org.hl7.fhir.dstu3.model.Resource convertResource(org.hl7.fhir.r5.model.Resource src) throws FHIRException {
if (src == null) return null;
if (src instanceof org.hl7.fhir.r5.model.Parameters) {
if (((org.hl7.fhir.r5.model.Parameters) src).hasParameter("profile-url"))
if (((org.hl7.fhir.r5.model.Parameters) src).hasParameterValue("profile-url"))
return ExpansionProfile30_50.convertExpansionProfile((org.hl7.fhir.r5.model.Parameters) src);
else return Parameters30_50.convertParameters((org.hl7.fhir.r5.model.Parameters) src);
}

View File

@ -12,52 +12,52 @@ public class ExpansionProfile30_50 {
if (src == null)
return null;
org.hl7.fhir.dstu3.model.ExpansionProfile tgt = new org.hl7.fhir.dstu3.model.ExpansionProfile();
if (src.hasParameter("profile-url"))
tgt.setUrl(src.getParameter("profile-url").primitiveValue());
if (src.hasParameter("profile-version"))
tgt.setVersion(src.getParameter("profile-version").primitiveValue());
if (src.hasParameter("profile-name"))
tgt.setName(src.getParameter("profile-name").primitiveValue());
if (src.hasParameter("profile-status"))
tgt.setStatus(PublicationStatus.fromCode(src.getParameter("profile-status").primitiveValue()));
for (DataType t : src.getParameters("system-version")) {
if (src.hasParameterValue("profile-url"))
tgt.setUrl(src.getParameterValue("profile-url").primitiveValue());
if (src.hasParameterValue("profile-version"))
tgt.setVersion(src.getParameterValue("profile-version").primitiveValue());
if (src.hasParameterValue("profile-name"))
tgt.setName(src.getParameterValue("profile-name").primitiveValue());
if (src.hasParameterValue("profile-status"))
tgt.setStatus(PublicationStatus.fromCode(src.getParameterValue("profile-status").primitiveValue()));
for (DataType t : src.getParameterValues("system-version")) {
String[] v = t.primitiveValue().split("\\|");
tgt.addFixedVersion().setSystem(v[0]).setVersion(v[1]).setMode(SystemVersionProcessingMode.DEFAULT);
}
for (DataType t : src.getParameters("force-system-version")) {
for (DataType t : src.getParameterValues("force-system-version")) {
String[] v = t.primitiveValue().split("\\|");
tgt.addFixedVersion().setSystem(v[0]).setVersion(v[1]).setMode(SystemVersionProcessingMode.OVERRIDE);
}
for (DataType t : src.getParameters("check-system-version")) {
for (DataType t : src.getParameterValues("check-system-version")) {
String[] v = t.primitiveValue().split("\\|");
tgt.addFixedVersion().setSystem(v[0]).setVersion(v[1]).setMode(SystemVersionProcessingMode.CHECK);
}
for (DataType t : src.getParameters("exclude-system")) {
for (DataType t : src.getParameterValues("exclude-system")) {
String[] v = t.primitiveValue().split("\\|");
tgt.getExcludedSystem().setSystem(v[0]).setVersion(v[1]);
}
if (src.hasParameter("includeDesignations"))
if (src.hasParameterValue("includeDesignations"))
tgt.setIncludeDesignations(src.getParameterBool(""));
for (DataType t : src.getParameters("designation")) {
for (DataType t : src.getParameterValues("designation")) {
String[] v = t.primitiveValue().split("\\|");
if ("urn:ietf:bcp:47".equals(v[0]))
tgt.getDesignation().getInclude().addDesignation().setLanguage(v[1]);
else
tgt.getDesignation().getInclude().addDesignation().getUse().setSystem(v[0]).setCode(v[1]);
}
if (src.hasParameter("includeDefinition"))
if (src.hasParameterValue("includeDefinition"))
tgt.setIncludeDefinition(src.getParameterBool("includeDefinition"));
if (src.hasParameter("activeOnly"))
if (src.hasParameterValue("activeOnly"))
tgt.setActiveOnly(src.getParameterBool("activeOnly"));
if (src.hasParameter("excludeNested"))
if (src.hasParameterValue("excludeNested"))
tgt.setExcludeNested(src.getParameterBool("excludeNested"));
if (src.hasParameter("excludeNotForUI"))
if (src.hasParameterValue("excludeNotForUI"))
tgt.setExcludeNotForUI(src.getParameterBool("excludeNotForUI"));
if (src.hasParameter("excludeNotForUI"))
if (src.hasParameterValue("excludeNotForUI"))
tgt.setExcludePostCoordinated(src.getParameterBool("excludeNotForUI"));
if (src.hasParameter("displayLanguage"))
tgt.setDisplayLanguage(src.getParameter("displayLanguage").primitiveValue());
if (src.hasParameter("limitedExpansion"))
if (src.hasParameterValue("displayLanguage"))
tgt.setDisplayLanguage(src.getParameterValue("displayLanguage").primitiveValue());
if (src.hasParameterValue("limitedExpansion"))
tgt.setLimitedExpansion(src.getParameterBool("getParameterBool"));
return tgt;
}

View File

@ -877,6 +877,14 @@ public class Parameters extends Resource implements IBaseParameters {
return this;
}
public boolean hasParameterValue(String name) {
for (ParametersParameterComponent p : getParameter()) {
if (p.getName().equals(name) && p.hasValue())
return true;
}
return false;
}
public boolean hasParameter(String name) {
for (ParametersParameterComponent p : getParameter()) {
if (p.getName().equals(name))
@ -885,7 +893,7 @@ public class Parameters extends Resource implements IBaseParameters {
return false;
}
public Type getParameter(String name) {
public Type getParameterValue(String name) {
for (ParametersParameterComponent p : getParameter()) {
if (p.getName().equals(name))
return p.getValue();
@ -893,7 +901,15 @@ public class Parameters extends Resource implements IBaseParameters {
return null;
}
public List<Type> getParameters(String name) {
public ParametersParameterComponent getParameter(String name) {
for (ParametersParameterComponent p : getParameter()) {
if (p.getName().equals(name))
return p;
}
return null;
}
public List<Type> getParameterValues(String name) {
List<Type> res = new ArrayList<Type>();
for (ParametersParameterComponent p : getParameter()) {
if (p.getName().equals(name))
@ -902,7 +918,15 @@ public class Parameters extends Resource implements IBaseParameters {
return res;
}
public List<ParametersParameterComponent> getParameters(String name) {
List<ParametersParameterComponent> res = new ArrayList<ParametersParameterComponent>();
for (ParametersParameterComponent p : getParameter()) {
if (p.getName().equals(name))
res.add(p);
}
return res;
}
public boolean getParameterBool(String name) {
for (ParametersParameterComponent p : getParameter()) {
if (p.getName().equals(name)) {

View File

@ -1667,6 +1667,14 @@ public Parameters addParameter(String name, boolean b) {
return this;
}
public boolean hasParameterValue(String name) {
for (ParametersParameterComponent p : getParameter()) {
if (p.getName().equals(name) && p.hasValue())
return true;
}
return false;
}
public boolean hasParameter(String name) {
for (ParametersParameterComponent p : getParameter()) {
if (p.getName().equals(name))
@ -1675,7 +1683,7 @@ public Parameters addParameter(String name, boolean b) {
return false;
}
public DataType getParameter(String name) {
public DataType getParameterValue(String name) {
for (ParametersParameterComponent p : getParameter()) {
if (p.getName().equals(name))
return p.getValue();
@ -1683,7 +1691,15 @@ public Parameters addParameter(String name, boolean b) {
return null;
}
public List<DataType> getParameters(String name) {
public ParametersParameterComponent getParameter(String name) {
for (ParametersParameterComponent p : getParameter()) {
if (p.getName().equals(name))
return p;
}
return null;
}
public List<DataType> getParameterValues(String name) {
List<DataType> res = new ArrayList<>();
for (ParametersParameterComponent p : getParameter()) {
if (p.getName().equals(name))
@ -1692,6 +1708,15 @@ public Parameters addParameter(String name, boolean b) {
return res;
}
public List<ParametersParameterComponent> getParameters(String name) {
List<ParametersParameterComponent> res = new ArrayList<>();
for (ParametersParameterComponent p : getParameter()) {
if (p.getName().equals(name))
res.add(p);
}
return res;
}
public boolean getParameterBool(String name) {
for (ParametersParameterComponent p : getParameter()) {

View File

@ -691,7 +691,7 @@ public class ProfileUtilities extends TranslatingUtilities {
derived.setSnapshot(new StructureDefinitionSnapshotComponent());
try {
checkDifferential(derived.getDifferential().getElement(), typeName(derived.getType()), derived.getUrl());
checkDifferential(derived.getDifferential().getElement(), derived.getTypeName(), derived.getUrl());
checkDifferentialBaseType(derived);
copyInheritedExtensions(base, derived);
@ -712,11 +712,9 @@ public class ProfileUtilities extends TranslatingUtilities {
StructureDefinitionDifferentialComponent diff = cloneDiff(derived.getDifferential()); // we make a copy here because we're sometimes going to hack the differential while processing it. Have to migrate user data back afterwards
StructureDefinitionSnapshotComponent baseSnapshot = base.getSnapshot();
if (derived.getDerivation() == TypeDerivationRule.SPECIALIZATION) {
String derivedType = derived.getType();
if (StructureDefinitionKind.LOGICAL.equals(derived.getKind()) && derived.getType().contains("/")) {
derivedType = derivedType.substring(derivedType.lastIndexOf("/")+1);
}
baseSnapshot = cloneSnapshot(baseSnapshot, base.getType(), derivedType);
String derivedType = derived.getTypeName();
baseSnapshot = cloneSnapshot(baseSnapshot, base.getTypeName(), derivedType);
}
// if (derived.getId().equals("2.16.840.1.113883.10.20.22.2.1.1")) {
// debug = true;
@ -726,7 +724,7 @@ public class ProfileUtilities extends TranslatingUtilities {
checkGroupConstraints(derived);
if (derived.getDerivation() == TypeDerivationRule.SPECIALIZATION) {
for (ElementDefinition e : diff.getElement()) {
if (!e.hasUserData(GENERATED_IN_SNAPSHOT)) {
if (!e.hasUserData(GENERATED_IN_SNAPSHOT) && e.getPath().contains(".")) {
ElementDefinition outcome = updateURLs(url, webUrl, e.copy());
e.setUserData(GENERATED_IN_SNAPSHOT, outcome);
derived.getSnapshot().addElement(outcome);
@ -878,11 +876,11 @@ public class ProfileUtilities extends TranslatingUtilities {
private void addInheritedElementsForSpecialization(StructureDefinitionSnapshotComponent snapshot, ElementDefinition focus, String type, String path, String url, String weburl) {
StructureDefinition sd = context.fetchTypeDefinition(type);
if (sd != null) {
addInheritedElementsForSpecialization(snapshot, focus, sd.getBaseDefinition(), path, url, weburl);
// don't do this. should already be in snapshot ... addInheritedElementsForSpecialization(snapshot, focus, sd.getBaseDefinition(), path, url, weburl);
for (ElementDefinition ed : sd.getSnapshot().getElement()) {
if (ed.getPath().contains(".")) {
ElementDefinition outcome = updateURLs(url, weburl, ed.copy());
outcome.setPath(outcome.getPath().replace(sd.getType(), path));
outcome.setPath(outcome.getPath().replace(sd.getTypeName(), path));
snapshot.getElement().add(outcome);
} else {
focus.getConstraint().addAll(ed.getConstraint());
@ -935,13 +933,6 @@ public class ProfileUtilities extends TranslatingUtilities {
return sd != null && type.size() == 1 && sd.getType().equals(type.get(0).getCode());
}
private String typeName(String type) {
if (Utilities.isAbsoluteUrl(type)) {
return type.substring(type.lastIndexOf("/")+1);
} else {
return type;
}
}
private void checkGroupConstraints(StructureDefinition derived) {
List<ElementDefinition> toRemove = new ArrayList<>();
@ -3722,7 +3713,7 @@ public class ProfileUtilities extends TranslatingUtilities {
c.getPieces().add(gen.new Piece("#"+ed.getElement().getPath(), tail(ed.getElement().getPath()), ed.getElement().getPath()));
} else {
c.getPieces().add(gen.new Piece(null, translate("sd.table", "See ", ed.getElement().getPath()), null));
c.getPieces().add(gen.new Piece(pfx(corePath, ed.getSource().getUserString("path"))+"#"+ed.getElement().getPath(), tail(ed.getElement().getPath())+" ("+ed.getSource().getType()+")", ed.getElement().getPath()));
c.getPieces().add(gen.new Piece(pfx(corePath, ed.getSource().getUserString("path"))+"#"+ed.getElement().getPath(), tail(ed.getElement().getPath())+" ("+ed.getSource().getTypeName()+")", ed.getElement().getPath()));
}
}
return c;
@ -3842,7 +3833,7 @@ public class ProfileUtilities extends TranslatingUtilities {
if (sd == null) {
c.addPiece(checkForNoChange(t, gen.new Piece(pkp.getLinkFor(corePath, tc), tc, null)));
} else {
c.addPiece(checkForNoChange(t, gen.new Piece(pkp.getLinkFor(corePath, tc), sd.getType(), null)));
c.addPiece(checkForNoChange(t, gen.new Piece(pkp.getLinkFor(corePath, tc), sd.getTypeName(), null)));
}
} else if (pkp != null && pkp.hasLinkFor(tc)) {
c.addPiece(checkForNoChange(t, gen.new Piece(pkp.getLinkFor(corePath, tc), tc, null)));
@ -4118,13 +4109,13 @@ public class ProfileUtilities extends TranslatingUtilities {
List<ElementDefinition> list = new ArrayList<>();
list.addAll(profile.getDifferential().getElement());
if (list.isEmpty()) {
ElementDefinition root = new ElementDefinition().setPath(profile.getType());
root.setId(profile.getType());
ElementDefinition root = new ElementDefinition().setPath(profile.getTypeName());
root.setId(profile.getTypeName());
list.add(root);
} else {
if (list.get(0).getPath().contains(".")) {
ElementDefinition root = new ElementDefinition().setPath(profile.getType());
root.setId(profile.getType());
ElementDefinition root = new ElementDefinition().setPath(profile.getTypeName());
root.setId(profile.getTypeName());
list.add(0, root);
}
}
@ -4652,7 +4643,7 @@ public class ProfileUtilities extends TranslatingUtilities {
choicerow.getCells().add(gen.new Cell());
choicerow.getCells().add(gen.new Cell(null, null, "", null, null));
choicerow.setIcon("icon_primitive.png", HierarchicalTableGenerator.TEXT_ICON_PRIMITIVE);
Cell c = gen.new Cell(null, corePath+"datatypes.html#"+t, sd.getType(), null, null);
Cell c = gen.new Cell(null, corePath+"datatypes.html#"+t, sd.getTypeName(), null, null);
choicerow.getCells().add(c);
if (!mustSupportMode && isMustSupport(tr) && element.getMustSupport()) {
c.addPiece(gen.new Piece(null, " ", null));
@ -4663,7 +4654,7 @@ public class ProfileUtilities extends TranslatingUtilities {
choicerow.getCells().add(gen.new Cell());
choicerow.getCells().add(gen.new Cell(null, null, "", null, null));
choicerow.setIcon("icon_datatype.gif", HierarchicalTableGenerator.TEXT_ICON_DATATYPE);
Cell c = gen.new Cell(null, pkp.getLinkFor(corePath, t), sd.getType(), null, null);
Cell c = gen.new Cell(null, pkp.getLinkFor(corePath, t), sd.getTypeName(), null, null);
choicerow.getCells().add(c);
if (!mustSupportMode && isMustSupport(tr) && element.getMustSupport()) {
c.addPiece(gen.new Piece(null, " ", null));
@ -4879,7 +4870,7 @@ public class ProfileUtilities extends TranslatingUtilities {
boolean first = true;
for (StructureDefinition sd : children) {
if (first) first = false; else c.addPiece(gen.new Piece(null, ", ", null));
c.addPiece(gen.new Piece(sd.getUserString("path"), sd.getType(), null));
c.addPiece(gen.new Piece(sd.getUserString("path"), sd.getTypeName(), null));
}
}
}
@ -5052,7 +5043,7 @@ public class ProfileUtilities extends TranslatingUtilities {
c.getPieces().add(gen.new Piece(null, type, null));
c.getPieces().add(gen.new Piece("</code>"));
} else {
c.getPieces().add(gen.new Piece(sd.getUserString("path"), sd.getType(), null));
c.getPieces().add(gen.new Piece(sd.getUserString("path"), sd.getTypeName(), null));
}
}
}
@ -5332,7 +5323,7 @@ public class ProfileUtilities extends TranslatingUtilities {
private ElementDefinition findElementDefinition(StructureDefinition sd, String name) {
String path = sd.getType()+"."+name;
String path = sd.getTypeName()+"."+name;
for (ElementDefinition ed : sd.getSnapshot().getElement()) {
if (ed.getPath().equals(path))
return ed;
@ -5403,7 +5394,7 @@ public class ProfileUtilities extends TranslatingUtilities {
if (ed.getSource() == profile) {
c.getPieces().add(gen.new Piece("#"+ed.getElement().getPath(), "See "+ed.getElement().getPath(), null));
} else {
c.getPieces().add(gen.new Piece(ed.getSource().getUserData("path")+"#"+ed.getElement().getPath(), "See "+ed.getSource().getType()+"."+ed.getElement().getPath(), null));
c.getPieces().add(gen.new Piece(ed.getSource().getUserData("path")+"#"+ed.getElement().getPath(), "See "+ed.getSource().getTypeName()+"."+ed.getElement().getPath(), null));
}
}
}
@ -5618,7 +5609,7 @@ public class ProfileUtilities extends TranslatingUtilities {
private String baseType(String value) {
StructureDefinition sd = context.fetchTypeDefinition(value);
if (sd != null) // might be running before all SDs are available
return sd.getType();
return sd.getTypeName();
if (Utilities.existsInList(value, "SimpleQuantity", "MoneyQuantity"))
return "Quantity";
throw new Error(context.formatMessage(I18nConstants.INTERNAL_ERROR___TYPE_NOT_KNOWN_, value));
@ -6736,7 +6727,7 @@ public class ProfileUtilities extends TranslatingUtilities {
res.setName(name);
res.setCardinality(cardinality);
res.setProfileLink(profile.getUserString("path"));
res.setResType(profile.getType());
res.setResType(profile.getTypeName());
StructureDefinition base = context.fetchResource(StructureDefinition.class, res.getResType());
if (base != null)
res.setResLink(base.getUserString("path"));
@ -7163,7 +7154,7 @@ public class ProfileUtilities extends TranslatingUtilities {
b.append("<a href=\"");
b.append(sd.getUserString("path"));
b.append("\">");
b.append(Utilities.escapeXml(sd.getType()));
b.append(Utilities.escapeXml(sd.getTypeName()));
b.append("</a>");
}
}

View File

@ -1238,5 +1238,18 @@ public class Element extends Base {
}
return "e:"+e+",w:"+w+",h:"+h;
}
public void populatePaths(String path) {
if (path == null) {
path = fhirType();
}
setPath(path);
if (children != null) {
for (Element n : children) {
n.populatePaths(path+"."+n.getName());
}
}
}
}

View File

@ -636,6 +636,10 @@ public class JsonParser extends ParserBase {
@Override
public void compose(Element e, OutputStream stream, OutputStyle style, String identity) throws FHIRException, IOException {
if (e.getPath() == null) {
e.populatePaths(null);
}
OutputStreamWriter osw = new OutputStreamWriter(stream, "UTF-8");
if (style == OutputStyle.CANONICAL)
json = new JsonCreatorCanonical(osw);
@ -654,6 +658,10 @@ public class JsonParser extends ParserBase {
}
public void compose(Element e, JsonCreator json) throws Exception {
if (e.getPath() == null) {
e.populatePaths(null);
}
this.json = json;
json.beginObject();

View File

@ -315,6 +315,10 @@ public class TurtleParser extends ParserBase {
public void compose(Element e, Turtle ttl, String base) throws FHIRException {
if (e.getPath() == null) {
e.populatePaths(null);
}
ttl.prefix("fhir", FHIR_URI_BASE);
ttl.prefix("rdfs", "http://www.w3.org/2000/01/rdf-schema#");
ttl.prefix("owl", "http://www.w3.org/2002/07/owl#");

View File

@ -602,6 +602,9 @@ public class XmlParser extends ParserBase {
xml.setSortAttributes(false);
xml.setPretty(style == OutputStyle.PRETTY);
xml.start();
if (e.getPath() == null) {
e.populatePaths(null);
}
String ns = e.getProperty().getXmlNamespace();
if (ns!=null && !"noNamespace".equals(ns)) {
xml.setDefaultNamespace(ns);
@ -654,6 +657,9 @@ public class XmlParser extends ParserBase {
}
public void compose(Element e, IXMLWriter xml) throws Exception {
if (e.getPath() == null) {
e.populatePaths(null);
}
xml.start();
xml.setDefaultNamespace(e.getProperty().getXmlNamespace());
if (schemaPath != null) {

View File

@ -39,6 +39,7 @@ import org.hl7.fhir.r5.model.Enumerations.*;
import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.instance.model.api.ICompositeType;
import ca.uhn.fhir.model.api.annotation.ResourceDef;
import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
@ -1747,6 +1748,14 @@ public Parameters addParameter(String name, boolean b) {
return this;
}
public boolean hasParameterValue(String name) {
for (ParametersParameterComponent p : getParameter()) {
if (p.getName().equals(name) && p.hasValue())
return true;
}
return false;
}
public boolean hasParameter(String name) {
for (ParametersParameterComponent p : getParameter()) {
if (p.getName().equals(name))
@ -1755,7 +1764,7 @@ public Parameters addParameter(String name, boolean b) {
return false;
}
public DataType getParameter(String name) {
public DataType getParameterValue(String name) {
for (ParametersParameterComponent p : getParameter()) {
if (p.getName().equals(name))
return p.getValue();
@ -1763,7 +1772,15 @@ public Parameters addParameter(String name, boolean b) {
return null;
}
public List<DataType> getParameters(String name) {
public ParametersParameterComponent getParameter(String name) {
for (ParametersParameterComponent p : getParameter()) {
if (p.getName().equals(name))
return p;
}
return null;
}
public List<DataType> getParameterValues(String name) {
List<DataType> res = new ArrayList<>();
for (ParametersParameterComponent p : getParameter()) {
if (p.getName().equals(name))
@ -1771,7 +1788,15 @@ public Parameters addParameter(String name, boolean b) {
}
return res;
}
public List<ParametersParameterComponent> getParameters(String name) {
List<ParametersParameterComponent> res = new ArrayList<ParametersParameterComponent>();
for (ParametersParameterComponent p : getParameter()) {
if (p.getName().equals(name))
res.add(p);
}
return res;
}
public boolean getParameterBool(String name) {
for (ParametersParameterComponent p : getParameter()) {

View File

@ -4671,7 +4671,14 @@ public String describeType() {
return "Definition";
}
}
public String getTypeName() {
String t = getType();
return StructureDefinitionKind.LOGICAL.equals(getKind()) && t.contains("/") ? t.substring(t.lastIndexOf("/")+1) : t;
}
// end addition
}

View File

@ -15,6 +15,7 @@ import java.time.format.FormatStyle;
import java.time.format.SignStyle;
import java.util.Currency;
import java.util.List;
import java.util.Set;
import org.hl7.fhir.exceptions.DefinitionException;
import org.hl7.fhir.exceptions.FHIRException;
@ -97,6 +98,45 @@ public class DataRenderer extends Renderer {
// -- 2. Markdown support -------------------------------------------------------
public static String processRelativeUrls(String markdown, String path) {
if (markdown == null) {
return "";
}
if (!Utilities.isAbsoluteUrl(path)) {
return markdown;
}
String basePath = path.contains("/") ? path.substring(0, path.lastIndexOf("/")+1) : path+"/";
StringBuilder b = new StringBuilder();
int i = 0;
while (i < markdown.length()) {
if (i < markdown.length()-3 && markdown.substring(i, i+2).equals("](")) {
int j = i + 2;
while (j < markdown.length() && markdown.charAt(j) != ')')
j++;
if (j < markdown.length()) {
String url = markdown.substring(i+2, j);
if (!Utilities.isAbsoluteUrl(url) && !url.startsWith("..")) {
// it's relative - so it's relative to the base URL
b.append("](");
b.append(basePath);
} else {
b.append("](");
}
i = i + 1;
} else
b.append(markdown.charAt(i));
} else {
b.append(markdown.charAt(i));
}
i++;
}
return b.toString();
}
protected void addMarkdown(XhtmlNode x, String text, String path) throws FHIRFormatError, IOException, DefinitionException {
addMarkdown(x, processRelativeUrls(text, path));
}
protected void addMarkdown(XhtmlNode x, String text) throws FHIRFormatError, IOException, DefinitionException {
if (text != null) {
// 1. custom FHIR extensions

View File

@ -68,6 +68,7 @@ import org.hl7.fhir.r5.renderers.utils.DirectWrappers;
import org.hl7.fhir.r5.renderers.utils.DirectWrappers.BaseWrapperDirect;
import org.hl7.fhir.r5.renderers.utils.DirectWrappers.PropertyWrapperDirect;
import org.hl7.fhir.r5.renderers.utils.DirectWrappers.ResourceWrapperDirect;
import org.hl7.fhir.r5.renderers.utils.ElementWrappers;
import org.hl7.fhir.r5.renderers.utils.RenderingContext;
import org.hl7.fhir.r5.renderers.utils.Resolver.ResourceContext;
import org.hl7.fhir.r5.renderers.utils.Resolver.ResourceWithReference;
@ -103,7 +104,7 @@ public class ProfileDrivenRenderer extends ResourceRenderer {
boolean idDone = false;
XhtmlNode p = x.para();
if (context.isAddGeneratedNarrativeHeader()) {
p.b().tx("Generated Narrative: "+r.fhirType());
p.b().tx("Generated Narrative: "+r.fhirType()+(context.isContained() ? " #"+r.getId() : ""));
if (!Utilities.noString(r.getId())) {
p.an(r.getId());
}
@ -756,35 +757,50 @@ public class ProfileDrivenRenderer extends ResourceRenderer {
if (children.isEmpty()) {
renderLeaf(res, e, defn, x, x, false, showCodeDetails, readDisplayHints(defn), path, indent);
} else {
for (PropertyWrapper p : splitExtensions(profile, e.children())) {
if (p.hasValues()) {
ElementDefinition child = getElementDefinition(children, path+"."+p.getName(), p);
if (child == null) {
child = p.getElementDefinition();
}
if (child != null) {
if (!child.getBase().hasPath() || !child.getBase().getPath().startsWith("Resource.")) {
generateElementByProfile(res, profile, allElements, x, path, showCodeDetails, indent, p, child);
}
}
List<PropertyWrapper> pl = splitExtensions(profile, e.children());
for (PropertyWrapper p : pl) {
generateForProperty(res, profile, allElements, children, x, path, showCodeDetails, indent, false, p);
}
for (PropertyWrapper p : pl) {
generateForProperty(res, profile, allElements, children, x, path, showCodeDetails, indent, true, p);
}
}
}
private void generateForProperty(ResourceWrapper res, StructureDefinition profile,
List<ElementDefinition> allElements, List<ElementDefinition> children, XhtmlNode x, String path,
boolean showCodeDetails, int indent, boolean round2, PropertyWrapper p)
throws UnsupportedEncodingException, IOException, EOperationOutcome {
if (p.hasValues()) {
ElementDefinition child = getElementDefinition(children, path+"."+p.getName(), p);
if (child == null) {
child = p.getElementDefinition();
}
if (child != null) {
if (!child.getBase().hasPath() || !child.getBase().getPath().startsWith("Resource.")) {
generateElementByProfile(res, profile, allElements, x, path, showCodeDetails, indent, p, child, round2);
}
}
}
}
public void generateElementByProfile(ResourceWrapper res, StructureDefinition profile, List<ElementDefinition> allElements, XhtmlNode x, String path,
boolean showCodeDetails, int indent, PropertyWrapper p, ElementDefinition child) throws UnsupportedEncodingException, IOException, EOperationOutcome {
boolean showCodeDetails, int indent, PropertyWrapper p, ElementDefinition child, boolean round2) throws UnsupportedEncodingException, IOException, EOperationOutcome {
Map<String, String> displayHints = readDisplayHints(child);
if ("DomainResource.contained".equals(child.getBase().getPath())) {
// for (BaseWrapper v : p.getValues()) {
// x.hr();
// RenderingContext ctxt = context.clone();
// ctxt.setContained(true);
// ResourceRenderer rnd = RendererFactory.factory(v.fhirType(), ctxt);
// ResourceWrapper rw = new ElementWrappers.ResourceWrapperMetaElement(ctxt, (org.hl7.fhir.r5.elementmodel.Element) v.getBase());
// rnd.render(x.blockquote(), rw);
// }
} else if (!exemptFromRendering(child)) {
if (round2) {
for (BaseWrapper v : p.getValues()) {
if (!RendererFactory.hasSpecificRenderer(v.fhirType())) {
x.hr();
RenderingContext ctxt = context.copy();
ctxt.setContained(true);
ResourceRenderer rnd = RendererFactory.factory(v.fhirType(), ctxt);
ResourceWrapper rw = new ElementWrappers.ResourceWrapperMetaElement(ctxt, (org.hl7.fhir.r5.elementmodel.Element) v.getBase());
rnd.render(x.blockquote(), rw);
}
}
}
} else if (!round2 && !exemptFromRendering(child)) {
if (isExtension(p)) {
hasExtensions = true;
}
@ -1004,7 +1020,7 @@ public class ProfileDrivenRenderer extends ResourceRenderer {
PropertyWrapper pe = map.get(p.getName()+"["+url+"]");
if (pe == null) {
if (ed == null) {
if (url.startsWith("http://hl7.org/fhir") && !url.startsWith("http://hl7.org/fhir/us")) {
if (url != null && url.startsWith("http://hl7.org/fhir") && !url.startsWith("http://hl7.org/fhir/us")) {
throw new DefinitionException("unknown extension "+url);
}
// System.out.println("unknown extension "+url);

View File

@ -769,7 +769,7 @@ public class ValueSetRenderer extends TerminologyRenderer {
td = tr.td();
if (cs != null) {
String defn = CodeSystemUtilities.getCodeDefinition(cs, c.getCode());
addMarkdown(td, defn);
addMarkdown(td, defn, cs.getUserString("path"));
}
}
for (String n : Utilities.sorted(properties.keySet())) {

View File

@ -98,7 +98,7 @@ public class Resolver {
if (resource instanceof Bundle) {
Bundle b = (Bundle) resource;
for (BundleEntryComponent be : b.getEntry()) {
if (be.getFullUrl().equals(value))
if (be.hasFullUrl() && be.getFullUrl().equals(value))
return be;
if (value.equals(be.getResource().fhirType()+"/"+be.getResource().getId()))
return be;

View File

@ -238,7 +238,8 @@ public class ToolingExtensions {
public static final String WEB_EXTENSION_STYLE = "http://build.fhir.org/ig/FHIR/fhir-tools-ig/branches/master/format-extensions.html#extension-related-extensions";
public static final String WEB_EXTENSION_STYLE = "http://build.fhir.org/ig/FHIR/fhir-tools-ig/format-extensions.html#extension-related-extensions";
public static final String EXT_IGDEP_COMMENT = "http://hl7.org/fhir/tools/StructureDefinition/implementationguide-dependency-comment";
;
// specific extension helpers

View File

@ -139,7 +139,9 @@ public class SimpleHTTPClient {
u = new URL(url);
c = (HttpURLConnection) u.openConnection();
c.setRequestMethod("GET");
c.setRequestProperty("Accept", accept);
if (accept != null) {
c.setRequestProperty("Accept", accept);
}
setHeaders(c);
c.setInstanceFollowRedirects(false);
if (trustAll && url.startsWith("https://")) {

View File

@ -737,6 +737,15 @@ public class I18nConstants {
public static final String TYPE_SPECIFIER_NM_ILLEGAL_TYPE = "TYPE_SPECIFIER_NM_ILLEGAL_TYPE";
public static final String TYPE_SPECIFIER_NM_ABSTRACT_TYPE = "TYPE_SPECIFIER_NM_ABSTRACT_TYPE";
public static final String Bundle_BUNDLE_Entry_NO_LOGICAL_EXPL = "Bundle_BUNDLE_Entry_NO_LOGICAL_EXPL";
public static final String SD_TYPE_MISSING = "SD_TYPE_MISSING";
public static final String SD_TYPE_NOT_MATCH_NS = "SD_TYPE_NOT_MATCH_NS";
public static final String SD_TYPE_NOT_DERIVED = "SD_TYPE_NOT_DERIVED";
public static final String SD_TYPE_NOT_LOCAL = "SD_TYPE_NOT_LOCAL";
public static final String SD_TYPE_NOT_LOGICAL = "SD_TYPE_NOT_LOGICAL";
public static final String SD_CONSTRAINED_TYPE_NO_MATCH = "SD_CONSTRAINED_TYPE_NO_MATCH";
public static final String SD_SPECIALIZED_TYPE_MATCHES = "SD_SPECIALIZED_TYPE_MATCHES";
public static final String SD_CONSTRAINED_KIND_NO_MATCH = "SD_CONSTRAINED_KIND_NO_MATCH";
public static final String SD_PATH_TYPE_MISMATCH = "SD_PATH_TYPE_MISMATCH";
}

View File

@ -6,6 +6,6 @@ public class CommonPackages {
public static final String VER_XVER = "0.0.11";
public static final String ID_PUBPACK = "hl7.fhir.pubpack";
public static final String VER_PUBPACK = "0.1.2";
public static final String VER_PUBPACK = "0.1.3";
}

View File

@ -787,4 +787,12 @@ MULTIPLE_LOGICAL_MODELS_PLURAL_one=
MULTIPLE_LOGICAL_MODELS_PLURAL_other={0} Logical Models found in supplied profiles, so unable to parse logical model (can only be one, found {1})
UNRECOGNISED_PROPERTY_TYPE = Invalid JSON type {0} for the element {1}; valid types = {2}
UNRECOGNISED_PROPERTY_TYPE_WRONG = Invalid type {2} for the element {1}; valid types = {3}, JSON type = {0}
SD_TYPE_MISSING = No type found
SD_TYPE_NOT_MATCH_NS = The type namespace {0} SHOULD match the url namespace {1} for the definition of the type
SD_TYPE_NOT_DERIVED = The type {0} can only be used as a type when constraining the base definition of the type
SD_TYPE_NOT_LOCAL = The type {0} is not legal because it is not defined in the FHIR specification. Other types must have a namespace on them
SD_TYPE_NOT_LOGICAL = The type {0} can only be defined if the kind is 'logical' not {1}
SD_CONSTRAINED_TYPE_NO_MATCH = The type {0} must be the same as the type in the base structure {1} that is being constrained
SD_SPECIALIZED_TYPE_MATCHES = The type {0} must not be the same as the type in the base structure {1} that is being specialised
SD_CONSTRAINED_KIND_NO_MATCH = The kind {0} must be the same as the kind {1} in the base structure {2}
SD_PATH_TYPE_MISMATCH = The path {1} must start with the type of the structure {0}

View File

@ -618,6 +618,7 @@ public class ValidationEngine implements IValidatorResourceFetcher, IValidationP
if (map == null) throw new Error("Unable to find map " + mapUri + " (Known Maps = " + context.listMapUrls() + ")");
org.hl7.fhir.r5.elementmodel.Element resource = getTargetResourceFromStructureMap(map);
scu.transform(null, src, map, resource);
resource.populatePaths(null);
return resource;
}

View File

@ -385,6 +385,7 @@ public class ValidationService {
for (String src : cliContext.getIgs()) {
igLoader.loadIg(validator.getIgs(), validator.getBinaries(), src, cliContext.isRecursive());
}
System.out.println(" Package Summary: "+validator.getContext().loadedPackageSummary());
System.out.print(" Get set... ");
validator.setQuestionnaireMode(cliContext.getQuestionnaireMode());
validator.setLevel(cliContext.getLevel());

View File

@ -2410,12 +2410,20 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
DecimalStatus ds = Utilities.checkDecimal(e.primitiveValue(), true, false);
if (rule(errors, IssueType.INVALID, e.line(), e.col(), path, ds == DecimalStatus.OK || ds == DecimalStatus.RANGE, I18nConstants.TYPE_SPECIFIC_CHECKS_DT_DECIMAL_VALID, e.primitiveValue())) {
warning(errors, IssueType.VALUE, e.line(), e.col(), path, ds != DecimalStatus.RANGE, I18nConstants.TYPE_SPECIFIC_CHECKS_DT_DECIMAL_RANGE, e.primitiveValue());
try {
try {
Decimal v = new Decimal(e.getValue());
ok = rule(errors, IssueType.INVALID, e.line(), e.col(), path, !context.hasMaxValueIntegerType() ||
!context.getMaxValueIntegerType().hasValue() || checkDecimalMaxValue(v, context.getMaxValueDecimalType().getValue()), I18nConstants.TYPE_SPECIFIC_CHECKS_DT_DECIMAL_GT, (context.hasMaxValueIntegerType() ? context.getMaxValueIntegerType() : "")) && ok;
ok = rule(errors, IssueType.INVALID, e.line(), e.col(), path, !context.hasMinValueIntegerType() ||
!context.getMinValueIntegerType().hasValue() || checkDecimalMinValue(v, context.getMaxValueDecimalType().getValue()), I18nConstants.TYPE_SPECIFIC_CHECKS_DT_DECIMAL_LT, (context.hasMinValueIntegerType() ? context.getMinValueIntegerType() : "")) && ok;
if (context.hasMaxValueDecimalType() && context.getMaxValueDecimalType().hasValue()) {
ok = rule(errors, IssueType.INVALID, e.line(), e.col(), path, checkDecimalMaxValue(v, context.getMaxValueDecimalType().getValue()), I18nConstants.TYPE_SPECIFIC_CHECKS_DT_DECIMAL_GT, context.getMaxValueDecimalType()) && ok;
} else if (context.hasMaxValueIntegerType() && context.getMaxValueIntegerType().hasValue()) {
// users can also provide a max integer type. It's not clear whether that's actually valid, but we'll check for it anyway
ok = rule(errors, IssueType.INVALID, e.line(), e.col(), path, checkDecimalMaxValue(v, new BigDecimal(context.getMaxValueIntegerType().getValue())), I18nConstants.TYPE_SPECIFIC_CHECKS_DT_DECIMAL_GT, context.getMaxValueIntegerType()) && ok;
}
if (context.hasMinValueDecimalType() && context.getMaxValueDecimalType().hasValue()) {
ok = rule(errors, IssueType.INVALID, e.line(), e.col(), path, checkDecimalMinValue(v, context.getMaxValueDecimalType().getValue()), I18nConstants.TYPE_SPECIFIC_CHECKS_DT_DECIMAL_LT, context.getMaxValueDecimalType()) && ok;
} else if (context.hasMinValueIntegerType() && context.getMaxValueIntegerType().hasValue()) {
ok = rule(errors, IssueType.INVALID, e.line(), e.col(), path, checkDecimalMinValue(v, new BigDecimal(context.getMaxValueIntegerType().getValue())), I18nConstants.TYPE_SPECIFIC_CHECKS_DT_DECIMAL_LT, context.getMaxValueIntegerType()) && ok;
}
} catch (Exception ex) {
// should never happen?
}
@ -2449,7 +2457,12 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
}
if (context.hasBinding() && e.primitiveValue() != null) {
ok = checkPrimitiveBinding(hostContext, errors, path, type, context, e, profile, node) && ok;
// special cases
if ("StructureDefinition.type".equals(context.getPath()) && "http://hl7.org/fhir/StructureDefinition/StructureDefinition".equals(profile.getUrl())) {
ok = checkTypeValue(errors, path, e, node.getElement());
} else {
ok = checkPrimitiveBinding(hostContext, errors, path, type, context, e, profile, node) && ok;
}
}
if (type.equals("markdown") && htmlInMarkdownCheck != HtmlInMarkdownCheck.NONE) {
@ -2493,6 +2506,40 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
return ok;
}
private boolean checkTypeValue(List<ValidationMessage> errors, String path, Element e, Element sd) {
String v = e.primitiveValue();
if (v == null) {
return rule(errors, IssueType.INVALID, e.line(), e.col(), path, false, I18nConstants.SD_TYPE_MISSING);
}
String url = sd.getChildValue("url");
String d = sd.getChildValue("derivation");
String k = sd.getChildValue("kind");
if (Utilities.isAbsoluteUrl(v)) {
warning(errors, IssueType.INVALID, e.line(), e.col(), path, ns(v).equals(ns(url)) || ns(v).equals(ns(url).replace("StructureDefinition/", "")), I18nConstants.SD_TYPE_NOT_MATCH_NS, v, url);
return rule(errors, IssueType.INVALID, e.line(), e.col(), path, "logical".equals(k), I18nConstants.SD_TYPE_NOT_LOGICAL, v, k);
} else {
boolean tok = false;
for (StructureDefinition t : context.fetchResourcesByType(StructureDefinition.class)) {
if (t.hasUserData("package") && t.getUserString("package").startsWith("hl7.fhir.r") && v.equals(t.getType())) {
tok = true;
}
}
if (tok) {
if (!(("http://hl7.org/fhir/StructureDefinition/"+v).equals(url))) {
return rule(errors, IssueType.INVALID, e.line(), e.col(), path, "constraint".equals(d), I18nConstants.SD_TYPE_NOT_DERIVED, v);
} else {
return true;
}
} else {
return rule(errors, IssueType.INVALID, e.line(), e.col(), path, tok, I18nConstants.SD_TYPE_NOT_LOCAL, v);
}
}
}
private String ns(String url) {
return url.contains("/") ? url.substring(0, url.lastIndexOf("/")) : url;
}
private Object prepWSPresentation(String s) {
if (Utilities.noString(s)) {
return "";

View File

@ -69,14 +69,18 @@ public class StructureDefinitionValidator extends BaseValidator {
public boolean validateStructureDefinition(List<ValidationMessage> errors, Element src, NodeStack stack) {
boolean ok = true;
StructureDefinition sd = null;
String typeName = null;
try {
sd = loadAsSD(src);
List<ElementDefinition> snapshot = sd.getSnapshot().getElement();
sd.setSnapshot(null);
typeName = sd.getTypeName();
StructureDefinition base = context.fetchResource(StructureDefinition.class, sd.getBaseDefinition());
if (warning(errors, IssueType.NOTFOUND, stack.getLiteralPath(), base != null, I18nConstants.UNABLE_TO_FIND_BASE__FOR_, sd.getBaseDefinition(), "StructureDefinition, so can't check the differential")) {
if (rule(errors, IssueType.NOTFOUND, stack.getLiteralPath(), sd.hasDerivation(), I18nConstants.SD_MUST_HAVE_DERIVATION, sd.getUrl())) {
rule(errors, IssueType.NOTFOUND, stack.getLiteralPath(), base.getAbstract() || sd.hasKind() && sd.getKind() == base.getKind(), I18nConstants.SD_CONSTRAINED_KIND_NO_MATCH, sd.getKind().toCode(), base.getKind().toCode(), base.getType());
if (sd.getDerivation() == TypeDerivationRule.CONSTRAINT) {
rule(errors, IssueType.NOTFOUND, stack.getLiteralPath(), sd.hasType() && sd.getType().equals(base.getType()), I18nConstants.SD_CONSTRAINED_TYPE_NO_MATCH, sd.getType(), base.getType());
List<ValidationMessage> msgs = new ArrayList<>();
ProfileUtilities pu = new ProfileUtilities(context, msgs, null);
pu.setXver(xverManager);
@ -100,6 +104,8 @@ public class StructureDefinitionValidator extends BaseValidator {
int is = sd.getSnapshot().getElement().size();
ok = rule(errors, IssueType.NOTFOUND, stack.getLiteralPath(), was == is, I18nConstants.SNAPSHOT_EXISTING_PROBLEM, was, is) && ok;
}
} else {
rule(errors, IssueType.NOTFOUND, stack.getLiteralPath(), sd.hasType() && !sd.getType().equals(base.getType()), I18nConstants.SD_SPECIALIZED_TYPE_MATCHES, sd.getType(), base.getType());
}
} else {
ok = false;
@ -116,28 +122,30 @@ public class StructureDefinitionValidator extends BaseValidator {
List<Element> differentials = src.getChildrenByName("differential");
List<Element> snapshots = src.getChildrenByName("snapshot");
for (Element differential : differentials) {
ok = validateElementList(errors, differential, stack.push(differential, -1, null, null), false, snapshots.size() > 0, sd) && ok;
ok = validateElementList(errors, differential, stack.push(differential, -1, null, null), false, snapshots.size() > 0, sd, typeName) && ok;
}
for (Element snapshot : snapshots) {
ok = validateElementList(errors, snapshot, stack.push(snapshot, -1, null, null), true, true, sd) && ok;
ok = validateElementList(errors, snapshot, stack.push(snapshot, -1, null, null), true, true, sd, typeName) && ok;
}
return ok;
}
private boolean validateElementList(List<ValidationMessage> errors, Element elementList, NodeStack stack, boolean snapshot, boolean hasSnapshot, StructureDefinition sd) {
private boolean validateElementList(List<ValidationMessage> errors, Element elementList, NodeStack stack, boolean snapshot, boolean hasSnapshot, StructureDefinition sd, String typeName) {
boolean ok = true;
List<Element> elements = elementList.getChildrenByName("element");
int cc = 0;
for (Element element : elements) {
ok = validateElementDefinition(errors, element, stack.push(element, cc, null, null), snapshot, hasSnapshot, sd) && ok;
ok = validateElementDefinition(errors, element, stack.push(element, cc, null, null), snapshot, hasSnapshot, sd, typeName) && ok;
cc++;
}
return ok;
}
private boolean validateElementDefinition(List<ValidationMessage> errors, Element element, NodeStack stack, boolean snapshot, boolean hasSnapshot, StructureDefinition sd) {
private boolean validateElementDefinition(List<ValidationMessage> errors, Element element, NodeStack stack, boolean snapshot, boolean hasSnapshot, StructureDefinition sd, String typeName) {
boolean ok = true;
boolean typeMustSupport = false;
String path = element.getNamedChildValue("path");
rule(errors, IssueType.NOTFOUND, stack.getLiteralPath(), typeName == null || path == null || path.equals(typeName) || path.startsWith(typeName+"."), I18nConstants.SD_PATH_TYPE_MISMATCH, typeName, path);
List<Element> types = element.getChildrenByName("type");
Set<String> typeCodes = new HashSet<>();
Set<String> characteristics = new HashSet<>();
@ -173,14 +181,14 @@ public class StructureDefinitionValidator extends BaseValidator {
}
// check the stated profile - must be a constraint on the type
if (snapshot || sd != null) {
ok = validateElementType(errors, type, stack.push(type, -1, null, null), sd, element.getChildValue("path")) && ok;
ok = validateElementType(errors, type, stack.push(type, -1, null, null), sd, path) && ok;
}
}
if (typeMustSupport) {
if (snapshot) {
ok = rule(errors, IssueType.EXCEPTION, stack.getLiteralPath(), "true".equals(element.getChildValue("mustSupport")), I18nConstants.SD_NESTED_MUST_SUPPORT_SNAPSHOT, element.getNamedChildValue("path")) && ok;
ok = rule(errors, IssueType.EXCEPTION, stack.getLiteralPath(), "true".equals(element.getChildValue("mustSupport")), I18nConstants.SD_NESTED_MUST_SUPPORT_SNAPSHOT, path) && ok;
} else {
hint(errors, IssueType.EXCEPTION, stack.getLiteralPath(), hasSnapshot || "true".equals(element.getChildValue("mustSupport")), I18nConstants.SD_NESTED_MUST_SUPPORT_DIFF, element.getNamedChildValue("path"));
hint(errors, IssueType.EXCEPTION, stack.getLiteralPath(), hasSnapshot || "true".equals(element.getChildValue("mustSupport")), I18nConstants.SD_NESTED_MUST_SUPPORT_DIFF, path);
}
}
if (element.hasChild("binding")) {
@ -188,7 +196,7 @@ public class StructureDefinitionValidator extends BaseValidator {
ok = rule(errors, IssueType.BUSINESSRULE, stack.getLiteralPath(), characteristics.contains("can-bind") , I18nConstants.SD_ILLEGAL_CHARACTERISTICS, "Binding", typeCodes) && ok;
}
Element binding = element.getNamedChild("binding");
ok = validateBinding(errors, binding, stack.push(binding, -1, null, null), typeCodes, snapshot, element.getNamedChildValue("path")) && ok;
ok = validateBinding(errors, binding, stack.push(binding, -1, null, null), typeCodes, snapshot, path) && ok;
} else {
// this is a good idea but there's plenty of cases where the rule isn't met; maybe one day it's worth investing the time to exclude these cases and bring this rule back
// String bt = boundType(typeCodes);
@ -375,7 +383,9 @@ public class StructureDefinitionValidator extends BaseValidator {
private boolean validateBinding(List<ValidationMessage> errors, Element binding, NodeStack stack, Set<String> typeCodes, boolean snapshot, String path) {
boolean ok = true;
ok = rule(errors, IssueType.BUSINESSRULE, stack.getLiteralPath(), !snapshot || bindableType(typeCodes) != null, I18nConstants.SD_ED_BIND_NO_BINDABLE, path, typeCodes.toString()) && ok;
if (bindableType(typeCodes) == null) {
ok = rule(errors, IssueType.BUSINESSRULE, stack.getLiteralPath(), !snapshot, I18nConstants.SD_ED_BIND_NO_BINDABLE, path, typeCodes.toString()) && ok;
}
if (!snapshot) {
Set<String> bindables = getListofBindableTypes(typeCodes);
hint(errors, IssueType.BUSINESSRULE, stack.getLiteralPath(), bindables.size() <= 1, I18nConstants.SD_ED_BIND_MULTIPLE_TYPES, path, typeCodes.toString());

View File

@ -2162,3 +2162,14 @@ v: {
"system" : "http://loinc.org"
}
-------------------------------------------------------------------------------------
{"code" : {
"system" : "http://loinc.org",
"code" : "57024-2",
"display" : "Health Quality Measure Document"
}, "valueSet" :null, "lang":"null", "useServer":"true", "useClient":"true", "guessSystem":"false", "valueSetMode":"ALL_CHECKS", "versionFlexible":"false"}####
v: {
"display" : "Health Quality Measure document",
"code" : "57024-2",
"system" : "http://loinc.org"
}
-------------------------------------------------------------------------------------

View File

@ -2056,3 +2056,25 @@ v: {
"system" : "http://snomed.info/sct"
}
-------------------------------------------------------------------------------------
{"code" : {
"system" : "http://snomed.info/sct",
"code" : "116288000",
"display" : "Paralytic stroke (disorder)"
}, "valueSet" :null, "lang":"null", "useServer":"true", "useClient":"true", "guessSystem":"false", "valueSetMode":"ALL_CHECKS", "versionFlexible":"false"}####
v: {
"display" : "Paralytic stroke",
"code" : "116288000",
"system" : "http://snomed.info/sct"
}
-------------------------------------------------------------------------------------
{"code" : {
"system" : "http://snomed.info/sct",
"code" : "324689003",
"display" : "Nystatin 100000 unit/mL oral suspension"
}, "valueSet" :null, "lang":"null", "useServer":"true", "useClient":"true", "guessSystem":"false", "valueSetMode":"ALL_CHECKS", "versionFlexible":"false"}####
v: {
"display" : "Product containing precisely nystatin 100000 unit/1 milliliter conventional release oral suspension (clinical drug)",
"code" : "324689003",
"system" : "http://snomed.info/sct"
}
-------------------------------------------------------------------------------------