ehrbase / openEHR_SDK

A SDK to facilitate the development of openEHR applications
Other
48 stars 27 forks source link

IllegalArgumentException while storing a composition with ITEM_TABLE #281

Closed subigre closed 2 years ago

subigre commented 3 years ago

Configuration information

{
  "ehrbase_version": "0.17.2",
  "openehr_sdk_version": "321ef09",
  "archie_version": "1.0.3",
  "jvm_version": "AdoptOpenJDK 11.0.11+9",
  "os_version": "Windows 10 amd64 10.0",
  "postgres_version": "PostgreSQL 11.5 on x86_64-pc-linux-musl, compiled by gcc (Alpine 8.3.0) 8.3.0, 64-bit"
}

Steps to reproduce

Create a composition using the following template and composition:

or executing the following test:

    @Test
    public void unmarshallComposition() throws IOException {
        String value = IOUtils.toString(CompositionTestDataCanonicalJson.CLINICAL_CONTENT_VALIDATION.getStream(), UTF_8);
        Composition expected = new CanonicalJson().unmarshal(value, Composition.class);

        RawJson rawJson = new RawJson();
        String json = rawJson.marshal(expected);
        Composition actual = rawJson.unmarshal(json, Composition.class);

        Assertions.assertEquals(expected, actual);
    }

Actual result

{
  "error": "DB inconsistency:java.lang.IllegalArgumentException: Could not resolve type id 'CLUSTER' as a subtype of `com.nedap.archie.rm.datastructures.Element`: Class `com.nedap.archie.rm.datastructures.Cluster` not subtype of `com.nedap.archie.rm.datastructures.Element`\n at [Source: (String)\"{\"archetype_node_id\":\"openEHR-EHR-COMPOSITION.validation_composition_test.v0\",\"_type\":\"COMPOSITION\",\"name\" : {\n    \"_type\" : \"DV_TEXT\",\n    \"value\" : \"Validation composition test\"},\"content\":[{\"name\":{\"value\":\"Action #1\",\"_type\":\"DV_TEXT\"},\"time\":{\"value\":\"2021-10-22T15:34:09.788+03:00\",\"_type\":\"DV_DATE_TIME\"},\"_type\":\"ACTION\",\"subject\":{\"_type\":\"PARTY_SELF\"},\"encoding\":{\"_type\":\"CODE_PHRASE\",\"code_string\":\"UTF-8\",\"terminology_id\":{\"_type\":\"TERMINOLOGY_ID\",\"value\":\"IANA_character-sets\"}},\"langua\"[truncated 17354 chars]; line: 3, column: 15813] (through reference chain: com.nedap.archie.rm.composition.Composition[\"content\"]->java.util.ArrayList[7]->com.nedap.archie.rm.composition.Evaluation[\"data\"]->com.nedap.archie.rm.datastructures.ItemTable[\"items\"]->java.util.ArrayList[0])",
  "status": "Bad Request"
}
java.lang.IllegalArgumentException: Could not resolve type id 'CLUSTER' as a subtype of `com.nedap.archie.rm.datastructures.Element`: Class `com.nedap.archie.rm.datastructures.Cluster` not subtype of `com.nedap.archie.rm.datastructures.Element`
 at [Source: (String)"{"archetype_node_id":"openEHR-EHR-COMPOSITION.validation_composition_test.v0","_type":"COMPOSITION","name" : {
    "_type" : "DV_TEXT",
    "value" : "Validation composition test"},"content":[{"_type":"OBSERVATION","archetype_details":{"archetype_id":{"qualified_rm_entity":"openEHR-EHR-OBSERVATION","domain_concept":"observation_test","rm_originator":"openEHR","rm_name":"EHR","rm_entity":"OBSERVATION","version_id":"0","value":"openEHR-EHR-OBSERVATION.observation_test.v0"},"rm_version":"1.0.1"},"a"[truncated 17354 chars]; line: 3, column: 9506] (through reference chain: com.nedap.archie.rm.composition.Composition["content"]->java.util.ArrayList[4]->com.nedap.archie.rm.composition.Evaluation["data"]->com.nedap.archie.rm.datastructures.ItemTable["items"]->java.util.ArrayList[0])

    at org.ehrbase.serialisation.dbencoding.RawJson.unmarshal(RawJson.java:58)
    at org.ehrbase.serialisation.dbencoding.RawJsonTest.unmarshallComposition(RawJsonTest.java:156)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
    at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
    at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
    at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
    at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
Caused by: com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Could not resolve type id 'CLUSTER' as a subtype of `com.nedap.archie.rm.datastructures.Element`: Class `com.nedap.archie.rm.datastructures.Cluster` not subtype of `com.nedap.archie.rm.datastructures.Element`
 at [Source: (String)"{"archetype_node_id":"openEHR-EHR-COMPOSITION.validation_composition_test.v0","_type":"COMPOSITION","name" : {
    "_type" : "DV_TEXT",
    "value" : "Validation composition test"},"content":[{"_type":"OBSERVATION","archetype_details":{"archetype_id":{"qualified_rm_entity":"openEHR-EHR-OBSERVATION","domain_concept":"observation_test","rm_originator":"openEHR","rm_name":"EHR","rm_entity":"OBSERVATION","version_id":"0","value":"openEHR-EHR-OBSERVATION.observation_test.v0"},"rm_version":"1.0.1"},"a"[truncated 17354 chars]; line: 3, column: 9506] (through reference chain: com.nedap.archie.rm.composition.Composition["content"]->java.util.ArrayList[4]->com.nedap.archie.rm.composition.Evaluation["data"]->com.nedap.archie.rm.datastructures.ItemTable["items"]->java.util.ArrayList[0])
    at com.fasterxml.jackson.databind.exc.InvalidTypeIdException.from(InvalidTypeIdException.java:43)
    at com.fasterxml.jackson.databind.DeserializationContext.invalidTypeIdException(DeserializationContext.java:1933)
    at com.fasterxml.jackson.databind.jsontype.impl.TypeDeserializerBase._findDeserializer(TypeDeserializerBase.java:199)
    at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer._deserializeTypedForId(AsPropertyTypeDeserializer.java:118)
    at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer.deserializeTypedFromObject(AsPropertyTypeDeserializer.java:105)
    at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeWithType(BeanDeserializerBase.java:1277)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer._deserializeFromArray(CollectionDeserializer.java:349)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:272)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:28)
    at com.fasterxml.jackson.databind.deser.impl.SetterlessProperty.deserializeAndSet(SetterlessProperty.java:134)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:324)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:225)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:197)
    at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer._deserializeTypedForId(AsPropertyTypeDeserializer.java:135)
    at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer.deserializeTypedFromObject(AsPropertyTypeDeserializer.java:105)
    at com.fasterxml.jackson.databind.deser.AbstractDeserializer.deserializeWithType(AbstractDeserializer.java:263)
    at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:138)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:324)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:225)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:197)
    at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer._deserializeTypedForId(AsPropertyTypeDeserializer.java:135)
    at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer.deserializeTypedFromObject(AsPropertyTypeDeserializer.java:105)
    at com.fasterxml.jackson.databind.deser.AbstractDeserializer.deserializeWithType(AbstractDeserializer.java:263)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer._deserializeFromArray(CollectionDeserializer.java:349)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:244)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:28)
    at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:129)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:324)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:225)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:197)
    at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer._deserializeTypedForId(AsPropertyTypeDeserializer.java:135)
    at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer.deserializeTypedFromObject(AsPropertyTypeDeserializer.java:105)
    at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeWithType(BeanDeserializerBase.java:1277)
    at com.fasterxml.jackson.databind.deser.impl.TypeWrappedDeserializer.deserialize(TypeWrappedDeserializer.java:74)
    at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:322)
    at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4593)
    at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3548)
    at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3516)
    at org.ehrbase.serialisation.dbencoding.RawJson.unmarshal(RawJson.java:56)
    ... 26 more

Expected result (Acceptance Criteria)

Definition of Done

wlad commented 2 years ago

is also covered by a robot test

# robot command to execute related test case(s)

robot -d results -i 281 robot/COMPOSITION_TESTS