Fix bugs in FHIRPath handling of logical models
This commit is contained in:
parent
5a858949d4
commit
363045c1c8
|
@ -2242,7 +2242,16 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
|||
if (Utilities.isAbsoluteUrl(typeName)) {
|
||||
return fetchResource(StructureDefinition.class, typeName);
|
||||
} else {
|
||||
return fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/"+typeName);
|
||||
Set<StructureDefinition> types = new HashSet<>();
|
||||
types.addAll(fetchTypeDefinitions(typeName));
|
||||
types.removeIf(sd -> sd.getDerivation() == TypeDerivationRule.CONSTRAINT);
|
||||
if (types.size() == 1) {
|
||||
return types.iterator().next();
|
||||
} else if (types.size() > 1) {
|
||||
throw new FHIRException("Ambiguous type "+typeName);
|
||||
} else {
|
||||
return fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/"+typeName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2250,7 +2259,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
|||
public List<StructureDefinition> fetchTypeDefinitions(String typeName) {
|
||||
List<StructureDefinition> res = new ArrayList<>();
|
||||
structures.listAll(res);
|
||||
res.removeIf(sd -> !sd.hasType() || !sd.getType().equals(typeName));
|
||||
res.removeIf(sd -> !sd.hasType() || !(sd.getType().equals(typeName) || sd.getTypeTail().equals(typeName)));
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
@ -675,7 +675,7 @@ public class FHIRPathEngine {
|
|||
if (ed.fixedType != null) {
|
||||
types = new TypeDetails(CollectionStatus.SINGLETON, ed.fixedType);
|
||||
} else if (ed.getDefinition().getType().isEmpty() || isAbstractType(ed.getDefinition().getType())) {
|
||||
types = new TypeDetails(CollectionStatus.SINGLETON, ctxt+"#"+t);
|
||||
types = new TypeDetails(CollectionStatus.SINGLETON, sd.getType()+"#"+t);
|
||||
} else {
|
||||
types = new TypeDetails(CollectionStatus.SINGLETON);
|
||||
for (TypeRefComponent tt : ed.getDefinition().getType()) {
|
||||
|
|
|
@ -549,13 +549,17 @@ public class StructureDefinitionValidator extends BaseValidator {
|
|||
|
||||
private List<String> getTypesForElement(List<Element> elements, Element element) {
|
||||
List<String> types = new ArrayList<>();
|
||||
for (Element tr : element.getChildrenByName("type")) {
|
||||
String t = tr.getNamedChildValue("code");
|
||||
if (t != null) {
|
||||
if (isAbstractType(t) && hasChildren(element, elements) ) {
|
||||
types.add(element.getNamedChildValue("path"));
|
||||
} else {
|
||||
types.add(t);
|
||||
if (element.hasChild("path") && !element.getNamedChildValue("path").contains(".")) {
|
||||
types.add(element.getNamedChildValue("path"));
|
||||
} else {
|
||||
for (Element tr : element.getChildrenByName("type")) {
|
||||
String t = tr.getNamedChildValue("code");
|
||||
if (t != null) {
|
||||
if (isAbstractType(t) && hasChildren(element, elements) ) {
|
||||
types.add(element.getNamedChildValue("path"));
|
||||
} else {
|
||||
types.add(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue