Skip to content
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

Multiversion #69

Merged
merged 22 commits into from
Mar 6, 2018
Merged

Multiversion #69

merged 22 commits into from
Mar 6, 2018

Conversation

jawalonoski
Copy link
Member

This pull request adds the capability for the client to support both STU3 (default) and DSTU2.

This is a short-term solution to move our dependent projects forward until a more robust multi-version approach can be developed.

The client defaults to STU3 but can be switched to DSTU2 or it can also attempt to autodetect the FHIR version based on the metadata endpoint.

# autodetect the FHIR version
client = FHIR::Client.new(url)
version = client.detect_version
if version == :stu3
  puts 'FHIR Client using STU3'
elsif version == :dstu2
  puts 'FHIR Client using DSTU2'
end

# tell the client to use STU3 (default)
client.use_stu3
# now use the client normally
patient = FHIR::Patient.read('example')
patient = client.read(FHIR::Patient, 'example').resource

# tell the client to use DSTU2
client.use_dstu2
# now use the client with the DSTU2 models
patient = FHIR::DSTU2::Patient.read('example')
patient = client.read(FHIR::DSTU2::Patient, 'example').resource

@arscan arscan requested a review from olbrich June 15, 2017 18:44
@arscan
Copy link
Member

arscan commented Jun 22, 2017

@olbrich or @wesrich -- thoughts on this? We are getting pressure to get a version of projectcrucible.org up that supports multiple versions simultaneously. This will help us achieve this (using namespacing) in the short term... understanding that a better solution might be implemented in the long term.

@arscan
Copy link
Member

arscan commented Jul 7, 2017

@jawalonoski -- I'm having trouble with the model extensions on the client. I get these errors when trying to do a create on a model:

ERROR x034_conditional_update_(multiple_matches)_test: Fatal Error: private method `handle_response' called for FHIR::Account:Class
            ----------------------------------------
            /Users/rscanlon/.rvm/gems/ruby-2.2.5/bundler/gems/fhir_client-825997e6ba3c/lib/fhir_client/ext/model.rb:53:in `handle_response'
            /Users/rscanlon/.rvm/gems/ruby-2.2.5/bundler/gems/fhir_client-825997e6ba3c/lib/fhir_client/ext/model.rb:35:in `conditional_update'
            /Users/rscanlon/Projects/plan_executor/lib/tests/suites/resource_test.rb:382:in `block (2 levels) in <class:ResourceTest>'
            /Users/rscanlon/Projects/plan_executor/lib/tests/base_test.rb:138:in `ignore_client_exception'

I think the metaprogramming you did to appease rubocop caused this issue. Changing "handle_responses" to public fixes the problem, but I don't know if we want to do that.

@arscan
Copy link
Member

arscan commented Jul 7, 2017

@jawalonoski -- I added at test for model extensions.

Also, I added a test for an issue I found in ClientReply. Looks like we have an instance variable that is supposed to track the fhir_version, but I don't think we actually set it to anything other than stu3 in practice. Can we either get away with not needing to know the fhir_version in there, or figure out some way of passing that information in that makes sense and isn't too cumbersome?

@arscan
Copy link
Member

arscan commented Jul 7, 2017

Also added some tests for checking the accept and content-type headers. I think the right behavior should be to send the old content-type/accepts to dstu2 servers, and the new content-type/accepts to stu3 servers. It isn't currently doing that though.

@arscan
Copy link
Member

arscan commented Aug 7, 2017

Transactions have references to FHIR::Bundle, but it should take the fhir version into account so that it gets the namespace right.

@jawalonoski
Copy link
Member Author

Other FHIR Operations have the same issues. Will fix...

@jawalonoski
Copy link
Member Author

FYI, the code climate "2 issues to fix" is a complaint of 2 lines of duplicated code within a module -- one version at an instance level, and the other at a class level. This is the result of allowing both patient.update(...) and FHIR::Patient.create(...) type of interactions.

@jawalonoski jawalonoski self-assigned this Mar 6, 2018
@jawalonoski jawalonoski merged commit d08a7fe into master Mar 6, 2018
@jawalonoski jawalonoski deleted the multiversion branch March 6, 2018 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants