Properly populate property definitions in expansions
This commit is contained in:
parent
4cdfb0fcd6
commit
cf72798e9f
|
@ -339,26 +339,31 @@ public class ValueSetUtilities extends TerminologyUtilities {
|
|||
return false;
|
||||
}
|
||||
|
||||
public static void addProperty(ValueSet vs, ValueSetExpansionContainsComponent ctxt, String url, String code, String value) {
|
||||
public static org.hl7.fhir.r5.model.ValueSet.ConceptPropertyComponent addProperty(ValueSet vs, ValueSetExpansionContainsComponent ctxt, String url, String code, String value) {
|
||||
if (value != null) {
|
||||
addProperty(vs, ctxt, url, code, new StringType(value));
|
||||
return addProperty(vs, ctxt, url, code, new StringType(value));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void addProperty(ValueSet vs, ValueSetExpansionContainsComponent ctxt, String url, String code, Integer value) {
|
||||
public static org.hl7.fhir.r5.model.ValueSet.ConceptPropertyComponent addProperty(ValueSet vs, ValueSetExpansionContainsComponent ctxt, String url, String code, Integer value) {
|
||||
if (value != null) {
|
||||
addProperty(vs, ctxt, url, code, new IntegerType(value));
|
||||
return addProperty(vs, ctxt, url, code, new IntegerType(value));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void addProperty(ValueSet vs, ValueSetExpansionContainsComponent ctxt, String url, String code, DataType value) {
|
||||
public static org.hl7.fhir.r5.model.ValueSet.ConceptPropertyComponent addProperty(ValueSet vs, ValueSetExpansionContainsComponent ctxt, String url, String code, DataType value) {
|
||||
code = defineProperty(vs, url, code);
|
||||
org.hl7.fhir.r5.model.ValueSet.ConceptPropertyComponent p = getProperty(ctxt.getProperty(), code);
|
||||
if (p != null)
|
||||
if (p != null) {
|
||||
p.setValue(value);
|
||||
else
|
||||
ctxt.addProperty().setCode(code).setValue(value);
|
||||
|
||||
} else {
|
||||
p = ctxt.addProperty().setCode(code).setValue(value);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
private static org.hl7.fhir.r5.model.ValueSet.ConceptPropertyComponent getProperty(List<org.hl7.fhir.r5.model.ValueSet.ConceptPropertyComponent> list, String code) {
|
||||
|
|
|
@ -185,7 +185,7 @@ public class ValueSetExpander extends ValueSetProcessBase {
|
|||
|
||||
private ValueSetExpansionContainsComponent addCode(WorkingContext wc, String system, String code, String display, String dispLang, ValueSetExpansionContainsComponent parent, List<ConceptDefinitionDesignationComponent> designations, Parameters expParams,
|
||||
boolean isAbstract, boolean inactive, List<ValueSet> filters, boolean noInactive, boolean deprecated, List<ValueSetExpansionPropertyComponent> vsProp,
|
||||
List<ConceptPropertyComponent> csProps, List<org.hl7.fhir.r5.model.ValueSet.ConceptPropertyComponent> expProps, List<Extension> csExtList, List<Extension> vsExtList, ValueSetExpansionComponent exp) throws ETooCostly {
|
||||
List<ConceptPropertyComponent> csProps, CodeSystem cs, List<org.hl7.fhir.r5.model.ValueSet.ConceptPropertyComponent> expProps, List<Extension> csExtList, List<Extension> vsExtList, ValueSetExpansionComponent exp) throws ETooCostly {
|
||||
opContext.deadCheck();
|
||||
|
||||
if (filters != null && !filters.isEmpty() && !filterContainsCode(filters, system, code, exp))
|
||||
|
@ -280,14 +280,36 @@ public class ValueSetExpander extends ValueSetProcessBase {
|
|||
if (csProps != null && p.hasValue()) {
|
||||
for (ConceptPropertyComponent cp : csProps) {
|
||||
if (p.getValue().primitiveValue().equals(cp.getCode())) {
|
||||
n.addProperty().setCode(cp.getCode()).setValue(cp.getValue()).copyExtensions(cp, "http://hl7.org/fhir/StructureDefinition/alternate-code-use", "http://hl7.org/fhir/StructureDefinition/alternate-code-status");
|
||||
PropertyComponent pd = cs.getProperty(cp.getCode());
|
||||
String url = pd == null ? null : pd.getUri();
|
||||
if (url == null) {
|
||||
if ("definition".equals(cp.getCode())) {
|
||||
url = "http://hl7.org/fhir/concept-properties#definition";
|
||||
} else {
|
||||
// ??
|
||||
}
|
||||
}
|
||||
ValueSetUtilities.addProperty(focus, n, url, cp.getCode(), cp.getValue()).copyExtensions(cp, "http://hl7.org/fhir/StructureDefinition/alternate-code-use", "http://hl7.org/fhir/StructureDefinition/alternate-code-status");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (expProps != null && p.hasValue()) {
|
||||
for (org.hl7.fhir.r5.model.ValueSet.ConceptPropertyComponent cp : expProps) {
|
||||
if (p.getValue().primitiveValue().equals(cp.getCode())) {
|
||||
n.addProperty(cp).copyExtensions(cp, "http://hl7.org/fhir/StructureDefinition/alternate-code-use", "http://hl7.org/fhir/StructureDefinition/alternate-code-status");
|
||||
String url = null;
|
||||
for (ValueSetExpansionPropertyComponent t : vsProp) {
|
||||
if (t.hasCode() && t.getCode().equals(cp.getCode())) {
|
||||
url = t.getUri();
|
||||
}
|
||||
}
|
||||
if (url == null) {
|
||||
if ("definition".equals(cp.getCode())) {
|
||||
url = "http://hl7.org/fhir/concept-properties#definition";
|
||||
} else {
|
||||
// TODO: try looking it up from the code system
|
||||
}
|
||||
}
|
||||
ValueSetUtilities.addProperty(focus, n, url, cp.getCode(), cp.getValue()).copyExtensions(cp, "http://hl7.org/fhir/StructureDefinition/alternate-code-use", "http://hl7.org/fhir/StructureDefinition/alternate-code-status");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -426,7 +448,7 @@ public class ValueSetExpander extends ValueSetProcessBase {
|
|||
ValueSetExpansionContainsComponent np = null;
|
||||
for (String code : getCodesForConcept(focus, expParams)) {
|
||||
ValueSetExpansionContainsComponent t = addCode(wc, focus.getSystem(), code, focus.getDisplay(), vsSrc.getLanguage(), parent,
|
||||
convert(focus.getDesignation()), expParams, focus.getAbstract(), focus.getInactive(), filters, noInactive, false, vsProps, makeCSProps(focus.getExtensionString(ToolingExtensions.EXT_DEFINITION), null), focus.getProperty(), null, focus.getExtension(), exp);
|
||||
convert(focus.getDesignation()), expParams, focus.getAbstract(), focus.getInactive(), filters, noInactive, false, vsProps, makeCSProps(focus.getExtensionString(ToolingExtensions.EXT_DEFINITION), null), null, focus.getProperty(), null, focus.getExtension(), exp);
|
||||
if (np == null) {
|
||||
np = t;
|
||||
}
|
||||
|
@ -483,7 +505,7 @@ public class ValueSetExpander extends ValueSetProcessBase {
|
|||
boolean dep = CodeSystemUtilities.isDeprecated(cs, def, false);
|
||||
if ((includeAbstract || !abs) && filterFunc.includeConcept(cs, def) && passesOtherFilters(otherFilters, cs, def.getCode())) {
|
||||
for (String code : getCodesForConcept(def, expParams)) {
|
||||
ValueSetExpansionContainsComponent t = addCode(wc, system, code, def.getDisplay(), cs.getLanguage(), parent, def.getDesignation(), expParams, abs, inc, filters, noInactive, dep, vsProps, makeCSProps(def.getDefinition(), def.getProperty()), null, def.getExtension(), null, exp);
|
||||
ValueSetExpansionContainsComponent t = addCode(wc, system, code, def.getDisplay(), cs.getLanguage(), parent, def.getDesignation(), expParams, abs, inc, filters, noInactive, dep, vsProps, makeCSProps(def.getDefinition(), def.getProperty()), cs, null, def.getExtension(), null, exp);
|
||||
if (np == null) {
|
||||
np = t;
|
||||
}
|
||||
|
@ -612,6 +634,7 @@ public class ValueSetExpander extends ValueSetProcessBase {
|
|||
} catch (ETooCostly e) {
|
||||
return new ValueSetExpansionOutcome(e.getMessage(), TerminologyServiceErrorClass.TOO_COSTLY, allErrors, false);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// well, we couldn't expand, so we'll return an interface to a checker that can check membership of the set
|
||||
// that might fail too, but it might not, later.
|
||||
return new ValueSetExpansionOutcome(e.getMessage(), TerminologyServiceErrorClass.UNKNOWN, allErrors, e instanceof EFhirClientException || e instanceof TerminologyServiceException);
|
||||
|
@ -912,7 +935,7 @@ public class ValueSetExpander extends ValueSetProcessBase {
|
|||
for (ValueSetExpansionContainsComponent c : list) {
|
||||
c.checkNoModifiers("Imported Expansion in Code System", "expanding");
|
||||
ValueSetExpansionContainsComponent np = addCode(dwc, c.getSystem(), c.getCode(), c.getDisplay(), vsSrc.getLanguage(), parent, null, expParams, c.getAbstract(), c.getInactive(),
|
||||
filter, noInactive, false, vsProps, makeCSProps(c.getExtensionString(ToolingExtensions.EXT_DEFINITION), null), c.getProperty(), null, c.getExtension(), exp);
|
||||
filter, noInactive, false, vsProps, makeCSProps(c.getExtensionString(ToolingExtensions.EXT_DEFINITION), null), null, c.getProperty(), null, c.getExtension(), exp);
|
||||
copyImportContains(c.getContains(), np, expParams, filter, noInactive, vsProps, vsSrc, exp);
|
||||
}
|
||||
}
|
||||
|
@ -1045,7 +1068,7 @@ public class ValueSetExpander extends ValueSetProcessBase {
|
|||
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);
|
||||
expParams, isAbstract, inactive, imports, noInactive, false, exp.getProperty(), makeCSProps(def.getDefinition(), def.getProperty()), cs, null, def.getExtension(), c.getExtension(), exp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1109,7 +1132,7 @@ public class ValueSetExpander extends ValueSetProcessBase {
|
|||
for (String code : getCodesForConcept(def, expParams)) {
|
||||
opContext.deadCheck();
|
||||
ValueSetExpansionContainsComponent t = addCode(wc, inc.getSystem(), code, def.getDisplay(), cs.getLanguage(), null, def.getDesignation(), expParams, CodeSystemUtilities.isNotSelectable(cs, def), CodeSystemUtilities.isInactive(cs, def),
|
||||
imports, noInactive, false, exp.getProperty(), makeCSProps(def.getDefinition(), def.getProperty()), null, def.getExtension(), null, exp);
|
||||
imports, noInactive, false, exp.getProperty(), makeCSProps(def.getDefinition(), def.getProperty()), cs, null, def.getExtension(), null, exp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -630,6 +630,7 @@ public class I18nConstants {
|
|||
public static final String VALIDATION_VAL_PROFILE_MATCHMULTIPLE = "Validation_VAL_Profile_MatchMultiple";
|
||||
public static final String VALIDATION_VAL_PROFILE_MAXIMUM = "Validation_VAL_Profile_Maximum";
|
||||
public static final String VALIDATION_VAL_PROFILE_MINIMUM = "Validation_VAL_Profile_Minimum";
|
||||
public static final String VALIDATION_VAL_PROFILE_MINIMUM_SLICE = "Validation_VAL_Profile_Minimum_SLICE";
|
||||
public static final String VALIDATION_VAL_PROFILE_MINIMUM_MAGIC = "VALIDATION_VAL_PROFILE_MINIMUM_MAGIC";
|
||||
public static final String VALIDATION_VAL_PROFILE_MULTIPLEMATCHES = "Validation_VAL_Profile_MultipleMatches";
|
||||
public static final String VALIDATION_VAL_PROFILE_NOCHECKMAX = "Validation_VAL_Profile_NoCheckMax";
|
||||
|
@ -1042,6 +1043,7 @@ public class I18nConstants {
|
|||
public static final String XHTML_IDREF_NOT_MULTIPLE_MATCHES = "XHTML_IDREF_NOT_MULTIPLE_MATCHES";
|
||||
public static final String SD_CONTEXT_SHOULD_NOT_BE_FHIRPATH = "SD_CONTEXT_SHOULD_NOT_BE_FHIRPATH";
|
||||
public static final String TX_GENERAL_CC_ERROR_MESSAGE = "TX_GENERAL_CC_ERROR_MESSAGE";
|
||||
public static final String FHIRPATH_UNKNOWN_EXTENSION = "FHIRPATH_UNKNOWN_EXTENSION";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -101,14 +101,24 @@ public class TxTesterSorters {
|
|||
|
||||
@Override
|
||||
public int compare(ValueSetExpansionPropertyComponent o1, ValueSetExpansionPropertyComponent o2) {
|
||||
int i = o1.getUri().compareTo(o2.getUri());
|
||||
int i;
|
||||
if (o1.getUri() == null || o2.getUri() == null) {
|
||||
if (o1.getUri() == null && o2.getUri() == null) {
|
||||
i = 0;
|
||||
} else if (o1.getUri() == null) {
|
||||
i = -1;
|
||||
} else {
|
||||
i = 1;
|
||||
}
|
||||
} else {
|
||||
i = o1.getUri().compareTo(o2.getUri());
|
||||
}
|
||||
if (i == 0) {
|
||||
return o1.getCode().compareTo(o2.getCode());
|
||||
} else {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class ExtensionSorter implements Comparator<Extension> {
|
||||
|
|
Loading…
Reference in New Issue