# Lifen Lifen is a Ruby client for [Lifen](http://developers.lifen.fr/) FHIR API (over JSON). ## Installation Add this line to your application's Gemfile: ```ruby gem 'lifen_fhir' ``` And then execute: $ bundle Or install it yourself as: $ gem install lifen_fhir ## Usage ### Configuration Lifen can be configured (ideally inside an initializer) like so: ```ruby LifenFhir.configure do |config| config.site = "https://demo.lifen.fr/" config.application_access_token = "application_access_token" # optionnal config.proxy_url = "http://my.proxy.fr/" end ``` Optionnal configuration: - `proxy_url`: enables you to route all your requests via a proxy ### Internal #### Managing a Binary ```ruby binary = LifenFhir::Binary.new(uuid: "b7c7dae671b93e951ce6a4f530736276") binary.download ``` ### Communication Request ```ruby sender = LifenFhir::Practitioner.find_by_rpps("899900018483") recipient = LifenFhir::Practitioner.find_by_rpps("899900018484") channel = recipient.channels.first binary = LifenFhir::Binary.new(uuid: "b7c7dae671b93e951ce6a4f530736276") communication_request = LifenFhir::CommunicationRequest.new(sender: sender, recipient: recipient, channel: channel, binary: binary, patient: patient, category: category) communication_request.send ``` #### Communication Request with multiple recipients ```ruby sender = LifenFhir::Practitioner.find_by_rpps("899900018483") recipient = LifenFhir::Practitioner.find_by_rpps("899900018484") medium = LifenFhir::Medium(uuid: recipient.channels.first.uuid) other_recipient = LifenFhir::Practitioner.find_by_rpps("899900018484") other_medium = LifenFhir::Medium(uuid: other_recipient.channels.first.uuid) binary = LifenFhir::Binary.new(uuid: "b7c7dae671b93e951ce6a4f530736276") communication_request_request = LifenFhir::CommunicationRequest.new(sender: sender, recipients: [recipient, other_recipient], medium: [medium, other_medium], binary: binary, patient: patient, category: category) communication_request_request.send ``` #### Custom Channels management ```ruby recipient = LifenFhir::Practitioner.new(uuid: "valid-user-uuid") # To create a new mailing address channel channel = recipient.create_address(type: "address", lines: ["39 rue Aboukir"], city: "Paris", postal_code: "75002", country: "France") # To create a new telecom channel fax channel = recipient.create_telecom(type: "telecom", system: "fax", value: "+33102030405") ``` #### Managing Patients ```ruby # To create a new patient address = LifenFhir::Address.new(lines: ["39 rue d'Aboukir"], city: "Paris", postal_code: "75002") patient = LifenFhir::Patient.create(first_name: ["Jean", "Charles"], last_name: "Dupond", birth_date: Date.new(1974, 12, 25), address: address) # To find a patient by id patient = LifenFhir::Patient.find_by_uuid("c3f96278-3bfe-4933-96e7-171ebca7489f") ``` ## Deploying to Rubygems Once the new version is validated, the deployment follows those steps : 1. update `lib/lifen/version.rb` 2. run `bundle install` to update `Gemfile.lock` 3. update `CHANGELOG.md` with the additional features of the new version 4. commit changes to Github 5. build the gem using `gem build lifen_fhir.gemspec` 6. publish the gem using `gem publish lifen_fhir-X.X.X.gem` 7. run `bundle update lifen` in related projects :) ## License The MIT License (MIT) Copyright (c) 2016-2017 Honestica Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.