hapifhir / hapi-fhir

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

Consent resource not searchable by patient property or error 500 #2360

Open cspielmann opened 3 years ago

cspielmann commented 3 years ago

Hello, I have a fancy behavior in the search of Consent resources.

Describe the bug a Consent resource is not found when querying it by Patient http://localhost:8880/hapi-fhir-jpaserver/fhir/Consent?patient=Patient%2F34373 replies with 0 results whereas a query by practitioner works and returns the Consent that is assigned to this patient and this practitioner.

To Reproduce Steps to reproduce the behavior:

  1. create a Consent resource as below
  2. query the resource by patient as http://localhost:8880/hapi-fhir-jpaserver/fhir/Consent?patient=Patient%2F34373 then re resource is not found
  3. query the resource by practitioner as _http://localhost:8880/hapi-fhir-jpaserver/fhir/Consent?actor=Practitioner%2F34371&_count=1000_ then the Consent resource is found and seen assigned to patient

Expected behavior Lookup by Patient (34373)

{
  "resourceType": "Bundle",
  "id": "ac70a1cb-cbd9-4de3-8fbb-845130971020",
  "meta": {
    "lastUpdated": "2021-02-05T14:39:53.438+01:00"
  },
  "type": "searchset",
  "total": 0,
  "link": [
    {
      "relation": "self",
      "url": "http://localhost:8080/hapi-fhir-jpaserver/fhir/Consent?patient=Patient%2F34373"
    }
  ]
}

Lookup by Practitioner 34371 We see that is replies with the consent assigned to patient (34373)

{
    "resourceType": "Bundle",
    "id": "233481bb-def3-4c98-972a-b4ff2fce43e3",
    "meta": {"lastUpdated": "2021-02-05T14:16:09.107+01:00"},
    "type": "searchset",
    "total": 1,
    "link": [
        {
            "relation": "self",
            "url": "http://localhost:8080/hapi-fhir-jpaserver/fhir/Consent?_count=1000&actor=Practitioner%2F34371"
        }
    ],
    "entry": [
        {
            "fullUrl": "http://localhost:8080/hapi-fhir-jpaserver/fhir/Consent/34462",
            "resource": {
                "resourceType": "Consent",
                "id": "34462",
                "meta": {
                    "versionId": "1",
                    "lastUpdated": "2021-02-05T14:10:40.967+01:00",
                    "source": "#OSAkLmD0e5HgdAt3"
                },
                "status": "active",
                "scope": {
                    "coding": [
                        {
                            "system": "http://terminology.hl7.org/CodeSystem/consentscope",
                            "code": "patient-privacy"
                        }
                    ]
                },
                "category": [
                    {
                        "coding": [
                            {
                                "system": "http://terminology.hl7.org/CodeSystem/v3-ActCode",
                                "code": "INFAO"
                            }
                        ]
                    },
                    {
                        "coding": [
                            {
                                "system": "http://esante.lu/consent",
                                "code": "ESANTE_DSP"
                            }
                        ]
                    }
                ],
                "patient": {"reference": "Patient/34373"},
                "dateTime": "2021-02-05T14:10:42+01:00",
                "performer": [
                    {"reference": "Patient/34373"}
                ],
                "provision": {
                    "type": "deny",
                    "actor": [
                        {
                            "role": {
                                "coding": [
                                    {
                                        "system": "http://terminology.hl7.org/CodeSystem/v3-ParticipationType",
                                        "code": "PRCP"
                                    }
                                ]
                            },
                            "reference": {"reference": "Practitioner/34371"}
                        }
                    ],
                    "action": [
                        {
                            "coding": [
                                {
                                    "system": "http://terminology.hl7.org/CodeSystem/consentaction",
                                    "code": "access"
                                }
                            ]
                        }
                    ]
                }
            },
            "search": {"mode": "match"}
        }
    ]
}

Environment (please complete the following information):

jamesagnew commented 3 years ago

@cspielmann can you please try to recreate this on the public server ( hapi.fhir.org ) and link to the relevant resources?

cspielmann commented 2 years ago

Unfortunately issue still present in 5.4. : search by patient Id does not work I Will test with a public server as a show case.

cspielmann commented 2 years ago

Hello, in version 5.6 of https://hapi.fhir.org/ I have an error 500 on the following query

_GET http://hapi.fhir.org/baseR4/Consent?patient=Patient/2641330&_pretty=true_

{ "resourceType": "OperationOutcome", "text": { "status": "generated", "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><h1>Operation Outcome</h1><table border=\"0\"><tr><td style=\"font-weight: bold;\">ERROR</td><td>[]</td><td><pre/></td>\n\t\t\t</tr>\n\t\t</table>\n\t</div>" }, "issue": [ { "severity": "error", "code": "processing" } ] }

GET http://hapi.fhir.org/baseR4/Patient/2641330?_pretty=true GET http://hapi.fhir.org/baseR4/Consent/2641331?_pretty=true

error 500 on search by patientId

`// Create a client (only needed once) FhirContext ctx = new FhirContext(); IGenericClient client = ctx.newRestfulGenericClient("http://hapi.fhir.org/baseR4");

// Invoke the client Bundle bundle = client.search().forResource(Consent.class) .where(new ReferenceClientParam("patient").hasId("Patient/2641330")) .prettyPrint() .execute();`