Class: CandidApiClient::PreEncounter::Patients::V1::AsyncV1Client
- Inherits:
-
Object
- Object
- CandidApiClient::PreEncounter::Patients::V1::AsyncV1Client
- Defined in:
- lib/candidhealth/pre_encounter/patients/v_1/client.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#create(request:, skip_duplicate_check: nil, request_options: nil) ⇒ CandidApiClient::PreEncounter::Patients::V1::Types::Patient
Adds a patient.
-
#create_with_mrn(request:, skip_duplicate_check: nil, request_options: nil) ⇒ CandidApiClient::PreEncounter::Patients::V1::Types::Patient
Adds a patient and hydrates their MRN with a pre-existing MRN.
-
#deactivate(id:, version:, request_options: nil) ⇒ Void
Sets a patient as deactivated.
-
#get(id:, request_options: nil) ⇒ CandidApiClient::PreEncounter::Patients::V1::Types::Patient
Gets a patient.
-
#get_history(id:, request_options: nil) ⇒ Array<CandidApiClient::PreEncounter::Patients::V1::Types::Patient>
Gets a patient along with it’s full history.
-
#get_multi(limit: nil, mrn: nil, page_token: nil, sort_field: nil, sort_direction: nil, request_options: nil) ⇒ CandidApiClient::PreEncounter::Patients::V1::Types::PatientPage
Searches for patients that match the query parameters.
- #initialize(request_client:) ⇒ CandidApiClient::PreEncounter::Patients::V1::AsyncV1Client constructor
-
#scan(since:, request_options: nil) ⇒ Array<CandidApiClient::PreEncounter::Patients::V1::Types::Patient>
Scans up to 100 patient updates.
-
#search(mrn: nil, similar_name_ordering: nil, request_options: nil) ⇒ Array<CandidApiClient::PreEncounter::Patients::V1::Types::Patient>
Returns a list of Patients based on the search criteria.
-
#update(id:, version:, request:, request_options: nil) ⇒ CandidApiClient::PreEncounter::Patients::V1::Types::Patient
Updates a patient.
Constructor Details
#initialize(request_client:) ⇒ CandidApiClient::PreEncounter::Patients::V1::AsyncV1Client
552 553 554 |
# File 'lib/candidhealth/pre_encounter/patients/v_1/client.rb', line 552 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ CandidApiClient::AsyncRequestClient (readonly)
548 549 550 |
# File 'lib/candidhealth/pre_encounter/patients/v_1/client.rb', line 548 def request_client @request_client end |
Instance Method Details
#create(request:, skip_duplicate_check: nil, request_options: nil) ⇒ CandidApiClient::PreEncounter::Patients::V1::Types::Patient
Adds a patient. VersionConflictError is returned when the patient’s external ID
is already in use.
647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 |
# File 'lib/candidhealth/pre_encounter/patients/v_1/client.rb', line 647 def create(request:, skip_duplicate_check: nil, request_options: nil) Async do response = @request_client.conn.post do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "skip_duplicate_check": skip_duplicate_check }.compact req.body = { **(request || {}), **(&.additional_body_parameters || {}) }.compact req.url "#{@request_client.get_url(environment: PreEncounter, request_options: )}/patients/v1" end CandidApiClient::PreEncounter::Patients::V1::Types::Patient.from_json(json_object: response.body) end end |
#create_with_mrn(request:, skip_duplicate_check: nil, request_options: nil) ⇒ CandidApiClient::PreEncounter::Patients::V1::Types::Patient
Adds a patient and hydrates their MRN with a pre-existing MRN. Once this patient
is created their MRN will not be editable. InvalidMRNError is returned when the
MRN is greater than 20 characters. VersionConflictError is returned when the
patient's external ID is already in use.
763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 |
# File 'lib/candidhealth/pre_encounter/patients/v_1/client.rb', line 763 def create_with_mrn(request:, skip_duplicate_check: nil, request_options: nil) Async do response = @request_client.conn.post do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "skip_duplicate_check": skip_duplicate_check }.compact req.body = { **(request || {}), **(&.additional_body_parameters || {}) }.compact req.url "#{@request_client.get_url(environment: PreEncounter, request_options: )}/patients/v1/with_mrn" end CandidApiClient::PreEncounter::Patients::V1::Types::Patient.from_json(json_object: response.body) end end |
#deactivate(id:, version:, request_options: nil) ⇒ Void
Sets a patient as deactivated. The path must contain the most recent version to
prevent race conditions. Deactivating historic versions is not supported.
Subsequent updates via PUT to the patient will "reactivate" the patient and set
the deactivated flag to false.
1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 |
# File 'lib/candidhealth/pre_encounter/patients/v_1/client.rb', line 1010 def deactivate(id:, version:, request_options: nil) Async do @request_client.conn.delete do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.url "#{@request_client.get_url(environment: PreEncounter, request_options: )}/patients/v1/#{id}/#{version}" end end end |
#get(id:, request_options: nil) ⇒ CandidApiClient::PreEncounter::Patients::V1::Types::Patient
Gets a patient.
837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 |
# File 'lib/candidhealth/pre_encounter/patients/v_1/client.rb', line 837 def get(id:, request_options: nil) Async do response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.url "#{@request_client.get_url(environment: PreEncounter, request_options: )}/patients/v1/#{id}" end CandidApiClient::PreEncounter::Patients::V1::Types::Patient.from_json(json_object: response.body) end end |
#get_history(id:, request_options: nil) ⇒ Array<CandidApiClient::PreEncounter::Patients::V1::Types::Patient>
Gets a patient along with it’s full history. The return list is ordered by
version ascending.
863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 |
# File 'lib/candidhealth/pre_encounter/patients/v_1/client.rb', line 863 def get_history(id:, request_options: nil) Async do response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.url "#{@request_client.get_url(environment: PreEncounter, request_options: )}/patients/v1/#{id}/history" end parsed_json = JSON.parse(response.body) parsed_json&.map do |item| item = item.to_json CandidApiClient::PreEncounter::Patients::V1::Types::Patient.from_json(json_object: item) end end end |
#get_multi(limit: nil, mrn: nil, page_token: nil, sort_field: nil, sort_direction: nil, request_options: nil) ⇒ CandidApiClient::PreEncounter::Patients::V1::Types::PatientPage
Searches for patients that match the query parameters.
803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 |
# File 'lib/candidhealth/pre_encounter/patients/v_1/client.rb', line 803 def get_multi(limit: nil, mrn: nil, page_token: nil, sort_field: nil, sort_direction: nil, request_options: nil) Async do response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "limit": limit, "mrn": mrn, "page_token": page_token, "sort_field": sort_field, "sort_direction": sort_direction }.compact req.url "#{@request_client.get_url(environment: PreEncounter, request_options: )}/patients/v1/get_multi" end CandidApiClient::PreEncounter::Patients::V1::Types::PatientPage.from_json(json_object: response.body) end end |
#scan(since:, request_options: nil) ⇒ Array<CandidApiClient::PreEncounter::Patients::V1::Types::Patient>
Scans up to 100 patient updates. The since query parameter is inclusive, and the
result list is ordered by updatedAt ascending.
1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 |
# File 'lib/candidhealth/pre_encounter/patients/v_1/client.rb', line 1070 def scan(since:, request_options: nil) Async do response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "since": since }.compact req.url "#{@request_client.get_url(environment: PreEncounter, request_options: )}/patients/v1/updates/scan" end parsed_json = JSON.parse(response.body) parsed_json&.map do |item| item = item.to_json CandidApiClient::PreEncounter::Patients::V1::Types::Patient.from_json(json_object: item) end end end |
#search(mrn: nil, similar_name_ordering: nil, request_options: nil) ⇒ Array<CandidApiClient::PreEncounter::Patients::V1::Types::Patient>
Returns a list of Patients based on the search criteria.
1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 |
# File 'lib/candidhealth/pre_encounter/patients/v_1/client.rb', line 1035 def search(mrn: nil, similar_name_ordering: nil, request_options: nil) Async do response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "mrn": mrn, "similar_name_ordering": similar_name_ordering }.compact req.url "#{@request_client.get_url(environment: PreEncounter, request_options: )}/patients/v1" end parsed_json = JSON.parse(response.body) parsed_json&.map do |item| item = item.to_json CandidApiClient::PreEncounter::Patients::V1::Types::Patient.from_json(json_object: item) end end end |
#update(id:, version:, request:, request_options: nil) ⇒ CandidApiClient::PreEncounter::Patients::V1::Types::Patient
Updates a patient. The path must contain the most recent version to prevent race
conditions. Updating historic versions is not supported.
980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 |
# File 'lib/candidhealth/pre_encounter/patients/v_1/client.rb', line 980 def update(id:, version:, request:, request_options: nil) Async do response = @request_client.conn.put do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.body = { **(request || {}), **(&.additional_body_parameters || {}) }.compact req.url "#{@request_client.get_url(environment: PreEncounter, request_options: )}/patients/v1/#{id}/#{version}" end CandidApiClient::PreEncounter::Patients::V1::Types::Patient.from_json(json_object: response.body) end end |