awslabs / fhir-works-on-aws-deployment

A serverless implementation of the FHIR standard that enables users to focus more on their business needs/uniqueness rather than the FHIR specification
Apache License 2.0
298 stars 162 forks source link

[Bug] Observation resourceType saved as Patient resourceType in database #641

Closed archtryingtocode closed 1 year ago

archtryingtocode commented 2 years ago

Describe the bug A clear and concise description of what the bug is. In the self monitoring workflow, I have created a patient with a bundle request ( adding height, weight, allergy and condition). The resource types created in this case are working fine. I can see resourceTypes - Patient, Observation, Condition and Allergy etc properly created in the database.

Now I would like to add daily observations like glucose measurements. Sending a request with resourceType - Observation with a reference link to the Patient. I can see the request in the FWOA API Gateway contains resourceType - Observation but response contains resourceType-Patient. To Reproduce Steps to reproduce the behavior:

  1. Create Patient
  2. Post creation of Patient, add an observation ( glucose measurement) for that patient.
  3. resourceType in request = Observation
  4. resourceType in Response = Patient.

Expected behavior While adding observation the resourceType should be Observation with a reference link to Patient.

Sample Observation Request from API Gateway:

Request: {"resourceType":"Observation","id":"OBSSG202206250953","modifierExtension":[],"basedOn":[],"status":"final","category":[{"coding":[{"system":"http://terminology.hl7.org/CodeSystem/observation-category","code":"vital-signs","display":"Vital Signs"}]}],"code":{"coding":[{"system":"http://loinc.org","code":"76629-5","display":"Glucose [Moles/volume] in Blood"}]},"subject":{"reference":"2d35209b-2cb7-485c-be64-f8df53172bd1/OBSSG"},"encounter":{"reference":"encounter/OBSSG"},"effectiveDateTime":"2022-06-25T09:54:00.000+02:00","effectivePeriod":{"start":"2021-06-25T00:00:00.000+02:00"},"issued":"2022-06-25T07:53:50.828594Z","performer":[{"id":"2d35209b-2cb7-485c-be64-f8df53172bd1","type":"http://vCare.dk","display":"Overeating"},{"id":"2d35209b-2cb7-485c-be64-f8df53172bd1","type":"http://vCare.dk","display":"Carbs"}],"valueQuantity":{"id":"202206250953","value":122,"unit":"mg/dl","system":"http://unitsofmeasure.org","code":"mg/dl"},"valueString":"sdfsfsdef\n","valueRange" [TRUNCATED]

Response:

(c481b753-e62d-49f5-a56c-f1a5c6d35094) Endpoint response body before transformations: {"statusCode":201,"headers":{"content-type":"application/fhir+json; charset=utf-8","etag":"W/\"1\"","last-modified":"2022-06-25T07:55:11.313Z","content-length":"1598"},"isBase64Encoded":false,"body":"{\"resourceType\":\"Patient\",\"id\":\"ce133487-ee5e-4bba-a6d0-a9ade9d15ec5\",\"modifierExtension\":[],\"basedOn\":[],\"status\":\"final\",\"category\":[{\"coding\":[{\"system\":\"http://terminology.hl7.org/CodeSystem/observation-category\",\"code\":\"vital-signs\",\"display\":\"Vital Signs\"}]}],\"code\":{\"coding\":[{\"system\":\"http://loinc.org\",\"code\":\"76629-5\",\"display\":\"Glucose [Moles/volume] in Blood\"}]},\"subject\":{\"reference\":\"2d35209b-2cb7-485c-be64-f8df53172bd1/OBSSG\"},\"encounter\":{\"reference\":\"encounter/OBSSG\"},\"effectiveDateTime\":\"2022-06-25T09:54:00.000+02:00\",\"effectivePeriod\":{\"start\":\"2021-06-25T00:00:00.000+02:00\"},\"issued\":\"2022-06-25T07:53:50.828594Z\",\"performer\":[{\"id\":\"2d35209b-2cb7-485c-be64-f8df53172bd1\ [TRUNCATED]

ssvegaraju commented 2 years ago

Hi @archtryingtocode, I tried your steps to reproduce this behavior on our end, but was unable to get the same result of a resource type of Patient; I see the expected resource type of Observation. Could I ask what endpoint you are trying to hit when posting the observation resource, and, if you have tried retrieving the Observation by the returned id to see if it is properly created?

ssvegaraju commented 2 years ago

HI @archtryingtocode, just wanted to update that I believe this is related to this issue: #682. We have published a new version with a fix for this as of v5.1.0 or v3.1.0-smart. Hope this helps!