-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
updated search function to allow user to specify request headers #133
base: master
Are you sure you want to change the base?
Conversation
I moved to this branch because I was having a lot of trouble properly rebasing the last branch to the latest commits from master. I apologize for the confusion, and hope you'll be patient with me as I work this out. The original pr and comments can be found here: #132 |
Thanks for the contribution @ashankland. fhirVersion is definitely something we need in the client. But we have to be a little careful with changing/extending the API of the library, because once we add something like this and people start using it, it becomes very difficult to remove or change in the future. But before I get into the content of the PR, I believe you can basically accomplish the same thing that you are doing here w/out changing the client code, using the additional_headers configuration option. For example: client = FHIR::Client.new('http://hapi.fhir.org/baseR4')
client.additional_headers = {Accept: 'application/json+fhir; fhirVersion=4.0'}
reply = client.search(FHIR::Patient, search: {parameters: {name: 'P'}})
puts reply.request[:headers] In the short term you can consider doing this workaround until we figure out the right way of upgrading the library. But it is a workaround because this was intended more for thinks like custom headers, not for overwriting existing headers, though I believe you can technically do that. Back to the PR and the proposed approach for the library -- I have a couple of concerns :
Also, before accepting a PR, we would need to update the README with instructions so they would know how to add fhirVersion. And ideally we would add in some tests to make sure that it worked as desired. In general, a good idea is to stay consistent with how the rest of the library is organized. Since the fhirVersion parameter applicable to just about every HTTP call made to the server, and we already have all the information we need stored in the client to send that information along, I think we could just add a global flag that toggles it on and off, and update the rest of the library to automatically add it when necessary. So we could add something like Then update the rest of the library so that the The API from a user perspective would just be to do:
..or until we decide to make it the default, which probably should wait until a new major version of the library. Agree / disagree? What do you think @radamson? |
@arscan That makes sense. I can use that workaround to test my changes and get unblocked for now. Would it make more sense to, rather than have a binary version parameter, let the user specify the version at that top end, and have that reflected as the client is setting version flags, and default to no version parameter if the user doesn't set that value? That could create naming confusion with the fhir_version parameter in https://github.com/fhir-crucible/fhir_client/blob/master/lib/fhir_client/client.rb#L24 (which I assume is the local version the client uses vs. the version of the server it's talking to), but that may be unavoidable under the circumstances. |
@arscan awesome level of detail in your response. That makes it really helpful even for me as another reviewer to understand! I agree with your suggestions and was thinking along the same lines so I won't restate it unnecessarily. I do think we would want If we were to go this route the first place I would look to implement this is in the We might also look to how we handle how we already handle the |
The FHIR specification allows for an FHIRVersion tag to be used in the content headers of requests, and which can change the return content: https://www.hl7.org/fhir/http.html#version-parameter
Currently, the search function doesn't allow the user to set headers for their http requests manually, so there is no way to modify it to include a version tag. This branch adds that functionality as an optional variable.
Note: this is a new copy of the pull request which doesn't omit any changes from the diff.