Merge pull request #1401 from hapifhir/2023-08-gg-more-tx-test-fixes

2023 08 gg more tx test fixes
This commit is contained in:
Grahame Grieve 2023-08-22 11:24:02 +10:00 committed by GitHub
commit 504e02bd32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 12 deletions

View File

@ -557,7 +557,7 @@ public class ValueSetExpander extends ValueSetProcessBase {
try { try {
if (source.hasCompose()) { if (source.hasCompose()) {
ExtensionsUtils.stripExtensions(focus.getCompose()); // ExtensionsUtils.stripExtensions(focus.getCompose()); - disabled 23/05/2023 GDG - why was this ever thought to be a good idea?
handleCompose(source.getCompose(), focus.getExpansion(), expParams, source.getUrl(), focus.getExpansion().getExtension(), source); handleCompose(source.getCompose(), focus.getExpansion(), expParams, source.getUrl(), focus.getExpansion().getExtension(), source);
} }
} catch (EFinished e) { } catch (EFinished e) {
@ -877,9 +877,9 @@ public class ValueSetExpander extends ValueSetProcessBase {
def.checkNoModifiers("Code in Code System", "expanding"); def.checkNoModifiers("Code in Code System", "expanding");
inactive = CodeSystemUtilities.isInactive(cs, def); inactive = CodeSystemUtilities.isInactive(cs, def);
isAbstract = CodeSystemUtilities.isNotSelectable(cs, def); isAbstract = CodeSystemUtilities.isNotSelectable(cs, def);
addCode(dwc, inc.getSystem(), c.getCode(), !Utilities.noString(c.getDisplay()) ? c.getDisplay() : def.getDisplay(), c.hasDisplay() ? vsSrc.getLanguage() : cs.getLanguage(), null, mergeDesignations(def, convertDesignations(c.getDesignation())),
expParams, isAbstract, inactive, imports, noInactive, false, exp.getProperty(), makeCSProps(def.getDefinition(), def.getProperty()), null, def.getExtension(), c.getExtension(), exp);
} }
addCode(dwc, inc.getSystem(), c.getCode(), !Utilities.noString(c.getDisplay()) ? c.getDisplay() : def == null ? null : def.getDisplay(), c.hasDisplay() ? vsSrc.getLanguage() : cs.getLanguage(), null, mergeDesignations(def, convertDesignations(c.getDesignation())),
expParams, isAbstract, inactive, imports, noInactive, false, exp.getProperty(), def == null ? null : makeCSProps(def.getDefinition(), def.getProperty()), null, def == null ? null : def.getExtension(), c.getExtension(), exp);
} }
} }
if (inc.getFilter().size() > 0) { if (inc.getFilter().size() > 0) {
@ -963,7 +963,9 @@ public class ValueSetExpander extends ValueSetProcessBase {
private List<ConceptDefinitionDesignationComponent> mergeDesignations(ConceptDefinitionComponent def, private List<ConceptDefinitionDesignationComponent> mergeDesignations(ConceptDefinitionComponent def,
List<ConceptDefinitionDesignationComponent> list) { List<ConceptDefinitionDesignationComponent> list) {
List<ConceptDefinitionDesignationComponent> res = new ArrayList<>(); List<ConceptDefinitionDesignationComponent> res = new ArrayList<>();
res.addAll(def.getDesignation()); if (def != null) {
res.addAll(def.getDesignation());
}
res.addAll(list); res.addAll(list);
return res; return res;
} }

View File

@ -4,12 +4,17 @@ import org.hl7.fhir.r5.model.Base;
import org.hl7.fhir.r5.model.Element; import org.hl7.fhir.r5.model.Element;
import org.hl7.fhir.r5.model.Property; import org.hl7.fhir.r5.model.Property;
import org.hl7.fhir.r5.model.Resource; import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.utils.ElementVisitor.ElementVisitorInstruction;
public class ElementVisitor { public class ElementVisitor {
public enum ElementVisitorInstruction {
VISIT_CHILDREN, NO_VISIT_CHILDREN;
}
public interface IElementVisitor { public interface IElementVisitor {
public void visit(Object context, Resource resource); public ElementVisitorInstruction visit(Object context, Resource resource);
public void visit(Object context, Element element); public ElementVisitorInstruction visit(Object context, Element element);
} }
private IElementVisitor visitor; private IElementVisitor visitor;
@ -33,13 +38,17 @@ public class ElementVisitor {
} }
public void visit(Object context, Resource res) { public void visit(Object context, Resource res) {
visitor.visit(context, res); ElementVisitorInstruction c = visitor.visit(context, res);
visitBase(context, res); if (c == ElementVisitorInstruction.VISIT_CHILDREN) {
visitBase(context, res);
}
} }
public void visit(Object context, Element e) { public void visit(Object context, Element e) {
visitor.visit(context, e); ElementVisitorInstruction c = visitor.visit(context, e);
visitBase(context, e); if (c == ElementVisitorInstruction.VISIT_CHILDREN) {
visitBase(context, e);
}
} }
} }

View File

@ -8,6 +8,7 @@ import org.hl7.fhir.r5.model.Parameters;
import org.hl7.fhir.r5.model.Resource; import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.ValueSet; import org.hl7.fhir.r5.model.ValueSet;
import org.hl7.fhir.r5.utils.ElementVisitor; import org.hl7.fhir.r5.utils.ElementVisitor;
import org.hl7.fhir.r5.utils.ElementVisitor.ElementVisitorInstruction;
import org.hl7.fhir.r5.utils.ElementVisitor.IElementVisitor; import org.hl7.fhir.r5.utils.ElementVisitor.IElementVisitor;
import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.Utilities;
@ -53,16 +54,22 @@ public class TxTesterScrubbers {
} }
@Override @Override
public void visit(Object context, Resource resource) { public ElementVisitorInstruction visit(Object context, Resource resource) {
if (resource instanceof DomainResource) { if (resource instanceof DomainResource) {
DomainResource dr = (DomainResource) resource; DomainResource dr = (DomainResource) resource;
dr.getExtension().removeIf(ext -> !isManagedExtension(ext)); dr.getExtension().removeIf(ext -> !isManagedExtension(ext));
} }
return ElementVisitorInstruction.VISIT_CHILDREN;
} }
@Override @Override
public void visit(Object context, Element element) { public ElementVisitorInstruction visit(Object context, Element element) {
element.getExtension().removeIf(ext -> !isManagedExtension(ext)); element.getExtension().removeIf(ext -> !isManagedExtension(ext));
if (element.fhirType().equals("ValueSet.compose")) {
return ElementVisitorInstruction.NO_VISIT_CHILDREN;
} else {
return ElementVisitorInstruction.VISIT_CHILDREN;
}
} }
} }

View File

@ -41,6 +41,7 @@ public class TxTesterSorters {
Collections.sort(vs.getExpansion().getParameter(), new TxTesterSorters.ExpParameterSorter()); Collections.sort(vs.getExpansion().getParameter(), new TxTesterSorters.ExpParameterSorter());
Collections.sort(vs.getExpansion().getProperty(), new TxTesterSorters.PropertyDefnSorter()); Collections.sort(vs.getExpansion().getProperty(), new TxTesterSorters.PropertyDefnSorter());
Collections.sort(vs.getExpansion().getExtension(), new TxTesterSorters.ExtensionSorter()); Collections.sort(vs.getExpansion().getExtension(), new TxTesterSorters.ExtensionSorter());
Collections.sort(vs.getExpansion().getContains(), new TxTesterSorters.ContainsSorter());
for (ValueSetExpansionContainsComponent cc : vs.getExpansion().getContains()) { for (ValueSetExpansionContainsComponent cc : vs.getExpansion().getContains()) {
sortContainsFeatures(cc); sortContainsFeatures(cc);
} }
@ -48,6 +49,7 @@ public class TxTesterSorters {
} }
public static void sortContainsFeatures(ValueSetExpansionContainsComponent cc) { public static void sortContainsFeatures(ValueSetExpansionContainsComponent cc) {
Collections.sort(cc.getContains(), new TxTesterSorters.ContainsSorter());
Collections.sort(cc.getExtension(), new TxTesterSorters.ExtensionSorter()); Collections.sort(cc.getExtension(), new TxTesterSorters.ExtensionSorter());
Collections.sort(cc.getDesignation(), new TxTesterSorters.DesignationSorter()); Collections.sort(cc.getDesignation(), new TxTesterSorters.DesignationSorter());
Collections.sort(cc.getProperty(), new TxTesterSorters.PropertyValueSorter()); Collections.sort(cc.getProperty(), new TxTesterSorters.PropertyValueSorter());
@ -129,6 +131,16 @@ public class TxTesterSorters {
} }
public static class ContainsSorter implements Comparator<ValueSetExpansionContainsComponent> {
@Override
public int compare(ValueSetExpansionContainsComponent o1, ValueSetExpansionContainsComponent o2) {
return o1.getCode().compareTo(o2.getCode());
}
}
public static class ExpParameterSorter implements Comparator<ValueSetExpansionParameterComponent> { public static class ExpParameterSorter implements Comparator<ValueSetExpansionParameterComponent> {
@Override @Override