make ProfileUtilities methods not static
This commit is contained in:
parent
f1d81dde81
commit
09e3816d37
|
@ -315,7 +315,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static List<ElementDefinition> getChildMap(StructureDefinition profile, ElementDefinition element) throws DefinitionException {
|
public List<ElementDefinition> getChildMap(StructureDefinition profile, ElementDefinition element) throws DefinitionException {
|
||||||
if (element.getContentReference()!=null) {
|
if (element.getContentReference()!=null) {
|
||||||
for (ElementDefinition e : profile.getSnapshot().getElement()) {
|
for (ElementDefinition e : profile.getSnapshot().getElement()) {
|
||||||
if (element.getContentReference().equals("#"+e.getId()))
|
if (element.getContentReference().equals("#"+e.getId()))
|
||||||
|
@ -341,7 +341,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static List<ElementDefinition> getSliceList(StructureDefinition profile, ElementDefinition element) throws DefinitionException {
|
public List<ElementDefinition> getSliceList(StructureDefinition profile, ElementDefinition element) throws DefinitionException {
|
||||||
if (!element.hasSlicing())
|
if (!element.hasSlicing())
|
||||||
throw new Error("getSliceList should only be called when the element has slicing");
|
throw new Error("getSliceList should only be called when the element has slicing");
|
||||||
|
|
||||||
|
@ -368,11 +368,11 @@ public class ProfileUtilities extends TranslatingUtilities {
|
||||||
* @param path The path of the element within the structure to get the children for
|
* @param path The path of the element within the structure to get the children for
|
||||||
* @return A List containing the element children (all of them are Elements)
|
* @return A List containing the element children (all of them are Elements)
|
||||||
*/
|
*/
|
||||||
public static List<ElementDefinition> getChildList(StructureDefinition profile, String path, String id) {
|
public List<ElementDefinition> getChildList(StructureDefinition profile, String path, String id) {
|
||||||
return getChildList(profile, path, id, false);
|
return getChildList(profile, path, id, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<ElementDefinition> getChildList(StructureDefinition profile, String path, String id, boolean diff) {
|
public List<ElementDefinition> getChildList(StructureDefinition profile, String path, String id, boolean diff) {
|
||||||
List<ElementDefinition> res = new ArrayList<ElementDefinition>();
|
List<ElementDefinition> res = new ArrayList<ElementDefinition>();
|
||||||
|
|
||||||
boolean capturing = id==null;
|
boolean capturing = id==null;
|
||||||
|
@ -415,11 +415,11 @@ public class ProfileUtilities extends TranslatingUtilities {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<ElementDefinition> getChildList(StructureDefinition structure, ElementDefinition element, boolean diff) {
|
public List<ElementDefinition> getChildList(StructureDefinition structure, ElementDefinition element, boolean diff) {
|
||||||
return getChildList(structure, element.getPath(), element.getId(), diff);
|
return getChildList(structure, element.getPath(), element.getId(), diff);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<ElementDefinition> getChildList(StructureDefinition structure, ElementDefinition element) {
|
public List<ElementDefinition> getChildList(StructureDefinition structure, ElementDefinition element) {
|
||||||
return getChildList(structure, element.getPath(), element.getId(), false);
|
return getChildList(structure, element.getPath(), element.getId(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -188,6 +188,7 @@ public class ShExGenerator {
|
||||||
* this makes internal metadata services available to the generator - retrieving structure definitions, and value set expansion etc
|
* this makes internal metadata services available to the generator - retrieving structure definitions, and value set expansion etc
|
||||||
*/
|
*/
|
||||||
private IWorkerContext context;
|
private IWorkerContext context;
|
||||||
|
private ProfileUtilities profileUtilities;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* innerTypes -- inner complex types. Currently flattened in ShEx (doesn't have to be, btw)
|
* innerTypes -- inner complex types. Currently flattened in ShEx (doesn't have to be, btw)
|
||||||
|
@ -208,6 +209,7 @@ public class ShExGenerator {
|
||||||
public ShExGenerator(IWorkerContext context) {
|
public ShExGenerator(IWorkerContext context) {
|
||||||
super();
|
super();
|
||||||
this.context = context;
|
this.context = context;
|
||||||
|
profileUtilities = new ProfileUtilities(context, null, null);
|
||||||
innerTypes = new HashSet<Pair<StructureDefinition, ElementDefinition>>();
|
innerTypes = new HashSet<Pair<StructureDefinition, ElementDefinition>>();
|
||||||
emittedInnerTypes = new HashSet<Pair<StructureDefinition, ElementDefinition>>();
|
emittedInnerTypes = new HashSet<Pair<StructureDefinition, ElementDefinition>>();
|
||||||
datatypes = new HashSet<String>();
|
datatypes = new HashSet<String>();
|
||||||
|
@ -486,7 +488,7 @@ public class ShExGenerator {
|
||||||
element_def.add("id", "fhir:" + (id.charAt(0) == id.toLowerCase().charAt(0)? shortId : id) + " ");
|
element_def.add("id", "fhir:" + (id.charAt(0) == id.toLowerCase().charAt(0)? shortId : id) + " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ElementDefinition> children = ProfileUtilities.getChildList(sd, ed);
|
List<ElementDefinition> children = profileUtilities.getChildList(sd, ed);
|
||||||
if (children.size() > 0) {
|
if (children.size() > 0) {
|
||||||
innerTypes.add(new ImmutablePair<StructureDefinition, ElementDefinition>(sd, ed));
|
innerTypes.add(new ImmutablePair<StructureDefinition, ElementDefinition>(sd, ed));
|
||||||
defn = simpleElement(sd, ed, id);
|
defn = simpleElement(sd, ed, id);
|
||||||
|
@ -571,7 +573,7 @@ public class ShExGenerator {
|
||||||
if(typ.hasProfile()) {
|
if(typ.hasProfile()) {
|
||||||
if(typ.getWorkingCode().equals("Reference"))
|
if(typ.getWorkingCode().equals("Reference"))
|
||||||
return genReference("", typ);
|
return genReference("", typ);
|
||||||
else if(ProfileUtilities.getChildList(sd, ed).size() > 0) {
|
else if(profileUtilities.getChildList(sd, ed).size() > 0) {
|
||||||
// inline anonymous type - give it a name and factor it out
|
// inline anonymous type - give it a name and factor it out
|
||||||
innerTypes.add(new ImmutablePair<StructureDefinition, ElementDefinition>(sd, ed));
|
innerTypes.add(new ImmutablePair<StructureDefinition, ElementDefinition>(sd, ed));
|
||||||
return simpleElement(sd, ed, id);
|
return simpleElement(sd, ed, id);
|
||||||
|
@ -704,7 +706,7 @@ public class ShExGenerator {
|
||||||
element_reference.add("comment", comment == null? " " : "# " + comment);
|
element_reference.add("comment", comment == null? " " : "# " + comment);
|
||||||
|
|
||||||
List<String> elements = new ArrayList<String>();
|
List<String> elements = new ArrayList<String>();
|
||||||
for (ElementDefinition child: ProfileUtilities.getChildList(sd, path, null))
|
for (ElementDefinition child: profileUtilities.getChildList(sd, path, null))
|
||||||
elements.add(genElementDefinition(sd, child));
|
elements.add(genElementDefinition(sd, child));
|
||||||
|
|
||||||
element_reference.add("elements", StringUtils.join(elements, "\n"));
|
element_reference.add("elements", StringUtils.join(elements, "\n"));
|
||||||
|
|
|
@ -107,10 +107,12 @@ public class XmlSchemaGenerator {
|
||||||
private String genDate;
|
private String genDate;
|
||||||
private String license;
|
private String license;
|
||||||
private boolean annotations;
|
private boolean annotations;
|
||||||
|
private ProfileUtilities profileUtilities;
|
||||||
|
|
||||||
public XmlSchemaGenerator(String folder, IWorkerContext context) {
|
public XmlSchemaGenerator(String folder, IWorkerContext context) {
|
||||||
this.folder = folder;
|
this.folder = folder;
|
||||||
this.context = context;
|
this.context = context;
|
||||||
|
this.profileUtilities = new ProfileUtilities(context, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSingle() {
|
public boolean isSingle() {
|
||||||
|
@ -325,12 +327,12 @@ public class XmlSchemaGenerator {
|
||||||
ln(" <xs:sequence>");
|
ln(" <xs:sequence>");
|
||||||
|
|
||||||
// hack....
|
// hack....
|
||||||
for (ElementDefinition edc : ProfileUtilities.getChildList(sd, ed)) {
|
for (ElementDefinition edc : profileUtilities.getChildList(sd, ed)) {
|
||||||
if (!(edc.hasRepresentation(PropertyRepresentation.XMLATTR) || edc.hasRepresentation(PropertyRepresentation.XMLTEXT)) && !inheritedElement(edc))
|
if (!(edc.hasRepresentation(PropertyRepresentation.XMLATTR) || edc.hasRepresentation(PropertyRepresentation.XMLTEXT)) && !inheritedElement(edc))
|
||||||
produceElement(sd, ed, edc, lang);
|
produceElement(sd, ed, edc, lang);
|
||||||
}
|
}
|
||||||
ln(" </xs:sequence>");
|
ln(" </xs:sequence>");
|
||||||
for (ElementDefinition edc : ProfileUtilities.getChildList(sd, ed)) {
|
for (ElementDefinition edc : profileUtilities.getChildList(sd, ed)) {
|
||||||
if ((edc.hasRepresentation(PropertyRepresentation.XMLATTR) || edc.hasRepresentation(PropertyRepresentation.XMLTEXT)) && !inheritedElement(edc))
|
if ((edc.hasRepresentation(PropertyRepresentation.XMLATTR) || edc.hasRepresentation(PropertyRepresentation.XMLTEXT)) && !inheritedElement(edc))
|
||||||
produceAttribute(sd, ed, edc, lang);
|
produceAttribute(sd, ed, edc, lang);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,9 +46,11 @@ import org.hl7.fhir.r5.model.DataType;
|
||||||
public class ObjectConverter {
|
public class ObjectConverter {
|
||||||
|
|
||||||
private IWorkerContext context;
|
private IWorkerContext context;
|
||||||
|
private ProfileUtilities profileUtilities;
|
||||||
|
|
||||||
public ObjectConverter(IWorkerContext context) {
|
public ObjectConverter(IWorkerContext context) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
|
profileUtilities = new ProfileUtilities(context, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Element convert(Resource ig) throws IOException, FHIRException {
|
public Element convert(Resource ig) throws IOException, FHIRException {
|
||||||
|
@ -76,7 +78,7 @@ public class ObjectConverter {
|
||||||
if (sd.getKind() == StructureDefinitionKind.PRIMITIVETYPE)
|
if (sd.getKind() == StructureDefinitionKind.PRIMITIVETYPE)
|
||||||
res.setValue(((PrimitiveType) base).asStringValue());
|
res.setValue(((PrimitiveType) base).asStringValue());
|
||||||
|
|
||||||
List<ElementDefinition> children = ProfileUtilities.getChildMap(sd, sd.getSnapshot().getElementFirstRep());
|
List<ElementDefinition> children = profileUtilities.getChildMap(sd, sd.getSnapshot().getElementFirstRep());
|
||||||
for (ElementDefinition child : children) {
|
for (ElementDefinition child : children) {
|
||||||
String n = tail(child.getPath());
|
String n = tail(child.getPath());
|
||||||
if (sd.getKind() != StructureDefinitionKind.PRIMITIVETYPE || !"value".equals(n)) {
|
if (sd.getKind() != StructureDefinitionKind.PRIMITIVETYPE || !"value".equals(n)) {
|
||||||
|
|
|
@ -45,11 +45,13 @@ public class Property {
|
||||||
private ElementDefinition definition;
|
private ElementDefinition definition;
|
||||||
private StructureDefinition structure;
|
private StructureDefinition structure;
|
||||||
private Boolean canBePrimitive;
|
private Boolean canBePrimitive;
|
||||||
|
private ProfileUtilities profileUtilities;
|
||||||
|
|
||||||
public Property(IWorkerContext context, ElementDefinition definition, StructureDefinition structure) {
|
public Property(IWorkerContext context, ElementDefinition definition, StructureDefinition structure) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.definition = definition;
|
this.definition = definition;
|
||||||
this.structure = structure;
|
this.structure = structure;
|
||||||
|
profileUtilities = new ProfileUtilities(context, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -248,7 +250,7 @@ public class Property {
|
||||||
protected List<Property> getChildProperties(String elementName, String statedType) throws FHIRException {
|
protected List<Property> getChildProperties(String elementName, String statedType) throws FHIRException {
|
||||||
ElementDefinition ed = definition;
|
ElementDefinition ed = definition;
|
||||||
StructureDefinition sd = structure;
|
StructureDefinition sd = structure;
|
||||||
List<ElementDefinition> children = ProfileUtilities.getChildMap(sd, ed);
|
List<ElementDefinition> children = profileUtilities.getChildMap(sd, ed);
|
||||||
String url = null;
|
String url = null;
|
||||||
if (children.isEmpty() || isElementWithOnlyExtension(ed, children)) {
|
if (children.isEmpty() || isElementWithOnlyExtension(ed, children)) {
|
||||||
// ok, find the right definitions
|
// ok, find the right definitions
|
||||||
|
@ -313,7 +315,7 @@ public class Property {
|
||||||
sd = context.fetchResource(StructureDefinition.class, url);
|
sd = context.fetchResource(StructureDefinition.class, url);
|
||||||
if (sd == null)
|
if (sd == null)
|
||||||
throw new DefinitionException("Unable to find type '"+t+"' for name '"+elementName+"' on property "+definition.getPath());
|
throw new DefinitionException("Unable to find type '"+t+"' for name '"+elementName+"' on property "+definition.getPath());
|
||||||
children = ProfileUtilities.getChildMap(sd, sd.getSnapshot().getElement().get(0));
|
children = profileUtilities.getChildMap(sd, sd.getSnapshot().getElement().get(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<Property> properties = new ArrayList<Property>();
|
List<Property> properties = new ArrayList<Property>();
|
||||||
|
@ -326,7 +328,7 @@ public class Property {
|
||||||
protected List<Property> getChildProperties(TypeDetails type) throws DefinitionException {
|
protected List<Property> getChildProperties(TypeDetails type) throws DefinitionException {
|
||||||
ElementDefinition ed = definition;
|
ElementDefinition ed = definition;
|
||||||
StructureDefinition sd = structure;
|
StructureDefinition sd = structure;
|
||||||
List<ElementDefinition> children = ProfileUtilities.getChildMap(sd, ed);
|
List<ElementDefinition> children = profileUtilities.getChildMap(sd, ed);
|
||||||
if (children.isEmpty()) {
|
if (children.isEmpty()) {
|
||||||
// ok, find the right definitions
|
// ok, find the right definitions
|
||||||
String t = null;
|
String t = null;
|
||||||
|
@ -352,7 +354,7 @@ public class Property {
|
||||||
sd = context.fetchResource(StructureDefinition.class, t);
|
sd = context.fetchResource(StructureDefinition.class, t);
|
||||||
if (sd == null)
|
if (sd == null)
|
||||||
throw new DefinitionException("Unable to find class '"+t+"' for name '"+ed.getPath()+"' on property "+definition.getPath());
|
throw new DefinitionException("Unable to find class '"+t+"' for name '"+ed.getPath()+"' on property "+definition.getPath());
|
||||||
children = ProfileUtilities.getChildMap(sd, sd.getSnapshot().getElement().get(0));
|
children = profileUtilities.getChildMap(sd, sd.getSnapshot().getElement().get(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<Property> properties = new ArrayList<Property>();
|
List<Property> properties = new ArrayList<Property>();
|
||||||
|
|
|
@ -152,6 +152,7 @@ public class FHIRPathEngine {
|
||||||
private Map<String, StructureDefinition> allTypes = new HashMap<String, StructureDefinition>();
|
private Map<String, StructureDefinition> allTypes = new HashMap<String, StructureDefinition>();
|
||||||
private boolean legacyMode; // some R2 and R3 constraints assume that != is valid for emptty sets, so when running for R2/R3, this is set ot true
|
private boolean legacyMode; // some R2 and R3 constraints assume that != is valid for emptty sets, so when running for R2/R3, this is set ot true
|
||||||
private ValidationOptions terminologyServiceOptions = new ValidationOptions();
|
private ValidationOptions terminologyServiceOptions = new ValidationOptions();
|
||||||
|
private ProfileUtilities profileUtilities;
|
||||||
|
|
||||||
// if the fhir path expressions are allowed to use constants beyond those defined in the specification
|
// if the fhir path expressions are allowed to use constants beyond those defined in the specification
|
||||||
// the application can implement them by providing a constant resolver
|
// the application can implement them by providing a constant resolver
|
||||||
|
@ -249,6 +250,7 @@ public class FHIRPathEngine {
|
||||||
public FHIRPathEngine(IWorkerContext worker) {
|
public FHIRPathEngine(IWorkerContext worker) {
|
||||||
super();
|
super();
|
||||||
this.worker = worker;
|
this.worker = worker;
|
||||||
|
profileUtilities = new ProfileUtilities(worker, null, null);
|
||||||
for (StructureDefinition sd : worker.getStructures()) {
|
for (StructureDefinition sd : worker.getStructures()) {
|
||||||
if (sd.getDerivation() == TypeDerivationRule.SPECIALIZATION && sd.getKind() != StructureDefinitionKind.LOGICAL)
|
if (sd.getDerivation() == TypeDerivationRule.SPECIALIZATION && sd.getKind() != StructureDefinitionKind.LOGICAL)
|
||||||
allTypes.put(sd.getName(), sd);
|
allTypes.put(sd.getName(), sd);
|
||||||
|
@ -4204,14 +4206,14 @@ public class FHIRPathEngine {
|
||||||
focus = element;
|
focus = element;
|
||||||
} else {
|
} else {
|
||||||
List<ElementDefinition> childDefinitions;
|
List<ElementDefinition> childDefinitions;
|
||||||
childDefinitions = ProfileUtilities.getChildMap(sd, element);
|
childDefinitions = profileUtilities.getChildMap(sd, element);
|
||||||
// if that's empty, get the children of the type
|
// if that's empty, get the children of the type
|
||||||
if (childDefinitions.isEmpty()) {
|
if (childDefinitions.isEmpty()) {
|
||||||
|
|
||||||
sd = fetchStructureByType(element);
|
sd = fetchStructureByType(element);
|
||||||
if (sd == null)
|
if (sd == null)
|
||||||
throw new DefinitionException("Problem with use of resolve() - profile '"+element.getType().get(0).getProfile()+"' on "+element.getId()+" could not be resolved");
|
throw new DefinitionException("Problem with use of resolve() - profile '"+element.getType().get(0).getProfile()+"' on "+element.getId()+" could not be resolved");
|
||||||
childDefinitions = ProfileUtilities.getChildMap(sd, sd.getSnapshot().getElementFirstRep());
|
childDefinitions = profileUtilities.getChildMap(sd, sd.getSnapshot().getElementFirstRep());
|
||||||
}
|
}
|
||||||
for (ElementDefinition t : childDefinitions) {
|
for (ElementDefinition t : childDefinitions) {
|
||||||
if (tailMatches(t, expr.getName())) {
|
if (tailMatches(t, expr.getName())) {
|
||||||
|
@ -4237,14 +4239,14 @@ public class FHIRPathEngine {
|
||||||
} else if ("extension".equals(expr.getName())) {
|
} else if ("extension".equals(expr.getName())) {
|
||||||
String targetUrl = expr.getParameters().get(0).getConstant().primitiveValue();
|
String targetUrl = expr.getParameters().get(0).getConstant().primitiveValue();
|
||||||
// targetUrl = targetUrl.substring(1,targetUrl.length()-1);
|
// targetUrl = targetUrl.substring(1,targetUrl.length()-1);
|
||||||
List<ElementDefinition> childDefinitions = ProfileUtilities.getChildMap(sd, element);
|
List<ElementDefinition> childDefinitions = profileUtilities.getChildMap(sd, element);
|
||||||
for (ElementDefinition t : childDefinitions) {
|
for (ElementDefinition t : childDefinitions) {
|
||||||
if (t.getPath().endsWith(".extension") && t.hasSliceName()) {
|
if (t.getPath().endsWith(".extension") && t.hasSliceName()) {
|
||||||
StructureDefinition exsd = worker.fetchResource(StructureDefinition.class, t.getType().get(0).getProfile().get(0).getValue());
|
StructureDefinition exsd = worker.fetchResource(StructureDefinition.class, t.getType().get(0).getProfile().get(0).getValue());
|
||||||
while (exsd!=null && !exsd.getBaseDefinition().equals("http://hl7.org/fhir/StructureDefinition/Extension"))
|
while (exsd!=null && !exsd.getBaseDefinition().equals("http://hl7.org/fhir/StructureDefinition/Extension"))
|
||||||
exsd = worker.fetchResource(StructureDefinition.class, exsd.getBaseDefinition());
|
exsd = worker.fetchResource(StructureDefinition.class, exsd.getBaseDefinition());
|
||||||
if (exsd.getUrl().equals(targetUrl)) {
|
if (exsd.getUrl().equals(targetUrl)) {
|
||||||
if (ProfileUtilities.getChildMap(sd, t).isEmpty())
|
if (profileUtilities.getChildMap(sd, t).isEmpty())
|
||||||
sd = exsd;
|
sd = exsd;
|
||||||
focus = t;
|
focus = t;
|
||||||
break;
|
break;
|
||||||
|
@ -4269,7 +4271,7 @@ public class FHIRPathEngine {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ElementDefinition pickMandatorySlice(StructureDefinition sd, ElementDefinition element) throws DefinitionException {
|
private ElementDefinition pickMandatorySlice(StructureDefinition sd, ElementDefinition element) throws DefinitionException {
|
||||||
List<ElementDefinition> list = ProfileUtilities.getSliceList(sd, element);
|
List<ElementDefinition> list = profileUtilities.getSliceList(sd, element);
|
||||||
for (ElementDefinition ed : list) {
|
for (ElementDefinition ed : list) {
|
||||||
if (ed.getMin() > 0)
|
if (ed.getMin() > 0)
|
||||||
return ed;
|
return ed;
|
||||||
|
|
|
@ -56,10 +56,12 @@ public class GraphQLSchemaGenerator {
|
||||||
|
|
||||||
private static final String INNER_TYPE_NAME = "gql.type.name";
|
private static final String INNER_TYPE_NAME = "gql.type.name";
|
||||||
IWorkerContext context;
|
IWorkerContext context;
|
||||||
|
private ProfileUtilities profileUtilities;
|
||||||
|
|
||||||
public GraphQLSchemaGenerator(IWorkerContext context) {
|
public GraphQLSchemaGenerator(IWorkerContext context) {
|
||||||
super();
|
super();
|
||||||
this.context = context;
|
this.context = context;
|
||||||
|
profileUtilities = new ProfileUtilities(context, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void generateTypes(OutputStream stream) throws IOException, FHIRException {
|
public void generateTypes(OutputStream stream) throws IOException, FHIRException {
|
||||||
|
@ -265,7 +267,7 @@ public class GraphQLSchemaGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateProperties(List<StringBuilder> list, StringBuilder b, String typeName, StructureDefinition sd, ElementDefinition ed, String mode, String suffix) throws IOException {
|
private void generateProperties(List<StringBuilder> list, StringBuilder b, String typeName, StructureDefinition sd, ElementDefinition ed, String mode, String suffix) throws IOException {
|
||||||
List<ElementDefinition> children = ProfileUtilities.getChildList(sd, ed);
|
List<ElementDefinition> children = profileUtilities.getChildList(sd, ed);
|
||||||
for (ElementDefinition child : children) {
|
for (ElementDefinition child : children) {
|
||||||
if (child.hasContentReference()) {
|
if (child.hasContentReference()) {
|
||||||
ElementDefinition ref = resolveContentReference(sd, child.getContentReference());
|
ElementDefinition ref = resolveContentReference(sd, child.getContentReference());
|
||||||
|
|
|
@ -482,7 +482,7 @@ public class NarrativeGenerator implements INarrativeGenerator {
|
||||||
@Override
|
@Override
|
||||||
public List<PropertyWrapper> children() {
|
public List<PropertyWrapper> children() {
|
||||||
if (list == null) {
|
if (list == null) {
|
||||||
children = ProfileUtilities.getChildList(structure, definition);
|
children = profileUtilities.getChildList(structure, definition);
|
||||||
list = new ArrayList<NarrativeGenerator.PropertyWrapper>();
|
list = new ArrayList<NarrativeGenerator.PropertyWrapper>();
|
||||||
for (ElementDefinition child : children) {
|
for (ElementDefinition child : children) {
|
||||||
List<Element> elements = new ArrayList<Element>();
|
List<Element> elements = new ArrayList<Element>();
|
||||||
|
@ -632,7 +632,7 @@ public class NarrativeGenerator implements INarrativeGenerator {
|
||||||
@Override
|
@Override
|
||||||
public List<PropertyWrapper> children() {
|
public List<PropertyWrapper> children() {
|
||||||
if (list == null) {
|
if (list == null) {
|
||||||
children = ProfileUtilities.getChildList(structure, definition);
|
children = profileUtilities.getChildList(structure, definition);
|
||||||
list = new ArrayList<NarrativeGenerator.PropertyWrapper>();
|
list = new ArrayList<NarrativeGenerator.PropertyWrapper>();
|
||||||
for (ElementDefinition child : children) {
|
for (ElementDefinition child : children) {
|
||||||
List<org.hl7.fhir.r5.elementmodel.Element> elements = new ArrayList<org.hl7.fhir.r5.elementmodel.Element>();
|
List<org.hl7.fhir.r5.elementmodel.Element> elements = new ArrayList<org.hl7.fhir.r5.elementmodel.Element>();
|
||||||
|
@ -703,7 +703,7 @@ public class NarrativeGenerator implements INarrativeGenerator {
|
||||||
@Override
|
@Override
|
||||||
public List<PropertyWrapper> children() {
|
public List<PropertyWrapper> children() {
|
||||||
if (list2 == null) {
|
if (list2 == null) {
|
||||||
List<ElementDefinition> children = ProfileUtilities.getChildList(definition, definition.getSnapshot().getElement().get(0));
|
List<ElementDefinition> children = profileUtilities.getChildList(definition, definition.getSnapshot().getElement().get(0));
|
||||||
list2 = new ArrayList<NarrativeGenerator.PropertyWrapper>();
|
list2 = new ArrayList<NarrativeGenerator.PropertyWrapper>();
|
||||||
for (ElementDefinition child : children) {
|
for (ElementDefinition child : children) {
|
||||||
List<org.hl7.fhir.r5.elementmodel.Element> elements = new ArrayList<org.hl7.fhir.r5.elementmodel.Element>();
|
List<org.hl7.fhir.r5.elementmodel.Element> elements = new ArrayList<org.hl7.fhir.r5.elementmodel.Element>();
|
||||||
|
@ -841,7 +841,7 @@ public class NarrativeGenerator implements INarrativeGenerator {
|
||||||
@Override
|
@Override
|
||||||
public List<PropertyWrapper> children() {
|
public List<PropertyWrapper> children() {
|
||||||
if (list2 == null) {
|
if (list2 == null) {
|
||||||
List<ElementDefinition> children = ProfileUtilities.getChildList(definition, definition.getSnapshot().getElement().get(0));
|
List<ElementDefinition> children = profileUtilities.getChildList(definition, definition.getSnapshot().getElement().get(0));
|
||||||
list2 = new ArrayList<NarrativeGenerator.PropertyWrapper>();
|
list2 = new ArrayList<NarrativeGenerator.PropertyWrapper>();
|
||||||
for (ElementDefinition child : children) {
|
for (ElementDefinition child : children) {
|
||||||
List<Element> elements = new ArrayList<Element>();
|
List<Element> elements = new ArrayList<Element>();
|
||||||
|
@ -1044,6 +1044,7 @@ public class NarrativeGenerator implements INarrativeGenerator {
|
||||||
private ValidationOptions terminologyServiceOptions = new ValidationOptions();
|
private ValidationOptions terminologyServiceOptions = new ValidationOptions();
|
||||||
private boolean noSlowLookup;
|
private boolean noSlowLookup;
|
||||||
private List<String> codeSystemPropList = new ArrayList<>();
|
private List<String> codeSystemPropList = new ArrayList<>();
|
||||||
|
private ProfileUtilities profileUtilities;
|
||||||
|
|
||||||
public NarrativeGenerator(String prefix, String basePath, IWorkerContext context) {
|
public NarrativeGenerator(String prefix, String basePath, IWorkerContext context) {
|
||||||
super();
|
super();
|
||||||
|
@ -1077,6 +1078,7 @@ public class NarrativeGenerator implements INarrativeGenerator {
|
||||||
|
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
|
profileUtilities = new ProfileUtilities(context, null, null);
|
||||||
renderingMaps.add(new ConceptMapRenderInstructions("Canonical Status", "http://hl7.org/fhir/ValueSet/resource-status", false));
|
renderingMaps.add(new ConceptMapRenderInstructions("Canonical Status", "http://hl7.org/fhir/ValueSet/resource-status", false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -136,10 +136,12 @@ public class QuestionnaireBuilder {
|
||||||
// processing the response. for technical reasons, we still go through the process, but
|
// processing the response. for technical reasons, we still go through the process, but
|
||||||
// we don't do the intensive parts of the work (save time)
|
// we don't do the intensive parts of the work (save time)
|
||||||
private Questionnaire prebuiltQuestionnaire;
|
private Questionnaire prebuiltQuestionnaire;
|
||||||
|
private ProfileUtilities profileUtilities;
|
||||||
|
|
||||||
public QuestionnaireBuilder(IWorkerContext context) {
|
public QuestionnaireBuilder(IWorkerContext context) {
|
||||||
super();
|
super();
|
||||||
this.context = context;
|
this.context = context;
|
||||||
|
profileUtilities = new ProfileUtilities(context, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Resource getReference() {
|
public Resource getReference() {
|
||||||
|
@ -291,7 +293,7 @@ public class QuestionnaireBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
// now, we iterate the children
|
// now, we iterate the children
|
||||||
List<ElementDefinition> list = ProfileUtilities.getChildList(profile, element);
|
List<ElementDefinition> list = profileUtilities.getChildList(profile, element);
|
||||||
for (ElementDefinition child : list) {
|
for (ElementDefinition child : list) {
|
||||||
|
|
||||||
if (!isExempt(element, child) && !parents.contains(child)) {
|
if (!isExempt(element, child) && !parents.contains(child)) {
|
||||||
|
|
|
@ -230,6 +230,7 @@ public class StructureMapUtilities {
|
||||||
private ProfileKnowledgeProvider pkp;
|
private ProfileKnowledgeProvider pkp;
|
||||||
private Map<String, Integer> ids = new HashMap<String, Integer>();
|
private Map<String, Integer> ids = new HashMap<String, Integer>();
|
||||||
private ValidationOptions terminologyServiceOptions = new ValidationOptions();
|
private ValidationOptions terminologyServiceOptions = new ValidationOptions();
|
||||||
|
private ProfileUtilities profileUtilities;
|
||||||
|
|
||||||
public StructureMapUtilities(IWorkerContext worker, ITransformerServices services, ProfileKnowledgeProvider pkp) {
|
public StructureMapUtilities(IWorkerContext worker, ITransformerServices services, ProfileKnowledgeProvider pkp) {
|
||||||
super();
|
super();
|
||||||
|
@ -238,6 +239,7 @@ public class StructureMapUtilities {
|
||||||
this.pkp = pkp;
|
this.pkp = pkp;
|
||||||
fpe = new FHIRPathEngine(worker);
|
fpe = new FHIRPathEngine(worker);
|
||||||
fpe.setHostServices(new FFHIRPathHostServices());
|
fpe.setHostServices(new FFHIRPathHostServices());
|
||||||
|
profileUtilities = new ProfileUtilities(worker, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public StructureMapUtilities(IWorkerContext worker, ITransformerServices services) {
|
public StructureMapUtilities(IWorkerContext worker, ITransformerServices services) {
|
||||||
|
@ -246,6 +248,7 @@ public class StructureMapUtilities {
|
||||||
this.services = services;
|
this.services = services;
|
||||||
fpe = new FHIRPathEngine(worker);
|
fpe = new FHIRPathEngine(worker);
|
||||||
fpe.setHostServices(new FFHIRPathHostServices());
|
fpe.setHostServices(new FFHIRPathHostServices());
|
||||||
|
profileUtilities = new ProfileUtilities(worker, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public StructureMapUtilities(IWorkerContext worker) {
|
public StructureMapUtilities(IWorkerContext worker) {
|
||||||
|
@ -253,6 +256,8 @@ public class StructureMapUtilities {
|
||||||
this.worker = worker;
|
this.worker = worker;
|
||||||
fpe = new FHIRPathEngine(worker);
|
fpe = new FHIRPathEngine(worker);
|
||||||
fpe.setHostServices(new FFHIRPathHostServices());
|
fpe.setHostServices(new FFHIRPathHostServices());
|
||||||
|
profileUtilities = new ProfileUtilities(worker, null, null);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String render(StructureMap map) {
|
public static String render(StructureMap map) {
|
||||||
|
@ -2934,7 +2939,7 @@ public class StructureMapUtilities {
|
||||||
|
|
||||||
private void addChildMappings(StringBuilder b, String id, String indent, StructureDefinition sd, ElementDefinition ed, boolean inner) throws DefinitionException {
|
private void addChildMappings(StringBuilder b, String id, String indent, StructureDefinition sd, ElementDefinition ed, boolean inner) throws DefinitionException {
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
List<ElementDefinition> children = ProfileUtilities.getChildMap(sd, ed);
|
List<ElementDefinition> children = profileUtilities.getChildMap(sd, ed);
|
||||||
for (ElementDefinition child : children) {
|
for (ElementDefinition child : children) {
|
||||||
if (first && inner) {
|
if (first && inner) {
|
||||||
b.append(" then {\r\n");
|
b.append(" then {\r\n");
|
||||||
|
|
|
@ -369,11 +369,13 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
private ValidatorHostServices validatorServices;
|
private ValidatorHostServices validatorServices;
|
||||||
private boolean assumeValidRestReferences;
|
private boolean assumeValidRestReferences;
|
||||||
private boolean allowExamples;
|
private boolean allowExamples;
|
||||||
|
private ProfileUtilities profileUtilities;
|
||||||
|
|
||||||
public InstanceValidator(IWorkerContext theContext, IEvaluationContext hostServices) {
|
public InstanceValidator(IWorkerContext theContext, IEvaluationContext hostServices) {
|
||||||
super(theContext);
|
super(theContext);
|
||||||
this.context = theContext;
|
this.context = theContext;
|
||||||
this.externalHostServices = hostServices;
|
this.externalHostServices = hostServices;
|
||||||
|
this.profileUtilities = new ProfileUtilities(theContext, null, null);
|
||||||
fpe = new FHIRPathEngine(context);
|
fpe = new FHIRPathEngine(context);
|
||||||
validatorServices = new ValidatorHostServices();
|
validatorServices = new ValidatorHostServices();
|
||||||
fpe.setHostServices(validatorServices);
|
fpe.setHostServices(validatorServices);
|
||||||
|
@ -4570,7 +4572,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
checkFixedValue(errors, stack.getLiteralPath(), element, definition.getFixed(), profile.getUrl(), definition.getSliceName(), null);
|
checkFixedValue(errors, stack.getLiteralPath(), element, definition.getFixed(), profile.getUrl(), definition.getSliceName(), null);
|
||||||
|
|
||||||
// get the list of direct defined children, including slices
|
// get the list of direct defined children, including slices
|
||||||
List<ElementDefinition> childDefinitions = ProfileUtilities.getChildMap(profile, definition);
|
List<ElementDefinition> childDefinitions = profileUtilities.getChildMap(profile, definition);
|
||||||
if (childDefinitions.isEmpty()) {
|
if (childDefinitions.isEmpty()) {
|
||||||
if (actualType == null)
|
if (actualType == null)
|
||||||
return; // there'll be an error elsewhere in this case, and we're going to stop.
|
return; // there'll be an error elsewhere in this case, and we're going to stop.
|
||||||
|
@ -4625,7 +4627,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
throw new DefinitionException(formatMessage(I18nConstants.UNABLE_TO_RESOLVE_ACTUAL_TYPE_, actualType));
|
throw new DefinitionException(formatMessage(I18nConstants.UNABLE_TO_RESOLVE_ACTUAL_TYPE_, actualType));
|
||||||
trackUsage(dt, hostContext, element);
|
trackUsage(dt, hostContext, element);
|
||||||
|
|
||||||
childDefinitions = ProfileUtilities.getChildMap(dt, dt.getSnapshot().getElement().get(0));
|
childDefinitions = profileUtilities.getChildMap(dt, dt.getSnapshot().getElement().get(0));
|
||||||
return childDefinitions;
|
return childDefinitions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4926,7 +4928,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
int count = 0;
|
int count = 0;
|
||||||
List<ElementDefinition> slices = null;
|
List<ElementDefinition> slices = null;
|
||||||
if (ed.hasSlicing())
|
if (ed.hasSlicing())
|
||||||
slices = ProfileUtilities.getSliceList(profile, ed);
|
slices = profileUtilities.getSliceList(profile, ed);
|
||||||
for (ElementInfo ei : children)
|
for (ElementInfo ei : children)
|
||||||
if (ei.definition == ed)
|
if (ei.definition == ed)
|
||||||
count++;
|
count++;
|
||||||
|
|
Loading…
Reference in New Issue