Find Patients with a specific Condition
# support
a
@rahul1, @reshma am evaluating Graphql to query FHIR data against my local setup. I have followed the request structure as provided here: https://www.medplum.com/docs/graphql/basic-queries. But I am getting the following message in the response: "Unknown operation named \"\".",. I have tried the same request against app.medplum.com but still get the same error. Here is my complete request for Postman CURL: curl --location 'http://localhost:8103/fhir/R4/$graphql' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer xxxx' \ --data '{"query":"{\n PatientList(name: \"Eve\", address_city: \"Philadelphia\") {\n resourceType\n id\n name {\n family\n given\n }\n address {\n line\n city\n state\n postalCode\n }\n }\n}\n","variables":{}}' Request query: { PatientList(name: "Eve", address_city: "Philadelphia") { resourceType id name { family given } address { line city state postalCode } } } Response: { "errors": [ { "message": "Unknown operation named \"\".", "extensions": {} } ] } Thanks
r
@Amarjeet I was able to reproduce your error, and it seems like your query string in
--data
is malformed. Copying the example from the documentation, I was able to get this command to work
Copy code
curl --location 'http://localhost:8103/fhir/R4/$graphql' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $TOKEN" \
--data '{"query":"{ PatientList(name: \"Eve\", address_city: \"Philadelphia\") { resourceType id name { family given } address { line city state postalCode } } }"}'
You might also be missing escaping on some of your quotes (
\"
)
a
@rahul1 , Thank you for the help. I am able to get it working with some additional changes. However, I am trying to retrieve male patients aged between 40 and 50, who have type 2 diabetic conditions. I have created the following query but it is retrieving all the male patients with empty conditions. Can you please help? Thanks. Query curl: curl --location 'http://localhost:8103/fhir/R4/$graphql' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6IjEwY2NlZmI3LTA4MjUtNGY2OC1hZDcwLTkwM2VlNGMwZmZkOSIsInR5cCI6IkpXVCJ9.eyJsb2dpbl9pZCI6ImU1MDM4M2IzLWZlZjEtNGI0OC1iMjg5LTFjOGNhMWYzNDQ5NCIsInN1YiI6IjYyNjFhYTQ4LWRkMTAtNDAwZC1hNWI1LWVlMWVmMGJmZjkxNyIsInVzZXJuYW1lIjoiNjI2MWFhNDgtZGQxMC00MDBkLWE1YjUtZWUxZWYwYmZmOTE3Iiwic2NvcGUiOiJvcGVuaWQiLCJwcm9maWxlIjoiUGF0aWVudC80ODk4ZTFhMy1kZTJiLTRhOTAtODFmNy01OWQxMTU2YmRkYmUiLCJpYXQiOjE2OTQ0NDc5NDgsImlzcyI6Imh0dHA6Ly9sb2NhbGhvc3Q6ODEwMy8iLCJleHAiOjE2OTQ0NTE1NDh9.YA7I617DbqHpC71mb6Ea7Kdvsee9xotC1cZkt5wSpHkeuE2BM8wqdHyKr6i_fJQ6qA3jW03Eo2Bd16lDyir8sPoTaoLyeWw6oi5uuKkLrXEENrr6gL2XSRszRgn8YKxYn-oWG4ndi3rcOqYToG9yGhtohEExRXSBY-92kFK8tXfS7eJyKzaghheJXYRA2VGAMepR0WPOvC67Q5vLPSlCYzvA-pR2y_cvMtjhFR-1gHUF5ha8Tt6CcwCc7etm2tB0wMAR7Fnt5CigJayYCiJiTN_3grGf71EKHVnz9j6LMQjTnPvCbNKe4Ug4be1e-ES9E33vQcDKOCKBIxeJnLesvw' \ --data '{"query":"query {\n PatientList(gender: \"male\") {\n resourceType\n id\n name {\n family\n given\n }\n address {\n line\n city\n state\n postalCode\n }\n ConditionList(_reference: subject) {\n resourceType\n id\n code {\n coding(code : \"44054006\") {\n system,\n code\n }\n }\n }\n }\n}\n","variables":{}}'
Hi @rahul1 , Could you please let me know if this is something possible with the medplum GraphQl? We have a client waiting on this. He is interested in querying the data from various EHR with complex queries. Thanks.
r
Hi @Amarjeet . The functionality you're describing is called "Search chaining". Medplum doesn't yet support this kind of query out of the box, but it is on our roadmap
My suggestion would be to Search for all the relevant conditions, and then perform a Linked Resource Search (https://www.medplum.com/docs/graphql/basic-queries#resolving-nested-resources-with-the-resource-element) to retrieve all the neccessary patients. Unfortunately, you would have to filter by on the client side to get the correct list, but this would at least make sure you retrieved the patients with teh correct conditions
@Amarjeet , I just wanted to let you know that we have implemted Search Chaining, the feature that directly solves your problem. You can find more details here: https://www.medplum.com/docs/search/chained-search
a
@rahul1, Thank you for the update.
157 Views