Merge pull request #880 from hapifhir/gg-202207-vs-validation

Gg 202207 vs validation
This commit is contained in:
Grahame Grieve 2022-07-26 06:43:59 +10:00 committed by GitHub
commit 15bfd84da9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 63 additions and 19 deletions

View File

@ -17,12 +17,15 @@ import org.hl7.fhir.r5.model.Bundle.BundleEntrySearchComponent;
import org.hl7.fhir.r5.model.Bundle.BundleType;
import org.hl7.fhir.r5.model.Composition;
import org.hl7.fhir.r5.model.Composition.SectionComponent;
import org.hl7.fhir.r5.model.Narrative.NarrativeStatus;
import org.hl7.fhir.r5.model.DomainResource;
import org.hl7.fhir.r5.model.Property;
import org.hl7.fhir.r5.model.Provenance;
import org.hl7.fhir.r5.model.Reference;
import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.StructureDefinition;
import org.hl7.fhir.r5.renderers.utils.BaseWrappers.BaseWrapper;
import org.hl7.fhir.r5.renderers.utils.BaseWrappers.PropertyWrapper;
import org.hl7.fhir.r5.renderers.utils.BaseWrappers.ResourceWrapper;
import org.hl7.fhir.r5.renderers.utils.RenderingContext;
import org.hl7.fhir.r5.renderers.utils.Resolver.ResourceContext;
@ -205,6 +208,10 @@ public class BundleRenderer extends ResourceRenderer {
}
}
x.hr();
if (!comp.getText().hasDiv()) {
ResourceRenderer rr = RendererFactory.factory(comp, getContext());
rr.render(comp);
}
if (comp.getText().hasDiv()) {
x.addChildren(comp.getText().getDiv());
x.hr();

View File

@ -676,23 +676,29 @@ public class ValueSetCheckerSimple extends ValueSetWorker implements ValueSetChe
}
private Boolean inComponent(ConceptSetComponent vsi, int vsiIndex, String system, String code, boolean only, List<String> warnings) throws FHIRException {
if (isValueSetUnionImports()) {
for (UriType uri : vsi.getValueSet()) {
if (inImport(uri.getValue(), system, code)) {
return true;
boolean ok = true;
if (vsi.hasValueSet()) {
if (isValueSetUnionImports()) {
ok = false;
for (UriType uri : vsi.getValueSet()) {
if (inImport(uri.getValue(), system, code)) {
return true;
}
}
}
} else {
for (UriType uri : vsi.getValueSet()) {
if (!inImport(uri.getValue(), system, code)) {
return false;
} else {
ok = inImport(vsi.getValueSet().get(0).getValue(), system, code);
for (int i = 1; i < vsi.getValueSet().size(); i++) {
UriType uri = vsi.getValueSet().get(i);
ok = ok && inImport(uri.getValue(), system, code);
}
}
}
if (!vsi.hasSystem()) {
return false;
if (!vsi.hasSystem() || !ok) {
return ok;
}
if (only && system == null) {
// whether we know the system or not, we'll accept the stated codes at face value
for (ConceptReferenceComponent cc : vsi.getConcept()) {
@ -726,18 +732,16 @@ public class ValueSetCheckerSimple extends ValueSetWorker implements ValueSetChe
return res.isOk();
} else {
if (vsi.hasFilter()) {
boolean ok = true;
ok = true;
for (ConceptSetFilterComponent f : vsi.getFilter()) {
if (!codeInFilter(cs, system, f, code)) {
ok = false;
break;
return false;
}
}
return ok;
}
List<ConceptDefinitionComponent> list = cs.getConcept();
boolean ok = validateCodeInConceptList(code, cs, list);
ok = validateCodeInConceptList(code, cs, list);
if (ok && vsi.hasConcept()) {
for (ConceptReferenceComponent cc : vsi.getConcept()) {
if (cc.getCode().equals(code)) {

View File

@ -1880,7 +1880,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
if (!ok) {
if (definition.hasUserData(XVerExtensionManager.XVER_EXT_MARKER)) {
warning(errors, IssueType.STRUCTURE, container.line(), container.col(), stack.getLiteralPath(), false,
modifier ? I18nConstants.EXTENSION_EXTM_CONTEXT_WRONG_XVER : I18nConstants.EXTENSION_EXTP_CONTEXT_WRONG_XVER, extUrl, contexts.toString(), plist.toString());
modifier ? I18nConstants.EXTENSION_EXTP_CONTEXT_WRONG_XVER : I18nConstants.EXTENSION_EXTM_CONTEXT_WRONG_XVER, extUrl, contexts.toString(), plist.toString());
} else {
rule(errors, IssueType.STRUCTURE, container.line(), container.col(), stack.getLiteralPath(), false,
modifier ? I18nConstants.EXTENSION_EXTP_CONTEXT_WRONG : I18nConstants.EXTENSION_EXTM_CONTEXT_WRONG, extUrl, contexts.toString(), plist.toString());
@ -2164,8 +2164,9 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
}
if (url != null && url.startsWith("urn:oid:")) {
String cc = url.substring(8);
// OIDs shorter than 5 chars are almost never valid for namespaces, except for the special OID 1.3.88
rule(errors, IssueType.INVALID, e.line(), e.col(), path, Utilities.isOid(cc) && (cc.lastIndexOf('.') >= 5 || "1.3.88".equals(cc)), I18nConstants.TYPE_SPECIFIC_CHECKS_DT_OID_VALID, cc);
// OIDs shorter than 5 chars are almost never valid for namespaces, except for the special OIDs 1.3.88 and 1.3.160
rule(errors, IssueType.INVALID, e.line(), e.col(), path, Utilities.isOid(cc) && (cc.lastIndexOf('.') >= 5 ||
Utilities.existsInList(cc, "1.3.160", "1.3.88")), I18nConstants.TYPE_SPECIFIC_CHECKS_DT_OID_VALID, cc);
}
if (isCanonicalURLElement(e)) {

View File

@ -352,3 +352,24 @@ v: {
"system" : "http://snomed.info/sct"
}
-------------------------------------------------------------------------------------
{"code" : {
"system" : "http://snomed.info/sct",
"code" : "17621005",
"display" : "Normal (qualifier value)"
}, "url": "http://hl7.org/fhir/ValueSet/security-labels", "version": "3.0.2", "lang":"null", "useServer":"true", "useClient":"true", "guessSystem":"false", "valueSetMode":"NO_MEMBERSHIP_CHECK", "versionFlexible":"false"}####
v: {
"display" : "Normal",
"code" : "17621005",
"system" : "http://snomed.info/sct"
}
-------------------------------------------------------------------------------------
{"code" : {
"system" : "http://snomed.info/sct",
"code" : "17621005"
}, "valueSet" :null, "lang":"null", "useServer":"true", "useClient":"true", "guessSystem":"false", "valueSetMode":"ALL_CHECKS", "versionFlexible":"false"}####
v: {
"display" : "Normal",
"code" : "17621005",
"system" : "http://snomed.info/sct"
}
-------------------------------------------------------------------------------------

View File

@ -1854,3 +1854,14 @@ v: {
"system" : "http://snomed.info/sct"
}
-------------------------------------------------------------------------------------
{"code" : {
"system" : "http://snomed.info/sct",
"code" : "17621005",
"display" : "Normal (qualifier value)"
}, "url": "http://hl7.org/fhir/ValueSet/security-labels", "version": "4.0.1", "lang":"null", "useServer":"true", "useClient":"true", "guessSystem":"false", "valueSetMode":"NO_MEMBERSHIP_CHECK", "versionFlexible":"false"}####
v: {
"display" : "Normal",
"code" : "17621005",
"system" : "http://snomed.info/sct"
}
-------------------------------------------------------------------------------------