{"id":30799190,"url":"https://github.com/inferno-framework/fhir_client","last_synced_at":"2026-03-16T20:01:42.583Z","repository":{"id":24336378,"uuid":"27733872","full_name":"inferno-framework/fhir_client","owner":"inferno-framework","description":"Ruby FHIR Client","archived":false,"fork":false,"pushed_at":"2024-11-17T20:30:53.000Z","size":512,"stargazers_count":174,"open_issues_count":24,"forks_count":59,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-08-11T03:10:14.163Z","etag":null,"topics":["fhir","fhir-client"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/inferno-framework.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-12-08T20:38:29.000Z","updated_at":"2025-07-31T12:40:04.000Z","dependencies_parsed_at":"2024-06-18T16:51:29.890Z","dependency_job_id":"7e4e42c7-07a4-4340-b4f1-1a755d91afb3","html_url":"https://github.com/inferno-framework/fhir_client","commit_stats":{"total_commits":367,"total_committers":31,"mean_commits":"11.838709677419354","dds":0.6348773841961852,"last_synced_commit":"b1fff3131ed293eaec1b92885c23645963d9d0a9"},"previous_names":["fhir-crucible/fhir_client"],"tags_count":25,"template":false,"template_full_name":null,"purl":"pkg:github/inferno-framework/fhir_client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inferno-framework%2Ffhir_client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inferno-framework%2Ffhir_client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inferno-framework%2Ffhir_client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inferno-framework%2Ffhir_client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inferno-framework","download_url":"https://codeload.github.com/inferno-framework/fhir_client/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inferno-framework%2Ffhir_client/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273806129,"owners_count":25171564,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-05T02:00:09.113Z","response_time":402,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fhir","fhir-client"],"created_at":"2025-09-05T19:08:58.210Z","updated_at":"2026-03-16T20:01:42.535Z","avatar_url":"https://github.com/inferno-framework.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FHIR Client [![Build Status](https://travis-ci.org/fhir-crucible/fhir_client.svg?branch=master)](https://travis-ci.org/fhir-crucible/fhir_client)\n\nRuby FHIR client.\n\nSupports:\n* FHIR R5, R4B, R4, STU3 and DSTU2\n* JSON and XML\n* All CRUD, including version read and history\n* Transactions and Batches\n* Search\n* Operations (e.g. `$everything`, `$validate`)\n* Support for OAuth2\n\n## Getting Started\n\n    $ bundle install\n    $ bundle exec rake fhir:console\n\n## Creating a Client\n```ruby\nclient = FHIR::Client.new(url)\n```\n\nThis client supports two modes of operation: basic and advanced.  The basic mode is useful for simple operations\nbecause it promotes an ActiveRecord-like style of interaction.  The advanced mode is less developer-friendly, but is currently necessary if you would like to use the entire range of operations exposed by FHIR.\n\n## Basic Usage\n\nAssociate the client with the model:\n\n```ruby\nFHIR::Model.client = client\n```\n\nThe FHIR models can now be used to directly interact with a FHIR server.\n\n```ruby\n# read an existing patient with an ID of 'example'\npatient = FHIR::Patient.read('example')\n\n# update a patient\npatient.gender = 'female'\npatient.update # saves the patient\n\n# create a patient\npatient = FHIR::Patient.create(name: {given: 'John', family: 'Doe'})\n\n#create a patient with specific headers\npatient = FHIR::Patient.new(name: {given: 'John', family: 'Doe'}).create({Prefer: \"return=representation\"})\n\n# search patients\nresults = FHIR::Patient.search(given: 'John', family: 'Doe')\nresults.count # results in an enumeration\n\n# delete the recently created patient\npatient.destroy\n```\n\n## Advanced Usage\n\n### Changing FHIR Versions\nThe client defaults to `R4` but can be switched to other versions. It can also attempt to autodetect the FHIR version based on the `metadata` endpoint.\n\n```ruby\n# autodetect the FHIR version\nclient = FHIR::Client.new(url)\nversion = client.detect_version\nif version == :stu3\n  puts 'FHIR Client using STU3'\nelsif version == :dstu2\n  puts 'FHIR Client using DSTU2'\nelsif version == :r4\n  puts 'FHIR Client using R4'\nelsif version == :r4b\n  puts 'FHIR Client using R4B'\nelsif\n  puts 'FHIR Client using R5'\nend\n\n# tell the client to use R4\nclient.use_r4\n# now use the client with the DSTU2 models\npatient = FHIR::Patient.read('example')\npatient = client.read(FHIR::Patient, 'example').resource\n\n# tell the client to use STU3\nclient.use_stu3\n# now use the client normally\npatient = FHIR::STU3::Patient.read('example')\npatient = client.read(FHIR::STU3::Patient, 'example').resource\n\n# tell the client to use DSTU2\nclient.use_dstu2\n# now use the client with the DSTU2 models\npatient = FHIR::DSTU2::Patient.read('example')\npatient = client.read(FHIR::DSTU2::Patient, 'example').resource\n\n\n```\n\n### Changing FHIR Formats\nThe client defaults to `json` representation of resources but can be switched to `xml` representations.\n\n```ruby\nclient = FHIR::Client.new(url)\n\n# Tell the client to use xml\nclient.default_xml\n\n# Tell the client to use json\nclient.default_json\n```\n\n### Configuration\n\nYou can specify additional properties for the `client`:\n\n```ruby\nclient.additional_headers = {Prefer: 'return=representation'}\nclient.proxy = 'https://your-proxy.com/'\n```\n\n### CRUD Examples\n```ruby\n# read an existing patient with id \"example\"\npatient = client.read(FHIR::Patient, \"example\").resource\n\n# read specifying Formats\npatient = client.read(FHIR::Patient, \"example\", FHIR::Formats::FeedFormat::FEED_JSON).resource\n\n# create a patient\npatient = FHIR::Patient.new\npatient_id = client.create(patient).id\n\n# update the patient\npatient.gender = 'female'\nclient.update(patient, patient_id)\n\n# conditional update\np_identifier = FHIR::Identifier.new\np_identifier.use = 'official'\np_identifier.system = 'http://projectcrucible.org'\np_identifier.value = '123'\npatient.identifier = [ p_identifier ]\nsearchParams = { :identifier =\u003e 'http://projectcrucible.org|123' }\nclient.conditional_update(patient, patient_id, searchParams)\n\n# conditional create\nifNoneExist = { :identifier =\u003e 'http://projectcrucible.org|123' }\nclient.conditional_create(patient, ifNoneExist)\n\n# destroy the patient\nclient.destroy(FHIR::Patient, patient_id)\n```\n\n### Searching\n```ruby\n# via GET\nreply = client.search(FHIR::Patient, search: {parameters: {name: 'P'}})\n\n# via POST\nreply = client.search(FHIR::Patient, search: {body: {name: 'P'}})\n\nbundle = reply.resource\npatient = bundle\u0026.entry\u0026.first\u0026.resource\n```\n\n### Fetching a Bundle\n```ruby\nreply = client.read_feed(FHIR::Patient) # fetch Bundle of Patients\nbundle = reply.resource\nbundle.entry.each do |entry|\n  patient = entry.resource\n  puts patient.name[0].text\nend\nputs reply.code # HTTP 200 (or whatever was returned)\nputs reply.body # Raw XML or JSON\n```\n\n### Transactions\n```ruby\n# Create a patient\n@patient = FHIR::Patient.new\n@patient.id = 'temporary_id'\n\n# Create an observation\n@observation = FHIR::Observation.new\n@observation.status = 'final'\n@coding = FHIR::Coding.new\n@coding.system = 'http://loinc.org'\n@coding.code='8302-2'\n@observation.code = FHIR::CodeableConcept.new\n@observation.code.coding = [ @coding ]\n@quantity = FHIR::Quantity.new\n@quantity.value = 170\n@quantity.unit = 'cm'\n@quantity.system = 'http://unitsofmeasure.org'\n@observation.valueQuantity = @quantity\n@reference = FHIR::Reference.new\n@reference.reference = \"Patient/#{@patient.id}\"\n@observation.subject = @reference\n\n# Submit them both as a transaction\n@client.begin_transaction\n@client.add_transaction_request('POST',nil,@patient)\n@client.add_transaction_request('POST',nil,@observation)\nreply = @client.end_transaction\n```\n\n### OAuth2 Support\n```ruby\nclient = FHIR::Client.new(url)\nclient_id = 'example'\nclient_secret = 'secret'\noptions = client.get_oauth2_metadata_from_conformance\nif options.empty?\n  puts 'This server does not support the expected OAuth2 extensions.'\nelse\n  client.set_oauth2_auth(client_id, client_secret, options[:authorize_url] ,options[:token_url], options[:site])\n  reply = client.read_feed(FHIR::Patient)\n  puts reply.body\nend\n```\n\n# License\n\nCopyright 2014-2022 The MITRE Corporation\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finferno-framework%2Ffhir_client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finferno-framework%2Ffhir_client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finferno-framework%2Ffhir_client/lists"}