fix problem where slicing depends on inner slicing

This commit is contained in:
Grahame Grieve 2019-05-22 11:13:47 +10:00
parent c5ace67136
commit 4e0c33755e
5 changed files with 4883 additions and 12 deletions

View File

@ -4123,10 +4123,18 @@ public class FHIRPathEngine {
ElementDefinition focus = null;
if (expr.getKind() == Kind.Name) {
if (element.hasSlicing()) {
ElementDefinition slice = pickMandatorySlice(sd, element);
if (slice == null)
throw new DefinitionException("Error in discriminator at "+element.getId()+": found a sliced element while resolving the fixed value for one of the slices");
element = slice;
}
List<ElementDefinition> childDefinitions;
childDefinitions = ProfileUtilities.getChildMap(sd, element);
// if that's empty, get the children of the type
if (childDefinitions.isEmpty()) {
sd = fetchStructureByType(element);
if (sd == null)
throw new DefinitionException("Problem with use of resolve() - profile '"+element.getType().get(0).getProfile()+"' on "+element.getId()+" could not be resolved");
@ -4181,10 +4189,21 @@ public class FHIRPathEngine {
throw new DefinitionException("Unable to resolve discriminator");
else if (expr.getInner() == null)
return focus;
else
else {
return evaluateDefinition(expr.getInner(), sd, focus);
}
}
private ElementDefinition pickMandatorySlice(StructureDefinition sd, ElementDefinition element) throws DefinitionException {
List<ElementDefinition> list = ProfileUtilities.getSliceList(sd, element);
for (ElementDefinition ed : list) {
if (ed.getMin() > 0)
return ed;
}
return null;
}
private StructureDefinition fetchStructureByType(ElementDefinition ed) throws DefinitionException {
if (ed.getType().size() == 0)
throw new DefinitionException("Error in discriminator at "+ed.getId()+": no children, no type");
@ -4192,8 +4211,6 @@ public class FHIRPathEngine {
throw new DefinitionException("Error in discriminator at "+ed.getId()+": no children, multiple types");
if (ed.getType().get(0).getProfile().size() > 1)
throw new DefinitionException("Error in discriminator at "+ed.getId()+": no children, multiple type profiles");
if (ed.hasSlicing())
throw new DefinitionException("Error in discriminator at "+ed.getId()+": slicing found");
if (ed.getType().get(0).hasProfile())
return worker.fetchResource(StructureDefinition.class, ed.getType().get(0).getProfile().get(0).getValue());
else

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,149 @@
{
"resourceType": "Observation",
"id": "blood-pressure",
"meta": {
"profile": [
"http://hl7.org/fhir/StructureDefinition/vitalsigns"
]
},
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p><b>Generated Narrative with Details</b></p><p><b>id</b>: blood-pressure</p><p><b>meta</b>: </p><p><b>identifier</b>: urn:uuid:187e0c12-8dd2-67e2-99b2-bf273c878281</p><p><b>basedOn</b>: </p><p><b>status</b>: final</p><p><b>category</b>: Vital Signs <span>(Details : {http://terminology.hl7.org/CodeSystem/observation-category code 'vital-signs' = 'Vital Signs', given as 'Vital Signs'})</span></p><p><b>code</b>: Blood pressure systolic &amp; diastolic <span>(Details : {LOINC code '85354-9' = 'Blood pressure panel with all children optional', given as 'Blood pressure panel with all children optional'})</span></p><p><b>subject</b>: <a>Patient/example</a></p><p><b>effective</b>: 17/09/2012</p><p><b>performer</b>: <a>Practitioner/example</a></p><p><b>interpretation</b>: Below low normal <span>(Details : {http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation code 'L' = 'Low', given as 'low'})</span></p><p><b>bodySite</b>: Right arm <span>(Details : {SNOMED CT code '368209003' = 'Right upper arm', given as 'Right arm'})</span></p><blockquote><p><b>component</b></p><p><b>code</b>: Systolic blood pressure <span>(Details : {LOINC code '8480-6' = 'Systolic blood pressure', given as 'Systolic blood pressure'}; {SNOMED CT code '271649006' = 'Systolic blood pressure', given as 'Systolic blood pressure'}; {http://acme.org/devices/clinical-codes code 'bp-s' = 'bp-s', given as 'Systolic Blood pressure'})</span></p><p><b>value</b>: 107 mmHg<span> (Details: UCUM code mm[Hg] = 'mmHg')</span></p><p><b>interpretation</b>: Normal <span>(Details : {http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation code 'N' = 'Normal', given as 'normal'})</span></p></blockquote><blockquote><p><b>component</b></p><p><b>code</b>: Diastolic blood pressure <span>(Details : {LOINC code '8462-4' = 'Diastolic blood pressure', given as 'Diastolic blood pressure'})</span></p><p><b>value</b>: 60 mmHg<span> (Details: UCUM code mm[Hg] = 'mmHg')</span></p><p><b>interpretation</b>: Below low normal <span>(Details : {http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation code 'L' = 'Low', given as 'low'})</span></p></blockquote></div>"
},
"identifier": [
{
"system": "urn:ietf:rfc:3986",
"value": "urn:uuid:187e0c12-8dd2-67e2-99b2-bf273c878281"
}
],
"basedOn": [
{
"identifier": {
"system": "https://acme.org/identifiers",
"value": "1234"
}
}
],
"status": "final",
"category": [
{
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/observation-category",
"code": "vital-signs",
"display": "Vital Signs"
}
]
}
],
"code": {
"coding": [
{
"system": "http://loinc.org",
"code": "85354-9",
"display": "Blood pressure panel with all children optional"
}
],
"text": "Blood pressure systolic & diastolic"
},
"subject": {
"reference": "Patient/example"
},
"effectiveDateTime": "2012-09-17",
"performer": [
{
"reference": "Practitioner/example"
}
],
"interpretation": [
{
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation",
"code": "L",
"display": "low"
}
],
"text": "Below low normal"
}
],
"bodySite": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "368209003",
"display": "Right arm"
}
]
},
"component": [
{
"code": {
"coding": [
{
"system": "http://loinc.org",
"code": "8480-6",
"display": "Systolic blood pressure"
},
{
"system": "http://snomed.info/sct",
"code": "271649006",
"display": "Systolic blood pressure"
},
{
"system": "http://acme.org/devices/clinical-codes",
"code": "bp-s",
"display": "Systolic Blood pressure"
}
]
},
"valueQuantity": {
"value": 107,
"unit": "mmHg",
"system": "http://unitsofmeasure.org",
"code": "mm[Hg]"
},
"interpretation": [
{
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation",
"code": "N",
"display": "normal"
}
],
"text": "Normal"
}
]
},
{
"code": {
"coding": [
{
"system": "http://loinc.org",
"code": "8462-4",
"display": "Diastolic blood pressure"
}
]
},
"valueQuantity": {
"value": 60,
"unit": "mmHg",
"system": "http://unitsofmeasure.org",
"code": "mm[Hg]"
},
"interpretation": [
{
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation",
"code": "L",
"display": "low"
}
],
"text": "Below low normal"
}
]
}
]
}

View File

@ -144,6 +144,14 @@
"medication-atc.json" : {
"errorCount": 1,
"allowed-extension-domain" : "https://api-v8-r4.hspconsortium.org/DrugFormulary0/open"
},
"bp.json" : {
"errorCount": 0,
"warningCount": 1,
"profile" : {
"source" : "bp-profile.xml",
"errorCount": 0
}
}
},
"Xml": {
@ -480,13 +488,7 @@
}
},
"observation-bp-validationfails.xml" : {
"errorCount": 4,
"errors": [
"ERROR: Observation.component[1]: Error in discriminator at Observation.component:SystolicBP.code.coding: slicing found",
"ERROR: Observation.component[2]: Error in discriminator at Observation.component:SystolicBP.code.coding: slicing found",
"ERROR: Observation.component[1]: Error in discriminator at Observation.component:DiastolicBP.code.coding: slicing found",
"ERROR: Observation.component[2]: Error in discriminator at Observation.component:DiastolicBP.code.coding: slicing found"
]
"errorCount": 0
},
"observation-bp.xml" : {
"errorCount": 0,

View File

@ -2,11 +2,11 @@ REM replace versions before running
REM make sure you are committed
@echo off
echo
echo ..
echo =====================================================================
echo upgrade and release fhir.core from 3.7.34-SNAPSHOT to 3.7.35-SNAPSHOT
echo =====================================================================
echo
echo ..
echo check versions and make sure committed...
pause