module NHS::PDS
Constants
- SEARCH_FIELDS
Public Class Methods
Source
# File app/lib/nhs/pds.rb, line 36 def get_patient(nhs_number) return unless Flipper.enabled?(:pds) NHS::API.connection.get( "personal-demographics/FHIR/R4/Patient/#{nhs_number}" ) rescue Faraday::BadRequestError => e if is_error?(e, "INVALID_RESOURCE_ID") raise InvalidNHSNumber, nhs_number else raise end rescue Faraday::ResourceNotFound => e if is_error?(e, "INVALIDATED_RESOURCE") raise InvalidatedResource, nhs_number elsif is_error?(e, "RESOURCE_NOT_FOUND") raise PatientNotFound, nhs_number else raise end end
Source
# File app/lib/nhs/pds.rb, line 58 def search_patients(attributes) return unless Flipper.enabled?(:pds) if (missing_attrs = (attributes.keys.map(&:to_s) - SEARCH_FIELDS)).any? raise "Unrecognised attributes: #{missing_attrs.join(", ")}" end response = NHS::API.connection.get( "personal-demographics/FHIR/R4/Patient", attributes ) if is_error?(response, "TOO_MANY_MATCHES") raise TooManyMatches else response end rescue Faraday::BadRequestError => e if is_error?(e, "INVALID_SEARCH_DATA") raise InvalidSearchData else raise end end