gematik / ref-eRp-FD-Server

ARCHIVED - This project acts as reference implementation of main aspects of an e-prescription server designed by gematik.
Other
44 stars 3 forks source link

Receipt JSON deserialize problem #26

Closed pandalec closed 3 years ago

pandalec commented 3 years ago

Hi!

Attached is a JSON response from "Quittung erneut abrufen (get receipt)". Problem is that it is quite hard to deserialize the response because identifier is once a List<Identifier> and once an object Identifier.

First appearance:

entry.resource[0].identifier:

[...]
                "identifier": [
                    {
                        "system": "https://gematik.de/fhir/NamingSystem/PrescriptionID",
                        "value": "160.000.902.508.100.91"
                    },
                    {
                        "system": "https://gematik.de/fhir/NamingSystem/AccessCode",
                        "value": "2cb848a92883123d51d54de3dbc0c116a842b99bae734d0fe329cb580ada7d2f"
                    },
                    {
                        "system": "https://gematik.de/fhir/NamingSystem/Secret",
                        "value": "d9a5ad024dbe66854fbf64ab7f326ac22cfd73bbc225fa8284c65ad8b729fb62"
                    }
                ],
[...]

Second:

entry.resource[1].identifier:

[...]
                "identifier": {
                    "system": "https://gematik.de/fhir/NamingSystem/PrescriptionID",
                    "value": "160.000.902.508.100.91"
                },
[...]

Is this wanted or could this be a problem with the implementation? Otherwise it is not trivial to deserialize this JSON answer, at least in Java or C#.

BR parsi

GetReceipt_Response_2021-04-15_10-58-40.txt

Gematik-Entwicklung commented 3 years ago

Hi @parsifallo,

this is the expected behaviour. The two entries in the Bundle are two different resources, with two different profiles. The Task.identifier is implemented as Array, but the Bundle.identifier is implemented as single field.

We recommend to use some kind of class hierarchy in object oriented programming languages. Like Resource as base class and Task and Bundle derived from Resource. In non object oriented programming languages you can use some kind of enumeration or union with Task and Bundle as enum/union variants.

Best regards, gematik Dev-Team.

pandalec commented 3 years ago

Ok, thank you for clarifying!