=fix r4b tests
This commit is contained in:
parent
33f6c57d48
commit
a34c33c0c0
|
@ -6,13 +6,19 @@ import java.io.FileNotFoundException;
|
|||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.naming.ldap.StartTlsRequest;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.hl7.fhir.convertors.misc.XVerPackegeFixer.References;
|
||||
import org.hl7.fhir.dstu2.model.ElementDefinition;
|
||||
import org.hl7.fhir.dstu2.model.StructureDefinition;
|
||||
import org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionSnapshotComponent;
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.json.JsonTrackingParser;
|
||||
|
@ -24,12 +30,35 @@ import com.google.gson.JsonObject;
|
|||
|
||||
public class XVerPackegeFixer {
|
||||
|
||||
private static final String R5_FOLDER = "C:\\work\\org.hl7.fhir\\packages\\hl7.fhir.rX\\hl7.fhir.r5.core\\package";
|
||||
private static final String R4_FOLDER = "C:\\work\\org.hl7.fhir\\packages\\hl7.fhir.rX\\hl7.fhir.r4.core\\package";
|
||||
private static final String R3_FOLDER = "C:\\work\\org.hl7.fhir\\packages\\hl7.fhir.rX\\hl7.fhir.r3.core\\package";
|
||||
private static final String R2B_FOLDER = "C:\\work\\org.hl7.fhir\\packages\\hl7.fhir.rX\\hl7.fhir.r2b.core\\package";
|
||||
private static final String R2_FOLDER = "C:\\work\\org.hl7.fhir\\packages\\hl7.fhir.rX\\hl7.fhir.r2.core\\package";
|
||||
private static int mod;
|
||||
public static class References {
|
||||
private boolean modifier;
|
||||
private boolean inherited;
|
||||
|
||||
public boolean getModifier() {
|
||||
return modifier;
|
||||
}
|
||||
|
||||
public void setModifier(boolean value) {
|
||||
this.modifier = value;
|
||||
}
|
||||
|
||||
public boolean getInherited() {
|
||||
return inherited;
|
||||
}
|
||||
|
||||
public void setInherited(boolean inherited) {
|
||||
this.inherited = inherited;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static final String R5_FOLDER = "/Users/grahamegrieve/work/packages/hl7.fhir.rX/hl7.fhir.r5.core/package";
|
||||
private static final String R4_FOLDER = "/Users/grahamegrieve/work/packages/hl7.fhir.rX/hl7.fhir.r4.core/package";
|
||||
private static final String R3_FOLDER = "/Users/grahamegrieve/work/packages/hl7.fhir.rX/hl7.fhir.r3.core/package";
|
||||
private static final String R2B_FOLDER = "/Users/grahamegrieve/work/packages/hl7.fhir.rX/hl7.fhir.r2b.core/package";
|
||||
private static final String R2_FOLDER = "/Users/grahamegrieve/work/packages/hl7.fhir.rX/hl7.fhir.r2.core/package";
|
||||
private static int modCount;
|
||||
|
||||
private static Map<String, org.hl7.fhir.r5.model.StructureDefinition> map5 = new HashMap<>();
|
||||
private static Map<String, org.hl7.fhir.r4.model.StructureDefinition> map4 = new HashMap<>();
|
||||
|
@ -38,21 +67,23 @@ public class XVerPackegeFixer {
|
|||
private static Map<String, org.hl7.fhir.dstu2016may.model.StructureDefinition> map2b = new HashMap<>();
|
||||
|
||||
public static void main(String[] args) throws FileNotFoundException, ParserConfigurationException, SAXException, IOException {
|
||||
mod = 0;
|
||||
modCount = 0;
|
||||
for (File f : new File(args[0]).listFiles()) {
|
||||
if (f.getName().startsWith("xver-")) {
|
||||
if (f.getName().startsWith("xver-") && f.getName().contains("1.0")) {
|
||||
JsonObject j = JsonTrackingParser.parseJson(f);
|
||||
fixUp(j, f.getName());
|
||||
JsonTrackingParser.write(j, f, true);
|
||||
}
|
||||
}
|
||||
System.out.println("all done: "+mod+" modifiers");
|
||||
System.out.println("all done: "+modCount+" modifiers");
|
||||
}
|
||||
|
||||
private static void fixUp(JsonObject j, String name) throws FHIRFormatError, FileNotFoundException, IOException {
|
||||
name = name.replace(".json", "");
|
||||
System.out.println("Process "+name);
|
||||
String version = name.substring(name.lastIndexOf("-")+1);
|
||||
Set<String> pr = new HashSet<>();
|
||||
|
||||
int i = 0;
|
||||
for (Entry<String, JsonElement> e : j.entrySet()) {
|
||||
if (i == 50) {
|
||||
|
@ -62,18 +93,31 @@ public class XVerPackegeFixer {
|
|||
i++;
|
||||
String n = e.getKey();
|
||||
JsonObject o = ((JsonObject) e.getValue());
|
||||
boolean ok = (o.has("types") && o.getAsJsonArray("types").size() > 0) || (o.has("elements") && o.getAsJsonArray("elements").size() > 0);
|
||||
if (!ok) {
|
||||
// boolean ok = (o.has("types") && o.getAsJsonArray("types").size() > 0) || (o.has("elements") && o.getAsJsonArray("elements").size() > 0);
|
||||
// if (!ok) {
|
||||
if (o.has("types")) {
|
||||
o.remove("types");
|
||||
}
|
||||
if (o.has("elements")) {
|
||||
o.remove("elements");
|
||||
}
|
||||
if (o.has("modifier")) {
|
||||
o.remove("modifier");
|
||||
}
|
||||
List<String> types = new ArrayList<>();
|
||||
List<String> elements = new ArrayList<>();
|
||||
getElementInfo(version, n, types, elements);
|
||||
References mod = new References();
|
||||
getElementInfo(version, n, types, elements, mod);
|
||||
if (mod.getInherited()) {
|
||||
pr.add(n);
|
||||
}
|
||||
if (elements.size() > 0) {
|
||||
JsonArray arr = o.getAsJsonArray("elements");
|
||||
if (arr == null) {
|
||||
arr = new JsonArray();
|
||||
o.add("elements", arr);
|
||||
}
|
||||
for (String s : types) {
|
||||
for (String s : elements) {
|
||||
arr.add(s);
|
||||
}
|
||||
} else if (types.size() > 0) {
|
||||
|
@ -86,30 +130,37 @@ public class XVerPackegeFixer {
|
|||
arr.add(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mod.getModifier()) {
|
||||
o.addProperty("modifier", true);
|
||||
modCount++;
|
||||
}
|
||||
// }
|
||||
}
|
||||
for (String s : pr) {
|
||||
j.remove(s);
|
||||
}
|
||||
System.out.println("done");
|
||||
}
|
||||
|
||||
private static boolean getElementInfo(String version, String n, List<String> types, List<String> elements) throws FHIRFormatError, FileNotFoundException, IOException {
|
||||
if ("contained".equals(n.substring(n.indexOf(".")+1))) {
|
||||
return false;
|
||||
}
|
||||
private static boolean getElementInfo(String version, String n, List<String> types, List<String> elements, References mod) throws FHIRFormatError, FileNotFoundException, IOException {
|
||||
// if ("contained".equals(n.substring(n.indexOf(".")+1))) {
|
||||
// return false;
|
||||
// }
|
||||
switch (version) {
|
||||
case "4.6": return getElementInfoR5(n, types, elements);
|
||||
case "4.0": return getElementInfoR4(n, types, elements);
|
||||
case "3.0": return getElementInfoR3(n, types, elements);
|
||||
case "1.4": return getElementInfoR2B(n, types, elements);
|
||||
case "1.0": return getElementInfoR2(n, types, elements);
|
||||
case "4.6": return getElementInfoR5(n, types, elements, mod);
|
||||
case "4.0": return getElementInfoR4(n, types, elements, mod);
|
||||
case "3.0": return getElementInfoR3(n, types, elements, mod);
|
||||
case "1.4": return getElementInfoR2B(n, types, elements, mod);
|
||||
case "1.0": return getElementInfoR2(n, types, elements, mod);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static Object tail(String value) {
|
||||
private static String tail(String value) {
|
||||
return value.contains("/") ? value.substring(value.lastIndexOf("/")+1) : value;
|
||||
}
|
||||
|
||||
private static boolean getElementInfoR5(String n, List<String> types, List<String> elements) throws FHIRFormatError, FileNotFoundException, IOException {
|
||||
private static boolean getElementInfoR5(String n, List<String> types, List<String> elements, References mod) throws FHIRFormatError, FileNotFoundException, IOException {
|
||||
String tn = n.substring(0, n.indexOf("."));
|
||||
org.hl7.fhir.r5.model.StructureDefinition sd = null;
|
||||
if (map5.containsKey(tn)) {
|
||||
|
@ -120,7 +171,8 @@ public class XVerPackegeFixer {
|
|||
}
|
||||
for (org.hl7.fhir.r5.model.ElementDefinition ed : sd.getSnapshot().getElement()) {
|
||||
if (ed.getPath().equals(n)) {
|
||||
List<org.hl7.fhir.r5.model.ElementDefinition> children = listChildrenR5(sd.getSnapshot().getElement(), ed);
|
||||
mod.setModifier(ed.getIsModifier());
|
||||
List<org.hl7.fhir.r5.model.ElementDefinition> children = listChildrenR5(sd.getSnapshot().getElement(), ed);
|
||||
if (children.size() > 0) {
|
||||
for (org.hl7.fhir.r5.model.ElementDefinition c : children) {
|
||||
String en = c.getPath().substring(ed.getPath().length()+1);
|
||||
|
@ -164,7 +216,7 @@ public class XVerPackegeFixer {
|
|||
return res;
|
||||
}
|
||||
|
||||
private static boolean getElementInfoR4(String n, List<String> types, List<String> elements) throws FHIRFormatError, FileNotFoundException, IOException {
|
||||
private static boolean getElementInfoR4(String n, List<String> types, List<String> elements, References mod) throws FHIRFormatError, FileNotFoundException, IOException {
|
||||
String tn = n.substring(0, n.indexOf("."));
|
||||
org.hl7.fhir.r4.model.StructureDefinition sd = null;
|
||||
if (map4.containsKey(tn)) {
|
||||
|
@ -175,6 +227,7 @@ public class XVerPackegeFixer {
|
|||
}
|
||||
for (org.hl7.fhir.r4.model.ElementDefinition ed : sd.getSnapshot().getElement()) {
|
||||
if (ed.getPath().equals(n)) {
|
||||
mod.setModifier(ed.getIsModifier());
|
||||
List<org.hl7.fhir.r4.model.ElementDefinition> children = listChildrenR4(sd.getSnapshot().getElement(), ed);
|
||||
if (children.size() > 0) {
|
||||
for (org.hl7.fhir.r4.model.ElementDefinition c : children) {
|
||||
|
@ -220,7 +273,7 @@ public class XVerPackegeFixer {
|
|||
}
|
||||
|
||||
|
||||
private static boolean getElementInfoR3(String n, List<String> types, List<String> elements) throws FHIRFormatError, FileNotFoundException, IOException {
|
||||
private static boolean getElementInfoR3(String n, List<String> types, List<String> elements, References mod) throws FHIRFormatError, FileNotFoundException, IOException {
|
||||
String tn = n.substring(0, n.indexOf("."));
|
||||
org.hl7.fhir.dstu3.model.StructureDefinition sd = null;
|
||||
if (map3.containsKey(tn)) {
|
||||
|
@ -231,6 +284,7 @@ public class XVerPackegeFixer {
|
|||
}
|
||||
for (org.hl7.fhir.dstu3.model.ElementDefinition ed : sd.getSnapshot().getElement()) {
|
||||
if (ed.getPath().equals(n)) {
|
||||
mod.setModifier(ed.getIsModifier());
|
||||
List<org.hl7.fhir.dstu3.model.ElementDefinition> children = listChildrenR3(sd.getSnapshot().getElement(), ed);
|
||||
if (children.size() > 0) {
|
||||
for (org.hl7.fhir.dstu3.model.ElementDefinition c : children) {
|
||||
|
@ -272,17 +326,14 @@ public class XVerPackegeFixer {
|
|||
}
|
||||
|
||||
|
||||
private static boolean getElementInfoR2(String n, List<String> types, List<String> elements) throws FHIRFormatError, FileNotFoundException, IOException {
|
||||
private static boolean getElementInfoR2(String n, List<String> types, List<String> elements, References mod) throws FHIRFormatError, FileNotFoundException, IOException {
|
||||
String tn = n.substring(0, n.indexOf("."));
|
||||
org.hl7.fhir.dstu2.model.StructureDefinition sd = null;
|
||||
if (map2.containsKey(tn)) {
|
||||
sd = map2.get(tn);
|
||||
} else {
|
||||
sd = (org.hl7.fhir.dstu2.model.StructureDefinition) new org.hl7.fhir.dstu2.formats.JsonParser().parse(new FileInputStream(Utilities.path(R2_FOLDER, "StructureDefinition-"+tn+".json")));
|
||||
map2.put(tn, sd);
|
||||
}
|
||||
sd = loadType(tn);
|
||||
mod.setInherited(isInherited(n, sd));
|
||||
for (org.hl7.fhir.dstu2.model.ElementDefinition ed : sd.getSnapshot().getElement()) {
|
||||
if (ed.getPath().equals(n)) {
|
||||
mod.setModifier(ed.getIsModifier());
|
||||
List<org.hl7.fhir.dstu2.model.ElementDefinition> children = listChildrenR2(sd.getSnapshot().getElement(), ed);
|
||||
if (children.size() > 0) {
|
||||
for (org.hl7.fhir.dstu2.model.ElementDefinition c : children) {
|
||||
|
@ -290,28 +341,76 @@ public class XVerPackegeFixer {
|
|||
elements.add(en);
|
||||
}
|
||||
} else {
|
||||
boolean isReference = false;
|
||||
StringBuilder r = new StringBuilder();
|
||||
r.append("Reference(");
|
||||
for (org.hl7.fhir.dstu2.model.ElementDefinition.TypeRefComponent t : ed.getType()) {
|
||||
if (t.hasProfile()) {
|
||||
StringBuilder b = new StringBuilder();
|
||||
b.append(t.getCode());
|
||||
b.append("(");
|
||||
boolean first = true;
|
||||
for (org.hl7.fhir.dstu2.model.UriType u : t.getProfile()) {
|
||||
if (first) first = false; else b.append("|");
|
||||
b.append(tail(u.getValue()));
|
||||
if ("Reference".equals(t.getCode())) {
|
||||
for (org.hl7.fhir.dstu2.model.UriType u : t.getProfile()) {
|
||||
if (isReference)
|
||||
r.append("|");
|
||||
r.append(tail(u.getValue()));
|
||||
isReference = true;
|
||||
}
|
||||
} else {
|
||||
StringBuilder b = new StringBuilder();
|
||||
b.append(t.getCode());
|
||||
b.append("(");
|
||||
boolean first = true;
|
||||
for (org.hl7.fhir.dstu2.model.UriType u : t.getProfile()) {
|
||||
if (first) first = false; else b.append("|");
|
||||
b.append(tail(u.getValue()));
|
||||
}
|
||||
b.append(")");
|
||||
types.add(b.toString());
|
||||
}
|
||||
b.append(")");
|
||||
types.add(b.toString());
|
||||
} else {
|
||||
types.add(t.getCode());
|
||||
}
|
||||
}
|
||||
if (isReference) {
|
||||
r.append(")");
|
||||
types.add(r.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static org.hl7.fhir.dstu2.model.StructureDefinition loadType(String tn)
|
||||
throws IOException, FileNotFoundException {
|
||||
org.hl7.fhir.dstu2.model.StructureDefinition sd;
|
||||
if (map2.containsKey(tn)) {
|
||||
sd = map2.get(tn);
|
||||
} else {
|
||||
sd = (org.hl7.fhir.dstu2.model.StructureDefinition) new org.hl7.fhir.dstu2.formats.JsonParser().parse(new FileInputStream(Utilities.path(R2_FOLDER, "StructureDefinition-"+tn+".json")));
|
||||
map2.put(tn, sd);
|
||||
}
|
||||
return sd;
|
||||
}
|
||||
|
||||
|
||||
private static boolean isInherited(String n, StructureDefinition sd) throws FileNotFoundException, IOException {
|
||||
String tail = n.substring(n.indexOf(".")+1);
|
||||
while (sd != null) {
|
||||
sd = sd.hasBase() ? loadType(tail(sd.getBase())) : null;
|
||||
if (sd != null && hasPath(sd.getSnapshot(), sd.getName()+"."+tail)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean hasPath(StructureDefinitionSnapshotComponent snapshot, String path) {
|
||||
for (ElementDefinition ed : snapshot.getElement()) {
|
||||
if (ed.getPath().equals(path)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static List<org.hl7.fhir.dstu2.model.ElementDefinition> listChildrenR2(List<org.hl7.fhir.dstu2.model.ElementDefinition> list, org.hl7.fhir.dstu2.model.ElementDefinition ed) {
|
||||
List<org.hl7.fhir.dstu2.model.ElementDefinition> res = new ArrayList<>();
|
||||
|
@ -328,7 +427,7 @@ public class XVerPackegeFixer {
|
|||
}
|
||||
|
||||
|
||||
private static boolean getElementInfoR2B(String n, List<String> types, List<String> elements) throws FHIRFormatError, FileNotFoundException, IOException {
|
||||
private static boolean getElementInfoR2B(String n, List<String> types, List<String> elements, References mod) throws FHIRFormatError, FileNotFoundException, IOException {
|
||||
String tn = n.substring(0, n.indexOf("."));
|
||||
org.hl7.fhir.dstu2016may.model.StructureDefinition sd = null;
|
||||
if (map2b.containsKey(tn)) {
|
||||
|
@ -339,6 +438,7 @@ public class XVerPackegeFixer {
|
|||
}
|
||||
for (org.hl7.fhir.dstu2016may.model.ElementDefinition ed : sd.getSnapshot().getElement()) {
|
||||
if (ed.getPath().equals(n)) {
|
||||
mod.setModifier(ed.getIsModifier());
|
||||
List<org.hl7.fhir.dstu2016may.model.ElementDefinition> children = listChildrenR2B(sd.getSnapshot().getElement(), ed);
|
||||
if (children.size() > 0) {
|
||||
for (org.hl7.fhir.dstu2016may.model.ElementDefinition c : children) {
|
||||
|
|
|
@ -45,14 +45,14 @@ public class ProfileComparer extends CanonicalResourceComparer {
|
|||
|
||||
public class ProfileComparison extends CanonicalResourceComparison<StructureDefinition> {
|
||||
|
||||
private StructuralMatch<ElementDefinition> combined;
|
||||
private StructuralMatch<ElementDefinitionNode> combined;
|
||||
|
||||
public ProfileComparison(StructureDefinition left, StructureDefinition right) {
|
||||
super(left, right);
|
||||
combined = new StructuralMatch<ElementDefinition>(); // base
|
||||
combined = new StructuralMatch<ElementDefinitionNode>(); // base
|
||||
}
|
||||
|
||||
public StructuralMatch<ElementDefinition> getCombined() {
|
||||
public StructuralMatch<ElementDefinitionNode> getCombined() {
|
||||
return combined;
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,21 @@ public class ProfileComparer extends CanonicalResourceComparer {
|
|||
}
|
||||
|
||||
|
||||
|
||||
private class ElementDefinitionNode {
|
||||
private ElementDefinition def;
|
||||
private StructureDefinition src;
|
||||
private ElementDefinitionNode(StructureDefinition src, ElementDefinition def) {
|
||||
super();
|
||||
this.src = src;
|
||||
this.def = def;
|
||||
}
|
||||
public ElementDefinition getDef() {
|
||||
return def;
|
||||
}
|
||||
public StructureDefinition getSrc() {
|
||||
return src;
|
||||
}
|
||||
}
|
||||
|
||||
private ProfileUtilities utilsLeft;
|
||||
private ProfileUtilities utilsRight;
|
||||
|
@ -127,7 +141,7 @@ public class ProfileComparer extends CanonicalResourceComparer {
|
|||
if (left.getType().equals(right.getType())) {
|
||||
DefinitionNavigator ln = new DefinitionNavigator(session.getContextLeft(), left);
|
||||
DefinitionNavigator rn = new DefinitionNavigator(session.getContextRight(), right);
|
||||
StructuralMatch<ElementDefinition> sm = new StructuralMatch<ElementDefinition>(ln.current(), rn.current());
|
||||
StructuralMatch<ElementDefinitionNode> sm = new StructuralMatch<ElementDefinitionNode>(new ElementDefinitionNode(left, ln.current()), new ElementDefinitionNode(right, rn.current()));
|
||||
compareElements(res, sm, ln.path(), null, ln, rn);
|
||||
res.combined = sm;
|
||||
}
|
||||
|
@ -147,7 +161,7 @@ public class ProfileComparer extends CanonicalResourceComparer {
|
|||
throw new DefinitionException("StructureDefinition snapshot is empty ("+name+": "+sd.getName()+")");
|
||||
}
|
||||
|
||||
private void compareElements(ProfileComparison comp, StructuralMatch<ElementDefinition> res, String path, String sliceName, DefinitionNavigator left, DefinitionNavigator right) throws DefinitionException, FHIRFormatError, IOException {
|
||||
private void compareElements(ProfileComparison comp, StructuralMatch<ElementDefinitionNode> res, String path, String sliceName, DefinitionNavigator left, DefinitionNavigator right) throws DefinitionException, FHIRFormatError, IOException {
|
||||
assert(path != null);
|
||||
assert(left != null);
|
||||
assert(right != null);
|
||||
|
@ -190,7 +204,7 @@ public class ProfileComparer extends CanonicalResourceComparer {
|
|||
subset.setExample(left.current().hasExample() ? left.current().getExample() : right.current().getExample());
|
||||
|
||||
if (left.current().getMustSupport() != right.current().getMustSupport()) {
|
||||
vm(IssueSeverity.ERROR, "Elements differ in definition for mustSupport:\r\n \""+left.current().getMustSupport()+"\"\r\n \""+right.current().getMustSupport()+"\"", path, comp.getMessages(), res.getMessages());
|
||||
vm(IssueSeverity.WARNING, "Elements differ in definition for mustSupport: '"+left.current().getMustSupport()+"' vs '"+right.current().getMustSupport()+"'", path, comp.getMessages(), res.getMessages());
|
||||
|
||||
}
|
||||
subset.setMustSupport(left.current().getMustSupport() || right.current().getMustSupport());
|
||||
|
@ -198,15 +212,20 @@ public class ProfileComparer extends CanonicalResourceComparer {
|
|||
|
||||
|
||||
// compare and intersect
|
||||
superset.setMin(unionMin(left.current().getMin(), right.current().getMin()));
|
||||
superset.setMax(unionMax(left.current().getMax(), right.current().getMax()));
|
||||
subset.setMin(intersectMin(left.current().getMin(), right.current().getMin()));
|
||||
subset.setMax(intersectMax(left.current().getMax(), right.current().getMax()));
|
||||
rule(comp, res, subset.getMax().equals("*") || Integer.parseInt(subset.getMax()) >= subset.getMin(), path, "Cardinality Mismatch: "+card(left)+"/"+card(right));
|
||||
int leftMin = left.current().getMin();
|
||||
int rightMin = right.current().getMin();
|
||||
int leftMax = "*".equals(left.current().getMax()) ? Integer.MAX_VALUE : Integer.parseInt(left.current().getMax());
|
||||
int rightMax = "*".equals(right.current().getMax()) ? Integer.MAX_VALUE : Integer.parseInt(right.current().getMax());
|
||||
|
||||
checkMinMax(comp, res, path, leftMin, rightMin, leftMax, rightMax);
|
||||
superset.setMin(unionMin(leftMin, rightMin));
|
||||
superset.setMax(unionMax(leftMax, rightMax, left.current().getMax(), right.current().getMax()));
|
||||
subset.setMin(intersectMin(leftMin, rightMin));
|
||||
subset.setMax(intersectMax(leftMax, rightMax, left.current().getMax(), right.current().getMax()));
|
||||
|
||||
superset.getType().addAll(unionTypes(comp, res, path, left.current().getType(), right.current().getType()));
|
||||
subset.getType().addAll(intersectTypes(comp, res, subset, path, left.current().getType(), right.current().getType()));
|
||||
rule(comp, res, !subset.getType().isEmpty() || (!left.current().hasType() && !right.current().hasType()), path, "Type Mismatch:\r\n "+typeCode(left)+"\r\n "+typeCode(right));
|
||||
rule(comp, res, !subset.getType().isEmpty() || (!left.current().hasType() && !right.current().hasType()), path, "Type Mismatch: "+typeCode(left)+" vs "+typeCode(right));
|
||||
// <fixed[x]><!-- ?? 0..1 * Value must be exactly this --></fixed[x]>
|
||||
// <pattern[x]><!-- ?? 0..1 * Value must have at least these property values --></pattern[x]>
|
||||
superset.setMaxLengthElement(unionMaxLength(left.current().getMaxLength(), right.current().getMaxLength()));
|
||||
|
@ -283,7 +302,8 @@ public class ProfileComparer extends CanonicalResourceComparer {
|
|||
// return null;
|
||||
}
|
||||
|
||||
private void compareChildren(ProfileComparison comp, StructuralMatch<ElementDefinition> res, String path, DefinitionNavigator left, DefinitionNavigator right) throws DefinitionException, IOException, FHIRFormatError {
|
||||
|
||||
private void compareChildren(ProfileComparison comp, StructuralMatch<ElementDefinitionNode> res, String path, DefinitionNavigator left, DefinitionNavigator right) throws DefinitionException, IOException, FHIRFormatError {
|
||||
List<DefinitionNavigator> lc = left.children();
|
||||
List<DefinitionNavigator> rc = right.children();
|
||||
// it's possible that one of these profiles walks into a data type and the other doesn't
|
||||
|
@ -299,10 +319,10 @@ public class ProfileComparer extends CanonicalResourceComparer {
|
|||
DefinitionNavigator r = findInList(rc, l);
|
||||
if (r == null) {
|
||||
comp.getUnion().getSnapshot().getElement().add(l.current().copy());
|
||||
res.getChildren().add(new StructuralMatch<ElementDefinition>(l.current(), vmI(IssueSeverity.INFORMATION, "Removed this element", path)));
|
||||
res.getChildren().add(new StructuralMatch<ElementDefinitionNode>(new ElementDefinitionNode(l.getStructure(), l.current()), vmI(IssueSeverity.INFORMATION, "Removed this element", path)));
|
||||
} else {
|
||||
matchR.add(r);
|
||||
StructuralMatch<ElementDefinition> sm = new StructuralMatch<ElementDefinition>(l.current(), r.current());
|
||||
StructuralMatch<ElementDefinitionNode> sm = new StructuralMatch<ElementDefinitionNode>(new ElementDefinitionNode(l.getStructure(), l.current()), new ElementDefinitionNode(r.getStructure(), r.current()));
|
||||
res.getChildren().add(sm);
|
||||
compareElements(comp, sm, l.path(), null, l, r);
|
||||
}
|
||||
|
@ -310,7 +330,7 @@ public class ProfileComparer extends CanonicalResourceComparer {
|
|||
for (DefinitionNavigator r : rc) {
|
||||
if (!matchR.contains(r)) {
|
||||
comp.getUnion().getSnapshot().getElement().add(r.current().copy());
|
||||
res.getChildren().add(new StructuralMatch<ElementDefinition>(vmI(IssueSeverity.INFORMATION, "Added this element", path), r.current()));
|
||||
res.getChildren().add(new StructuralMatch<ElementDefinitionNode>(vmI(IssueSeverity.INFORMATION, "Added this element", path), new ElementDefinitionNode(r.getStructure(), r.current())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -324,7 +344,7 @@ public class ProfileComparer extends CanonicalResourceComparer {
|
|||
return null;
|
||||
}
|
||||
|
||||
private void ruleEqual(ProfileComparison comp, StructuralMatch<ElementDefinition> res, DataType vLeft, DataType vRight, String name, String path) throws IOException {
|
||||
private void ruleEqual(ProfileComparison comp, StructuralMatch<ElementDefinitionNode> res, DataType vLeft, DataType vRight, String name, String path) throws IOException {
|
||||
if (vLeft == null && vRight == null) {
|
||||
// nothing
|
||||
} else if (vLeft == null) {
|
||||
|
@ -338,7 +358,7 @@ public class ProfileComparer extends CanonicalResourceComparer {
|
|||
|
||||
private String toString(DataType val, boolean left) throws IOException {
|
||||
if (val instanceof PrimitiveType)
|
||||
return "\"" + ((PrimitiveType) val).getValueAsString()+"\"";
|
||||
return "'" + ((PrimitiveType) val).getValueAsString()+"'";
|
||||
|
||||
IParser jp = left ? session.getContextLeft().newJsonParser() : session.getContextRight().newJsonParser();
|
||||
return jp.composeString(val, "value");
|
||||
|
@ -356,14 +376,14 @@ public class ProfileComparer extends CanonicalResourceComparer {
|
|||
return s;
|
||||
}
|
||||
|
||||
private boolean rule(ProfileComparison comp, StructuralMatch<ElementDefinition> res, boolean test, String path, String message) {
|
||||
private boolean rule(ProfileComparison comp, StructuralMatch<ElementDefinitionNode> res, boolean test, String path, String message) {
|
||||
if (!test) {
|
||||
vm(IssueSeverity.ERROR, message, path, comp.getMessages(), res.getMessages());
|
||||
}
|
||||
return test;
|
||||
}
|
||||
|
||||
private String mergeText(ProfileComparison comp, StructuralMatch<ElementDefinition> res, String path, String name, String left, String right, boolean isError) {
|
||||
private String mergeText(ProfileComparison comp, StructuralMatch<ElementDefinitionNode> res, String path, String name, String left, String right, boolean isError) {
|
||||
if (left == null && right == null)
|
||||
return null;
|
||||
if (left == null)
|
||||
|
@ -375,7 +395,7 @@ public class ProfileComparer extends CanonicalResourceComparer {
|
|||
if (left.equalsIgnoreCase(right))
|
||||
return left;
|
||||
if (path != null) {
|
||||
vm(isError ? IssueSeverity.ERROR : IssueSeverity.WARNING, "Elements differ in "+name+":\r\n \""+left+"\"\r\n \""+right+"\"", path, comp.getMessages(), res.getMessages());
|
||||
vm(isError ? IssueSeverity.ERROR : IssueSeverity.WARNING, "Elements differ in "+name+": '"+left+"' vs '"+right+"'", path, comp.getMessages(), res.getMessages());
|
||||
}
|
||||
return "left: "+left+"; right: "+right;
|
||||
}
|
||||
|
@ -429,6 +449,36 @@ public class ProfileComparer extends CanonicalResourceComparer {
|
|||
return right;
|
||||
}
|
||||
|
||||
private void checkMinMax(ProfileComparison comp, StructuralMatch<ElementDefinitionNode> res, String path, int leftMin, int rightMin, int leftMax, int rightMax) {
|
||||
if (leftMin != rightMin) {
|
||||
if (leftMin == 0) {
|
||||
vm(IssueSeverity.INFORMATION, "Element minimum cardinalities differ: '"+leftMin+"' vs '"+rightMin+"'", path, comp.getMessages(), res.getMessages());
|
||||
} else if (rightMin == 0) {
|
||||
vm(IssueSeverity.INFORMATION, "Element minimum cardinalities differ: '"+leftMin+"' vs '"+rightMin+"'", path, comp.getMessages(), res.getMessages());
|
||||
} else {
|
||||
vm(IssueSeverity.INFORMATION, "Element minimum cardinalities differ: '"+leftMin+"' vs '"+rightMin+"'", path, comp.getMessages(), res.getMessages());
|
||||
}
|
||||
}
|
||||
if (leftMax != rightMax) {
|
||||
if (leftMax == Integer.MAX_VALUE) {
|
||||
vm(IssueSeverity.INFORMATION, "Element maximum cardinalities differ: '"+leftMax+"' vs '"+rightMax+"'", path, comp.getMessages(), res.getMessages());
|
||||
} else if (rightMax == Integer.MAX_VALUE) {
|
||||
vm(IssueSeverity.INFORMATION, "Element maximum cardinalities differ: '"+leftMax+"' vs '"+rightMax+"'", path, comp.getMessages(), res.getMessages());
|
||||
} else {
|
||||
vm(IssueSeverity.INFORMATION, "Element maximum cardinalities differ: '"+leftMax+"' vs '"+rightMax+"'", path, comp.getMessages(), res.getMessages());
|
||||
}
|
||||
}
|
||||
// rule(comp, res, subset.getMax().equals("*") || Integer.parseInt(subset.getMax()) >= subset.getMin(), path, "Cardinality Mismatch: "+card(left)+"/"+card(right));
|
||||
|
||||
// cross comparison - if max > min in either direction, there can be no instances that are valid against both
|
||||
if (leftMax < rightMin) {
|
||||
vm(IssueSeverity.ERROR, "Element minimum cardinalities conflict: '"+leftMin+".."+leftMax+"' vs '"+rightMin+".."+rightMax+"': No instances can be valid against both profiles", path, comp.getMessages(), res.getMessages());
|
||||
}
|
||||
if (rightMax < leftMin) {
|
||||
vm(IssueSeverity.ERROR, "Element minimum cardinalities conflict: '"+leftMin+".."+leftMax+"' vs '"+rightMin+".."+rightMax+"': No instances can be valid against both profiles", path, comp.getMessages(), res.getMessages());
|
||||
}
|
||||
}
|
||||
|
||||
private int unionMin(int left, int right) {
|
||||
if (left > right)
|
||||
return right;
|
||||
|
@ -436,18 +486,14 @@ public class ProfileComparer extends CanonicalResourceComparer {
|
|||
return left;
|
||||
}
|
||||
|
||||
private String intersectMax(String left, String right) {
|
||||
int l = "*".equals(left) ? Integer.MAX_VALUE : Integer.parseInt(left);
|
||||
int r = "*".equals(right) ? Integer.MAX_VALUE : Integer.parseInt(right);
|
||||
private String intersectMax(int l, int r, String left, String right) {
|
||||
if (l < r)
|
||||
return left;
|
||||
else
|
||||
return right;
|
||||
}
|
||||
|
||||
private String unionMax(String left, String right) {
|
||||
int l = "*".equals(left) ? Integer.MAX_VALUE : Integer.parseInt(left);
|
||||
int r = "*".equals(right) ? Integer.MAX_VALUE : Integer.parseInt(right);
|
||||
private String unionMax(int l, int r, String left, String right) {
|
||||
if (l < r)
|
||||
return right;
|
||||
else
|
||||
|
@ -480,7 +526,7 @@ public class ProfileComparer extends CanonicalResourceComparer {
|
|||
return Integer.toString(defn.current().getMin())+".."+defn.current().getMax();
|
||||
}
|
||||
|
||||
private Collection<? extends TypeRefComponent> unionTypes(ProfileComparison comp, StructuralMatch<ElementDefinition> res, String path, List<TypeRefComponent> left, List<TypeRefComponent> right) throws DefinitionException, IOException, FHIRFormatError {
|
||||
private Collection<? extends TypeRefComponent> unionTypes(ProfileComparison comp, StructuralMatch<ElementDefinitionNode> res, String path, List<TypeRefComponent> left, List<TypeRefComponent> right) throws DefinitionException, IOException, FHIRFormatError {
|
||||
List<TypeRefComponent> result = new ArrayList<TypeRefComponent>();
|
||||
for (TypeRefComponent l : left)
|
||||
checkAddTypeUnion(comp, res, path, result, l, session.getContextLeft());
|
||||
|
@ -489,7 +535,7 @@ public class ProfileComparer extends CanonicalResourceComparer {
|
|||
return result;
|
||||
}
|
||||
|
||||
private void checkAddTypeUnion(ProfileComparison comp, StructuralMatch<ElementDefinition> res, String path, List<TypeRefComponent> results, TypeRefComponent nw, IWorkerContext ctxt) throws DefinitionException, IOException, FHIRFormatError {
|
||||
private void checkAddTypeUnion(ProfileComparison comp, StructuralMatch<ElementDefinitionNode> res, String path, List<TypeRefComponent> results, TypeRefComponent nw, IWorkerContext ctxt) throws DefinitionException, IOException, FHIRFormatError {
|
||||
boolean pfound = false;
|
||||
boolean tfound = false;
|
||||
nw = nw.copy();
|
||||
|
@ -586,7 +632,7 @@ public class ProfileComparer extends CanonicalResourceComparer {
|
|||
return false;
|
||||
}
|
||||
|
||||
private Collection<? extends TypeRefComponent> intersectTypes(ProfileComparison comp, StructuralMatch<ElementDefinition> res, ElementDefinition ed, String path, List<TypeRefComponent> left, List<TypeRefComponent> right) throws DefinitionException, IOException, FHIRFormatError {
|
||||
private Collection<? extends TypeRefComponent> intersectTypes(ProfileComparison comp, StructuralMatch<ElementDefinitionNode> res, ElementDefinition ed, String path, List<TypeRefComponent> left, List<TypeRefComponent> right) throws DefinitionException, IOException, FHIRFormatError {
|
||||
List<TypeRefComponent> result = new ArrayList<TypeRefComponent>();
|
||||
for (TypeRefComponent l : left) {
|
||||
if (l.hasAggregation())
|
||||
|
@ -665,7 +711,7 @@ public class ProfileComparer extends CanonicalResourceComparer {
|
|||
return b.toString();
|
||||
}
|
||||
|
||||
private boolean compareBindings(ProfileComparison comp, StructuralMatch<ElementDefinition> res, ElementDefinition subset, ElementDefinition superset, String path, ElementDefinition lDef, ElementDefinition rDef) throws FHIRFormatError, DefinitionException, IOException {
|
||||
private boolean compareBindings(ProfileComparison comp, StructuralMatch<ElementDefinitionNode> res, ElementDefinition subset, ElementDefinition superset, String path, ElementDefinition lDef, ElementDefinition rDef) throws FHIRFormatError, DefinitionException, IOException {
|
||||
assert(lDef.hasBinding() || rDef.hasBinding());
|
||||
if (!lDef.hasBinding()) {
|
||||
subset.setBinding(rDef.getBinding());
|
||||
|
@ -801,7 +847,7 @@ public class ProfileComparer extends CanonicalResourceComparer {
|
|||
}
|
||||
|
||||
// we can't really know about constraints. We create warnings, and collate them
|
||||
private List<ElementDefinitionConstraintComponent> unionConstraints(ProfileComparison comp, StructuralMatch<ElementDefinition> res, String path, List<ElementDefinitionConstraintComponent> left, List<ElementDefinitionConstraintComponent> right) {
|
||||
private List<ElementDefinitionConstraintComponent> unionConstraints(ProfileComparison comp, StructuralMatch<ElementDefinitionNode> res, String path, List<ElementDefinitionConstraintComponent> left, List<ElementDefinitionConstraintComponent> right) {
|
||||
List<ElementDefinitionConstraintComponent> result = new ArrayList<ElementDefinitionConstraintComponent>();
|
||||
for (ElementDefinitionConstraintComponent l : left) {
|
||||
boolean found = false;
|
||||
|
@ -829,7 +875,7 @@ public class ProfileComparer extends CanonicalResourceComparer {
|
|||
return result;
|
||||
}
|
||||
|
||||
private StructureDefinition resolveProfile(ProfileComparison comp, StructuralMatch<ElementDefinition> res, String path, String url, String name, IWorkerContext ctxt) {
|
||||
private StructureDefinition resolveProfile(ProfileComparison comp, StructuralMatch<ElementDefinitionNode> res, String path, String url, String name, IWorkerContext ctxt) {
|
||||
StructureDefinition sd = ctxt.fetchResource(StructureDefinition.class, url);
|
||||
if (sd == null) {
|
||||
ValidationMessage vm = vmI(IssueSeverity.WARNING, "Unable to resolve profile "+url+" in profile "+name, path);
|
||||
|
@ -841,7 +887,7 @@ public class ProfileComparer extends CanonicalResourceComparer {
|
|||
return binding.getStrength() == BindingStrength.EXAMPLE || binding.getStrength() == BindingStrength.PREFERRED;
|
||||
}
|
||||
|
||||
private ElementDefinitionBindingComponent unionBindings(ProfileComparison comp, StructuralMatch<ElementDefinition> res, String path, ElementDefinitionBindingComponent left, ElementDefinitionBindingComponent right) throws FHIRFormatError, DefinitionException, IOException {
|
||||
private ElementDefinitionBindingComponent unionBindings(ProfileComparison comp, StructuralMatch<ElementDefinitionNode> res, String path, ElementDefinitionBindingComponent left, ElementDefinitionBindingComponent right) throws FHIRFormatError, DefinitionException, IOException {
|
||||
ElementDefinitionBindingComponent union = new ElementDefinitionBindingComponent();
|
||||
if (left.getStrength().compareTo(right.getStrength()) < 0)
|
||||
union.setStrength(left.getStrength());
|
||||
|
@ -881,17 +927,17 @@ public class ProfileComparer extends CanonicalResourceComparer {
|
|||
return gen.generate(model, prefix, 0, null);
|
||||
}
|
||||
|
||||
private void genElementComp(String defPath, HierarchicalTableGenerator gen, List<Row> rows, StructuralMatch<ElementDefinition> combined, String corePath, String prefix, Row slicingRow, boolean root) throws IOException {
|
||||
private void genElementComp(String defPath, HierarchicalTableGenerator gen, List<Row> rows, StructuralMatch<ElementDefinitionNode> combined, String corePath, String prefix, Row slicingRow, boolean root) throws IOException {
|
||||
Row originalRow = slicingRow;
|
||||
Row typesRow = null;
|
||||
|
||||
List<StructuralMatch<ElementDefinition>> children = combined.getChildren();
|
||||
List<StructuralMatch<ElementDefinitionNode>> children = combined.getChildren();
|
||||
|
||||
Row row = gen.new Row();
|
||||
rows.add(row);
|
||||
String path = combined.either().getPath();
|
||||
String path = combined.either().getDef().getPath();
|
||||
row.setAnchor(path);
|
||||
row.setColor(utilsRight.getRowColor(combined.either(), false));
|
||||
row.setColor(utilsRight.getRowColor(combined.either().getDef(), false));
|
||||
if (eitherHasSlicing(combined))
|
||||
row.setLineColor(1);
|
||||
else if (eitherHasSliceName(combined))
|
||||
|
@ -917,7 +963,7 @@ public class ProfileComparer extends CanonicalResourceComparer {
|
|||
row.setIcon("icon_choice.gif", HierarchicalTableGenerator.TEXT_ICON_CHOICE);
|
||||
typesRow = row;
|
||||
}
|
||||
} else if (combined.either().hasContentReference())
|
||||
} else if (combined.either().getDef().hasContentReference())
|
||||
row.setIcon("icon_reuse.png", HierarchicalTableGenerator.TEXT_ICON_REUSE);
|
||||
else if (isPrimitive(combined))
|
||||
row.setIcon("icon_primitive.png", HierarchicalTableGenerator.TEXT_ICON_PRIMITIVE);
|
||||
|
@ -927,7 +973,7 @@ public class ProfileComparer extends CanonicalResourceComparer {
|
|||
row.setIcon("icon_datatype.gif", HierarchicalTableGenerator.TEXT_ICON_DATATYPE);
|
||||
else
|
||||
row.setIcon("icon_resource.png", HierarchicalTableGenerator.TEXT_ICON_RESOURCE);
|
||||
String ref = defPath == null ? null : defPath + combined.either().getId();
|
||||
String ref = defPath == null ? null : defPath + combined.either().getDef().getId();
|
||||
String sName = tail(path);
|
||||
String sn = getSliceName(combined);
|
||||
if (sn != null)
|
||||
|
@ -937,23 +983,23 @@ public class ProfileComparer extends CanonicalResourceComparer {
|
|||
String leftColor = !combined.hasLeft() ? COLOR_NO_ROW_LEFT : combined.hasErrors() ? COLOR_DIFFERENT : null;
|
||||
String rightColor = !combined.hasRight() ? COLOR_NO_ROW_LEFT : combined.hasErrors() ? COLOR_DIFFERENT : null;
|
||||
if (combined.hasLeft()) {
|
||||
nc = utilsRight.genElementNameCell(gen, combined.getLeft(), "??", true, corePath, prefix, root, false, false, null, typesRow, row, false, ext, used , ref, sName);
|
||||
nc = utilsRight.genElementNameCell(gen, combined.getLeft().getDef(), "??", true, corePath, prefix, root, false, false, combined.getLeft().getSrc(), typesRow, row, false, ext, used , ref, sName);
|
||||
} else {
|
||||
nc = utilsRight.genElementNameCell(gen, combined.getRight(), "??", true, corePath, prefix, root, false, false, null, typesRow, row, false, ext, used , ref, sName);
|
||||
nc = utilsRight.genElementNameCell(gen, combined.getRight().getDef(), "??", true, corePath, prefix, root, false, false, combined.getRight().getSrc(), typesRow, row, false, ext, used , ref, sName);
|
||||
}
|
||||
if (combined.hasLeft()) {
|
||||
frame(utilsRight.genElementCells(gen, combined.getLeft(), "??", true, corePath, prefix, root, false, false, null, typesRow, row, false, ext, used , ref, sName, nc, false), leftColor);
|
||||
frame(utilsRight.genElementCells(gen, combined.getLeft().getDef(), "??", true, corePath, prefix, root, false, false, combined.getLeft().getSrc(), typesRow, row, true, ext, used , ref, sName, nc, false, false), leftColor);
|
||||
} else {
|
||||
frame(spacers(row, 4, gen), leftColor);
|
||||
}
|
||||
if (combined.hasRight()) {
|
||||
frame(utilsRight.genElementCells(gen, combined.getRight(), "??", true, corePath, prefix, root, false, false, null, typesRow, row, false, ext, used, ref, sName, nc, false), rightColor);
|
||||
frame(utilsRight.genElementCells(gen, combined.getRight().getDef(), "??", true, corePath, prefix, root, false, false, combined.getRight().getSrc(), typesRow, row, true, ext, used, ref, sName, nc, false, false), rightColor);
|
||||
} else {
|
||||
frame(spacers(row, 4, gen), rightColor);
|
||||
}
|
||||
row.getCells().add(cellForMessages(gen, combined.getMessages()));
|
||||
|
||||
for (StructuralMatch<ElementDefinition> child : children) {
|
||||
for (StructuralMatch<ElementDefinitionNode> child : children) {
|
||||
genElementComp(defPath, gen, row.getSubRows(), child, corePath, prefix, originalRow, false);
|
||||
}
|
||||
}
|
||||
|
@ -978,47 +1024,47 @@ public class ProfileComparer extends CanonicalResourceComparer {
|
|||
return res;
|
||||
}
|
||||
|
||||
private String getSliceName(StructuralMatch<ElementDefinition> combined) {
|
||||
private String getSliceName(StructuralMatch<ElementDefinitionNode> combined) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isDataType(StructuralMatch<ElementDefinition> combined) {
|
||||
private boolean isDataType(StructuralMatch<ElementDefinitionNode> combined) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean hasTarget(StructuralMatch<ElementDefinition> combined) {
|
||||
private boolean hasTarget(StructuralMatch<ElementDefinitionNode> combined) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isPrimitive(StructuralMatch<ElementDefinition> combined) {
|
||||
private boolean isPrimitive(StructuralMatch<ElementDefinitionNode> combined) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean allAreReference(StructuralMatch<ElementDefinition> combined) {
|
||||
private boolean allAreReference(StructuralMatch<ElementDefinitionNode> combined) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean hasChoice(StructuralMatch<ElementDefinition> combined) {
|
||||
private boolean hasChoice(StructuralMatch<ElementDefinitionNode> combined) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean elementIsComplex(StructuralMatch<ElementDefinition> combined) {
|
||||
private boolean elementIsComplex(StructuralMatch<ElementDefinitionNode> combined) {
|
||||
// TODO Auto-generated method stub velement.hasType() && element.getType().get(0).hasProfile() && extensionIsComplex(element.getType().get(0).getProfile().get(0).getValue()
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean eitherHasSliceName(StructuralMatch<ElementDefinition> combined) {
|
||||
private boolean eitherHasSliceName(StructuralMatch<ElementDefinitionNode> combined) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean eitherHasSlicing(StructuralMatch<ElementDefinition> combined) {
|
||||
private boolean eitherHasSlicing(StructuralMatch<ElementDefinitionNode> combined) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -549,7 +549,17 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
}
|
||||
|
||||
public List<ElementDefinition> getChildList(StructureDefinition structure, ElementDefinition element) {
|
||||
return getChildList(structure, element.getPath(), element.getId(), false);
|
||||
if (element.hasContentReference()) {
|
||||
ElementDefinition target = element;
|
||||
for (ElementDefinition t : structure.getSnapshot().getElement()) {
|
||||
if (t.getId().equals(element.getContentReference().substring(1))) {
|
||||
target = t;
|
||||
}
|
||||
}
|
||||
return getChildList(structure, target.getPath(), target.getId(), false);
|
||||
} else {
|
||||
return getChildList(structure, element.getPath(), element.getId(), false);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateMaps(StructureDefinition base, StructureDefinition derived) throws DefinitionException {
|
||||
|
@ -1077,6 +1087,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
ElementDefinition outcome = updateURLs(url, webUrl, currentBase.copy());
|
||||
outcome.setPath(fixedPathDest(contextPathDst, outcome.getPath(), redirector, contextPathSrc));
|
||||
updateFromBase(outcome, currentBase);
|
||||
updateConstraintSources(outcome, srcSD.getUrl());
|
||||
markDerived(outcome);
|
||||
if (resultPathBase == null)
|
||||
resultPathBase = outcome.getPath();
|
||||
|
@ -1913,6 +1924,15 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
return res;
|
||||
}
|
||||
|
||||
private void updateConstraintSources(ElementDefinition ed, String url) {
|
||||
for (ElementDefinitionConstraintComponent c : ed.getConstraint()) {
|
||||
if (!c.hasSource()) {
|
||||
c.setSource(url);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Set<String> getListOfTypes(ElementDefinition e) {
|
||||
Set<String> result = new HashSet<>();
|
||||
for (TypeRefComponent t : e.getType()) {
|
||||
|
@ -2087,6 +2107,8 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
|
||||
private void removeStatusExtensions(ElementDefinition outcome) {
|
||||
outcome.removeExtension(ToolingExtensions.EXT_FMM_LEVEL);
|
||||
outcome.removeExtension(ToolingExtensions.EXT_FMM_SUPPORT);
|
||||
outcome.removeExtension(ToolingExtensions.EXT_FMM_DERIVED);
|
||||
outcome.removeExtension(ToolingExtensions.EXT_STANDARDS_STATUS);
|
||||
outcome.removeExtension(ToolingExtensions.EXT_NORMATIVE_VERSION);
|
||||
outcome.removeExtension(ToolingExtensions.EXT_WORKGROUP);
|
||||
|
@ -2406,6 +2428,11 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
StructureDefinition sd = null;
|
||||
if (type.hasProfile()) {
|
||||
sd = context.fetchResource(StructureDefinition.class, type.getProfile().get(0).getValue());
|
||||
if (sd == null) {
|
||||
if (xver != null && xver.matchingUrl(type.getProfile().get(0).getValue()) && xver.status(type.getProfile().get(0).getValue()) == XVerExtensionStatus.Valid) {
|
||||
sd = xver.makeDefinition(type.getProfile().get(0).getValue());
|
||||
}
|
||||
}
|
||||
if (sd == null)
|
||||
System.out.println("Failed to find referenced profile: " + type.getProfile());
|
||||
}
|
||||
|
@ -2475,19 +2502,19 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
if (webUrl != null) {
|
||||
// also, must touch up the markdown
|
||||
if (element.hasDefinition())
|
||||
element.setDefinition(processRelativeUrls(element.getDefinition(), webUrl, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames));
|
||||
element.setDefinition(processRelativeUrls(element.getDefinition(), webUrl, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames, true));
|
||||
if (element.hasComment())
|
||||
element.setComment(processRelativeUrls(element.getComment(), webUrl, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames));
|
||||
element.setComment(processRelativeUrls(element.getComment(), webUrl, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames, true));
|
||||
if (element.hasRequirements())
|
||||
element.setRequirements(processRelativeUrls(element.getRequirements(), webUrl, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames));
|
||||
element.setRequirements(processRelativeUrls(element.getRequirements(), webUrl, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames, true));
|
||||
if (element.hasMeaningWhenMissing())
|
||||
element.setMeaningWhenMissing(processRelativeUrls(element.getMeaningWhenMissing(), webUrl, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames));
|
||||
element.setMeaningWhenMissing(processRelativeUrls(element.getMeaningWhenMissing(), webUrl, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames, true));
|
||||
}
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
public static String processRelativeUrls(String markdown, String webUrl, String basePath, List<String> resourceNames, Set<String> filenames) {
|
||||
public static String processRelativeUrls(String markdown, String webUrl, String basePath, List<String> resourceNames, Set<String> filenames, boolean processRelatives) {
|
||||
StringBuilder b = new StringBuilder();
|
||||
int i = 0;
|
||||
while (i < markdown.length()) {
|
||||
|
@ -2515,7 +2542,14 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
} else {
|
||||
b.append("](");
|
||||
// disabled 7-Dec 2021 GDG - we don't want to fool with relative URLs at all?
|
||||
// b.append(webUrl);
|
||||
// re-enabled 11-Feb 2022 GDG - we do want to do this. At least, $assemble in davinci-dtr, where the markdown comes from the SDC IG, and an SDC local reference must be changed to point to SDC. in this case, it's called when generating snapshots
|
||||
// added processRelatives parameter to deal with this (well, to try)
|
||||
if (processRelatives && webUrl != null) {
|
||||
// System.out.println("Making "+url+" relative to '"+webUrl+"'");
|
||||
b.append(webUrl);
|
||||
} else {
|
||||
// System.out.println("Not making "+url+" relative to '"+webUrl+"'");
|
||||
}
|
||||
i = i + 1;
|
||||
}
|
||||
} else
|
||||
|
@ -2773,7 +2807,9 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
profile = source.getType().size() == 1 && source.getTypeFirstRep().hasProfile() ? context.fetchResource(StructureDefinition.class, source.getTypeFirstRep().getProfile().get(0).getValue()) : null;
|
||||
if (profile != null) {
|
||||
ElementDefinition e = profile.getSnapshot().getElement().get(0);
|
||||
base.setDefinition(e.getDefinition());
|
||||
String webroot = profile.getUserString("webroot");
|
||||
|
||||
base.setDefinition(processRelativeUrls(e.getDefinition(), webroot, baseSpecUrl(), context.getResourceNames(), masterSourceFileNames, true));
|
||||
base.setShort(e.getShort());
|
||||
if (e.hasCommentElement())
|
||||
base.setCommentElement(e.getCommentElement());
|
||||
|
@ -3502,7 +3538,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
List<TypeRefComponent> types = e.getType();
|
||||
if (!e.hasType()) {
|
||||
if (root) { // we'll use base instead of types then
|
||||
StructureDefinition bsd = context.fetchResource(StructureDefinition.class, profile.getBaseDefinition());
|
||||
StructureDefinition bsd = profile == null ? null : context.fetchResource(StructureDefinition.class, profile.getBaseDefinition());
|
||||
if (bsd != null) {
|
||||
if (bsd.hasUserData("path")) {
|
||||
c.getPieces().add(gen.new Piece(Utilities.isAbsoluteUrl(bsd.getUserString("path")) ? bsd.getUserString("path") : imagePath +bsd.getUserString("path"), bsd.getName(), null));
|
||||
|
@ -3584,7 +3620,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
c.addPiece(checkForNoChange(tl, gen.new Piece(null,", ", null)));
|
||||
}
|
||||
|
||||
ref = pkp.getLinkForProfile(profile, p.getValue());
|
||||
ref = pkp == null ? null : pkp.getLinkForProfile(profile, p.getValue());
|
||||
if (ref != null) {
|
||||
String[] parts = ref.split("\\|");
|
||||
if (parts[0].startsWith("http:") || parts[0].startsWith("https:")) {
|
||||
|
@ -3665,7 +3701,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
}
|
||||
|
||||
|
||||
private String codeForAggregation(AggregationMode a) {
|
||||
public static String codeForAggregation(AggregationMode a) {
|
||||
switch (a) {
|
||||
case BUNDLED : return "b";
|
||||
case CONTAINED : return "c";
|
||||
|
@ -3674,7 +3710,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
}
|
||||
}
|
||||
|
||||
private String hintForAggregation(AggregationMode a) {
|
||||
public static String hintForAggregation(AggregationMode a) {
|
||||
if (a != null)
|
||||
return a.getDefinition();
|
||||
else
|
||||
|
@ -3683,7 +3719,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
|
||||
|
||||
private String checkPrepend(String corePath, String path) {
|
||||
if (pkp.prependLinks() && !(path.startsWith("http:") || path.startsWith("https:")))
|
||||
if (pkp != null && pkp.prependLinks() && !(path.startsWith("http:") || path.startsWith("https:")))
|
||||
return corePath+path;
|
||||
else
|
||||
return path;
|
||||
|
@ -4055,7 +4091,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
if (logicalModel && element.hasRepresentation(PropertyRepresentation.XMLATTR))
|
||||
sName = "@"+sName;
|
||||
Cell nc = genElementNameCell(gen, element, profileBaseFileName, snapshot, corePath, imagePath, root, logicalModel, allInvariants, profile, typesRow, row, hasDef, ext, used, ref, sName);
|
||||
genElementCells(gen, element, profileBaseFileName, snapshot, corePath, imagePath, root, logicalModel, allInvariants, profile, typesRow, row, hasDef, ext, used, ref, sName, nc, mustSupport);
|
||||
genElementCells(gen, element, profileBaseFileName, snapshot, corePath, imagePath, root, logicalModel, allInvariants, profile, typesRow, row, hasDef, ext, used, ref, sName, nc, mustSupport, true);
|
||||
if (element.hasSlicing()) {
|
||||
if (standardExtensionSlicing(element)) {
|
||||
used.used = true; // doesn't matter whether we have a type, we're used if we're setting up slicing ... element.hasType() && element.getType().get(0).hasProfile();
|
||||
|
@ -4183,7 +4219,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
|
||||
public List<Cell> genElementCells(HierarchicalTableGenerator gen, ElementDefinition element, String profileBaseFileName, boolean snapshot, String corePath,
|
||||
String imagePath, boolean root, boolean logicalModel, boolean allInvariants, StructureDefinition profile, Row typesRow, Row row, boolean hasDef,
|
||||
boolean ext, UnusedTracker used, String ref, String sName, Cell nameCell, boolean mustSupport) throws IOException {
|
||||
boolean ext, UnusedTracker used, String ref, String sName, Cell nameCell, boolean mustSupport, boolean allowSubRows) throws IOException {
|
||||
List<Cell> res = new ArrayList<>();
|
||||
Cell gc = gen.new Cell();
|
||||
row.getCells().add(gc);
|
||||
|
@ -4209,7 +4245,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
if (extDefn == null) {
|
||||
res.add(genCardinality(gen, element, row, hasDef, used, null));
|
||||
res.add(addCell(row, gen.new Cell(null, null, "?gen-e1? "+element.getType().get(0).getProfile(), null, null)));
|
||||
res.add(generateDescription(gen, row, element, (ElementDefinition) element.getUserData(DERIVATION_POINTER), used.used, profile == null ? "" : profile.getUrl(), eurl, profile, corePath, imagePath, root, logicalModel, allInvariants, snapshot, mustSupport));
|
||||
res.add(generateDescription(gen, row, element, (ElementDefinition) element.getUserData(DERIVATION_POINTER), used.used, profile == null ? "" : profile.getUrl(), eurl, profile, corePath, imagePath, root, logicalModel, allInvariants, snapshot, mustSupport, allowSubRows));
|
||||
} else {
|
||||
String name = urltail(eurl);
|
||||
nameCell.getPieces().get(0).setText(name);
|
||||
|
@ -4222,7 +4258,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
else // if it's complex, we just call it nothing
|
||||
// genTypes(gen, row, extDefn.getSnapshot().getElement().get(0), profileBaseFileName, profile);
|
||||
res.add(addCell(row, gen.new Cell(null, null, "("+translate("sd.table", "Complex")+")", null, null)));
|
||||
res.add(generateDescription(gen, row, element, extDefn.getElement(), used.used, null, extDefn.getUrl(), profile, corePath, imagePath, root, logicalModel, allInvariants, valueDefn, snapshot, mustSupport));
|
||||
res.add(generateDescription(gen, row, element, extDefn.getElement(), used.used, null, extDefn.getUrl(), profile, corePath, imagePath, root, logicalModel, allInvariants, valueDefn, snapshot, mustSupport, allowSubRows));
|
||||
}
|
||||
} else {
|
||||
res.add(genCardinality(gen, element, row, hasDef, used, null));
|
||||
|
@ -4230,7 +4266,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
res.add(addCell(row, gen.new Cell()));
|
||||
else
|
||||
res.add(genTypes(gen, row, element, profileBaseFileName, profile, corePath, imagePath, root, mustSupport));
|
||||
res.add(generateDescription(gen, row, element, (ElementDefinition) element.getUserData(DERIVATION_POINTER), used.used, null, null, profile, corePath, imagePath, root, logicalModel, allInvariants, snapshot, mustSupport));
|
||||
res.add(generateDescription(gen, row, element, (ElementDefinition) element.getUserData(DERIVATION_POINTER), used.used, null, null, profile, corePath, imagePath, root, logicalModel, allInvariants, snapshot, mustSupport, allowSubRows));
|
||||
}
|
||||
} else {
|
||||
res.add(genCardinality(gen, element, row, hasDef, used, null));
|
||||
|
@ -4238,7 +4274,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
res.add(genTypes(gen, row, element, profileBaseFileName, profile, corePath, imagePath, root, mustSupport));
|
||||
else
|
||||
res.add(addCell(row, gen.new Cell()));
|
||||
res.add(generateDescription(gen, row, element, (ElementDefinition) element.getUserData(DERIVATION_POINTER), used.used, null, null, profile, corePath, imagePath, root, logicalModel, allInvariants, snapshot, mustSupport));
|
||||
res.add(generateDescription(gen, row, element, (ElementDefinition) element.getUserData(DERIVATION_POINTER), used.used, null, null, profile, corePath, imagePath, root, logicalModel, allInvariants, snapshot, mustSupport, allowSubRows));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
@ -4544,11 +4580,11 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
&& element.getSlicing().getRules() != SlicingRules.CLOSED && element.getSlicing().getDiscriminator().size() == 1 && element.getSlicing().getDiscriminator().get(0).getPath().equals("url") && element.getSlicing().getDiscriminator().get(0).getType().equals(DiscriminatorType.VALUE);
|
||||
}
|
||||
|
||||
private Cell generateDescription(HierarchicalTableGenerator gen, Row row, ElementDefinition definition, ElementDefinition fallback, boolean used, String baseURL, String url, StructureDefinition profile, String corePath, String imagePath, boolean root, boolean logicalModel, boolean allInvariants, boolean snapshot, boolean mustSupportOnly) throws IOException, FHIRException {
|
||||
return generateDescription(gen, row, definition, fallback, used, baseURL, url, profile, corePath, imagePath, root, logicalModel, allInvariants, null, snapshot, mustSupportOnly);
|
||||
private Cell generateDescription(HierarchicalTableGenerator gen, Row row, ElementDefinition definition, ElementDefinition fallback, boolean used, String baseURL, String url, StructureDefinition profile, String corePath, String imagePath, boolean root, boolean logicalModel, boolean allInvariants, boolean snapshot, boolean mustSupportOnly, boolean allowSubRows) throws IOException, FHIRException {
|
||||
return generateDescription(gen, row, definition, fallback, used, baseURL, url, profile, corePath, imagePath, root, logicalModel, allInvariants, null, snapshot, mustSupportOnly, allowSubRows);
|
||||
}
|
||||
|
||||
private Cell generateDescription(HierarchicalTableGenerator gen, Row row, ElementDefinition definition, ElementDefinition fallback, boolean used, String baseURL, String url, StructureDefinition profile, String corePath, String imagePath, boolean root, boolean logicalModel, boolean allInvariants, ElementDefinition valueDefn, boolean snapshot, boolean mustSupportOnly) throws IOException, FHIRException {
|
||||
private Cell generateDescription(HierarchicalTableGenerator gen, Row row, ElementDefinition definition, ElementDefinition fallback, boolean used, String baseURL, String url, StructureDefinition profile, String corePath, String imagePath, boolean root, boolean logicalModel, boolean allInvariants, ElementDefinition valueDefn, boolean snapshot, boolean mustSupportOnly, boolean allowSubRows) throws IOException, FHIRException {
|
||||
Cell c = gen.new Cell();
|
||||
row.getCells().add(c);
|
||||
|
||||
|
@ -4564,7 +4600,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
}
|
||||
}
|
||||
if (root) {
|
||||
if (profile.getAbstract()) {
|
||||
if (profile != null && profile.getAbstract()) {
|
||||
if (!c.getPieces().isEmpty()) { c.addPiece(gen.new Piece("br")); }
|
||||
c.addPiece(gen.new Piece(null, "This is an abstract profile", null));
|
||||
}
|
||||
|
@ -4659,7 +4695,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
if (binding!=null && !binding.isEmpty()) {
|
||||
if (!c.getPieces().isEmpty())
|
||||
c.addPiece(gen.new Piece("br"));
|
||||
BindingResolution br = pkp.resolveBinding(profile, binding, definition.getPath());
|
||||
BindingResolution br = pkp == null ? makeNullBr(binding) : pkp.resolveBinding(profile, binding, definition.getPath());
|
||||
c.getPieces().add(checkForNoChange(binding, gen.new Piece(null, translate("sd.table", "Binding")+": ", null).addStyle("font-weight:bold")));
|
||||
c.getPieces().add(checkForNoChange(binding.getValueSetElement(), gen.new Piece(br.url == null ? null : Utilities.isAbsoluteUrl(br.url) || !pkp.prependLinks() ? br.url : corePath+br.url, br.display, null)));
|
||||
if (binding.hasStrength()) {
|
||||
|
@ -4668,7 +4704,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
c.getPieces().add(checkForNoChange(binding.getStrengthElement(), gen.new Piece(null, ")", null)));
|
||||
}
|
||||
if (binding.hasExtension(ToolingExtensions.EXT_MAX_VALUESET)) {
|
||||
br = pkp.resolveBinding(profile, ToolingExtensions.readStringExtension(binding, ToolingExtensions.EXT_MAX_VALUESET), definition.getPath());
|
||||
br = pkp == null ? makeNullBr(binding) : pkp.resolveBinding(profile, ToolingExtensions.readStringExtension(binding, ToolingExtensions.EXT_MAX_VALUESET), definition.getPath());
|
||||
c.addPiece(gen.new Piece("br"));
|
||||
c.getPieces().add(checkForNoChange(binding, gen.new Piece(corePath+"extension-elementdefinition-maxvalueset.html", translate("sd.table", "Max Binding")+": ", "Max Value Set Extension").addStyle("font-weight:bold")));
|
||||
c.getPieces().add(checkForNoChange(binding, gen.new Piece(br.url == null ? null : Utilities.isAbsoluteUrl(br.url) || !pkp.prependLinks() ? br.url : corePath+br.url, br.display, null)));
|
||||
|
@ -4683,6 +4719,13 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
c.getPieces().add(gen.new Piece(null, ": ", null));
|
||||
c.addMarkdownNoPara(PublicationHacker.fixBindingDescriptions(context, binding.getDescriptionElement()).asStringValue(), checkForNoChange(PublicationHacker.fixBindingDescriptions(context, binding.getDescriptionElement())));
|
||||
}
|
||||
if (binding.hasExtension(ToolingExtensions.EXT_BINDING_ADDITIONAL)) {
|
||||
c.addPiece(gen.new Piece("br"));
|
||||
c.getPieces().add(checkForNoChange(binding, gen.new Piece(null, translate("sd.table", "Additional Bindings")+": ", null).addStyle("font-weight:bold")));
|
||||
for (Extension ext : binding.getExtensionsByUrl(ToolingExtensions.EXT_BINDING_ADDITIONAL)) {
|
||||
renderAdditionalBinding(gen, c, ext);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (ElementDefinitionConstraintComponent inv : definition.getConstraint()) {
|
||||
if (!inv.hasSource() || profile == null || inv.getSource().equals(profile.getUrl()) || allInvariants) {
|
||||
|
@ -4704,7 +4747,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
if (definition.hasFixed()) {
|
||||
if (!c.getPieces().isEmpty()) { c.addPiece(gen.new Piece("br")); }
|
||||
c.getPieces().add(checkForNoChange(definition.getFixed(), gen.new Piece(null, translate("sd.table", "Fixed Value")+": ", null).addStyle("font-weight:bold")));
|
||||
if (!useTableForFixedValues || definition.getFixed().isPrimitive()) {
|
||||
if (!useTableForFixedValues || !allowSubRows || definition.getFixed().isPrimitive()) {
|
||||
String s = buildJson(definition.getFixed());
|
||||
String link = null;
|
||||
if (Utilities.isAbsoluteUrl(s))
|
||||
|
@ -4712,7 +4755,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
c.getPieces().add(checkForNoChange(definition.getFixed(), gen.new Piece(link, s, null).addStyle("color: darkgreen")));
|
||||
} else {
|
||||
c.getPieces().add(checkForNoChange(definition.getFixed(), gen.new Piece(null, "As shown", null).addStyle("color: darkgreen")));
|
||||
genFixedValue(gen, row, definition.getFixed(), snapshot, false, corePath, false);
|
||||
genFixedValue(gen, row, definition.getFixed(), snapshot, false, corePath, false);
|
||||
}
|
||||
if (isCoded(definition.getFixed()) && !hasDescription(definition.getFixed())) {
|
||||
Piece p = describeCoded(gen, definition.getFixed());
|
||||
|
@ -4722,7 +4765,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
} else if (definition.hasPattern()) {
|
||||
if (!c.getPieces().isEmpty()) { c.addPiece(gen.new Piece("br")); }
|
||||
c.getPieces().add(checkForNoChange(definition.getPattern(), gen.new Piece(null, translate("sd.table", "Required Pattern")+": ", null).addStyle("font-weight:bold")));
|
||||
if (!useTableForFixedValues || definition.getPattern().isPrimitive())
|
||||
if (!useTableForFixedValues || !allowSubRows || definition.getPattern().isPrimitive())
|
||||
c.getPieces().add(checkForNoChange(definition.getPattern(), gen.new Piece(null, buildJson(definition.getPattern()), null).addStyle("color: darkgreen")));
|
||||
else {
|
||||
c.getPieces().add(checkForNoChange(definition.getPattern(), gen.new Piece(null, "At least the following", null).addStyle("color: darkgreen")));
|
||||
|
@ -4762,6 +4805,30 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
return c;
|
||||
}
|
||||
|
||||
private void renderAdditionalBinding(HierarchicalTableGenerator gen, Cell c, Extension ext) {
|
||||
// <nsbp>2 <sp> purpose <sp> value-set-link ([context]) {documentation}
|
||||
String purpose = ext.getExtensionString("purpose");
|
||||
String valueSet = ext.getExtensionString("valueSet");
|
||||
String doco = ext.getExtensionString("documentation");
|
||||
//UsageContext usage = (ext.hasExtension("usage")) ? ext.getExtensionByUrl("usage").getValueUsageContext() : null;
|
||||
//
|
||||
// purpose: code - defines how the binding is used
|
||||
// usage : UsageContext - defines the contexts in which this binding is used for it's purpose
|
||||
// valueSet : canonical(ValueSet)
|
||||
// documentation : markdown
|
||||
// !!
|
||||
// c.getPieces().add(checkForNoChange(inv, gen.new Piece(null, inv.getKey()+": ", null).addStyle("font-weight:bold")));
|
||||
// c.getPieces().add(checkForNoChange(inv, gen.new Piece(null, gt(inv.getHumanElement()), null)));
|
||||
|
||||
}
|
||||
|
||||
private BindingResolution makeNullBr(ElementDefinitionBindingComponent binding) {
|
||||
BindingResolution br = new BindingResolution();
|
||||
br.url = "http://none.none/none";
|
||||
br.display = "todo";
|
||||
return br;
|
||||
}
|
||||
|
||||
private ElementDefinitionBindingComponent makeUnifiedBinding(ElementDefinitionBindingComponent binding, ElementDefinition element) {
|
||||
if (!element.hasUserData(DERIVATION_POINTER)) {
|
||||
return binding;
|
||||
|
|
|
@ -198,6 +198,9 @@ public class ToolingExtensions {
|
|||
public static final String EXT_TARGET_ID = "http://hl7.org/fhir/StructureDefinition/targetElement";
|
||||
public static final String EXT_TARGET_PATH = "http://hl7.org/fhir/StructureDefinition/targetPath";
|
||||
public static final String EXT_VALUESET_SYSTEM = "http://hl7.org/fhir/StructureDefinition/valueset-system";
|
||||
public static final String EXT_EXPAND_RULES = "http://hl7.org/fhir/StructureDefinition/valueset-expand-rules";
|
||||
public static final String EXT_EXPAND_GROUP = "http://hl7.org/fhir/StructureDefinition/valueset-expand-group";
|
||||
public static final String EXT_BINDING_ADDITIONAL = "http://hl7.org/fhir/tools/StructureDefinition/additional-binding";
|
||||
|
||||
// specific extension helpers
|
||||
|
||||
|
@ -511,7 +514,7 @@ public class ToolingExtensions {
|
|||
* @return The extension, if on this element, else null
|
||||
*/
|
||||
public static Extension getExtension(DomainResource resource, String name) {
|
||||
if (name == null)
|
||||
if (resource == null || name == null)
|
||||
return null;
|
||||
if (!resource.hasExtension())
|
||||
return null;
|
||||
|
|
|
@ -50,9 +50,6 @@ public class XVerExtensionManager {
|
|||
return XVerExtensionStatus.Invalid;
|
||||
}
|
||||
String v = url.substring(20, 23);
|
||||
if ("5.0".equals(v)) {
|
||||
v = "4.6"; // for now
|
||||
}
|
||||
String e = url.substring(54);
|
||||
if (!lists.containsKey(v)) {
|
||||
if (context.getBinaries().containsKey("xver-paths-"+v+".json")) {
|
||||
|
@ -67,6 +64,9 @@ public class XVerExtensionManager {
|
|||
}
|
||||
JsonObject root = lists.get(v);
|
||||
JsonObject path = root.getAsJsonObject(e);
|
||||
if (path == null) {
|
||||
path = root.getAsJsonObject(e+"[x]");
|
||||
}
|
||||
if (path == null) {
|
||||
return XVerExtensionStatus.Unknown;
|
||||
}
|
||||
|
@ -83,13 +83,13 @@ public class XVerExtensionManager {
|
|||
|
||||
public StructureDefinition makeDefinition(String url) {
|
||||
String verSource = url.substring(20, 23);
|
||||
if ("5.0".equals(verSource)) {
|
||||
verSource = "4.6"; // for now
|
||||
}
|
||||
String verTarget = VersionUtilities.getMajMin(context.getVersion());
|
||||
String e = url.substring(54);
|
||||
JsonObject root = lists.get(verSource);
|
||||
JsonObject path = root.getAsJsonObject(e);
|
||||
if (path == null) {
|
||||
path = root.getAsJsonObject(e+"[x]");
|
||||
}
|
||||
|
||||
StructureDefinition sd = new StructureDefinition();
|
||||
sd.setUserData(XVER_EXT_MARKER, "true");
|
||||
|
@ -117,16 +117,18 @@ public class XVerExtensionManager {
|
|||
populateTypes(path, val, verSource, verTarget);
|
||||
} else if (path.has("elements")) {
|
||||
for (JsonElement i : path.getAsJsonArray("elements")) {
|
||||
String s = i.getAsString();
|
||||
JsonObject elt = root.getAsJsonObject(e+"."+i.getAsString());
|
||||
if (elt != null) {
|
||||
String s = i.getAsString().replace("[x]", "");
|
||||
sd.getDifferential().addElement().setPath("Extension.extension").setSliceName(s);
|
||||
sd.getDifferential().addElement().setPath("Extension.extension.extension").setMax("0");
|
||||
sd.getDifferential().addElement().setPath("Extension.extension.url").setFixed(new UriType(s));
|
||||
ElementDefinition val = sd.getDifferential().addElement().setPath("Extension.extension.value[x]").setMin(1);
|
||||
JsonObject elt = root.getAsJsonObject(e+"."+s);
|
||||
if (!elt.has("types")) {
|
||||
throw new FHIRException("Internal error - nested elements not supported yet");
|
||||
}
|
||||
populateTypes(elt, val, verSource, verTarget);
|
||||
}
|
||||
}
|
||||
sd.getDifferential().addElement().setPath("Extension.url").setFixed(new UriType(url));
|
||||
sd.getDifferential().addElement().setPath("Extension.value[x]").setMax("0");
|
||||
|
|
|
@ -4,6 +4,7 @@ import org.hl7.fhir.exceptions.FHIRException;
|
|||
import org.hl7.fhir.r4b.conformance.ProfileUtilities;
|
||||
import org.hl7.fhir.r4b.model.Base;
|
||||
import org.hl7.fhir.r4b.model.ElementDefinition;
|
||||
import org.hl7.fhir.r4b.model.ElementDefinition.ElementDefinitionConstraintComponent;
|
||||
import org.hl7.fhir.r4b.model.IntegerType;
|
||||
import org.hl7.fhir.r4b.model.StructureDefinition;
|
||||
import org.hl7.fhir.r4b.model.StructureDefinition.TypeDerivationRule;
|
||||
|
@ -51,6 +52,12 @@ public class ProfileUtilitiesTests {
|
|||
f.setBase(null);
|
||||
b.setRequirements(null);
|
||||
f.setRequirements(null);
|
||||
for (ElementDefinitionConstraintComponent c : b.getConstraint()) {
|
||||
c.setSource(null);
|
||||
}
|
||||
for (ElementDefinitionConstraintComponent c : f.getConstraint()) {
|
||||
c.setSource(null);
|
||||
}
|
||||
ok = Base.compareDeep(b, f, true);
|
||||
}
|
||||
}
|
||||
|
@ -83,6 +90,12 @@ public class ProfileUtilitiesTests {
|
|||
if (ok) {
|
||||
ElementDefinition b = base.getSnapshot().getElement().get(i);
|
||||
ElementDefinition f = focus.getSnapshot().getElement().get(i);
|
||||
for (ElementDefinitionConstraintComponent c : b.getConstraint()) {
|
||||
c.setSource(null);
|
||||
}
|
||||
for (ElementDefinitionConstraintComponent c : f.getConstraint()) {
|
||||
c.setSource(null);
|
||||
}
|
||||
if (!f.hasBase() || !b.getPath().equals(f.getPath()))
|
||||
ok = false;
|
||||
else {
|
||||
|
@ -128,6 +141,12 @@ public class ProfileUtilitiesTests {
|
|||
ElementDefinition f = focus.getSnapshot().getElement().get(i);
|
||||
b.setRequirements(null);
|
||||
f.setRequirements(null);
|
||||
for (ElementDefinitionConstraintComponent c : b.getConstraint()) {
|
||||
c.setSource(null);
|
||||
}
|
||||
for (ElementDefinitionConstraintComponent c : f.getConstraint()) {
|
||||
c.setSource(null);
|
||||
}
|
||||
if (!f.hasBase() || !b.getPath().equals(f.getPath())) {
|
||||
ok = false;
|
||||
}
|
||||
|
@ -174,6 +193,12 @@ public class ProfileUtilitiesTests {
|
|||
ElementDefinition f = focus.getSnapshot().getElement().get(i);
|
||||
b.setRequirements(null);
|
||||
f.setRequirements(null);
|
||||
for (ElementDefinitionConstraintComponent c : b.getConstraint()) {
|
||||
c.setSource(null);
|
||||
}
|
||||
for (ElementDefinitionConstraintComponent c : f.getConstraint()) {
|
||||
c.setSource(null);
|
||||
}
|
||||
if (!f.hasBase() || !b.getPath().equals(f.getPath())) {
|
||||
ok = false;
|
||||
}
|
||||
|
@ -221,6 +246,12 @@ public class ProfileUtilitiesTests {
|
|||
ElementDefinition f = focus.getSnapshot().getElement().get(i);
|
||||
b.setRequirements(null);
|
||||
f.setRequirements(null);
|
||||
for (ElementDefinitionConstraintComponent c : b.getConstraint()) {
|
||||
c.setSource(null);
|
||||
}
|
||||
for (ElementDefinitionConstraintComponent c : f.getConstraint()) {
|
||||
c.setSource(null);
|
||||
}
|
||||
if (!f.hasBase() || !b.getPath().equals(f.getPath())) {
|
||||
ok = false;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import java.util.List;
|
|||
import java.util.stream.Stream;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.soap.Text;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.NotImplementedException;
|
||||
|
@ -49,6 +50,7 @@ import org.hl7.fhir.utilities.npm.ToolsVersion;
|
|||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
||||
import org.hl7.fhir.utilities.xml.XMLUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
|
@ -137,7 +139,8 @@ public class SnapShotGenerationTests {
|
|||
private boolean fail;
|
||||
private boolean newSliceProcessing;
|
||||
private boolean debug;
|
||||
|
||||
private boolean noR4b;
|
||||
|
||||
private List<Rule> rules = new ArrayList<>();
|
||||
private StructureDefinition source;
|
||||
private List<StructureDefinition> included = new ArrayList<>();
|
||||
|
@ -161,6 +164,7 @@ public class SnapShotGenerationTests {
|
|||
rules.add(new Rule(rule));
|
||||
rule = XMLUtil.getNextSibling(rule);
|
||||
}
|
||||
noR4b = test.hasAttribute("r4b") && "false".equals(test.getAttribute("r4b"));
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
|
@ -466,33 +470,37 @@ public class SnapShotGenerationTests {
|
|||
fp.setHostServices(context);
|
||||
messages = new ArrayList<ValidationMessage>();
|
||||
|
||||
System.out.println("---- "+id+" -----------------------------------------");
|
||||
if (test.isFail()) {
|
||||
boolean failed = true;
|
||||
try {
|
||||
if (test.isGen())
|
||||
testGen(true, test, context);
|
||||
else
|
||||
testSort(test, context);
|
||||
failed = false;
|
||||
} catch (Throwable e) {
|
||||
System.out.println("Error running test: " + e.getMessage());
|
||||
if (!Utilities.noString(test.regex)) {
|
||||
Assertions.assertTrue(e.getMessage().matches(test.regex), "correct error message");
|
||||
} else if ("Should have failed".equals(e.getMessage())) {
|
||||
throw e;
|
||||
} else {
|
||||
if (test.noR4b) {
|
||||
Assert.assertTrue(true);
|
||||
} else {
|
||||
System.out.println("---- "+id+" -----------------------------------------");
|
||||
if (test.isFail()) {
|
||||
boolean failed = true;
|
||||
try {
|
||||
if (test.isGen())
|
||||
testGen(true, test, context);
|
||||
else
|
||||
testSort(test, context);
|
||||
failed = false;
|
||||
} catch (Throwable e) {
|
||||
System.out.println("Error running test: " + e.getMessage());
|
||||
if (!Utilities.noString(test.regex)) {
|
||||
Assertions.assertTrue(e.getMessage().matches(test.regex), "correct error message");
|
||||
} else if ("Should have failed".equals(e.getMessage())) {
|
||||
throw e;
|
||||
} else {
|
||||
}
|
||||
}
|
||||
Assertions.assertTrue(failed, "Should have failed");
|
||||
} else if (test.isGen())
|
||||
testGen(false, test, context);
|
||||
else
|
||||
testSort(test, context);
|
||||
for (Rule r : test.getRules()) {
|
||||
StructureDefinition sdn = new StructureDefinition();
|
||||
boolean ok = fp.evaluateToBoolean(sdn, sdn, sdn, r.expression);
|
||||
Assertions.assertTrue(ok, r.description);
|
||||
}
|
||||
Assertions.assertTrue(failed, "Should have failed");
|
||||
} else if (test.isGen())
|
||||
testGen(false, test, context);
|
||||
else
|
||||
testSort(test, context);
|
||||
for (Rule r : test.getRules()) {
|
||||
StructureDefinition sdn = new StructureDefinition();
|
||||
boolean ok = fp.evaluateToBoolean(sdn, sdn, sdn, r.expression);
|
||||
Assertions.assertTrue(ok, r.description);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue