Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2023 08 gg more tx test fixes #1401

Merged
merged 2 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ public ValueSetExpansionOutcome doExpand(ValueSet source, Parameters expParams)

try {
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);
}
} catch (EFinished e) {
Expand Down Expand Up @@ -877,9 +877,9 @@ public void doInternalIncludeCodes(ConceptSetComponent inc, ValueSetExpansionCom
def.checkNoModifiers("Code in Code System", "expanding");
inactive = CodeSystemUtilities.isInactive(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) {
Expand Down Expand Up @@ -963,7 +963,9 @@ private void processFilter(ConceptSetComponent inc, ValueSetExpansionComponent e
private List<ConceptDefinitionDesignationComponent> mergeDesignations(ConceptDefinitionComponent def,
List<ConceptDefinitionDesignationComponent> list) {
List<ConceptDefinitionDesignationComponent> res = new ArrayList<>();
res.addAll(def.getDesignation());
if (def != null) {
res.addAll(def.getDesignation());
}
res.addAll(list);
return res;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@
import org.hl7.fhir.r5.model.Element;
import org.hl7.fhir.r5.model.Property;
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.utils.ElementVisitor.ElementVisitorInstruction;

public class ElementVisitor {

public enum ElementVisitorInstruction {
VISIT_CHILDREN, NO_VISIT_CHILDREN;
}

public interface IElementVisitor {
public void visit(Object context, Resource resource);
public void visit(Object context, Element element);
public ElementVisitorInstruction visit(Object context, Resource resource);
public ElementVisitorInstruction visit(Object context, Element element);
}

private IElementVisitor visitor;
Expand All @@ -33,13 +38,17 @@ private void visitBase(Object context, Base base) {
}

public void visit(Object context, Resource res) {
visitor.visit(context, res);
visitBase(context, res);
ElementVisitorInstruction c = visitor.visit(context, res);
if (c == ElementVisitorInstruction.VISIT_CHILDREN) {
visitBase(context, res);
}
}

public void visit(Object context, Element e) {
visitor.visit(context, e);
visitBase(context, e);
ElementVisitorInstruction c = visitor.visit(context, e);
if (c == ElementVisitorInstruction.VISIT_CHILDREN) {
visitBase(context, e);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.ValueSet;
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.utilities.Utilities;

Expand Down Expand Up @@ -53,16 +54,22 @@ private boolean isManagedExtension(Extension extension) {
}

@Override
public void visit(Object context, Resource resource) {
public ElementVisitorInstruction visit(Object context, Resource resource) {
if (resource instanceof DomainResource) {
DomainResource dr = (DomainResource) resource;
dr.getExtension().removeIf(ext -> !isManagedExtension(ext));
}
return ElementVisitorInstruction.VISIT_CHILDREN;
}

@Override
public void visit(Object context, Element element) {
public ElementVisitorInstruction visit(Object context, Element element) {
element.getExtension().removeIf(ext -> !isManagedExtension(ext));
if (element.fhirType().equals("ValueSet.compose")) {
return ElementVisitorInstruction.NO_VISIT_CHILDREN;
} else {
return ElementVisitorInstruction.VISIT_CHILDREN;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ public static void sortValueSet(ValueSet vs) {
Collections.sort(vs.getExpansion().getParameter(), new TxTesterSorters.ExpParameterSorter());
Collections.sort(vs.getExpansion().getProperty(), new TxTesterSorters.PropertyDefnSorter());
Collections.sort(vs.getExpansion().getExtension(), new TxTesterSorters.ExtensionSorter());
Collections.sort(vs.getExpansion().getContains(), new TxTesterSorters.ContainsSorter());
for (ValueSetExpansionContainsComponent cc : vs.getExpansion().getContains()) {
sortContainsFeatures(cc);
}
}
}

public static void sortContainsFeatures(ValueSetExpansionContainsComponent cc) {
Collections.sort(cc.getContains(), new TxTesterSorters.ContainsSorter());
Collections.sort(cc.getExtension(), new TxTesterSorters.ExtensionSorter());
Collections.sort(cc.getDesignation(), new TxTesterSorters.DesignationSorter());
Collections.sort(cc.getProperty(), new TxTesterSorters.PropertyValueSorter());
Expand Down Expand Up @@ -129,6 +131,16 @@ public int compare(ConceptPropertyComponent o1, ConceptPropertyComponent o2) {
}


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> {

@Override
Expand Down
Loading