smart-on-fhir / Swift-SMART

Swift SMART on FHIR framework for iOS and OS X
Other
135 stars 47 forks source link

Problem with FHIR Token type parameters containing '|' (pipe) characters #6

Closed johncneal closed 7 years ago

johncneal commented 7 years ago

I've managed to query the Cerner endpoints and pull back a patient using an '_id' I found in their Google group. Subsequently I tried using that same patients MRN to retrieve the patient using the 'identifier' search parameter and got an http 400 error back with a helpful message pointing out I need to supply the 'system' part of the identifier as well as the value part. Looking at Cerner's documentation, it suggested I need to quote an oid to identify the system part of the parameter value; eg "urn:oid:1.1.1.1.1.1|10002701".

When I tried this, Swift-SMART declined to make the url call at all. After some tracing through the code I discovered it was being prevented by the call to absoluteURL() in FHIROpenServer -

func absoluteURL(for path: String, handler: FHIRServerRequestHandler) -> URL? { return URL(string: path, relativeTo: baseURL)

This was returning nil, presumably because the url contains unencoded reserved characters. So I sort of conclude that some part of url construction in Swift-SMART is not encoding all relevant characters. To test this hypothesis, I substituted %7C for the pipe character in the call to Patient.search as follows- Patient.search(["identifier": "urn:oid:1.1.1.1.1.1%7C10002701"]).perform(...

. . . .and it worked - it quite happily retrieved the required patient.

So the question is - is this an issue with parameter/url encoding in Swift-SMART or is there a syntax for expressing this search in the Patient.search initialiser which might avoid the problem?

john n

p2 commented 7 years ago

Thanks for reporting! Yes indeed, you were bitten by a long-standing TODO that I have just addressed. While I'd love to overhaul FHIRSearch more, as pointed out in the README, this fix should at least prevent the error you've encountered.

johncneal commented 7 years ago

Hi Pascal - thank you for confirming my suspicions and for the fix. Time to explore further possibilities with Cerners FHIR server :-) john n