fix bugs in type handling
This commit is contained in:
parent
363045c1c8
commit
bb4379f5dd
|
@ -2245,12 +2245,17 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
||||||
Set<StructureDefinition> types = new HashSet<>();
|
Set<StructureDefinition> types = new HashSet<>();
|
||||||
types.addAll(fetchTypeDefinitions(typeName));
|
types.addAll(fetchTypeDefinitions(typeName));
|
||||||
types.removeIf(sd -> sd.getDerivation() == TypeDerivationRule.CONSTRAINT);
|
types.removeIf(sd -> sd.getDerivation() == TypeDerivationRule.CONSTRAINT);
|
||||||
if (types.size() == 1) {
|
if (types.size() == 0) {
|
||||||
|
return null; // throw new FHIRException("Unresolved type "+typeName+" (0)");
|
||||||
|
} else if (types.size() == 1) {
|
||||||
return types.iterator().next();
|
return types.iterator().next();
|
||||||
} else if (types.size() > 1) {
|
|
||||||
throw new FHIRException("Ambiguous type "+typeName);
|
|
||||||
} else {
|
} else {
|
||||||
return fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/"+typeName);
|
types.removeIf(sd -> !sd.getUrl().startsWith("http://hl7.org/fhir/StructureDefinition/"));
|
||||||
|
if (types.size() != 1) {
|
||||||
|
throw new FHIRException("Ambiguous type "+typeName+" ("+types.toString()+") (contact Grahame Grieve for investigation)");
|
||||||
|
} else {
|
||||||
|
return types.iterator().next();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ import org.hl7.fhir.r5.model.NamingSystem;
|
||||||
import org.hl7.fhir.r5.model.StructureDefinition;
|
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||||
import org.hl7.fhir.utilities.OIDUtils;
|
import org.hl7.fhir.utilities.OIDUtils;
|
||||||
import org.hl7.fhir.utilities.Utilities;
|
import org.hl7.fhir.utilities.Utilities;
|
||||||
|
import org.hl7.fhir.utilities.VersionUtilities;
|
||||||
import org.hl7.fhir.utilities.i18n.I18nConstants;
|
import org.hl7.fhir.utilities.i18n.I18nConstants;
|
||||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType;
|
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType;
|
||||||
|
@ -156,9 +157,11 @@ public class ContextUtilities implements ProfileKnowledgeProvider {
|
||||||
public Set<String> getTypeNameSet() {
|
public Set<String> getTypeNameSet() {
|
||||||
Set<String> result = new HashSet<String>();
|
Set<String> result = new HashSet<String>();
|
||||||
for (StructureDefinition sd : context.fetchResourcesByType(StructureDefinition.class)) {
|
for (StructureDefinition sd : context.fetchResourcesByType(StructureDefinition.class)) {
|
||||||
if (sd.getKind() != StructureDefinitionKind.LOGICAL && sd.getDerivation() == TypeDerivationRule.SPECIALIZATION)
|
if (sd.getKind() != StructureDefinitionKind.LOGICAL && sd.getDerivation() == TypeDerivationRule.SPECIALIZATION &&
|
||||||
|
VersionUtilities.versionsCompatible(context.getVersion(), sd.getFhirVersion().toCode())) {
|
||||||
result.add(sd.getName());
|
result.add(sd.getName());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue