Merge pull request #1123 from hapifhir/gg-202302-fhirpath-check
Gg 202302 fhirpath check
This commit is contained in:
commit
d00a672f08
|
@ -79,6 +79,7 @@ import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator;
|
|||
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell;
|
||||
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Piece;
|
||||
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row;
|
||||
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableGenerationMode;
|
||||
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableModel;
|
||||
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
|
||||
import org.hl7.fhir.utilities.xml.SchematronWriter;
|
||||
|
@ -1183,7 +1184,7 @@ public class ProfileUtilities {
|
|||
|
||||
public XhtmlNode generateExtensionTable(String defFile, StructureDefinition ed, String imageFolder, boolean inlineGraphics, boolean full, String corePath, Set<String> outputTracker) throws IOException, FHIRException {
|
||||
HierarchicalTableGenerator gen = new HierarchicalTableGenerator(imageFolder, inlineGraphics);
|
||||
TableModel model = gen.initNormalTable(corePath, false, true, ed.getId(), false);
|
||||
TableModel model = gen.initNormalTable(corePath, false, true, ed.getId(), false, TableGenerationMode.XML);
|
||||
|
||||
boolean deep = false;
|
||||
boolean vdeep = false;
|
||||
|
@ -1447,7 +1448,7 @@ public class ProfileUtilities {
|
|||
public XhtmlNode generateTable(String defFile, StructureDefinition profile, boolean diff, String imageFolder, boolean inlineGraphics, String profileBaseFileName, boolean snapshot, String corePath, Set<String> outputTracker) throws IOException, FHIRException {
|
||||
assert(diff != snapshot);// check it's ok to get rid of one of these
|
||||
HierarchicalTableGenerator gen = new HierarchicalTableGenerator(imageFolder, inlineGraphics);
|
||||
TableModel model = gen.initNormalTable(corePath, false, true, profile.getId()+(diff ? "d" : "s"), false);
|
||||
TableModel model = gen.initNormalTable(corePath, false, true, profile.getId()+(diff ? "d" : "s"), false, TableGenerationMode.XML);
|
||||
List<ElementDefinition> list = diff ? profile.getDifferential().getElement() : profile.getSnapshot().getElement();
|
||||
List<StructureDefinition> profiles = new ArrayList<StructureDefinition>();
|
||||
profiles.add(profile);
|
||||
|
|
|
@ -80,6 +80,7 @@ import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator;
|
|||
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell;
|
||||
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Piece;
|
||||
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row;
|
||||
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableGenerationMode;
|
||||
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableModel;
|
||||
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
|
||||
import org.hl7.fhir.utilities.xml.SchematronWriter;
|
||||
|
@ -1184,7 +1185,7 @@ public class ProfileUtilities {
|
|||
|
||||
public XhtmlNode generateExtensionTable(String defFile, StructureDefinition ed, String imageFolder, boolean inlineGraphics, boolean full, String corePath, Set<String> outputTracker) throws IOException, FHIRException {
|
||||
HierarchicalTableGenerator gen = new HierarchicalTableGenerator(imageFolder, inlineGraphics);
|
||||
TableModel model = gen.initNormalTable(corePath, false, true, ed.getId(), false);
|
||||
TableModel model = gen.initNormalTable(corePath, false, true, ed.getId(), false, TableGenerationMode.XML);
|
||||
|
||||
boolean deep = false;
|
||||
boolean vdeep = false;
|
||||
|
@ -1446,7 +1447,7 @@ public class ProfileUtilities {
|
|||
public XhtmlNode generateTable(String defFile, StructureDefinition profile, boolean diff, String imageFolder, boolean inlineGraphics, String profileBaseFileName, boolean snapshot, String corePath, boolean logicalModel, Set<String> outputTracker) throws IOException, FHIRException {
|
||||
assert(diff != snapshot);// check it's ok to get rid of one of these
|
||||
HierarchicalTableGenerator gen = new HierarchicalTableGenerator(imageFolder, inlineGraphics);
|
||||
TableModel model = gen.initNormalTable(corePath, false, true, profile.getId()+(diff ? "d" : "s"), false);
|
||||
TableModel model = gen.initNormalTable(corePath, false, true, profile.getId()+(diff ? "d" : "s"), false, TableGenerationMode.XML);
|
||||
List<ElementDefinition> list = diff ? profile.getDifferential().getElement() : profile.getSnapshot().getElement();
|
||||
List<StructureDefinition> profiles = new ArrayList<StructureDefinition>();
|
||||
profiles.add(profile);
|
||||
|
|
|
@ -102,6 +102,7 @@ import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator;
|
|||
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell;
|
||||
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Piece;
|
||||
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row;
|
||||
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableGenerationMode;
|
||||
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableModel;
|
||||
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
|
||||
import org.hl7.fhir.utilities.xml.SchematronWriter;
|
||||
|
@ -1621,7 +1622,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
public XhtmlNode generateExtensionTable(String defFile, StructureDefinition ed, String imageFolder, boolean inlineGraphics, boolean full, String corePath, String imagePath, Set<String> outputTracker) throws IOException, FHIRException {
|
||||
HierarchicalTableGenerator gen = new HierarchicalTableGenerator(imageFolder, inlineGraphics);
|
||||
gen.setTranslator(getTranslator());
|
||||
TableModel model = gen.initNormalTable(corePath, false, true, ed.getId(), false);
|
||||
TableModel model = gen.initNormalTable(corePath, false, true, ed.getId(), false, TableGenerationMode.XML);
|
||||
|
||||
boolean deep = false;
|
||||
String m = "";
|
||||
|
@ -1990,7 +1991,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
assert(diff != snapshot);// check it's ok to get rid of one of these
|
||||
HierarchicalTableGenerator gen = new HierarchicalTableGenerator(imageFolder, inlineGraphics);
|
||||
gen.setTranslator(getTranslator());
|
||||
TableModel model = gen.initNormalTable(corePath, false, true, profile.getId()+(diff ? "d" : "s"), false);
|
||||
TableModel model = gen.initNormalTable(corePath, false, true, profile.getId()+(diff ? "d" : "s"), false, TableGenerationMode.XML);
|
||||
List<ElementDefinition> list = diff ? profile.getDifferential().getElement() : profile.getSnapshot().getElement();
|
||||
List<StructureDefinition> profiles = new ArrayList<StructureDefinition>();
|
||||
profiles.add(profile);
|
||||
|
|
|
@ -110,6 +110,7 @@ import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator;
|
|||
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell;
|
||||
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Piece;
|
||||
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row;
|
||||
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableGenerationMode;
|
||||
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableModel;
|
||||
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
|
||||
import org.hl7.fhir.utilities.xml.SchematronWriter;
|
||||
|
@ -2149,7 +2150,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
public XhtmlNode generateExtensionTable(String defFile, StructureDefinition ed, String imageFolder, boolean inlineGraphics, boolean full, String corePath, String imagePath, Set<String> outputTracker) throws IOException, FHIRException {
|
||||
HierarchicalTableGenerator gen = new HierarchicalTableGenerator(imageFolder, inlineGraphics, true);
|
||||
gen.setTranslator(getTranslator());
|
||||
TableModel model = gen.initNormalTable(corePath, false, true, ed.getId(), false);
|
||||
TableModel model = gen.initNormalTable(corePath, false, true, ed.getId(), false, TableGenerationMode.XML);
|
||||
|
||||
boolean deep = false;
|
||||
String m = "";
|
||||
|
@ -2519,7 +2520,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
assert(diff != snapshot);// check it's ok to get rid of one of these
|
||||
HierarchicalTableGenerator gen = new HierarchicalTableGenerator(imageFolder, inlineGraphics, true);
|
||||
gen.setTranslator(getTranslator());
|
||||
TableModel model = gen.initNormalTable(corePath, false, true, profile.getId()+(diff ? "d" : "s"), false);
|
||||
TableModel model = gen.initNormalTable(corePath, false, true, profile.getId()+(diff ? "d" : "s"), false, TableGenerationMode.XML);
|
||||
List<ElementDefinition> list = diff ? profile.getDifferential().getElement() : profile.getSnapshot().getElement();
|
||||
List<StructureDefinition> profiles = new ArrayList<StructureDefinition>();
|
||||
profiles.add(profile);
|
||||
|
|
|
@ -130,6 +130,7 @@ import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator;
|
|||
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell;
|
||||
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Piece;
|
||||
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row;
|
||||
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableGenerationMode;
|
||||
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableModel;
|
||||
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
|
||||
import org.hl7.fhir.utilities.xml.SchematronWriter;
|
||||
|
@ -3471,7 +3472,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
public XhtmlNode generateExtensionTable(String defFile, StructureDefinition ed, String imageFolder, boolean inlineGraphics, boolean full, String corePath, String imagePath, Set<String> outputTracker, RenderingContext rc) throws IOException, FHIRException {
|
||||
HierarchicalTableGenerator gen = new HierarchicalTableGenerator(imageFolder, inlineGraphics, true);
|
||||
gen.setTranslator(getTranslator());
|
||||
TableModel model = gen.initNormalTable(corePath, false, true, ed.getId()+(full ? "f" : "n"), true);
|
||||
TableModel model = gen.initNormalTable(corePath, false, true, ed.getId()+(full ? "f" : "n"), true, TableGenerationMode.XHTML);
|
||||
|
||||
boolean deep = false;
|
||||
String m = "";
|
||||
|
@ -3988,7 +3989,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
assert(diff != snapshot);// check it's ok to get rid of one of these
|
||||
HierarchicalTableGenerator gen = new HierarchicalTableGenerator(imageFolder, inlineGraphics, true);
|
||||
gen.setTranslator(getTranslator());
|
||||
TableModel model = gen.initNormalTable(corePath, false, true, profile.getId()+(diff ? "d" : "s"), active);
|
||||
TableModel model = gen.initNormalTable(corePath, false, true, profile.getId()+(diff ? "d" : "s"), active, active ? TableGenerationMode.XHTML : TableGenerationMode.XML);
|
||||
List<ElementDefinition> list = new ArrayList<>();
|
||||
if (diff)
|
||||
list.addAll(profile.getDifferential().getElement());
|
||||
|
|
|
@ -42,6 +42,7 @@ public class ContextUtilities implements ProfileKnowledgeProvider {
|
|||
private boolean ignoreProfileErrors;
|
||||
private XVerExtensionManager xverManager;
|
||||
private Map<String, String> oidCache = new HashMap<>();
|
||||
private List<StructureDefinition> allStructuresList = new ArrayList<StructureDefinition>();
|
||||
|
||||
public ContextUtilities(IWorkerContext context) {
|
||||
super();
|
||||
|
@ -209,28 +210,29 @@ public class ContextUtilities implements ProfileKnowledgeProvider {
|
|||
* @return a list of all structure definitions, with snapshots generated (if possible)
|
||||
*/
|
||||
public List<StructureDefinition> allStructures(){
|
||||
List<StructureDefinition> result = new ArrayList<StructureDefinition>();
|
||||
Set<StructureDefinition> set = new HashSet<StructureDefinition>();
|
||||
for (StructureDefinition sd : getStructures()) {
|
||||
if (!set.contains(sd)) {
|
||||
try {
|
||||
generateSnapshot(sd);
|
||||
// new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path("[tmp]", "snapshot", tail(sd.getUrl())+".xml")), sd);
|
||||
} catch (Exception e) {
|
||||
if (!isSuppressDebugMessages()) {
|
||||
System.out.println("Unable to generate snapshot for "+tail(sd.getUrl()) +" from "+tail(sd.getBaseDefinition())+" because "+e.getMessage());
|
||||
if (context.getLogger().isDebugLogging()) {
|
||||
e.printStackTrace();
|
||||
if (allStructuresList.isEmpty()) {
|
||||
Set<StructureDefinition> set = new HashSet<StructureDefinition>();
|
||||
for (StructureDefinition sd : getStructures()) {
|
||||
if (!set.contains(sd)) {
|
||||
try {
|
||||
generateSnapshot(sd);
|
||||
// new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path("[tmp]", "snapshot", tail(sd.getUrl())+".xml")), sd);
|
||||
} catch (Exception e) {
|
||||
if (!isSuppressDebugMessages()) {
|
||||
System.out.println("Unable to generate snapshot for "+tail(sd.getUrl()) +" from "+tail(sd.getBaseDefinition())+" because "+e.getMessage());
|
||||
if (context.getLogger().isDebugLogging()) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
allStructuresList.add(sd);
|
||||
set.add(sd);
|
||||
}
|
||||
result.add(sd);
|
||||
set.add(sd);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return allStructuresList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return a list of all structure definitions, without trying to generate snapshots
|
||||
*/
|
||||
|
|
|
@ -151,6 +151,7 @@ public class TypeDetails {
|
|||
addType(pt);
|
||||
return res;
|
||||
}
|
||||
|
||||
public void addType(ProfiledType pt) {
|
||||
for (ProfiledType et : types) {
|
||||
if (et.uri.equals(pt.uri)) {
|
||||
|
@ -175,7 +176,29 @@ public class TypeDetails {
|
|||
}
|
||||
types.add(pt);
|
||||
}
|
||||
|
||||
|
||||
public void addType(CollectionStatus status, ProfiledType pt) {
|
||||
addType(pt);
|
||||
if (collectionStatus == null) {
|
||||
collectionStatus = status;
|
||||
} else {
|
||||
switch (status) {
|
||||
case ORDERED:
|
||||
if (collectionStatus == CollectionStatus.SINGLETON) {
|
||||
collectionStatus = status;
|
||||
}
|
||||
break;
|
||||
case SINGLETON:
|
||||
break;
|
||||
case UNORDERED:
|
||||
collectionStatus = status;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addTypes(Collection<String> names) {
|
||||
for (String n : names)
|
||||
addType(new ProfiledType(n));
|
||||
|
|
|
@ -125,7 +125,11 @@ public class DiagnosticReportRenderer extends ResourceRenderer {
|
|||
|
||||
pw = getProperty(dr, "conclusion");
|
||||
if (valued(pw)) {
|
||||
render(x.para(), pw.value());
|
||||
if (pw.fhirType().equals("markdown")) {
|
||||
render(x, pw.value());
|
||||
} else {
|
||||
render(x.para(), pw.value());
|
||||
}
|
||||
}
|
||||
|
||||
pw = getProperty(dr, "conclusionCode");
|
||||
|
|
|
@ -77,6 +77,7 @@ import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator;
|
|||
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell;
|
||||
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Piece;
|
||||
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Row;
|
||||
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableGenerationMode;
|
||||
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableModel;
|
||||
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Title;
|
||||
import org.hl7.fhir.utilities.xhtml.NodeType;
|
||||
|
@ -324,7 +325,7 @@ public class StructureDefinitionRenderer extends ResourceRenderer {
|
|||
model = initCustomTable(gen, corePath, false, true, profile.getId()+(diff ? "d" : "s"), rc.getRules() == GenerationRules.IG_PUBLISHER, columns);
|
||||
break;
|
||||
case SUMMARY:
|
||||
model = gen.initNormalTable(corePath, false, true, profile.getId()+(diff ? "d" : "s"), rc.getRules() == GenerationRules.IG_PUBLISHER);
|
||||
model = gen.initNormalTable(corePath, false, true, profile.getId()+(diff ? "d" : "s"), rc.getRules() == GenerationRules.IG_PUBLISHER, rc.getRules() == GenerationRules.IG_PUBLISHER ? TableGenerationMode.XHTML : TableGenerationMode.XML);
|
||||
break;
|
||||
default:
|
||||
throw new Error("Unknown structure mode");
|
||||
|
@ -2667,7 +2668,7 @@ public class StructureDefinitionRenderer extends ResourceRenderer {
|
|||
public XhtmlNode generateExtensionTable(String defFile, StructureDefinition ed, String imageFolder, boolean inlineGraphics, boolean full, String corePath, String imagePath, Set<String> outputTracker, RenderingContext rc) throws IOException, FHIRException {
|
||||
HierarchicalTableGenerator gen = new HierarchicalTableGenerator(imageFolder, inlineGraphics, true);
|
||||
gen.setTranslator(getTranslator());
|
||||
TableModel model = gen.initNormalTable(corePath, false, true, ed.getId()+(full ? "f" : "n"), true);
|
||||
TableModel model = gen.initNormalTable(corePath, false, true, ed.getId()+(full ? "f" : "n"), true, TableGenerationMode.XHTML);
|
||||
|
||||
boolean deep = false;
|
||||
String m = "";
|
||||
|
|
|
@ -386,6 +386,7 @@ public class FHIRPathEngine {
|
|||
}
|
||||
}
|
||||
initFlags();
|
||||
cu = new ContextUtilities(worker);
|
||||
}
|
||||
|
||||
private void initFlags() {
|
||||
|
@ -578,6 +579,22 @@ public class FHIRPathEngine {
|
|||
* @if the path is not valid
|
||||
*/
|
||||
public TypeDetails check(Object appContext, String resourceType, String context, ExpressionNode expr) throws FHIRLexerException, PathEngineException, DefinitionException {
|
||||
return check(appContext, resourceType, context, expr, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* check that paths referred to in the ExpressionNode are valid
|
||||
*
|
||||
* xPathStartsWithValueRef is a hack work around for the fact that FHIR Path sometimes needs a different starting point than the xpath
|
||||
*
|
||||
* returns a list of the possible types that might be returned by executing the ExpressionNode against a particular context
|
||||
*
|
||||
* @param context - the logical type against which this path is applied
|
||||
* @throws DefinitionException
|
||||
* @throws PathEngineException
|
||||
* @if the path is not valid
|
||||
*/
|
||||
public TypeDetails check(Object appContext, String resourceType, String context, ExpressionNode expr, Set<ElementDefinition> elementDependencies) throws FHIRLexerException, PathEngineException, DefinitionException {
|
||||
// if context is a path that refers to a type, do that conversion now
|
||||
TypeDetails types;
|
||||
if (context == null) {
|
||||
|
@ -610,7 +627,7 @@ public class FHIRPathEngine {
|
|||
}
|
||||
}
|
||||
|
||||
return executeType(new ExecutionTypeContext(appContext, resourceType, types, types), types, expr, true);
|
||||
return executeType(new ExecutionTypeContext(appContext, resourceType, types, types), types, expr, elementDependencies, true);
|
||||
}
|
||||
|
||||
private FHIRException makeExceptionPlural(Integer num, ExpressionNode holder, String constName, Object... args) {
|
||||
|
@ -659,13 +676,13 @@ public class FHIRPathEngine {
|
|||
}
|
||||
}
|
||||
|
||||
return executeType(new ExecutionTypeContext(appContext, sd.getUrl(), types, types), types, expr, true);
|
||||
return executeType(new ExecutionTypeContext(appContext, sd.getUrl(), types, types), types, expr, null, true);
|
||||
}
|
||||
|
||||
public TypeDetails check(Object appContext, StructureDefinition sd, ExpressionNode expr) throws FHIRLexerException, PathEngineException, DefinitionException {
|
||||
// if context is a path that refers to a type, do that conversion now
|
||||
TypeDetails types = null; // this is a special case; the first path reference will have to resolve to something in the context
|
||||
return executeType(new ExecutionTypeContext(appContext, sd == null ? null : sd.getUrl(), null, types), types, expr, true);
|
||||
return executeType(new ExecutionTypeContext(appContext, sd == null ? null : sd.getUrl(), null, types), types, expr, null, true);
|
||||
}
|
||||
|
||||
public TypeDetails check(Object appContext, String resourceType, String context, String expr) throws FHIRLexerException, PathEngineException, DefinitionException {
|
||||
|
@ -1557,7 +1574,7 @@ public class FHIRPathEngine {
|
|||
return new TypeDetails(CollectionStatus.SINGLETON, exp.getName());
|
||||
}
|
||||
|
||||
private TypeDetails executeType(ExecutionTypeContext context, TypeDetails focus, ExpressionNode exp, boolean atEntry) throws PathEngineException, DefinitionException {
|
||||
private TypeDetails executeType(ExecutionTypeContext context, TypeDetails focus, ExpressionNode exp, Set<ElementDefinition> elementDependencies, boolean atEntry) throws PathEngineException, DefinitionException {
|
||||
TypeDetails result = new TypeDetails(null);
|
||||
switch (exp.getKind()) {
|
||||
case Name:
|
||||
|
@ -1571,7 +1588,7 @@ public class FHIRPathEngine {
|
|||
result.update(executeContextType(context, exp.getName(), exp));
|
||||
} else {
|
||||
for (String s : focus.getTypes()) {
|
||||
result.update(executeType(s, exp, atEntry));
|
||||
result.update(executeType(s, exp, atEntry, elementDependencies));
|
||||
}
|
||||
if (result.hasNoTypes()) {
|
||||
throw makeException(exp, I18nConstants.FHIRPATH_UNKNOWN_NAME, exp.getName(), focus.describe());
|
||||
|
@ -1579,7 +1596,7 @@ public class FHIRPathEngine {
|
|||
}
|
||||
break;
|
||||
case Function:
|
||||
result.update(evaluateFunctionType(context, focus, exp));
|
||||
result.update(evaluateFunctionType(context, focus, exp, elementDependencies));
|
||||
break;
|
||||
case Unary:
|
||||
result.addType(TypeDetails.FP_Integer);
|
||||
|
@ -1590,12 +1607,12 @@ public class FHIRPathEngine {
|
|||
result.update(resolveConstantType(context, exp.getConstant(), exp));
|
||||
break;
|
||||
case Group:
|
||||
result.update(executeType(context, focus, exp.getGroup(), atEntry));
|
||||
result.update(executeType(context, focus, exp.getGroup(), elementDependencies, atEntry));
|
||||
}
|
||||
exp.setTypes(result);
|
||||
|
||||
if (exp.getInner() != null) {
|
||||
result = executeType(context, result, exp.getInner(), false);
|
||||
result = executeType(context, result, exp.getInner(), elementDependencies, false);
|
||||
}
|
||||
|
||||
if (exp.isProximal() && exp.getOperation() != null) {
|
||||
|
@ -1606,7 +1623,7 @@ public class FHIRPathEngine {
|
|||
if (last.getOperation() == Operation.Is || last.getOperation() == Operation.As) {
|
||||
work = executeTypeName(context, focus, next, atEntry);
|
||||
} else {
|
||||
work = executeType(context, focus, next, atEntry);
|
||||
work = executeType(context, focus, next, elementDependencies, atEntry);
|
||||
}
|
||||
result = operateTypes(result, last.getOperation(), work, last);
|
||||
last = next;
|
||||
|
@ -3102,12 +3119,12 @@ public class FHIRPathEngine {
|
|||
return hostServices.resolveConstantType(context.appInfo, name);
|
||||
}
|
||||
|
||||
private TypeDetails executeType(String type, ExpressionNode exp, boolean atEntry) throws PathEngineException, DefinitionException {
|
||||
private TypeDetails executeType(String type, ExpressionNode exp, boolean atEntry, Set<ElementDefinition> elementDependencies) throws PathEngineException, DefinitionException {
|
||||
if (atEntry && Character.isUpperCase(exp.getName().charAt(0)) && hashTail(type).equals(exp.getName())) { // special case for start up
|
||||
return new TypeDetails(CollectionStatus.SINGLETON, type);
|
||||
}
|
||||
TypeDetails result = new TypeDetails(null);
|
||||
getChildTypesByName(type, exp.getName(), result, exp);
|
||||
getChildTypesByName(type, exp.getName(), result, exp, elementDependencies);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -3118,7 +3135,7 @@ public class FHIRPathEngine {
|
|||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private TypeDetails evaluateFunctionType(ExecutionTypeContext context, TypeDetails focus, ExpressionNode exp) throws PathEngineException, DefinitionException {
|
||||
private TypeDetails evaluateFunctionType(ExecutionTypeContext context, TypeDetails focus, ExpressionNode exp, Set<ElementDefinition> elementDependencies) throws PathEngineException, DefinitionException {
|
||||
List<TypeDetails> paramTypes = new ArrayList<TypeDetails>();
|
||||
if (exp.getFunction() == Function.Is || exp.getFunction() == Function.As || exp.getFunction() == Function.OfType) {
|
||||
paramTypes.add(new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_String));
|
||||
|
@ -3126,9 +3143,9 @@ public class FHIRPathEngine {
|
|||
int i = 0;
|
||||
for (ExpressionNode expr : exp.getParameters()) {
|
||||
if (isExpressionParameter(exp, i)) {
|
||||
paramTypes.add(executeType(changeThis(context, focus), focus, expr, true));
|
||||
paramTypes.add(executeType(changeThis(context, focus), focus, expr, elementDependencies, true));
|
||||
} else {
|
||||
paramTypes.add(executeType(context, context.thisItem, expr, true));
|
||||
paramTypes.add(executeType(context, context.thisItem, expr, elementDependencies, true));
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
@ -3159,11 +3176,11 @@ public class FHIRPathEngine {
|
|||
case Where :
|
||||
return focus;
|
||||
case Select :
|
||||
return anything(focus.getCollectionStatus());
|
||||
return paramTypes.get(0);
|
||||
case All :
|
||||
return new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_Boolean);
|
||||
case Repeat :
|
||||
return anything(focus.getCollectionStatus());
|
||||
return paramTypes.get(0); // this might be a little more complicated...
|
||||
case Aggregate :
|
||||
return anything(focus.getCollectionStatus());
|
||||
case Item : {
|
||||
|
@ -3572,7 +3589,7 @@ public class FHIRPathEngine {
|
|||
private TypeDetails childTypes(TypeDetails focus, String mask, ExpressionNode expr) throws PathEngineException, DefinitionException {
|
||||
TypeDetails result = new TypeDetails(CollectionStatus.UNORDERED);
|
||||
for (String f : focus.getTypes()) {
|
||||
getChildTypesByName(f, mask, result, expr);
|
||||
getChildTypesByName(f, mask, result, expr, null);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -4011,6 +4028,7 @@ public class FHIRPathEngine {
|
|||
}
|
||||
|
||||
private static final char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray();
|
||||
private ContextUtilities cu;
|
||||
public static String bytesToHex(byte[] bytes) {
|
||||
char[] hexChars = new char[bytes.length * 2];
|
||||
for (int j = 0; j < bytes.length; j++) {
|
||||
|
@ -5693,7 +5711,7 @@ public class FHIRPathEngine {
|
|||
|
||||
}
|
||||
|
||||
private void getChildTypesByName(String type, String name, TypeDetails result, ExpressionNode expr) throws PathEngineException, DefinitionException {
|
||||
private void getChildTypesByName(String type, String name, TypeDetails result, ExpressionNode expr, Set<ElementDefinition> elementDependencies) throws PathEngineException, DefinitionException {
|
||||
if (Utilities.noString(type)) {
|
||||
throw makeException(expr, I18nConstants.FHIRPATH_NO_TYPE, "", "getChildTypesByName");
|
||||
}
|
||||
|
@ -5704,6 +5722,8 @@ public class FHIRPathEngine {
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (type.equals(TypeDetails.FP_SimpleTypeInfo)) {
|
||||
getSimpleTypeChildTypesByName(name, result);
|
||||
} else if (type.equals(TypeDetails.FP_ClassInfo)) {
|
||||
|
@ -5737,11 +5757,11 @@ public class FHIRPathEngine {
|
|||
if (dt == null) {
|
||||
throw makeException(expr, I18nConstants.FHIRPATH_NO_TYPE, ProfileUtilities.sdNs(t.getCode(), null), "getChildTypesByName");
|
||||
}
|
||||
addTypeAndDescendents(sdl, dt, new ContextUtilities(worker).allStructures());
|
||||
addTypeAndDescendents(sdl, dt, cu.allStructures());
|
||||
// also add any descendant types
|
||||
}
|
||||
} else {
|
||||
addTypeAndDescendents(sdl, sd, new ContextUtilities(worker).allStructures());
|
||||
addTypeAndDescendents(sdl, sd, cu.allStructures());
|
||||
if (type.contains("#")) {
|
||||
tail = type.substring(type.indexOf("#")+1);
|
||||
tail = tail.substring(tail.indexOf("."));
|
||||
|
@ -5753,26 +5773,44 @@ public class FHIRPathEngine {
|
|||
if (name.equals("**")) {
|
||||
assert(result.getCollectionStatus() == CollectionStatus.UNORDERED);
|
||||
for (ElementDefinition ed : sdi.getSnapshot().getElement()) {
|
||||
if (ed.getPath().startsWith(path))
|
||||
for (TypeRefComponent t : ed.getType()) {
|
||||
if (t.hasCode() && t.getCodeElement().hasValue()) {
|
||||
String tn = null;
|
||||
if (t.getCode().equals("Element") || t.getCode().equals("BackboneElement")) {
|
||||
tn = sdi.getType()+"#"+ed.getPath();
|
||||
} else {
|
||||
tn = t.getCode();
|
||||
if (ed.getPath().startsWith(path)) {
|
||||
if (ed.hasContentReference()) {
|
||||
String cpath = ed.getContentReference();
|
||||
String tn = sdi.getType()+cpath;
|
||||
if (!result.hasType(worker, tn)) {
|
||||
if (elementDependencies != null) {
|
||||
elementDependencies.add(ed);
|
||||
}
|
||||
if (t.getCode().equals("Resource")) {
|
||||
for (String rn : worker.getResourceNames()) {
|
||||
if (!result.hasType(worker, rn)) {
|
||||
getChildTypesByName(result.addType(rn), "**", result, expr);
|
||||
}
|
||||
getChildTypesByName(result.addType(tn), "**", result, expr, elementDependencies);
|
||||
}
|
||||
} else {
|
||||
for (TypeRefComponent t : ed.getType()) {
|
||||
if (t.hasCode() && t.getCodeElement().hasValue()) {
|
||||
String tn = null;
|
||||
if (t.getCode().equals("Element") || t.getCode().equals("BackboneElement")) {
|
||||
tn = sdi.getType()+"#"+ed.getPath();
|
||||
} else {
|
||||
tn = t.getCode();
|
||||
}
|
||||
if (t.getCode().equals("Resource")) {
|
||||
for (String rn : worker.getResourceNames()) {
|
||||
if (!result.hasType(worker, rn)) {
|
||||
if (elementDependencies != null) {
|
||||
elementDependencies.add(ed);
|
||||
}
|
||||
getChildTypesByName(result.addType(rn), "**", result, expr, elementDependencies);
|
||||
}
|
||||
}
|
||||
} else if (!result.hasType(worker, tn)) {
|
||||
if (elementDependencies != null) {
|
||||
elementDependencies.add(ed);
|
||||
}
|
||||
getChildTypesByName(result.addType(tn), "**", result, expr, elementDependencies);
|
||||
}
|
||||
} else if (!result.hasType(worker, tn)) {
|
||||
getChildTypesByName(result.addType(tn), "**", result, expr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (name.equals("*")) {
|
||||
assert(result.getCollectionStatus() == CollectionStatus.UNORDERED);
|
||||
|
@ -5780,12 +5818,24 @@ public class FHIRPathEngine {
|
|||
if (ed.getPath().startsWith(path) && !ed.getPath().substring(path.length()).contains("."))
|
||||
for (TypeRefComponent t : ed.getType()) {
|
||||
if (Utilities.noString(t.getCode())) { // Element.id or Extension.url
|
||||
if (elementDependencies != null) {
|
||||
elementDependencies.add(ed);
|
||||
}
|
||||
result.addType("System.string");
|
||||
} else if (t.getCode().equals("Element") || t.getCode().equals("BackboneElement")) {
|
||||
if (elementDependencies != null) {
|
||||
elementDependencies.add(ed);
|
||||
}
|
||||
result.addType(sdi.getType()+"#"+ed.getPath());
|
||||
} else if (t.getCode().equals("Resource")) {
|
||||
if (elementDependencies != null) {
|
||||
elementDependencies.add(ed);
|
||||
}
|
||||
result.addTypes(worker.getResourceNames());
|
||||
} else {
|
||||
if (elementDependencies != null) {
|
||||
elementDependencies.add(ed);
|
||||
}
|
||||
result.addType(t.getCode());
|
||||
}
|
||||
}
|
||||
|
@ -5795,12 +5845,18 @@ public class FHIRPathEngine {
|
|||
|
||||
ElementDefinitionMatch ed = getElementDefinition(sdi, path, isAllowPolymorphicNames(), expr);
|
||||
if (ed != null) {
|
||||
if (!Utilities.noString(ed.getFixedType()))
|
||||
if (!Utilities.noString(ed.getFixedType())) {
|
||||
if (elementDependencies != null) {
|
||||
elementDependencies.add(ed.definition);
|
||||
}
|
||||
result.addType(ed.getFixedType());
|
||||
else {
|
||||
} else {
|
||||
for (TypeRefComponent t : ed.getDefinition().getType()) {
|
||||
if (Utilities.noString(t.getCode())) {
|
||||
if (Utilities.existsInList(ed.getDefinition().getId(), "Element.id", "Extension.url") || Utilities.existsInList(ed.getDefinition().getBase().getPath(), "Resource.id", "Element.id", "Extension.url")) {
|
||||
if (elementDependencies != null) {
|
||||
elementDependencies.add(ed.definition);
|
||||
}
|
||||
result.addType(TypeDetails.FP_NS, "string");
|
||||
}
|
||||
break; // throw new PathEngineException("Illegal reference to primitive value attribute @ "+path);
|
||||
|
@ -5810,6 +5866,9 @@ public class FHIRPathEngine {
|
|||
if (t.getCode().equals("Element") || t.getCode().equals("BackboneElement")) {
|
||||
pt = new ProfiledType(sdi.getUrl()+"#"+path);
|
||||
} else if (t.getCode().equals("Resource")) {
|
||||
if (elementDependencies != null) {
|
||||
elementDependencies.add(ed.definition);
|
||||
}
|
||||
result.addTypes(worker.getResourceNames());
|
||||
} else {
|
||||
pt = new ProfiledType(t.getCode());
|
||||
|
@ -5821,7 +5880,10 @@ public class FHIRPathEngine {
|
|||
if (ed.getDefinition().hasBinding()) {
|
||||
pt.addBinding(ed.getDefinition().getBinding());
|
||||
}
|
||||
result.addType(pt);
|
||||
if (elementDependencies != null) {
|
||||
elementDependencies.add(ed.definition);
|
||||
}
|
||||
result.addType(ed.definition.unbounded() ? CollectionStatus.ORDERED : CollectionStatus.SINGLETON, pt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,9 +83,14 @@ import org.commonmark.renderer.html.HtmlRenderer;
|
|||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.utilities.TranslatingUtilities;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.TableGenerationMode;
|
||||
|
||||
|
||||
public class HierarchicalTableGenerator extends TranslatingUtilities {
|
||||
public enum TableGenerationMode {
|
||||
XML, XHTML
|
||||
}
|
||||
|
||||
public static final String TEXT_ICON_REFERENCE = "Reference to another Resource";
|
||||
public static final String TEXT_ICON_PRIMITIVE = "Primitive Data Type";
|
||||
public static final String TEXT_ICON_KEY = "JSON Key Value";
|
||||
|
@ -599,6 +604,8 @@ public class HierarchicalTableGenerator extends TranslatingUtilities {
|
|||
*/
|
||||
private boolean inLineGraphics;
|
||||
|
||||
private TableGenerationMode mode;
|
||||
|
||||
public HierarchicalTableGenerator() {
|
||||
super();
|
||||
}
|
||||
|
@ -626,7 +633,9 @@ public class HierarchicalTableGenerator extends TranslatingUtilities {
|
|||
checkSetup();
|
||||
}
|
||||
|
||||
public TableModel initNormalTable(String prefix, boolean isLogical, boolean alternating, String id, boolean isActive) {
|
||||
public TableModel initNormalTable(String prefix, boolean isLogical, boolean alternating, String id, boolean isActive, TableGenerationMode mode) {
|
||||
this.mode = mode;
|
||||
|
||||
TableModel model = new TableModel(id, isActive);
|
||||
|
||||
model.setAlternating(alternating);
|
||||
|
@ -686,12 +695,16 @@ public class HierarchicalTableGenerator extends TranslatingUtilities {
|
|||
tr.setAttribute("style", "border: " + Integer.toString(1 + border) + "px #F0F0F0 solid; font-size: 11px; font-family: verdana; vertical-align: top");
|
||||
XhtmlNode tc = null;
|
||||
for (Title t : model.getTitles()) {
|
||||
tc = renderCell(tr, t, "th", null, null, null, false, null, "white", 0, imagePath, border, outputTracker, model, null);
|
||||
tc = renderCell(tr, t, "th", null, null, null, false, null, "white", 0, imagePath, border, outputTracker, model, null, true);
|
||||
if (t.width != 0)
|
||||
tc.setAttribute("style", "width: "+Integer.toString(t.width)+"px");
|
||||
}
|
||||
if (tc != null && model.getDocoRef() != null) {
|
||||
XhtmlNode img = tc.addTag("span").setAttribute("style", "float: right").addTag("a").setAttribute("title", "Legend for this format").setAttribute("href", model.getDocoRef()).addTag("img");
|
||||
XhtmlNode a = tc.addTag("span").setAttribute("style", "float: right").addTag("a").setAttribute("title", "Legend for this format").setAttribute("href", model.getDocoRef());
|
||||
if (mode == TableGenerationMode.XHTML) {
|
||||
a.setAttribute("no-external", "true");
|
||||
}
|
||||
XhtmlNode img = a.addTag("img");
|
||||
img.setAttribute("alt", "doco").setAttribute("style", "background-color: inherit").setAttribute("src", model.getDocoImg());
|
||||
if (model.isActive()) {
|
||||
img.setAttribute("onLoad", "fhirTableInit(this)");
|
||||
|
@ -732,7 +745,7 @@ public class HierarchicalTableGenerator extends TranslatingUtilities {
|
|||
}
|
||||
boolean first = true;
|
||||
for (Cell t : r.getCells()) {
|
||||
renderCell(tr, t, "td", first ? r.getIcon() : null, first ? r.getHint() : null, first ? indents : null, !r.getSubRows().isEmpty(), first ? r.getAnchor() : null, color, r.getLineColor(), imagePath, border, outputTracker, model, r);
|
||||
renderCell(tr, t, "td", first ? r.getIcon() : null, first ? r.getHint() : null, first ? indents : null, !r.getSubRows().isEmpty(), first ? r.getAnchor() : null, color, r.getLineColor(), imagePath, border, outputTracker, model, r, first);
|
||||
first = false;
|
||||
}
|
||||
table.addText("\r\n");
|
||||
|
@ -751,7 +764,7 @@ public class HierarchicalTableGenerator extends TranslatingUtilities {
|
|||
}
|
||||
|
||||
|
||||
private XhtmlNode renderCell(XhtmlNode tr, Cell c, String name, String icon, String hint, List<Integer> indents, boolean hasChildren, String anchor, String color, int lineColor, String imagePath, int border, Set<String> outputTracker, TableModel table, Row row) throws IOException {
|
||||
private XhtmlNode renderCell(XhtmlNode tr, Cell c, String name, String icon, String hint, List<Integer> indents, boolean hasChildren, String anchor, String color, int lineColor, String imagePath, int border, Set<String> outputTracker, TableModel table, Row row, boolean suppressExternals) throws IOException {
|
||||
XhtmlNode tc = tr.addTag(name);
|
||||
tc.setAttribute("class", "hierarchy");
|
||||
if (c.span > 1) {
|
||||
|
@ -837,6 +850,9 @@ public class HierarchicalTableGenerator extends TranslatingUtilities {
|
|||
} else if (!Utilities.noString(p.getReference())) {
|
||||
XhtmlNode a = addStyle(tc.addTag("a"), p);
|
||||
a.setAttribute("href", p.getReference());
|
||||
if (mode == TableGenerationMode.XHTML && suppressExternals) {
|
||||
a.setAttribute("no-external", "true");
|
||||
}
|
||||
if (!Utilities.noString(p.getHint()))
|
||||
a.setAttribute("title", p.getHint());
|
||||
if (p.getText() != null) {
|
||||
|
|
Loading…
Reference in New Issue