hapifhir / hapi-fhir

🔥 HAPI FHIR - Java API for HL7 FHIR Clients and Servers
http://hapifhir.io
Apache License 2.0
2.04k stars 1.33k forks source link

Meta security label not serialised #5235

Open Wpyh opened 1 year ago

Wpyh commented 1 year ago

Describe the bug Meta of a fhir resource (e.g. MedicationAdministration) gets serialised for Response. However, I can see only some fields of Meta such as id, profile and source gets serialised whereas Security is missed out. This prevents putting a security label (https://hl7.org/fhir/valueset-security-labels.html) for the contained resource in the List API.

To Reproduce Issue 1: Steps to reproduce the behavior:

  1. Create a Coding for Redacted security label (https://hl7.org/fhir/valueset-security-labels.html).
  2. Set this to a Meta data as Security.
  3. Set this Meta to a Domain Resource e.g. Medication Administration.
  4. Set this Resource to a Reference
  5. Set this Reference as an item of a ListResource
  6. Serialise this ListResource using FhirContext.forR4().newJsonParser().encodeResourceToString()

Expected behavior Issue 1: contained.meta holds a security field with system and code Example

"resource": {
                "resourceType": "MedicationAdministration",
                "id": "someId",
                "meta": {
                    "security": [
                        {
                            "system": "http://terminology.hl7.org/CodeSystem/v3-ObservationValue",
                            "code": "REDACTED",
                                                          "display": "redacted"
                        }
                    ]
                }
            }

Environment (please complete the following information):

Additional context See the comment to find a Maven project that demonstrates the bug in testing.

Wpyh commented 1 year ago

FYI, to give more detailed context, please find the attached for a simple test that you can run after unzipping. hapiFhirMetaTest.zip