This commit is contained in:
Grahame Grieve 2023-05-07 12:02:00 -05:00
parent bcb0656ff5
commit 6232c54f15
9 changed files with 12 additions and 18 deletions

View File

@ -98,7 +98,7 @@ public class JavaExtensionsFactoryGenerator extends JavaBaseGenerator {
ElementDefinition edRoot = sd.getSnapshot().getElementFirstRep(); ElementDefinition edRoot = sd.getSnapshot().getElementFirstRep();
boolean repeats = !edRoot.getMax().equals("1"); boolean repeats = !edRoot.getMax().equals("1");
String verb = repeats ? "add" : "set"; String verb = repeats ? "add" : "set";
ElementDefinition edValue = sd.getSnapshot().getElementByPath("Extension.value[x]", false); ElementDefinition edValue = sd.getSnapshot().getElementByPath("Extension.value[x]");
List<TypeTuple> types = analyseTypes(edValue); List<TypeTuple> types = analyseTypes(edValue);
if (types.size() > 5) { if (types.size() > 5) {
src.append(" public static Extension make"+name+"(DataType value) {\r\n"); src.append(" public static Extension make"+name+"(DataType value) {\r\n");

View File

@ -3969,12 +3969,12 @@ public class ProfileUtilities extends TranslatingUtilities {
if (!isExtensionDefinition(sd)) { if (!isExtensionDefinition(sd)) {
return false; return false;
} }
ElementDefinition value = sd.getSnapshot().getElementByPath("Extension.value", true); ElementDefinition value = sd.getSnapshot().getElementByPath("Extension.value");
return value != null && !value.isProhibited(); return value != null && !value.isProhibited();
} }
public static boolean isModifierExtension(StructureDefinition sd) { public static boolean isModifierExtension(StructureDefinition sd) {
ElementDefinition defn = sd.getSnapshot().getElementByPath("Extension", true); ElementDefinition defn = sd.getSnapshot().getElementByPath("Extension");
return defn.getIsModifier(); return defn.getIsModifier();
} }

View File

@ -1451,7 +1451,7 @@ public class Element extends Base {
if (property.getStructure().hasExtension(ToolingExtensions.EXT_RESOURCE_IMPLEMENTS)) { if (property.getStructure().hasExtension(ToolingExtensions.EXT_RESOURCE_IMPLEMENTS)) {
StructureDefinition sd = property.getContext().fetchResource(StructureDefinition.class, ExtensionsUtils.getExtensionString(property.getStructure(), ToolingExtensions.EXT_RESOURCE_IMPLEMENTS)); StructureDefinition sd = property.getContext().fetchResource(StructureDefinition.class, ExtensionsUtils.getExtensionString(property.getStructure(), ToolingExtensions.EXT_RESOURCE_IMPLEMENTS));
if (sd != null) { if (sd != null) {
ElementDefinition ed = sd.getSnapshot().getElementByPath(property.getDefinition().getPath().replace(property.getStructure().getType(), sd.getType()), true); ElementDefinition ed = sd.getSnapshot().getElementByPath(property.getDefinition().getPath().replace(property.getStructure().getType(), sd.getType()));
if (ed != null) { if (ed != null) {
return ed.getBase().getPath(); return ed.getBase().getPath();
} }

View File

@ -301,9 +301,7 @@ public abstract class Element extends Base implements IBaseHasExtensions, IBaseE
} }
public boolean isEmpty() { public boolean isEmpty() {
boolean idIsEmpty = id == null || id.isEmpty(); return super.isEmpty() && ca.uhn.fhir.util.ElementUtil.isEmpty(id, extension);
boolean extensionIsEmpty = extension == null || extension.size() == 0;
return super.isEmpty() && idIsEmpty && extensionIsEmpty;
} }
// Manual code (from Configuration.txt): // Manual code (from Configuration.txt):

View File

@ -130,8 +130,7 @@ public abstract class PrimitiveType<T> extends DataType implements IPrimitiveTyp
@Override @Override
public boolean isEmpty() { public boolean isEmpty() {
String value = getValueAsString(); return super.isEmpty() && StringUtils.isBlank(getValueAsString());
return !super.isEmpty() || (value != null && value.length() > 0);
} }
public boolean isPrimitive() { public boolean isPrimitive() {

View File

@ -1233,15 +1233,12 @@ public class StructureDefinition extends CanonicalResource {
// added from java-adornments.txt: // added from java-adornments.txt:
public ElementDefinition getElementByPath(String path, boolean autoChoice) { public ElementDefinition getElementByPath(String path) {
if (autoChoice && path.endsWith("[x]")) {
path = path.substring(0, path.length()-3);
}
if (path == null) { if (path == null) {
return null; return null;
} }
for (ElementDefinition ed : getElement()) { for (ElementDefinition ed : getElement()) {
if (path.equals(ed.getPath()) || (autoChoice && (path+"[x]").equals(ed.getPath()))) { if (path.equals(ed.getPath()) || (path+"[x]").equals(ed.getPath())) {
return ed; return ed;
} }
} }

View File

@ -129,7 +129,7 @@ public abstract class PEDefinition {
type= type.substring(0, type.indexOf(".")); type= type.substring(0, type.indexOf("."));
} }
StructureDefinition sd = builder.getContext().fetchTypeDefinition(type); StructureDefinition sd = builder.getContext().fetchTypeDefinition(type);
return sd.getSnapshot().getElementByPath(definition.getBase().getPath(), true); return sd.getSnapshot().getElementByPath(definition.getBase().getPath());
} }
/** /**

View File

@ -21,8 +21,8 @@ public class PEDefinitionExtension extends PEDefinition {
super(builder, name, profile, definition, ppath); super(builder, name, profile, definition, ppath);
this.sliceDefinition = sliceDefinition; this.sliceDefinition = sliceDefinition;
this.extension= extension; this.extension= extension;
eed = extension.getSnapshot().getElementByPath("Extension.extension", true); eed = extension.getSnapshot().getElementByPath("Extension.extension");
ved = extension.getSnapshot().getElementByPath("Extension.value[x]", true); ved = extension.getSnapshot().getElementByPath("Extension.value[x]");
} }
@Override @Override

View File

@ -1060,7 +1060,7 @@ public class StructureMapValidator extends BaseValidator {
if (sdt == null) { if (sdt == null) {
throw new Error("Unable to resolve "+url); throw new Error("Unable to resolve "+url);
} else { } else {
ElementDefinition t2 = sdt.getSnapshot().getElementByPath(path, true); ElementDefinition t2 = sdt.getSnapshot().getElementByPath(path);
if (t2 == null) { if (t2 == null) {
throw new Error("Unable to resolve "+path+" in "+url); throw new Error("Unable to resolve "+path+" in "+url);
} else { } else {