Fix R4 vital signs issue with component units

This commit is contained in:
Grahame Grieve 2024-05-25 15:11:27 -05:00
parent 42a6abbf44
commit 56b0ad11f3
1 changed files with 17 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package org.hl7.fhir.r5.utils;
import org.hl7.fhir.r5.context.CanonicalResourceManager.CanonicalResourceProxy;
import org.hl7.fhir.r5.model.ElementDefinition;
import org.hl7.fhir.r5.model.Enumerations.BindingStrength;
import org.hl7.fhir.r5.model.PackageInformation;
import org.hl7.fhir.r5.model.StructureDefinition;
@ -60,6 +61,22 @@ public class PackageHackerR5 {
}
}
}
if (r.getUrl() != null && r.getUrl().startsWith("http://hl7.org/fhir/StructureDefinition/") && "StructureDefinition".equals(r.getType()) && "4.0.1".equals(r.getVersion())) {
// the R4 profile wrongly applies this value set to all types. Fixing it properly is too big a thing to do here, but we can at least back off the binding strength
StructureDefinition sd = (StructureDefinition) r.getResource();
if (sd.getType().equals("Observation") && ("http://hl7.org/fhir/StructureDefinition/vitalsigns".equals(sd.getUrl()) || "http://hl7.org/fhir/StructureDefinition/vitalsigns".equals(sd.getBaseDefinition()))) {
for (ElementDefinition ed : sd.getSnapshot().getElement()) {
if (ed.getPath().equals("Observation.component.value[x]") && ed.hasBinding() && "http://hl7.org/fhir/ValueSet/ucum-vitals-common|4.0.1".equals(ed.getBinding().getValueSet())) {
ed.getBinding().setStrength(BindingStrength.EXTENSIBLE);
}
}
for (ElementDefinition ed : sd.getDifferential().getElement()) {
if (ed.getPath().equals("Observation.component.value[x]") && ed.hasBinding() && "http://hl7.org/fhir/ValueSet/ucum-vitals-common|4.0.1".equals(ed.getBinding().getValueSet())) {
ed.getBinding().setStrength(BindingStrength.EXTENSIBLE);
}
}
}
}
if (r.hasUrl() && r.getUrl().contains("|")) {
assert false;
}