Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Deserialisation of Primitive Values in Extensions #767

Closed
RaffaelBild opened this issue Jul 8, 2022 · 2 comments
Closed

Fix Deserialisation of Primitive Values in Extensions #767

RaffaelBild opened this issue Jul 8, 2022 · 2 comments
Assignees
Labels
bug Something isn't working module:fhir-structure
Milestone

Comments

@RaffaelBild
Copy link

Hello,

I am receiving unexpected results when I try to create a Patient resource with a certain extension on the Blaze server. The command I've executed to create the resource is
curl -H "Content-Type: application/fhir+json" -d @patient.json https://{BASE_URL}/Patient
with the file patient.json containing the following resource:

{
        "resourceType": "Patient",
        "extension": [
                {
                        "url": "https://www.netzwerk-universitaetsmedizin.de/fhir/StructureDefinition/age",
                        "extension": [
                                {
                                        "url": "dateTimeOfDocumentation",
                                        "_valueDateTime": {
                                                "extension": [
                                                        {
                                                                "url": "http://hl7.org/fhir/StructureDefinition/data-absent-reason",
                                                                "valueCode": "unknown"
                                                        }
                                                ]
                                        }
                                },
                                {
                                        "url": "age",
                                        "valueAge": {
                                                "value": 135.52,
                                                "unit": "years",
                                                "system": "http://unitsofmeasure.org",
                                                "code": "a"
                                        }
                                }
                        ]
                }
        ]
}

The result varies depending on the version of Blaze being used:

  • When using the image samply/blaze:0.16 I receive the response
    {"meta":{"versionId":"3","lastUpdated":"2022-07-08T07:43:31.733Z"},"resourceType":"Patient","extension":[{"extension":[{"url":"dateTimeOfDocumentation"},{"url":"age","valueAge":{"system":"http://unitsofmeasure.org","unit":"years","value":135.52,"code":"a"}}],"url":"https://www.netzwerk-universitaetsmedizin.de/fhir/StructureDefinition/age"}],"id":"DAO4YOFUWCD7FEPY"}
    When I then query the newly created resource via a GET request to https://{BASE_URL}/fhir/Patient/DAO4YOFUWCD7FEPY, I obtain the following:
{
    "meta": {
        "versionId": "3",
        "lastUpdated": "2022-07-08T07:43:31.733Z"
    },
    "resourceType": "Patient",
    "extension": [
        {
            "extension": [
                {
                    "url": "dateTimeOfDocumentation"
                },
                {
                    "url": "age",
                    "valueAge": {
                        "system": "http://unitsofmeasure.org",
                        "unit": "years",
                        "value": 135.52,
                        "code": "a"
                    }
                }
            ],
            "url": "https://www.netzwerk-universitaetsmedizin.de/fhir/StructureDefinition/age"
        }
    ],
    "id": "DAO4YOFUWCD7FEPY"
}

As can be seen, the extension included in the resource returned differs from the extension in the original resource, which is not what I would have expected.

  • When using the image samply/blaze:0.17 I get an issue with severity "error" as a reply from the server and see the following in the logs of the docker container running Blaze (with log level set to debug):
2022-07-08T07:30:13.803Z 6d3362f6db6a resource-store-kv-2 ERROR [blaze.handler.util:138] -
                                         java.lang.Thread.run              Thread.java:  833
           java.util.concurrent.ThreadPoolExecutor$Worker.run  ThreadPoolExecutor.java:  635
            java.util.concurrent.ThreadPoolExecutor.runWorker  ThreadPoolExecutor.java: 1136
       java.util.concurrent.CompletableFuture$AsyncSupply.run   CompletableFuture.java: 1768
                                  blaze.async.comp//reify/get                 comp.clj:  141
            blaze.db.resource-store.kv/get-and-parse-async/fn                   kv.clj:   94
                     blaze.db.resource-store.kv/get-and-parse                   kv.clj:   90
            blaze.db.resource-store.kv/parse-and-conform-cbor                   kv.clj:   73
                      blaze.db.resource-store.kv/conform-cbor                   kv.clj:   62
                                 blaze.fhir.spec/conform-cbor                 spec.clj:   75
                                   clojure.alpha.spec/conform                 spec.clj:  241
                                   clojure.alpha.spec/conform                 spec.clj:  245
         clojure.alpha.spec.impl/and-spec-impl/reify/conform*                 impl.clj:  910
                     clojure.alpha.spec.impl/and-spec-impl/fn                 impl.clj:  888
           clojure.alpha.spec.impl/schema-impl/reify/conform*                 impl.clj:  435
            clojure.alpha.spec.impl/every-impl/reify/conform*                 impl.clj: 1087
   blaze.fhir.spec.impl.specs/json-object-impl/reify/conform*                specs.clj:  262
                                       clojure.core/reduce-kv                 core.clj: 6919
                                  clojure.core.protocols/fn/G            protocols.clj:  175
                                              clojure.core/fn                 core.clj: 6908
                                                          ...
         blaze.fhir.spec.impl.specs/json-object-impl/reify/fn                specs.clj:  264
            clojure.alpha.spec.impl/every-impl/reify/conform*                 impl.clj: 1087
   blaze.fhir.spec.impl.specs/json-object-impl/reify/conform*                specs.clj:  262
                                       clojure.core/reduce-kv                 core.clj: 6919
                                  clojure.core.protocols/fn/G            protocols.clj:  175
                                              clojure.core/fn                 core.clj: 6908
                                                          ...
         blaze.fhir.spec.impl.specs/json-object-impl/reify/fn                specs.clj:  264
blaze.fhir.spec.impl.specs/cbor-primitive-impl/reify/conform*                specs.clj:  171
                                   blaze.fhir.spec.type/fn/fn                 type.clj:  806
                   blaze.fhir.spec.type/parse-date-time-value                 type.clj:  782
                 blaze.fhir.spec.type.system/parse-date-time*               system.clj:  416
                                         java.time.Year.parse                Year.java:  279
                                         java.time.Year.parse                Year.java:  294
                     java.time.format.DateTimeFormatter.parse   DateTimeFormatter.java: 1951
                             java.util.Objects.requireNonNull             Objects.java:  233
java.lang.NullPointerException: text

Jul 08, 2022 7:30:13 AM com.github.benmanes.caffeine.cache.LocalAsyncCache lambda$handleCompletion$7
WARNING: Exception thrown during asynchronous load
java.util.concurrent.CompletionException: java.lang.NullPointerException: text
       at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315)
       at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320)
       at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1770)
       at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
       at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
       at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.NullPointerException: text
       at java.base/java.util.Objects.requireNonNull(Objects.java:233)
       at java.base/java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1951)
       at java.base/java.time.Year.parse(Year.java:294)
       at java.base/java.time.Year.parse(Year.java:279)
       at blaze.fhir.spec.type.system$parse_date_time_STAR_.invokeStatic(system.clj:416)
       at blaze.fhir.spec.type.system$parse_date_time_STAR_.invoke(system.clj:407)
       at blaze.fhir.spec.type$parse_date_time_value.invokeStatic(type.clj:782)
       at blaze.fhir.spec.type$parse_date_time_value.invoke(type.clj:780)
       at blaze.fhir.spec.type$fn__16256$fn__16257.invoke(type.clj:806)
       at blaze.fhir.spec.impl.specs$cbor_primitive_impl$reify__18854.conform_STAR_(specs.clj:171)
       at blaze.fhir.spec.impl.specs$json_object_impl$reify__18923$fn__18924.invoke(specs.clj:264)
       at clojure.lang.PersistentHashMap$NodeSeq.kvreduce(PersistentHashMap.java:1307)
       at clojure.lang.PersistentHashMap$BitmapIndexedNode.kvreduce(PersistentHashMap.java:802)
       at clojure.lang.PersistentHashMap.kvreduce(PersistentHashMap.java:236)
       at clojure.core$fn__8525.invokeStatic(core.clj:6908)
       at clojure.core$fn__8525.invoke(core.clj:6888)
       at clojure.core.protocols$fn__8257$G__8252__8266.invoke(protocols.clj:175)
       at clojure.core$reduce_kv.invokeStatic(core.clj:6919)
       at clojure.core$reduce_kv.invoke(core.clj:6910)
       at blaze.fhir.spec.impl.specs$json_object_impl$reify__18923.conform_STAR_(specs.clj:262)
       at clojure.alpha.spec.impl$every_impl$reify__13850.conform_STAR_(impl.clj:1087)
       at blaze.fhir.spec.impl.specs$json_object_impl$reify__18923$fn__18924.invoke(specs.clj:264)
       at clojure.lang.PersistentHashMap$NodeSeq.kvreduce(PersistentHashMap.java:1307)
       at clojure.lang.PersistentHashMap$BitmapIndexedNode.kvreduce(PersistentHashMap.java:802)
       at clojure.lang.PersistentHashMap.kvreduce(PersistentHashMap.java:236)
       at clojure.core$fn__8525.invokeStatic(core.clj:6908)
       at clojure.core$fn__8525.invoke(core.clj:6888)
       at clojure.core.protocols$fn__8257$G__8252__8266.invoke(protocols.clj:175)
       at clojure.core$reduce_kv.invokeStatic(core.clj:6919)
       at clojure.core$reduce_kv.invoke(core.clj:6910)
       at blaze.fhir.spec.impl.specs$json_object_impl$reify__18923.conform_STAR_(specs.clj:262)
       at clojure.alpha.spec.impl$every_impl$reify__13850.conform_STAR_(impl.clj:1087)
       at clojure.alpha.spec.impl$schema_impl$reify__13384.conform_STAR_(impl.clj:435)
       at clojure.alpha.spec.impl$and_spec_impl$fn__13698.invoke(impl.clj:888)
       at clojure.alpha.spec.impl$and_spec_impl$reify__13713.conform_STAR_(impl.clj:910)
       at clojure.alpha.spec$conform.invokeStatic(spec.clj:245)
       at clojure.alpha.spec$conform.invoke(spec.clj:237)
       at clojure.alpha.spec$conform.invokeStatic(spec.clj:241)
       at clojure.alpha.spec$conform.invoke(spec.clj:237)
       at blaze.fhir.spec$conform_cbor.invokeStatic(spec.clj:75)
       at blaze.fhir.spec$conform_cbor.invoke(spec.clj:65)
       at blaze.db.resource_store.kv$conform_cbor.invokeStatic(kv.clj:62)
       at blaze.db.resource_store.kv$conform_cbor.invoke(kv.clj:61)
       at blaze.db.resource_store.kv$parse_and_conform_cbor.invokeStatic(kv.clj:73)
       at blaze.db.resource_store.kv$parse_and_conform_cbor.invoke(kv.clj:70)
       at blaze.db.resource_store.kv$get_and_parse.invokeStatic(kv.clj:90)
       at blaze.db.resource_store.kv$get_and_parse.invoke(kv.clj:89)
       at blaze.db.resource_store.kv$get_and_parse_async$fn__27940.invoke(kv.clj:94)
       at blaze.async.comp$$reify__9476.get(comp.clj:141)
       at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768)
       ... 3 more

It would be excellent if there would be a way to successfully create the resource in a recent version of Blaze in such a way that it can then be retrieved with the extension preserved exactly as it was in the original resource.

@alexanderkiel alexanderkiel self-assigned this Jul 12, 2022
@alexanderkiel alexanderkiel added the bug Something isn't working label Jul 12, 2022
@alexanderkiel alexanderkiel added this to the v0.18 milestone Jul 12, 2022
@alexanderkiel alexanderkiel changed the title Unexpected results when creating a Patient resource with a certain extension Fix Deserialisation of Primitive Values in Extensions Jul 13, 2022
@alexanderkiel alexanderkiel modified the milestones: v0.18, v0.17.11 Jul 13, 2022
@alexanderkiel
Copy link
Member

HI @RaffaelBild thanks for reporting. If you have already imported your data, you have to start with an empty database, because the Blaze was storing the data wrong. If you like preserve your data, please file a new issue or contact me at chat.fhir.org.

@RaffaelBild
Copy link
Author

Thank you very much, all works as expected with v0.17.11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working module:fhir-structure
Projects
None yet
Development

No branches or pull requests

2 participants