candidhealth 0.24.2 → 0.24.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/lib/candidhealth/commons/types/primitive.rb +17 -0
  3. data/lib/candidhealth/custom_schemas/client.rb +30 -0
  4. data/lib/candidhealth/custom_schemas/v_1/client.rb +291 -0
  5. data/lib/candidhealth/custom_schemas/v_1/types/key_with_name_already_exists_error.rb +71 -0
  6. data/lib/candidhealth/custom_schemas/v_1/types/schema.rb +91 -0
  7. data/lib/candidhealth/custom_schemas/v_1/types/schema_field.rb +71 -0
  8. data/lib/candidhealth/custom_schemas/v_1/types/schema_get_multi_response.rb +65 -0
  9. data/lib/candidhealth/custom_schemas/v_1/types/schema_instance.rb +76 -0
  10. data/lib/candidhealth/custom_schemas/v_1/types/schema_validation_error.rb +100 -0
  11. data/lib/candidhealth/custom_schemas/v_1/types/schema_validation_failure.rb +65 -0
  12. data/lib/candidhealth/custom_schemas/v_1/types/schema_with_name_already_exists_error.rb +70 -0
  13. data/lib/candidhealth/encounters/v_4/client.rb +49 -12
  14. data/lib/candidhealth/encounters/v_4/types/encounter.rb +17 -1
  15. data/lib/candidhealth/encounters/v_4/types/key_does_not_exist_error.rb +70 -0
  16. data/lib/candidhealth/encounters/v_4/types/multiple_instances_for_schema_error.rb +60 -0
  17. data/lib/candidhealth/encounters/v_4/types/schema_does_not_exist_error.rb +60 -0
  18. data/lib/candidhealth/encounters/v_4/types/schema_instance_validation_error.rb +139 -0
  19. data/lib/candidhealth/encounters/v_4/types/schema_instance_validation_failure.rb +65 -0
  20. data/lib/candidhealth/encounters/v_4/types/schema_unauthorized_access_error.rb +60 -0
  21. data/lib/candidhealth/encounters/v_4/types/value_does_not_match_key_type_error.rb +90 -0
  22. data/lib/candidhealth/pre_encounter/common/types/disability_status.rb +14 -0
  23. data/lib/candidhealth/pre_encounter/common/types/ethnicity.rb +16 -0
  24. data/lib/candidhealth/pre_encounter/common/types/gender.rb +5 -2
  25. data/lib/candidhealth/pre_encounter/common/types/race.rb +21 -0
  26. data/lib/candidhealth/pre_encounter/common/types/sex.rb +16 -0
  27. data/lib/candidhealth/pre_encounter/common/types/sexual_orientation.rb +19 -0
  28. data/lib/candidhealth/pre_encounter/coverages/client.rb +6 -6
  29. data/lib/candidhealth/pre_encounter/coverages/v_1/client.rb +464 -11
  30. data/lib/candidhealth/pre_encounter/coverages/v_1/types/coverage.rb +183 -0
  31. data/lib/candidhealth/pre_encounter/coverages/v_1/types/coverage_status.rb +20 -0
  32. data/lib/candidhealth/pre_encounter/coverages/v_1/types/insurance_plan.rb +134 -0
  33. data/lib/candidhealth/pre_encounter/coverages/v_1/types/mutable_coverage.rb +129 -0
  34. data/lib/candidhealth/pre_encounter/coverages/v_1/types/network_type.rb +33 -0
  35. data/lib/candidhealth/pre_encounter/coverages/v_1/types/subscriber.rb +88 -0
  36. data/lib/candidhealth/pre_encounter/patients/client.rb +6 -6
  37. data/lib/candidhealth/pre_encounter/patients/v_1/client.rb +607 -11
  38. data/lib/candidhealth/pre_encounter/patients/v_1/types/contact.rb +133 -0
  39. data/lib/candidhealth/pre_encounter/patients/v_1/types/external_provenance.rb +73 -0
  40. data/lib/candidhealth/pre_encounter/patients/v_1/types/external_provider.rb +122 -0
  41. data/lib/candidhealth/pre_encounter/patients/v_1/types/filing_order.rb +63 -0
  42. data/lib/candidhealth/pre_encounter/patients/v_1/types/marital_status.rb +26 -0
  43. data/lib/candidhealth/pre_encounter/patients/v_1/types/mutable_patient.rb +325 -0
  44. data/lib/candidhealth/pre_encounter/patients/v_1/types/patient.rb +389 -0
  45. data/lib/candidhealth.rb +14 -7
  46. data/lib/requests.rb +2 -2
  47. data/lib/types_export.rb +34 -12
  48. metadata +38 -16
  49. data/lib/candidhealth/pre_encounter/coverages/v_1/coverages/client.rb +0 -487
  50. data/lib/candidhealth/pre_encounter/coverages/v_1/coverages/types/coverage.rb +0 -185
  51. data/lib/candidhealth/pre_encounter/coverages/v_1/coverages/types/coverage_status.rb +0 -22
  52. data/lib/candidhealth/pre_encounter/coverages/v_1/coverages/types/coverage_type.rb +0 -18
  53. data/lib/candidhealth/pre_encounter/coverages/v_1/coverages/types/insurance_plan.rb +0 -136
  54. data/lib/candidhealth/pre_encounter/coverages/v_1/coverages/types/mutable_coverage.rb +0 -131
  55. data/lib/candidhealth/pre_encounter/coverages/v_1/coverages/types/subscriber.rb +0 -90
  56. data/lib/candidhealth/pre_encounter/patients/v_1/patients/client.rb +0 -590
  57. data/lib/candidhealth/pre_encounter/patients/v_1/patients/types/contact.rb +0 -135
  58. data/lib/candidhealth/pre_encounter/patients/v_1/patients/types/external_provenance.rb +0 -75
  59. data/lib/candidhealth/pre_encounter/patients/v_1/patients/types/external_provider.rb +0 -116
  60. data/lib/candidhealth/pre_encounter/patients/v_1/patients/types/marital_status.rb +0 -28
  61. data/lib/candidhealth/pre_encounter/patients/v_1/patients/types/mutable_patient.rb +0 -242
  62. data/lib/candidhealth/pre_encounter/patients/v_1/patients/types/patient.rb +0 -294
@@ -1,31 +1,627 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "../../../../requests"
4
- require_relative "patients/client"
4
+ require_relative "types/mutable_patient"
5
+ require_relative "types/patient"
6
+ require "json"
7
+ require "date"
8
+ require "async"
5
9
 
6
10
  module CandidApiClient
7
11
  module PreEncounter
8
12
  module Patients
9
13
  module V1
10
- class Client
11
- # @return [CandidApiClient::PreEncounter::Patients::V1::PatientsClient]
12
- attr_reader :patients
14
+ class V1Client
15
+ # @return [CandidApiClient::RequestClient]
16
+ attr_reader :request_client
13
17
 
14
18
  # @param request_client [CandidApiClient::RequestClient]
15
- # @return [CandidApiClient::PreEncounter::Patients::V1::Client]
19
+ # @return [CandidApiClient::PreEncounter::Patients::V1::V1Client]
16
20
  def initialize(request_client:)
17
- @patients = CandidApiClient::PreEncounter::Patients::V1::PatientsClient.new(request_client: request_client)
21
+ @request_client = request_client
22
+ end
23
+
24
+ # Adds a patient. VersionConflictError is returned when the patient's external ID
25
+ # is already in use.
26
+ #
27
+ # @param request [Hash] Request of type CandidApiClient::PreEncounter::Patients::V1::Types::MutablePatient, as a Hash
28
+ # * :name (Hash)
29
+ # * :family (String)
30
+ # * :given (Array<String>)
31
+ # * :use (CandidApiClient::PreEncounter::Common::Types::NameUse)
32
+ # * :period (Hash)
33
+ # * :start (Date)
34
+ # * :end_ (Date)
35
+ # * :other_names (Array<CandidApiClient::PreEncounter::Common::Types::HumanName>)
36
+ # * :gender (CandidApiClient::PreEncounter::Common::Types::Gender)
37
+ # * :birth_date (Date)
38
+ # * :social_security_number (String)
39
+ # * :biological_sex (CandidApiClient::PreEncounter::Common::Types::Sex)
40
+ # * :sexual_orientation (CandidApiClient::PreEncounter::Common::Types::SexualOrientation)
41
+ # * :race (CandidApiClient::PreEncounter::Common::Types::Race)
42
+ # * :ethnicity (CandidApiClient::PreEncounter::Common::Types::Ethnicity)
43
+ # * :disability_status (CandidApiClient::PreEncounter::Common::Types::DisabilityStatus)
44
+ # * :marital_status (CandidApiClient::PreEncounter::Patients::V1::Types::MaritalStatus)
45
+ # * :deceased (DateTime)
46
+ # * :multiple_birth (Integer)
47
+ # * :primary_address (Hash)
48
+ # * :use (CandidApiClient::PreEncounter::Common::Types::AddressUse)
49
+ # * :line (Array<String>)
50
+ # * :city (String)
51
+ # * :state (String)
52
+ # * :postal_code (String)
53
+ # * :country (String)
54
+ # * :period (Hash)
55
+ # * :start (Date)
56
+ # * :end_ (Date)
57
+ # * :other_addresses (Array<CandidApiClient::PreEncounter::Common::Types::Address>)
58
+ # * :primary_telecom (Hash)
59
+ # * :value (String)
60
+ # * :use (CandidApiClient::PreEncounter::Common::Types::ContactPointUse)
61
+ # * :period (Hash)
62
+ # * :start (Date)
63
+ # * :end_ (Date)
64
+ # * :other_telecoms (Array<CandidApiClient::PreEncounter::Common::Types::ContactPoint>)
65
+ # * :email (String)
66
+ # * :electronic_communication_opt_in (Boolean)
67
+ # * :photo (String)
68
+ # * :language (String)
69
+ # * :external_provenance (Hash)
70
+ # * :external_id (String)
71
+ # * :system_name (String)
72
+ # * :contacts (Array<CandidApiClient::PreEncounter::Patients::V1::Types::Contact>)
73
+ # * :general_practitioners (Array<CandidApiClient::PreEncounter::Patients::V1::Types::ExternalProvider>)
74
+ # * :filing_order (Hash)
75
+ # * :coverages (Array<String>)
76
+ # @param request_options [CandidApiClient::RequestOptions]
77
+ # @return [CandidApiClient::PreEncounter::Patients::V1::Types::Patient]
78
+ # @example
79
+ # api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
80
+ # api.pre_encounter.patients.v_1.create(request: { name: { }, other_names: [{ }], gender: MAN, birth_date: DateTime.parse(2023-01-15), social_security_number: "string", biological_sex: FEMALE, sexual_orientation: HETEROSEXUAL, race: AMERICAN_INDIAN_OR_ALASKA_NATIVE, ethnicity: HISPANIC_OR_LATINO, disability_status: DISABLED, marital_status: ANNULLED, deceased: DateTime.parse(2024-01-15T09:30:00.000Z), multiple_birth: 1, primary_address: { }, other_addresses: [{ }], primary_telecom: { }, other_telecoms: [{ }], email: "string", electronic_communication_opt_in: true, photo: "string", language: "string", external_provenance: { external_id: "string", system_name: "string" }, contacts: [{ relationship: [SELF], name: { }, gender: MAN, telecoms: [{ }], addresses: [{ }], period: { } }], general_practitioners: [{ name: { }, npi: "string", telecoms: [{ }], addresses: [{ }], period: { } }], filing_order: { coverages: ["d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32"] } })
81
+ def create(request:, request_options: nil)
82
+ response = @request_client.conn.post do |req|
83
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
84
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
85
+ req.headers = {
86
+ **(req.headers || {}),
87
+ **@request_client.get_headers,
88
+ **(request_options&.additional_headers || {})
89
+ }.compact
90
+ req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact
91
+ req.url "#{@request_client.get_url(environment: PreEncounter,
92
+ request_options: request_options)}/patients/v1"
93
+ end
94
+ CandidApiClient::PreEncounter::Patients::V1::Types::Patient.from_json(json_object: response.body)
95
+ end
96
+
97
+ # Gets a patient.
98
+ #
99
+ # @param id [String]
100
+ # @param request_options [CandidApiClient::RequestOptions]
101
+ # @return [CandidApiClient::PreEncounter::Patients::V1::Types::Patient]
102
+ # @example
103
+ # api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
104
+ # api.pre_encounter.patients.v_1.get(id: "string")
105
+ def get(id:, request_options: nil)
106
+ response = @request_client.conn.get do |req|
107
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
108
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
109
+ req.headers = {
110
+ **(req.headers || {}),
111
+ **@request_client.get_headers,
112
+ **(request_options&.additional_headers || {})
113
+ }.compact
114
+ req.url "#{@request_client.get_url(environment: PreEncounter,
115
+ request_options: request_options)}/patients/v1/#{id}"
116
+ end
117
+ CandidApiClient::PreEncounter::Patients::V1::Types::Patient.from_json(json_object: response.body)
118
+ end
119
+
120
+ # Gets a patient along with it's full history. The return list is ordered by
121
+ # version ascending.
122
+ #
123
+ # @param id [String]
124
+ # @param request_options [CandidApiClient::RequestOptions]
125
+ # @return [Array<CandidApiClient::PreEncounter::Patients::V1::Types::Patient>]
126
+ # @example
127
+ # api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
128
+ # api.pre_encounter.patients.v_1.get_history(id: "string")
129
+ def get_history(id:, request_options: nil)
130
+ response = @request_client.conn.get do |req|
131
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
132
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
133
+ req.headers = {
134
+ **(req.headers || {}),
135
+ **@request_client.get_headers,
136
+ **(request_options&.additional_headers || {})
137
+ }.compact
138
+ req.url "#{@request_client.get_url(environment: PreEncounter,
139
+ request_options: request_options)}/patients/v1/#{id}/history"
140
+ end
141
+ parsed_json = JSON.parse(response.body)
142
+ parsed_json&.map do |item|
143
+ item = item.to_json
144
+ CandidApiClient::PreEncounter::Patients::V1::Types::Patient.from_json(json_object: item)
145
+ end
146
+ end
147
+
148
+ # Updates a patient. The path must contain the most recent version to prevent
149
+ # races. Updating historic versions is not supported.
150
+ #
151
+ # @param id [String]
152
+ # @param version [String]
153
+ # @param request [Hash] Request of type CandidApiClient::PreEncounter::Patients::V1::Types::MutablePatient, as a Hash
154
+ # * :name (Hash)
155
+ # * :family (String)
156
+ # * :given (Array<String>)
157
+ # * :use (CandidApiClient::PreEncounter::Common::Types::NameUse)
158
+ # * :period (Hash)
159
+ # * :start (Date)
160
+ # * :end_ (Date)
161
+ # * :other_names (Array<CandidApiClient::PreEncounter::Common::Types::HumanName>)
162
+ # * :gender (CandidApiClient::PreEncounter::Common::Types::Gender)
163
+ # * :birth_date (Date)
164
+ # * :social_security_number (String)
165
+ # * :biological_sex (CandidApiClient::PreEncounter::Common::Types::Sex)
166
+ # * :sexual_orientation (CandidApiClient::PreEncounter::Common::Types::SexualOrientation)
167
+ # * :race (CandidApiClient::PreEncounter::Common::Types::Race)
168
+ # * :ethnicity (CandidApiClient::PreEncounter::Common::Types::Ethnicity)
169
+ # * :disability_status (CandidApiClient::PreEncounter::Common::Types::DisabilityStatus)
170
+ # * :marital_status (CandidApiClient::PreEncounter::Patients::V1::Types::MaritalStatus)
171
+ # * :deceased (DateTime)
172
+ # * :multiple_birth (Integer)
173
+ # * :primary_address (Hash)
174
+ # * :use (CandidApiClient::PreEncounter::Common::Types::AddressUse)
175
+ # * :line (Array<String>)
176
+ # * :city (String)
177
+ # * :state (String)
178
+ # * :postal_code (String)
179
+ # * :country (String)
180
+ # * :period (Hash)
181
+ # * :start (Date)
182
+ # * :end_ (Date)
183
+ # * :other_addresses (Array<CandidApiClient::PreEncounter::Common::Types::Address>)
184
+ # * :primary_telecom (Hash)
185
+ # * :value (String)
186
+ # * :use (CandidApiClient::PreEncounter::Common::Types::ContactPointUse)
187
+ # * :period (Hash)
188
+ # * :start (Date)
189
+ # * :end_ (Date)
190
+ # * :other_telecoms (Array<CandidApiClient::PreEncounter::Common::Types::ContactPoint>)
191
+ # * :email (String)
192
+ # * :electronic_communication_opt_in (Boolean)
193
+ # * :photo (String)
194
+ # * :language (String)
195
+ # * :external_provenance (Hash)
196
+ # * :external_id (String)
197
+ # * :system_name (String)
198
+ # * :contacts (Array<CandidApiClient::PreEncounter::Patients::V1::Types::Contact>)
199
+ # * :general_practitioners (Array<CandidApiClient::PreEncounter::Patients::V1::Types::ExternalProvider>)
200
+ # * :filing_order (Hash)
201
+ # * :coverages (Array<String>)
202
+ # @param request_options [CandidApiClient::RequestOptions]
203
+ # @return [CandidApiClient::PreEncounter::Patients::V1::Types::Patient]
204
+ # @example
205
+ # api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
206
+ # api.pre_encounter.patients.v_1.update(
207
+ # id: "string",
208
+ # version: "string",
209
+ # request: { name: { }, other_names: [{ }], gender: MAN, birth_date: DateTime.parse(2023-01-15), social_security_number: "string", biological_sex: FEMALE, sexual_orientation: HETEROSEXUAL, race: AMERICAN_INDIAN_OR_ALASKA_NATIVE, ethnicity: HISPANIC_OR_LATINO, disability_status: DISABLED, marital_status: ANNULLED, deceased: DateTime.parse(2024-01-15T09:30:00.000Z), multiple_birth: 1, primary_address: { }, other_addresses: [{ }], primary_telecom: { }, other_telecoms: [{ }], email: "string", electronic_communication_opt_in: true, photo: "string", language: "string", external_provenance: { external_id: "string", system_name: "string" }, contacts: [{ relationship: [SELF], name: { }, gender: MAN, telecoms: [{ }], addresses: [{ }], period: { } }], general_practitioners: [{ name: { }, npi: "string", telecoms: [{ }], addresses: [{ }], period: { } }], filing_order: { coverages: ["d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32"] } }
210
+ # )
211
+ def update(id:, version:, request:, request_options: nil)
212
+ response = @request_client.conn.put do |req|
213
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
214
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
215
+ req.headers = {
216
+ **(req.headers || {}),
217
+ **@request_client.get_headers,
218
+ **(request_options&.additional_headers || {})
219
+ }.compact
220
+ req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact
221
+ req.url "#{@request_client.get_url(environment: PreEncounter,
222
+ request_options: request_options)}/patients/v1/#{id}/#{version}"
223
+ end
224
+ CandidApiClient::PreEncounter::Patients::V1::Types::Patient.from_json(json_object: response.body)
225
+ end
226
+
227
+ # Sets a patient as deactivated. The path must contain the most recent version to
228
+ # prevent races. Dactivating historic versions is not supported. Subsequent
229
+ # updates via PUT to the patient will "reactivate" the patient and set the
230
+ # deactivated flag to false.
231
+ #
232
+ # @param id [String]
233
+ # @param version [String]
234
+ # @param request_options [CandidApiClient::RequestOptions]
235
+ # @return [Void]
236
+ # @example
237
+ # api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
238
+ # api.pre_encounter.patients.v_1.deactivate(id: "string", version: "string")
239
+ def deactivate(id:, version:, request_options: nil)
240
+ @request_client.conn.delete do |req|
241
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
242
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
243
+ req.headers = {
244
+ **(req.headers || {}),
245
+ **@request_client.get_headers,
246
+ **(request_options&.additional_headers || {})
247
+ }.compact
248
+ req.url "#{@request_client.get_url(environment: PreEncounter,
249
+ request_options: request_options)}/patients/v1/#{id}/#{version}"
250
+ end
251
+ end
252
+
253
+ # Searches for patients that match the query parameters.
254
+ #
255
+ # @param name_contains [String]
256
+ # @param request_options [CandidApiClient::RequestOptions]
257
+ # @return [Array<CandidApiClient::PreEncounter::Patients::V1::Types::Patient>]
258
+ # @example
259
+ # api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
260
+ # api.pre_encounter.patients.v_1.search(name_contains: "string")
261
+ def search(name_contains: nil, request_options: nil)
262
+ response = @request_client.conn.get do |req|
263
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
264
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
265
+ req.headers = {
266
+ **(req.headers || {}),
267
+ **@request_client.get_headers,
268
+ **(request_options&.additional_headers || {})
269
+ }.compact
270
+ req.params = {
271
+ **(request_options&.additional_query_parameters || {}),
272
+ "name_contains": name_contains
273
+ }.compact
274
+ req.url "#{@request_client.get_url(environment: PreEncounter,
275
+ request_options: request_options)}/patients/v1"
276
+ end
277
+ parsed_json = JSON.parse(response.body)
278
+ parsed_json&.map do |item|
279
+ item = item.to_json
280
+ CandidApiClient::PreEncounter::Patients::V1::Types::Patient.from_json(json_object: item)
281
+ end
282
+ end
283
+
284
+ # Scans up to 100 patient updates. The since query parameter is inclusive, and the
285
+ # result list is ordered by updatedAt descending.
286
+ #
287
+ # @param since [DateTime]
288
+ # @param request_options [CandidApiClient::RequestOptions]
289
+ # @return [Array<CandidApiClient::PreEncounter::Patients::V1::Types::Patient>]
290
+ # @example
291
+ # api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
292
+ # api.pre_encounter.patients.v_1.scan(since: DateTime.parse(2024-01-15T09:30:00.000Z))
293
+ def scan(since:, request_options: nil)
294
+ response = @request_client.conn.get do |req|
295
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
296
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
297
+ req.headers = {
298
+ **(req.headers || {}),
299
+ **@request_client.get_headers,
300
+ **(request_options&.additional_headers || {})
301
+ }.compact
302
+ req.params = { **(request_options&.additional_query_parameters || {}), "since": since }.compact
303
+ req.url "#{@request_client.get_url(environment: PreEncounter,
304
+ request_options: request_options)}/patients/v1/updates/scan"
305
+ end
306
+ parsed_json = JSON.parse(response.body)
307
+ parsed_json&.map do |item|
308
+ item = item.to_json
309
+ CandidApiClient::PreEncounter::Patients::V1::Types::Patient.from_json(json_object: item)
310
+ end
18
311
  end
19
312
  end
20
313
 
21
- class AsyncClient
22
- # @return [CandidApiClient::PreEncounter::Patients::V1::AsyncPatientsClient]
23
- attr_reader :patients
314
+ class AsyncV1Client
315
+ # @return [CandidApiClient::AsyncRequestClient]
316
+ attr_reader :request_client
24
317
 
25
318
  # @param request_client [CandidApiClient::AsyncRequestClient]
26
- # @return [CandidApiClient::PreEncounter::Patients::V1::AsyncClient]
319
+ # @return [CandidApiClient::PreEncounter::Patients::V1::AsyncV1Client]
27
320
  def initialize(request_client:)
28
- @patients = CandidApiClient::PreEncounter::Patients::V1::AsyncPatientsClient.new(request_client: request_client)
321
+ @request_client = request_client
322
+ end
323
+
324
+ # Adds a patient. VersionConflictError is returned when the patient's external ID
325
+ # is already in use.
326
+ #
327
+ # @param request [Hash] Request of type CandidApiClient::PreEncounter::Patients::V1::Types::MutablePatient, as a Hash
328
+ # * :name (Hash)
329
+ # * :family (String)
330
+ # * :given (Array<String>)
331
+ # * :use (CandidApiClient::PreEncounter::Common::Types::NameUse)
332
+ # * :period (Hash)
333
+ # * :start (Date)
334
+ # * :end_ (Date)
335
+ # * :other_names (Array<CandidApiClient::PreEncounter::Common::Types::HumanName>)
336
+ # * :gender (CandidApiClient::PreEncounter::Common::Types::Gender)
337
+ # * :birth_date (Date)
338
+ # * :social_security_number (String)
339
+ # * :biological_sex (CandidApiClient::PreEncounter::Common::Types::Sex)
340
+ # * :sexual_orientation (CandidApiClient::PreEncounter::Common::Types::SexualOrientation)
341
+ # * :race (CandidApiClient::PreEncounter::Common::Types::Race)
342
+ # * :ethnicity (CandidApiClient::PreEncounter::Common::Types::Ethnicity)
343
+ # * :disability_status (CandidApiClient::PreEncounter::Common::Types::DisabilityStatus)
344
+ # * :marital_status (CandidApiClient::PreEncounter::Patients::V1::Types::MaritalStatus)
345
+ # * :deceased (DateTime)
346
+ # * :multiple_birth (Integer)
347
+ # * :primary_address (Hash)
348
+ # * :use (CandidApiClient::PreEncounter::Common::Types::AddressUse)
349
+ # * :line (Array<String>)
350
+ # * :city (String)
351
+ # * :state (String)
352
+ # * :postal_code (String)
353
+ # * :country (String)
354
+ # * :period (Hash)
355
+ # * :start (Date)
356
+ # * :end_ (Date)
357
+ # * :other_addresses (Array<CandidApiClient::PreEncounter::Common::Types::Address>)
358
+ # * :primary_telecom (Hash)
359
+ # * :value (String)
360
+ # * :use (CandidApiClient::PreEncounter::Common::Types::ContactPointUse)
361
+ # * :period (Hash)
362
+ # * :start (Date)
363
+ # * :end_ (Date)
364
+ # * :other_telecoms (Array<CandidApiClient::PreEncounter::Common::Types::ContactPoint>)
365
+ # * :email (String)
366
+ # * :electronic_communication_opt_in (Boolean)
367
+ # * :photo (String)
368
+ # * :language (String)
369
+ # * :external_provenance (Hash)
370
+ # * :external_id (String)
371
+ # * :system_name (String)
372
+ # * :contacts (Array<CandidApiClient::PreEncounter::Patients::V1::Types::Contact>)
373
+ # * :general_practitioners (Array<CandidApiClient::PreEncounter::Patients::V1::Types::ExternalProvider>)
374
+ # * :filing_order (Hash)
375
+ # * :coverages (Array<String>)
376
+ # @param request_options [CandidApiClient::RequestOptions]
377
+ # @return [CandidApiClient::PreEncounter::Patients::V1::Types::Patient]
378
+ # @example
379
+ # api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
380
+ # api.pre_encounter.patients.v_1.create(request: { name: { }, other_names: [{ }], gender: MAN, birth_date: DateTime.parse(2023-01-15), social_security_number: "string", biological_sex: FEMALE, sexual_orientation: HETEROSEXUAL, race: AMERICAN_INDIAN_OR_ALASKA_NATIVE, ethnicity: HISPANIC_OR_LATINO, disability_status: DISABLED, marital_status: ANNULLED, deceased: DateTime.parse(2024-01-15T09:30:00.000Z), multiple_birth: 1, primary_address: { }, other_addresses: [{ }], primary_telecom: { }, other_telecoms: [{ }], email: "string", electronic_communication_opt_in: true, photo: "string", language: "string", external_provenance: { external_id: "string", system_name: "string" }, contacts: [{ relationship: [SELF], name: { }, gender: MAN, telecoms: [{ }], addresses: [{ }], period: { } }], general_practitioners: [{ name: { }, npi: "string", telecoms: [{ }], addresses: [{ }], period: { } }], filing_order: { coverages: ["d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32"] } })
381
+ def create(request:, request_options: nil)
382
+ Async do
383
+ response = @request_client.conn.post do |req|
384
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
385
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
386
+ req.headers = {
387
+ **(req.headers || {}),
388
+ **@request_client.get_headers,
389
+ **(request_options&.additional_headers || {})
390
+ }.compact
391
+ req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact
392
+ req.url "#{@request_client.get_url(environment: PreEncounter,
393
+ request_options: request_options)}/patients/v1"
394
+ end
395
+ CandidApiClient::PreEncounter::Patients::V1::Types::Patient.from_json(json_object: response.body)
396
+ end
397
+ end
398
+
399
+ # Gets a patient.
400
+ #
401
+ # @param id [String]
402
+ # @param request_options [CandidApiClient::RequestOptions]
403
+ # @return [CandidApiClient::PreEncounter::Patients::V1::Types::Patient]
404
+ # @example
405
+ # api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
406
+ # api.pre_encounter.patients.v_1.get(id: "string")
407
+ def get(id:, request_options: nil)
408
+ Async do
409
+ response = @request_client.conn.get do |req|
410
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
411
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
412
+ req.headers = {
413
+ **(req.headers || {}),
414
+ **@request_client.get_headers,
415
+ **(request_options&.additional_headers || {})
416
+ }.compact
417
+ req.url "#{@request_client.get_url(environment: PreEncounter,
418
+ request_options: request_options)}/patients/v1/#{id}"
419
+ end
420
+ CandidApiClient::PreEncounter::Patients::V1::Types::Patient.from_json(json_object: response.body)
421
+ end
422
+ end
423
+
424
+ # Gets a patient along with it's full history. The return list is ordered by
425
+ # version ascending.
426
+ #
427
+ # @param id [String]
428
+ # @param request_options [CandidApiClient::RequestOptions]
429
+ # @return [Array<CandidApiClient::PreEncounter::Patients::V1::Types::Patient>]
430
+ # @example
431
+ # api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
432
+ # api.pre_encounter.patients.v_1.get_history(id: "string")
433
+ def get_history(id:, request_options: nil)
434
+ Async do
435
+ response = @request_client.conn.get do |req|
436
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
437
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
438
+ req.headers = {
439
+ **(req.headers || {}),
440
+ **@request_client.get_headers,
441
+ **(request_options&.additional_headers || {})
442
+ }.compact
443
+ req.url "#{@request_client.get_url(environment: PreEncounter,
444
+ request_options: request_options)}/patients/v1/#{id}/history"
445
+ end
446
+ parsed_json = JSON.parse(response.body)
447
+ parsed_json&.map do |item|
448
+ item = item.to_json
449
+ CandidApiClient::PreEncounter::Patients::V1::Types::Patient.from_json(json_object: item)
450
+ end
451
+ end
452
+ end
453
+
454
+ # Updates a patient. The path must contain the most recent version to prevent
455
+ # races. Updating historic versions is not supported.
456
+ #
457
+ # @param id [String]
458
+ # @param version [String]
459
+ # @param request [Hash] Request of type CandidApiClient::PreEncounter::Patients::V1::Types::MutablePatient, as a Hash
460
+ # * :name (Hash)
461
+ # * :family (String)
462
+ # * :given (Array<String>)
463
+ # * :use (CandidApiClient::PreEncounter::Common::Types::NameUse)
464
+ # * :period (Hash)
465
+ # * :start (Date)
466
+ # * :end_ (Date)
467
+ # * :other_names (Array<CandidApiClient::PreEncounter::Common::Types::HumanName>)
468
+ # * :gender (CandidApiClient::PreEncounter::Common::Types::Gender)
469
+ # * :birth_date (Date)
470
+ # * :social_security_number (String)
471
+ # * :biological_sex (CandidApiClient::PreEncounter::Common::Types::Sex)
472
+ # * :sexual_orientation (CandidApiClient::PreEncounter::Common::Types::SexualOrientation)
473
+ # * :race (CandidApiClient::PreEncounter::Common::Types::Race)
474
+ # * :ethnicity (CandidApiClient::PreEncounter::Common::Types::Ethnicity)
475
+ # * :disability_status (CandidApiClient::PreEncounter::Common::Types::DisabilityStatus)
476
+ # * :marital_status (CandidApiClient::PreEncounter::Patients::V1::Types::MaritalStatus)
477
+ # * :deceased (DateTime)
478
+ # * :multiple_birth (Integer)
479
+ # * :primary_address (Hash)
480
+ # * :use (CandidApiClient::PreEncounter::Common::Types::AddressUse)
481
+ # * :line (Array<String>)
482
+ # * :city (String)
483
+ # * :state (String)
484
+ # * :postal_code (String)
485
+ # * :country (String)
486
+ # * :period (Hash)
487
+ # * :start (Date)
488
+ # * :end_ (Date)
489
+ # * :other_addresses (Array<CandidApiClient::PreEncounter::Common::Types::Address>)
490
+ # * :primary_telecom (Hash)
491
+ # * :value (String)
492
+ # * :use (CandidApiClient::PreEncounter::Common::Types::ContactPointUse)
493
+ # * :period (Hash)
494
+ # * :start (Date)
495
+ # * :end_ (Date)
496
+ # * :other_telecoms (Array<CandidApiClient::PreEncounter::Common::Types::ContactPoint>)
497
+ # * :email (String)
498
+ # * :electronic_communication_opt_in (Boolean)
499
+ # * :photo (String)
500
+ # * :language (String)
501
+ # * :external_provenance (Hash)
502
+ # * :external_id (String)
503
+ # * :system_name (String)
504
+ # * :contacts (Array<CandidApiClient::PreEncounter::Patients::V1::Types::Contact>)
505
+ # * :general_practitioners (Array<CandidApiClient::PreEncounter::Patients::V1::Types::ExternalProvider>)
506
+ # * :filing_order (Hash)
507
+ # * :coverages (Array<String>)
508
+ # @param request_options [CandidApiClient::RequestOptions]
509
+ # @return [CandidApiClient::PreEncounter::Patients::V1::Types::Patient]
510
+ # @example
511
+ # api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
512
+ # api.pre_encounter.patients.v_1.update(
513
+ # id: "string",
514
+ # version: "string",
515
+ # request: { name: { }, other_names: [{ }], gender: MAN, birth_date: DateTime.parse(2023-01-15), social_security_number: "string", biological_sex: FEMALE, sexual_orientation: HETEROSEXUAL, race: AMERICAN_INDIAN_OR_ALASKA_NATIVE, ethnicity: HISPANIC_OR_LATINO, disability_status: DISABLED, marital_status: ANNULLED, deceased: DateTime.parse(2024-01-15T09:30:00.000Z), multiple_birth: 1, primary_address: { }, other_addresses: [{ }], primary_telecom: { }, other_telecoms: [{ }], email: "string", electronic_communication_opt_in: true, photo: "string", language: "string", external_provenance: { external_id: "string", system_name: "string" }, contacts: [{ relationship: [SELF], name: { }, gender: MAN, telecoms: [{ }], addresses: [{ }], period: { } }], general_practitioners: [{ name: { }, npi: "string", telecoms: [{ }], addresses: [{ }], period: { } }], filing_order: { coverages: ["d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32"] } }
516
+ # )
517
+ def update(id:, version:, request:, request_options: nil)
518
+ Async do
519
+ response = @request_client.conn.put do |req|
520
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
521
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
522
+ req.headers = {
523
+ **(req.headers || {}),
524
+ **@request_client.get_headers,
525
+ **(request_options&.additional_headers || {})
526
+ }.compact
527
+ req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact
528
+ req.url "#{@request_client.get_url(environment: PreEncounter,
529
+ request_options: request_options)}/patients/v1/#{id}/#{version}"
530
+ end
531
+ CandidApiClient::PreEncounter::Patients::V1::Types::Patient.from_json(json_object: response.body)
532
+ end
533
+ end
534
+
535
+ # Sets a patient as deactivated. The path must contain the most recent version to
536
+ # prevent races. Dactivating historic versions is not supported. Subsequent
537
+ # updates via PUT to the patient will "reactivate" the patient and set the
538
+ # deactivated flag to false.
539
+ #
540
+ # @param id [String]
541
+ # @param version [String]
542
+ # @param request_options [CandidApiClient::RequestOptions]
543
+ # @return [Void]
544
+ # @example
545
+ # api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
546
+ # api.pre_encounter.patients.v_1.deactivate(id: "string", version: "string")
547
+ def deactivate(id:, version:, request_options: nil)
548
+ Async do
549
+ @request_client.conn.delete do |req|
550
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
551
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
552
+ req.headers = {
553
+ **(req.headers || {}),
554
+ **@request_client.get_headers,
555
+ **(request_options&.additional_headers || {})
556
+ }.compact
557
+ req.url "#{@request_client.get_url(environment: PreEncounter,
558
+ request_options: request_options)}/patients/v1/#{id}/#{version}"
559
+ end
560
+ end
561
+ end
562
+
563
+ # Searches for patients that match the query parameters.
564
+ #
565
+ # @param name_contains [String]
566
+ # @param request_options [CandidApiClient::RequestOptions]
567
+ # @return [Array<CandidApiClient::PreEncounter::Patients::V1::Types::Patient>]
568
+ # @example
569
+ # api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
570
+ # api.pre_encounter.patients.v_1.search(name_contains: "string")
571
+ def search(name_contains: nil, request_options: nil)
572
+ Async do
573
+ response = @request_client.conn.get do |req|
574
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
575
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
576
+ req.headers = {
577
+ **(req.headers || {}),
578
+ **@request_client.get_headers,
579
+ **(request_options&.additional_headers || {})
580
+ }.compact
581
+ req.params = {
582
+ **(request_options&.additional_query_parameters || {}),
583
+ "name_contains": name_contains
584
+ }.compact
585
+ req.url "#{@request_client.get_url(environment: PreEncounter,
586
+ request_options: request_options)}/patients/v1"
587
+ end
588
+ parsed_json = JSON.parse(response.body)
589
+ parsed_json&.map do |item|
590
+ item = item.to_json
591
+ CandidApiClient::PreEncounter::Patients::V1::Types::Patient.from_json(json_object: item)
592
+ end
593
+ end
594
+ end
595
+
596
+ # Scans up to 100 patient updates. The since query parameter is inclusive, and the
597
+ # result list is ordered by updatedAt descending.
598
+ #
599
+ # @param since [DateTime]
600
+ # @param request_options [CandidApiClient::RequestOptions]
601
+ # @return [Array<CandidApiClient::PreEncounter::Patients::V1::Types::Patient>]
602
+ # @example
603
+ # api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
604
+ # api.pre_encounter.patients.v_1.scan(since: DateTime.parse(2024-01-15T09:30:00.000Z))
605
+ def scan(since:, request_options: nil)
606
+ Async do
607
+ response = @request_client.conn.get do |req|
608
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
609
+ req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
610
+ req.headers = {
611
+ **(req.headers || {}),
612
+ **@request_client.get_headers,
613
+ **(request_options&.additional_headers || {})
614
+ }.compact
615
+ req.params = { **(request_options&.additional_query_parameters || {}), "since": since }.compact
616
+ req.url "#{@request_client.get_url(environment: PreEncounter,
617
+ request_options: request_options)}/patients/v1/updates/scan"
618
+ end
619
+ parsed_json = JSON.parse(response.body)
620
+ parsed_json&.map do |item|
621
+ item = item.to_json
622
+ CandidApiClient::PreEncounter::Patients::V1::Types::Patient.from_json(json_object: item)
623
+ end
624
+ end
29
625
  end
30
626
  end
31
627
  end