ahdis / matchbox

Apache License 2.0
28 stars 20 forks source link

FML: Side effect exception when updating a StructureMap #227

Closed oliveregger closed 6 months ago

oliveregger commented 6 months ago

when updating a specific StructureMap (till now only one known), the server returns an error:

it looks it is only dependent on the specific map (it does not happen with the cda/fhir maps)

either it was a "StructureMap" already uploaded?

map "http://fhir.ch/ig/ch-alis/StructureMap/Alis43ToBundle" = "Alis43ToBundle"

uses "http://hl7.org/fhir/StructureDefinition/Patient" alias Patient as source
uses "http://hl7.org/fhir/StructureDefinition/Patient" alias Patient as target

group MemberOf(source src : Patient, target tgt : Patient) {
//  src where gender.memberOf("http://hl7.org/fhir/ValueSet/administrative-gender") -> tgt.gender = 'male' "memberof";
    src where maritalStatus.memberOf("http://hl7.org/fhir/ValueSet/marital-status") -> tgt.gender = 'male' "memberof";
}
<OperationOutcome 
  xmlns="http://hl7.org/fhir">
  <issue>
    <severity value="error"/>
    <code value="processing"/>
    <diagnostics value="HAPI-0389: Failed to call access method: org.hl7.fhir.exceptions.FHIRException: Multiple matching extensions found for extension 'http://hl7.org/fhir/1.0/StructureDefinition/extension-ConceptMap.element.target.equivalence'"/>
  </issue>
</OperationOutcome>
oliveregger commented 6 months ago

Element.getExtensionString is the culprit

however it does come form every access to the server for StructureMap:

https://test.ahdis.ch/matchbox/fhir/StructureMap

probably because the render functionality is called? somehow we seem to have loaded the extension twice in the context.

oliveregger commented 6 months ago

problem is that R5ExtensionsLoader is trying to load newer /a additional ValueSets

ch.ahdis.matchbox.engine.exception.IgLoadException: Failed to load R5 specials at ch.ahdis.matchbox.MatchboxEngineSupport.getMatchboxEngineNotSynchronized(MatchboxEngineSupport.java:287) at ch.ahdis.fhir.hapi.jpa.validation.ImplementationGuideProviderR4.loadAll(ImplementationGuideProviderR4.java:240) at ch.ahdis.matchbox.spring.MatchboxEventListener.onApplicationEvent(MatchboxEventListener.java:35) at ch.ahdis.matchbox.spring.MatchboxEventListener.onApplicationEvent(MatchboxEventListener.java:1) at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:178) at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:171) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:149) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:451) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:384) at org.springframework.boot.context.event.EventPublishingRunListener.ready(EventPublishingRunListener.java:109) at org.springframework.boot.SpringApplicationRunListeners.lambda$ready$6(SpringApplicationRunListeners.java:80) at java.base/java.lang.Iterable.forEach(Iterable.java:75) at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:118) at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:112) at org.springframework.boot.SpringApplicationRunListeners.ready(SpringApplicationRunListeners.java:80) at org.springframework.boot.SpringApplication.run(SpringApplication.java:348) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1354) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343) at ca.uhn.fhir.jpa.starter.Application.main(Application.java:36) Caused by: org.hl7.fhir.exceptions.DefinitionException: Duplicate Resource http://hl7.org/fhir/ValueSet/all-languages of type ValueSet (existing version 4.0.1, new version 5.0.0) at org.hl7.fhir.r5.context.BaseWorkerContext.cacheResourceFromPackage(BaseWorkerContext.java:512) at org.hl7.fhir.r5.conformance.R5ExtensionsLoader.loadValueSet(R5ExtensionsLoader.java:190) at org.hl7.fhir.r5.conformance.R5ExtensionsLoader.registerTerminologies(R5ExtensionsLoader.java:179) at org.hl7.fhir.r5.conformance.R5ExtensionsLoader.loadR5SpecialTypes(R5ExtensionsLoader.java:141) at ch.ahdis.matchbox.MatchboxEngineSupport.getMatchboxEngineNotSynchronized(MatchboxEngineSupport.java:282)

oliveregger commented 6 months ago

Caused by: org.hl7.fhir.exceptions.FHIRException: Multiple matching extensions found for extension 'http://hl7.org/fhir/1.0/StructureDefinition/extension-ConceptMap.element.target.equivalence' at org.hl7.fhir.r5.model.Element.getExtensionString(Element.java:477) at org.hl7.fhir.convertors.conv40_50.resources40_50.ConceptMap40_50.convertConceptMapEquivalence(ConceptMap40_50.java:283) at org.hl7.fhir.convertors.conv40_50.resources40_50.ConceptMap40_50.convertTargetElementComponent(ConceptMap40_50.java:265) at org.hl7.fhir.convertors.conv40_50.resources40_50.ConceptMap40_50.convertSourceElementComponent(ConceptMap40_50.java:230) at org.hl7.fhir.convertors.conv40_50.resources40_50.ConceptMap40_50.convertConceptMapGroupComponent(ConceptMap40_50.java:192) at org.hl7.fhir.convertors.conv40_50.resources40_50.ConceptMap40_50.convertConceptMap(ConceptMap40_50.java:141) at org.hl7.fhir.convertors.conv40_50.resources40_50.Resource40_50.convertResource(Resource40_50.java:343)

oliveregger commented 6 months ago

"TargetElementComponent [code=urn:oid:2.16.756.5.30.1.129.1.4, relationship=Enumeration[equivalent]]"

oliveregger commented 6 months ago

coming actually from the StructureMap itself, directly out of the IG Publisher:

input/resources/structuremap/Alis43ToBundle.xml The modifier extension http://hl7.org/fhir/1.0/StructureDefinition/extension-ConceptMap.element.target.equivalence from FHIR version 1.0 is not allowed to be used at this point (allowed = e:ConceptMap.element.target; this element is [[BackboneElement, ConceptMap.group.element.target, StructureMap.contained/ConceptMap/serviceMap/.group.element.target]; this is a warning since contexts may be renamed between FHIR versions)

oliveregger commented 6 months ago
{
      "resourceType" : "ConceptMap",
      "id" : "serviceMap",
      "status" : "draft",
      "group" : [
        {
          "source" : "http://fhir.ch/ig/ch-alis",
          "target" : "http://hl7.org/fhir",
          "element" : [
            {
              "code" : "TARMED",
              "target" : [
                {
                  "modifierExtension" : [
                    {
                      "url" : "http://hl7.org/fhir/1.0/StructureDefinition/extension-ConceptMap.element.target.equivalence",
                      "valueCode" : "equivalent"
                    }
                  ],
                  "code" : "urn:oid:2.16.756.5.30.1.129.1.4",
                  "equivalence" : "equivalent"
                }
              ]
            },
            {
              "code" : "ICD10",
              "target" : [
                {
                  "modifierExtension" : [
                    {
                      "url" : "http://hl7.org/fhir/1.0/StructureDefinition/extension-ConceptMap.element.target.equivalence",
                      "valueCode" : "equivalent"
                    }
                  ],
                  "code" : "urn:oid:2.16.756.5.30.1.126.3.2",
                  "equivalence" : "equivalent"
                }
              ]
            }
          ]
        }
      ]