Skip to content

Commit

Permalink
in order to get the tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
Grahame Grieve committed Aug 22, 2023
2 parents 9303aa7 + f3d6541 commit f5f35d5
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 14 deletions.
7 changes: 6 additions & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
* Fix issue in FHIRPath .combine focus handling
* Check Extension fixed values for URLs - enforce consistency
* Fix R4 FML parser problem
* Track and report inactive status when reported from terminology server
* Add defense against large terminology operations causing obscure java errors

## Other code changes

Expand All @@ -24,8 +26,11 @@
* Remove spurious logging in FHIRPath engine
* Fix addChild error in PEBuilder (#1343) + Add test case
* CPT Importer
* Dependencies fixed: okhttp, thymeleaf, and commonmark
* Dependencies fixed/updated: okhttp, thymeleaf, commonmark & UCUM
* Xhtml fluent improvements + related XHtmlNode improvements
* Release new pubpack for new icons
* Json Object comparison: fix bug in arrays with multiple optional elements + improved error messages + support for external strings
* fix cross-version extensions web references where possible
* Don't suppress exceptions in terminology clients
* Add first cut of Profile Generation code
* Stop putting invalid codes in expansions if they are not in the code system
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,12 @@ private ValueSetExpansionContainsComponent addCode(WorkingContext wc, String sys
String dstLang = focus.getLanguage();

boolean usedDisplay = false;
ConceptDefinitionDesignationComponent tu = expParams.hasParameter("displayLanguage") ? getMatchingLang(designations, expParams.getParameterString("displayLanguage")) : null;
ConceptDefinitionDesignationComponent tu;
if (LanguageUtils.langsMatch(dstLang, dispLang)) {
tu = null; // use display
} else {
tu = expParams.hasParameter("displayLanguage") ? getMatchingLang(designations, expParams.getParameterString("displayLanguage")) : null;
}
if (tu != null) {
n.setDisplay(tu.getValue());
} else if (display != null && (srcLang == null || dstLang == null || LanguageUtils.langsMatch(dstLang, srcLang))) {
Expand Down Expand Up @@ -557,7 +562,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 +882,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 +968,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

0 comments on commit f5f35d5

Please sign in to comment.