candidhealth 1.7.0 → 1.8.0

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 (83) hide show
  1. checksums.yaml +4 -4
  2. data/lib/candidhealth/auth/default/client.rb +34 -6
  3. data/lib/candidhealth/charge_capture/v_1/client.rb +48 -48
  4. data/lib/candidhealth/charge_capture/v_1/types/charge_capture_data.rb +70 -56
  5. data/lib/candidhealth/commons/types/clearinghouse.rb +18 -0
  6. data/lib/candidhealth/commons/types/procedure_modifier.rb +11 -0
  7. data/lib/candidhealth/encounter_providers/v_2/types/billing_provider.rb +1 -1
  8. data/lib/candidhealth/encounter_providers/v_2/types/billing_provider_update.rb +1 -1
  9. data/lib/candidhealth/encounter_providers/v_2/types/billing_provider_update_with_optional_address.rb +1 -1
  10. data/lib/candidhealth/encounters/v_4/client.rb +3253 -2040
  11. data/lib/candidhealth/encounters/v_4/types/encounter.rb +111 -86
  12. data/lib/candidhealth/encounters/v_4/types/encounter_base.rb +39 -33
  13. data/lib/candidhealth/encounters/v_4/types/encounter_create.rb +796 -0
  14. data/lib/candidhealth/encounters/v_4/types/encounter_create_from_pre_encounter.rb +131 -117
  15. data/lib/candidhealth/encounters/v_4/types/encounter_deep_optional.rb +70 -56
  16. data/lib/candidhealth/encounters/v_4/types/encounter_optional.rb +29 -39
  17. data/lib/candidhealth/encounters/v_4/types/encounter_rendering_or_attending_provider_required_error.rb +55 -0
  18. data/lib/candidhealth/encounters/v_4/types/encounter_update.rb +736 -0
  19. data/lib/candidhealth/encounters_universal/types/universal_encounter_create.rb +944 -0
  20. data/lib/candidhealth/encounters_universal/types/universal_encounter_create_base.rb +691 -0
  21. data/lib/candidhealth/encounters_universal/types/universal_encounter_create_from_pre_encounter.rb +791 -0
  22. data/lib/candidhealth/encounters_universal/types/universal_encounter_create_from_pre_encounter_base.rb +572 -0
  23. data/lib/candidhealth/encounters_universal/types/universal_encounter_update.rb +872 -0
  24. data/lib/candidhealth/encounters_universal/types/universal_encounter_update_base.rb +700 -0
  25. data/lib/candidhealth/fee_schedules/v_3/client.rb +57 -0
  26. data/lib/candidhealth/fee_schedules/v_3/types/validation_error.rb +12 -0
  27. data/lib/candidhealth/financials/types/patient_transaction_source.rb +1 -0
  28. data/lib/candidhealth/health_care_code_information/v_1/types/admitting_diagnosis_new.rb +206 -0
  29. data/lib/candidhealth/health_care_code_information/v_1/types/condition_information_new.rb +207 -0
  30. data/lib/candidhealth/health_care_code_information/v_1/types/diagnosis_related_group_new.rb +206 -0
  31. data/lib/candidhealth/health_care_code_information/v_1/types/external_cause_of_injury_new.rb +245 -0
  32. data/lib/candidhealth/health_care_code_information/v_1/types/health_care_code_information_create.rb +225 -0
  33. data/lib/candidhealth/health_care_code_information/v_1/types/occurrence_information_new.rb +219 -0
  34. data/lib/candidhealth/health_care_code_information/v_1/types/occurrence_span_information_new.rb +222 -0
  35. data/lib/candidhealth/health_care_code_information/v_1/types/other_diagnosis_information_new.rb +215 -0
  36. data/lib/candidhealth/health_care_code_information/v_1/types/other_procedure_information_new.rb +218 -0
  37. data/lib/candidhealth/health_care_code_information/v_1/types/patient_reason_for_visit_new.rb +206 -0
  38. data/lib/candidhealth/health_care_code_information/v_1/types/principal_diagnosis_new.rb +215 -0
  39. data/lib/candidhealth/health_care_code_information/v_1/types/principal_procedure_information_new.rb +216 -0
  40. data/lib/candidhealth/health_care_code_information/v_1/types/treatment_code_information_new.rb +206 -0
  41. data/lib/candidhealth/health_care_code_information/v_1/types/value_information_new.rb +215 -0
  42. data/lib/candidhealth/individual/types/patient.rb +6 -6
  43. data/lib/candidhealth/individual/types/patient_base.rb +6 -6
  44. data/lib/candidhealth/individual/types/patient_create.rb +6 -6
  45. data/lib/candidhealth/individual/types/patient_update.rb +6 -6
  46. data/lib/candidhealth/individual/types/patient_update_with_optional_address.rb +6 -6
  47. data/lib/candidhealth/organization_providers/v_2/types/license_type.rb +2 -0
  48. data/lib/candidhealth/payers/client.rb +7 -0
  49. data/lib/candidhealth/payers/v_4/client.rb +137 -0
  50. data/lib/candidhealth/payers/v_4/types/clearinghouse_payer_info.rb +93 -0
  51. data/lib/candidhealth/payers/v_4/types/payer.rb +116 -0
  52. data/lib/candidhealth/payers/v_4/types/payer_ids.rb +107 -0
  53. data/lib/candidhealth/payers/v_4/types/payer_page.rb +88 -0
  54. data/lib/candidhealth/payers/v_4/types/support_state.rb +15 -0
  55. data/lib/candidhealth/pre_encounter/coverages/v_1/client.rb +4 -4
  56. data/lib/candidhealth/pre_encounter/coverages/v_1/types/subscriber.rb +3 -3
  57. data/lib/candidhealth/pre_encounter/patients/v_1/client.rb +72 -6
  58. data/lib/candidhealth/pre_encounter/patients/v_1/types/guarantor.rb +3 -3
  59. data/lib/candidhealth/pre_encounter/patients/v_1/types/inferred_patient_metadata.rb +80 -0
  60. data/lib/candidhealth/pre_encounter/patients/v_1/types/mutable_patient.rb +19 -5
  61. data/lib/candidhealth/pre_encounter/patients/v_1/types/mutable_patient_with_mrn.rb +19 -5
  62. data/lib/candidhealth/pre_encounter/patients/v_1/types/patient.rb +18 -4
  63. data/lib/candidhealth/pre_encounter/patients/v_1/types/referral_type.rb +1 -0
  64. data/lib/candidhealth/service_lines/v_2/client.rb +252 -10
  65. data/lib/candidhealth/service_lines/v_2/types/service_line.rb +28 -10
  66. data/lib/candidhealth/service_lines/v_2/types/service_line_create.rb +52 -40
  67. data/lib/candidhealth/service_lines/v_2/types/service_line_create_base.rb +251 -0
  68. data/lib/candidhealth/service_lines/v_2/types/service_line_create_base_base.rb +243 -0
  69. data/lib/candidhealth/service_lines/v_2/types/service_line_create_optional.rb +48 -24
  70. data/lib/candidhealth/service_lines/v_2/types/service_line_create_standalone.rb +58 -46
  71. data/lib/candidhealth/service_lines/v_2/types/service_line_create_standalone_base.rb +273 -0
  72. data/lib/candidhealth/service_lines/v_2/types/service_line_create_standalone_base_base.rb +265 -0
  73. data/lib/candidhealth/service_lines/v_2/types/service_line_update.rb +64 -54
  74. data/lib/candidhealth/service_lines/v_2/types/service_line_update_base.rb +263 -0
  75. data/lib/candidhealth/service_lines/v_2/types/universal_service_line_create.rb +271 -0
  76. data/lib/candidhealth/service_lines/v_2/types/universal_service_line_create_standalone.rb +317 -0
  77. data/lib/candidhealth/service_lines/v_2/types/universal_service_line_update.rb +307 -0
  78. data/lib/candidhealth/x_12/v_1/types/type_of_bill_composite.rb +2 -2
  79. data/lib/candidhealth/x_12/v_1/types/type_of_bill_composite_base.rb +90 -0
  80. data/lib/candidhealth/x_12/v_1/types/type_of_bill_composite_update.rb +112 -0
  81. data/lib/requests.rb +2 -2
  82. data/lib/types_export.rb +44 -4
  83. metadata +43 -2
@@ -0,0 +1,796 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../../encounter_providers/v_2/types/billing_provider"
4
+ require_relative "../../../diagnoses/types/diagnosis_create"
5
+ require_relative "../../../commons/types/facility_type_code"
6
+ require_relative "../../../encounter_providers/v_2/types/rendering_provider"
7
+ require_relative "../../../service_lines/v_2/types/service_line_create"
8
+ require_relative "../../../individual/types/patient_create"
9
+ require_relative "../../../encounter_providers/v_2/types/referring_provider"
10
+ require_relative "../../../encounter_providers/v_2/types/initial_referring_provider"
11
+ require_relative "../../../encounter_providers/v_2/types/supervising_provider"
12
+ require_relative "../../../service_facility/types/encounter_service_facility_base"
13
+ require_relative "../../../individual/types/subscriber_create"
14
+ require_relative "responsible_party_type"
15
+ require_relative "clinical_note_category_create"
16
+ require_relative "../../../billing_notes/v_2/types/billing_note_base"
17
+ require_relative "patient_history_category"
18
+ require_relative "../../../guarantor/v_1/types/guarantor_create"
19
+ require_relative "../../../claim_submission/v_1/types/external_claim_submission_create"
20
+ require_relative "../../../custom_schemas/v_1/types/schema_instance"
21
+ require_relative "epsdt_referral"
22
+ require_relative "claim_supplemental_information"
23
+ require "date"
24
+ require_relative "medication"
25
+ require_relative "intervention"
26
+ require_relative "../../../commons/types/street_address_long_zip"
27
+ require_relative "synchronicity_type"
28
+ require_relative "vitals"
29
+ require_relative "billable_status_type"
30
+ require_relative "service_authorization_exception_code"
31
+ require_relative "../../../commons/types/delay_reason_code"
32
+ require "ostruct"
33
+ require "json"
34
+
35
+ module CandidApiClient
36
+ module Encounters
37
+ module V4
38
+ module Types
39
+ class EncounterCreate
40
+ # @return [CandidApiClient::EncounterProviders::V2::Types::BillingProvider] The billing provider is the provider or business entity submitting the claim.
41
+ # Billing provider may be, but is not necessarily, the same person/NPI as the
42
+ # rendering provider. From a payer's perspective, this represents the person or
43
+ # entity being reimbursed. When a contract exists with the target payer, the
44
+ # billing provider should be the entity contracted with the payer. In some
45
+ # circumstances, this will be an individual provider. In that case, submit that
46
+ # provider's NPI and the tax ID (TIN) that the provider gave to the payer during
47
+ # contracting. In other cases, the billing entity will be a medical group. If so,
48
+ # submit the group NPI and the group's tax ID. Box 33 on the CMS-1500 claim form
49
+ # or Form Locator 1 on a UB-04 claim form..
50
+ attr_reader :billing_provider
51
+ # @return [Array<CandidApiClient::Diagnoses::Types::DiagnosisCreate>] Ideally, this field should contain no more than 12 diagnoses. However, more
52
+ # diagnoses
53
+ # may be submitted at this time, and coders will later prioritize the 12 that will
54
+ # be
55
+ # submitted to the payor.
56
+ attr_reader :diagnoses
57
+ # @return [CandidApiClient::Commons::Types::FacilityTypeCode] Box 24B on the CMS-1500 claim form. 837p Loop2300, CLM-05-1. 02 for
58
+ # telemedicine, 11 for in-person. Full list
59
+ # //www.cms.gov/Medicare/Coding/place-of-service-codes/Place_of_Service_Code_Set).
60
+ attr_reader :place_of_service_code
61
+ # @return [CandidApiClient::EncounterProviders::V2::Types::RenderingProvider] The rendering provider is the practitioner -- physician, nurse practitioner,
62
+ # etc. -- performing the service.
63
+ # For telehealth services, the rendering provider performs the visit, asynchronous
64
+ # communication, or other service. The rendering provider address should generally
65
+ # be the same as the service facility address.
66
+ attr_reader :rendering_provider
67
+ # @return [Array<CandidApiClient::ServiceLines::V2::Types::ServiceLineCreate>] Each service line must be linked to a diagnosis. Concretely,
68
+ # `service_line.diagnosis_pointers`must contain at least one entry which should be
69
+ # in bounds of the diagnoses list field.
70
+ attr_reader :service_lines
71
+ # @return [CandidApiClient::Individual::Types::PatientCreate] Contains the identification information of the individual receiving medical
72
+ # services.
73
+ attr_reader :patient
74
+ # @return [CandidApiClient::EncounterProviders::V2::Types::ReferringProvider] The final provider who referred the services that were rendered.
75
+ # All physicians who order services or refer Medicare beneficiaries must
76
+ # report this data.
77
+ attr_reader :referring_provider
78
+ # @return [CandidApiClient::EncounterProviders::V2::Types::InitialReferringProvider] The second iteration of Loop ID-2310 on an 837P form. Use code "P3 - Primary
79
+ # Care Provider" in this loop to
80
+ # indicate the initial referral from the primary care provider or whatever
81
+ # provider wrote the initial referral for this patient's episode of care being
82
+ # billed/reported in this transaction.
83
+ # Not used in an 837i claim
84
+ attr_reader :initial_referring_provider
85
+ # @return [CandidApiClient::EncounterProviders::V2::Types::SupervisingProvider] Required when the rendering provider is supervised by a physician. If not
86
+ # required by this implementation guide, do not send.
87
+ attr_reader :supervising_provider
88
+ # @return [CandidApiClient::ServiceFacility::Types::EncounterServiceFacilityBase] Encounter Service facility is typically the location a medical service was
89
+ # rendered, such as a provider office or hospital. For telehealth, service
90
+ # facility can represent the provider's location when the service was delivered
91
+ # (e.g., home), or the location where an in-person visit would have taken place,
92
+ # whichever is easier to identify. If the provider is in-network, service facility
93
+ # may be defined in payer contracts. Box 32 on the CMS-1500 claim form. There is
94
+ # no equivalent on the paper UB-04 claim form, but this field is equivalent to
95
+ # Loop 2310E Service Facility Location details on an 837i form, and is used when
96
+ # this is different to the entity identified as the Billing Provider. Note that
97
+ # for an in-network claim to be successfully adjudicated, the service facility
98
+ # address listed
99
+ attr_reader :service_facility
100
+ # @return [CandidApiClient::Individual::Types::SubscriberCreate] Subscriber_primary is required when responsible_party is INSURANCE_PAY (i.e.
101
+ # when the claim should be billed to insurance).
102
+ # These are not required fields when responsible_party is SELF_PAY (i.e. when the
103
+ # claim should be billed to the patient).
104
+ # However, if you collect this for patients, even self-pay, we recommend including
105
+ # it when sending encounters to Candid.
106
+ # Note: Cash Pay is no longer a valid payer_id in v4, please use responsible party
107
+ # to define self-pay claims.
108
+ attr_reader :subscriber_primary
109
+ # @return [CandidApiClient::Individual::Types::SubscriberCreate] Please always include this when you have it, even for self-pay claims.
110
+ attr_reader :subscriber_secondary
111
+ # @return [CandidApiClient::Individual::Types::SubscriberCreate] Please always include this when you have it, even for self-pay claims.
112
+ attr_reader :subscriber_tertiary
113
+ # @return [String] Box 23 on the CMS-1500 claim form or Form Locator 63 on a UB-04 claim form.
114
+ attr_reader :prior_authorization_number
115
+ # @return [CandidApiClient::Encounters::V4::Types::ResponsiblePartyType] Defines the party to be billed with the initial balance owed on the claim.
116
+ attr_reader :responsible_party
117
+ # @return [Array<CandidApiClient::Encounters::V4::Types::ClinicalNoteCategoryCreate>] Holds a collection of clinical observations made by healthcare providers during
118
+ # patient encounters. Please note that medical records for appeals should be sent
119
+ # using the Encounter Attachments API.
120
+ attr_reader :clinical_notes
121
+ # @return [Array<CandidApiClient::BillingNotes::V2::Types::BillingNoteBase>] Spot to store misc, human-readable, notes about this encounter to be used
122
+ # in the billing process.
123
+ attr_reader :billing_notes
124
+ # @return [Array<CandidApiClient::Encounters::V4::Types::PatientHistoryCategory>]
125
+ attr_reader :patient_histories
126
+ # @return [CandidApiClient::Guarantor::V1::Types::GuarantorCreate] Personal and contact info for the guarantor of the patient responsibility.
127
+ attr_reader :guarantor
128
+ # @return [CandidApiClient::ClaimSubmission::V1::Types::ExternalClaimSubmissionCreate] To be included for claims that have been submitted outside of Candid.
129
+ # Candid supports posting remits and payments to these claims and working them
130
+ # in-platform (e.g. editing, resubmitting).
131
+ attr_reader :external_claim_submission
132
+ # @return [Array<String>] Names of tags that should be on the encounter.
133
+ attr_reader :tag_ids
134
+ # @return [Array<CandidApiClient::CustomSchemas::V1::Types::SchemaInstance>] Key-value pairs that must adhere to a schema created via the Custom Schema API.
135
+ # Multiple schema
136
+ # instances cannot be created for the same schema on an encounter.
137
+ attr_reader :schema_instances
138
+ # @return [String] Refers to REF*9F on the 837p and 837i. Value cannot be greater than 50
139
+ # characters.
140
+ attr_reader :referral_number
141
+ # @return [CandidApiClient::Encounters::V4::Types::EpsdtReferral] Refers to Box 24H on the CMS1500 form and Loop 2300 CRC - EPSDT Referral on the
142
+ # 837P and 837i form
143
+ attr_reader :epsdt_referral
144
+ # @return [Array<CandidApiClient::Encounters::V4::Types::ClaimSupplementalInformation>] Refers to Loop 2300 - Segment PWK on the 837P and 837i forms. No more than 10
145
+ # entries are permitted.
146
+ attr_reader :claim_supplemental_information
147
+ # @return [String] When Medicaid is billed as the secondary payer the Carrier Code is used to
148
+ # identify the primary payer. This is required for certain states.
149
+ attr_reader :secondary_payer_carrier_code
150
+ # @return [String] A client-specified unique ID to associate with this encounter;
151
+ # for example, your internal encounter ID or a Dr. Chrono encounter ID.
152
+ # This field should not contain PHI.
153
+ attr_reader :external_id
154
+ # @return [Date] Date formatted as YYYY-MM-DD; eg: 2019-08-24.
155
+ # This date must be the local date in the timezone where the service occurred.
156
+ # Box 24a on the CMS-1500 claim form or Form Locator 45 on the UB-04 claim form.
157
+ # If service occurred over a range of dates, this should be the start date.
158
+ # date_of_service must be defined on either the encounter or the service lines but
159
+ # not both.
160
+ # If there are greater than zero service lines, it is recommended to specify
161
+ # date_of_service on the service_line instead of on the encounter to prepare for
162
+ # future API versions.
163
+ attr_reader :date_of_service
164
+ # @return [Date] Date formatted as YYYY-MM-DD; eg: 2019-08-25.
165
+ # This date must be the local date in the timezone where the service occurred.
166
+ # If omitted, the Encounter is assumed to be for a single day.
167
+ # Must not be temporally before the date_of_service field.
168
+ # If there are greater than zero service lines, it is recommended to specify
169
+ # end_date_of_service on the service_line instead of on the encounter to prepare
170
+ # for future API versions.
171
+ attr_reader :end_date_of_service
172
+ # @return [Boolean] Whether this patient has authorized the release of medical information
173
+ # for billing purpose.
174
+ # Box 12 on the CMS-1500 claim form or Form Locator 52 on a UB-04 claim form.
175
+ attr_reader :patient_authorized_release
176
+ # @return [Boolean] Whether this patient has authorized insurance payments to be made to you,
177
+ # not them. If false, patient may receive reimbursement.
178
+ # Box 13 on the CMS-1500 claim form or Form Locator 53 on a UB-04 claim form.
179
+ attr_reader :benefits_assigned_to_provider
180
+ # @return [Boolean] Whether you have accepted the patient's authorization for insurance payments
181
+ # to be made to you, not them.
182
+ # Box 27 on the CMS-1500 claim form. There is no exact equivalent of this field on
183
+ # a UB-04 claim, however contributes to the concept of Form Locator 53.
184
+ attr_reader :provider_accepts_assignment
185
+ # @return [String] Human-readable description of the appointment type (ex: "Acupuncture -
186
+ # Headaches").
187
+ attr_reader :appointment_type
188
+ # @return [Array<CandidApiClient::Encounters::V4::Types::Medication>]
189
+ attr_reader :existing_medications
190
+ # @return [Array<CandidApiClient::Encounters::V4::Types::Intervention>]
191
+ attr_reader :interventions
192
+ # @return [CandidApiClient::Commons::Types::StreetAddressLongZip] Specifies the address to which payments for the claim should be sent.
193
+ attr_reader :pay_to_address
194
+ # @return [CandidApiClient::Encounters::V4::Types::SynchronicityType] Whether or not this was a synchronous or asynchronous encounter.
195
+ # Asynchronous encounters occur when providers and patients communicate online
196
+ # using
197
+ # forms, instant messaging, or other pre-recorded digital mediums.
198
+ # Synchronous encounters occur in live, real-time settings where the patient
199
+ # interacts
200
+ # directly with the provider, such as over video or a phone call.
201
+ attr_reader :synchronicity
202
+ # @return [CandidApiClient::Encounters::V4::Types::Vitals]
203
+ attr_reader :vitals
204
+ # @return [CandidApiClient::Encounters::V4::Types::BillableStatusType] Defines if the Encounter is to be billed by Candid to the responsible_party.
205
+ # Examples for when this should be set to NOT_BILLABLE include
206
+ # if the Encounter has not occurred yet or if there is no intention of ever
207
+ # billing the responsible_party.
208
+ attr_reader :billable_status
209
+ # @return [String] Defines additional information on the claim needed by the payer.
210
+ # Box 19 on the CMS-1500 claim form or Form Locator 80 on a UB-04 claim form.
211
+ attr_reader :additional_information
212
+ # @return [CandidApiClient::Encounters::V4::Types::ServiceAuthorizationExceptionCode] 837p Loop2300 REF*4N
213
+ # Required when mandated by government law or regulation to obtain authorization
214
+ # for specific service(s) but, for the
215
+ # reasons listed in one of the enum values of ServiceAuthorizationExceptionCode,
216
+ # the service was performed without
217
+ # obtaining the authorization.
218
+ attr_reader :service_authorization_exception_code
219
+ # @return [Date] 837p Loop2300 DTP*435, CMS-1500 Box 18 or UB-04 Form Locator 12.
220
+ # Required on all ambulance claims when the patient was known to be admitted to
221
+ # the hospital.
222
+ # OR
223
+ # Required on all claims involving inpatient medical visits.
224
+ attr_reader :admission_date
225
+ # @return [Date] 837p Loop2300 DTP*096, CMS-1500 Box 18 Required for inpatient claims when the
226
+ # patient was discharged from the facility and the discharge date is known. Not
227
+ # used on an institutional claim.
228
+ attr_reader :discharge_date
229
+ # @return [Date] 837p Loop2300 DTP*431, CMS-1500 Box 14
230
+ # Required for the initial medical service or visit performed in response to a
231
+ # medical emergency when the date is available and is different than the date of
232
+ # service.
233
+ # OR
234
+ # This date is the onset of acute symptoms for the current illness or condition.
235
+ # For UB-04 claims, this is populated separately via occurrence codes.
236
+ attr_reader :onset_of_current_illness_or_symptom_date
237
+ # @return [Date] 837p Loop2300 DTP*484, CMS-1500 Box 14
238
+ # Required when, in the judgment of the provider, the services on this claim are
239
+ # related to the patient's pregnancy.
240
+ # This field is populated separately via occurrence codes for UB-04 claim forms.
241
+ attr_reader :last_menstrual_period_date
242
+ # @return [CandidApiClient::Commons::Types::DelayReasonCode] 837i Loop2300, CLM-1300 Box 20
243
+ # Code indicating the reason why a request was delayed
244
+ attr_reader :delay_reason_code
245
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
246
+ attr_reader :additional_properties
247
+ # @return [Object]
248
+ attr_reader :_field_set
249
+ protected :_field_set
250
+
251
+ OMIT = Object.new
252
+
253
+ # @param billing_provider [CandidApiClient::EncounterProviders::V2::Types::BillingProvider] The billing provider is the provider or business entity submitting the claim.
254
+ # Billing provider may be, but is not necessarily, the same person/NPI as the
255
+ # rendering provider. From a payer's perspective, this represents the person or
256
+ # entity being reimbursed. When a contract exists with the target payer, the
257
+ # billing provider should be the entity contracted with the payer. In some
258
+ # circumstances, this will be an individual provider. In that case, submit that
259
+ # provider's NPI and the tax ID (TIN) that the provider gave to the payer during
260
+ # contracting. In other cases, the billing entity will be a medical group. If so,
261
+ # submit the group NPI and the group's tax ID. Box 33 on the CMS-1500 claim form
262
+ # or Form Locator 1 on a UB-04 claim form..
263
+ # @param diagnoses [Array<CandidApiClient::Diagnoses::Types::DiagnosisCreate>] Ideally, this field should contain no more than 12 diagnoses. However, more
264
+ # diagnoses
265
+ # may be submitted at this time, and coders will later prioritize the 12 that will
266
+ # be
267
+ # submitted to the payor.
268
+ # @param place_of_service_code [CandidApiClient::Commons::Types::FacilityTypeCode] Box 24B on the CMS-1500 claim form. 837p Loop2300, CLM-05-1. 02 for
269
+ # telemedicine, 11 for in-person. Full list
270
+ # //www.cms.gov/Medicare/Coding/place-of-service-codes/Place_of_Service_Code_Set).
271
+ # @param rendering_provider [CandidApiClient::EncounterProviders::V2::Types::RenderingProvider] The rendering provider is the practitioner -- physician, nurse practitioner,
272
+ # etc. -- performing the service.
273
+ # For telehealth services, the rendering provider performs the visit, asynchronous
274
+ # communication, or other service. The rendering provider address should generally
275
+ # be the same as the service facility address.
276
+ # @param service_lines [Array<CandidApiClient::ServiceLines::V2::Types::ServiceLineCreate>] Each service line must be linked to a diagnosis. Concretely,
277
+ # `service_line.diagnosis_pointers`must contain at least one entry which should be
278
+ # in bounds of the diagnoses list field.
279
+ # @param patient [CandidApiClient::Individual::Types::PatientCreate] Contains the identification information of the individual receiving medical
280
+ # services.
281
+ # @param referring_provider [CandidApiClient::EncounterProviders::V2::Types::ReferringProvider] The final provider who referred the services that were rendered.
282
+ # All physicians who order services or refer Medicare beneficiaries must
283
+ # report this data.
284
+ # @param initial_referring_provider [CandidApiClient::EncounterProviders::V2::Types::InitialReferringProvider] The second iteration of Loop ID-2310 on an 837P form. Use code "P3 - Primary
285
+ # Care Provider" in this loop to
286
+ # indicate the initial referral from the primary care provider or whatever
287
+ # provider wrote the initial referral for this patient's episode of care being
288
+ # billed/reported in this transaction.
289
+ # Not used in an 837i claim
290
+ # @param supervising_provider [CandidApiClient::EncounterProviders::V2::Types::SupervisingProvider] Required when the rendering provider is supervised by a physician. If not
291
+ # required by this implementation guide, do not send.
292
+ # @param service_facility [CandidApiClient::ServiceFacility::Types::EncounterServiceFacilityBase] Encounter Service facility is typically the location a medical service was
293
+ # rendered, such as a provider office or hospital. For telehealth, service
294
+ # facility can represent the provider's location when the service was delivered
295
+ # (e.g., home), or the location where an in-person visit would have taken place,
296
+ # whichever is easier to identify. If the provider is in-network, service facility
297
+ # may be defined in payer contracts. Box 32 on the CMS-1500 claim form. There is
298
+ # no equivalent on the paper UB-04 claim form, but this field is equivalent to
299
+ # Loop 2310E Service Facility Location details on an 837i form, and is used when
300
+ # this is different to the entity identified as the Billing Provider. Note that
301
+ # for an in-network claim to be successfully adjudicated, the service facility
302
+ # address listed
303
+ # @param subscriber_primary [CandidApiClient::Individual::Types::SubscriberCreate] Subscriber_primary is required when responsible_party is INSURANCE_PAY (i.e.
304
+ # when the claim should be billed to insurance).
305
+ # These are not required fields when responsible_party is SELF_PAY (i.e. when the
306
+ # claim should be billed to the patient).
307
+ # However, if you collect this for patients, even self-pay, we recommend including
308
+ # it when sending encounters to Candid.
309
+ # Note: Cash Pay is no longer a valid payer_id in v4, please use responsible party
310
+ # to define self-pay claims.
311
+ # @param subscriber_secondary [CandidApiClient::Individual::Types::SubscriberCreate] Please always include this when you have it, even for self-pay claims.
312
+ # @param subscriber_tertiary [CandidApiClient::Individual::Types::SubscriberCreate] Please always include this when you have it, even for self-pay claims.
313
+ # @param prior_authorization_number [String] Box 23 on the CMS-1500 claim form or Form Locator 63 on a UB-04 claim form.
314
+ # @param responsible_party [CandidApiClient::Encounters::V4::Types::ResponsiblePartyType] Defines the party to be billed with the initial balance owed on the claim.
315
+ # @param clinical_notes [Array<CandidApiClient::Encounters::V4::Types::ClinicalNoteCategoryCreate>] Holds a collection of clinical observations made by healthcare providers during
316
+ # patient encounters. Please note that medical records for appeals should be sent
317
+ # using the Encounter Attachments API.
318
+ # @param billing_notes [Array<CandidApiClient::BillingNotes::V2::Types::BillingNoteBase>] Spot to store misc, human-readable, notes about this encounter to be used
319
+ # in the billing process.
320
+ # @param patient_histories [Array<CandidApiClient::Encounters::V4::Types::PatientHistoryCategory>]
321
+ # @param guarantor [CandidApiClient::Guarantor::V1::Types::GuarantorCreate] Personal and contact info for the guarantor of the patient responsibility.
322
+ # @param external_claim_submission [CandidApiClient::ClaimSubmission::V1::Types::ExternalClaimSubmissionCreate] To be included for claims that have been submitted outside of Candid.
323
+ # Candid supports posting remits and payments to these claims and working them
324
+ # in-platform (e.g. editing, resubmitting).
325
+ # @param tag_ids [Array<String>] Names of tags that should be on the encounter.
326
+ # @param schema_instances [Array<CandidApiClient::CustomSchemas::V1::Types::SchemaInstance>] Key-value pairs that must adhere to a schema created via the Custom Schema API.
327
+ # Multiple schema
328
+ # instances cannot be created for the same schema on an encounter.
329
+ # @param referral_number [String] Refers to REF*9F on the 837p and 837i. Value cannot be greater than 50
330
+ # characters.
331
+ # @param epsdt_referral [CandidApiClient::Encounters::V4::Types::EpsdtReferral] Refers to Box 24H on the CMS1500 form and Loop 2300 CRC - EPSDT Referral on the
332
+ # 837P and 837i form
333
+ # @param claim_supplemental_information [Array<CandidApiClient::Encounters::V4::Types::ClaimSupplementalInformation>] Refers to Loop 2300 - Segment PWK on the 837P and 837i forms. No more than 10
334
+ # entries are permitted.
335
+ # @param secondary_payer_carrier_code [String] When Medicaid is billed as the secondary payer the Carrier Code is used to
336
+ # identify the primary payer. This is required for certain states.
337
+ # @param external_id [String] A client-specified unique ID to associate with this encounter;
338
+ # for example, your internal encounter ID or a Dr. Chrono encounter ID.
339
+ # This field should not contain PHI.
340
+ # @param date_of_service [Date] Date formatted as YYYY-MM-DD; eg: 2019-08-24.
341
+ # This date must be the local date in the timezone where the service occurred.
342
+ # Box 24a on the CMS-1500 claim form or Form Locator 45 on the UB-04 claim form.
343
+ # If service occurred over a range of dates, this should be the start date.
344
+ # date_of_service must be defined on either the encounter or the service lines but
345
+ # not both.
346
+ # If there are greater than zero service lines, it is recommended to specify
347
+ # date_of_service on the service_line instead of on the encounter to prepare for
348
+ # future API versions.
349
+ # @param end_date_of_service [Date] Date formatted as YYYY-MM-DD; eg: 2019-08-25.
350
+ # This date must be the local date in the timezone where the service occurred.
351
+ # If omitted, the Encounter is assumed to be for a single day.
352
+ # Must not be temporally before the date_of_service field.
353
+ # If there are greater than zero service lines, it is recommended to specify
354
+ # end_date_of_service on the service_line instead of on the encounter to prepare
355
+ # for future API versions.
356
+ # @param patient_authorized_release [Boolean] Whether this patient has authorized the release of medical information
357
+ # for billing purpose.
358
+ # Box 12 on the CMS-1500 claim form or Form Locator 52 on a UB-04 claim form.
359
+ # @param benefits_assigned_to_provider [Boolean] Whether this patient has authorized insurance payments to be made to you,
360
+ # not them. If false, patient may receive reimbursement.
361
+ # Box 13 on the CMS-1500 claim form or Form Locator 53 on a UB-04 claim form.
362
+ # @param provider_accepts_assignment [Boolean] Whether you have accepted the patient's authorization for insurance payments
363
+ # to be made to you, not them.
364
+ # Box 27 on the CMS-1500 claim form. There is no exact equivalent of this field on
365
+ # a UB-04 claim, however contributes to the concept of Form Locator 53.
366
+ # @param appointment_type [String] Human-readable description of the appointment type (ex: "Acupuncture -
367
+ # Headaches").
368
+ # @param existing_medications [Array<CandidApiClient::Encounters::V4::Types::Medication>]
369
+ # @param interventions [Array<CandidApiClient::Encounters::V4::Types::Intervention>]
370
+ # @param pay_to_address [CandidApiClient::Commons::Types::StreetAddressLongZip] Specifies the address to which payments for the claim should be sent.
371
+ # @param synchronicity [CandidApiClient::Encounters::V4::Types::SynchronicityType] Whether or not this was a synchronous or asynchronous encounter.
372
+ # Asynchronous encounters occur when providers and patients communicate online
373
+ # using
374
+ # forms, instant messaging, or other pre-recorded digital mediums.
375
+ # Synchronous encounters occur in live, real-time settings where the patient
376
+ # interacts
377
+ # directly with the provider, such as over video or a phone call.
378
+ # @param vitals [CandidApiClient::Encounters::V4::Types::Vitals]
379
+ # @param billable_status [CandidApiClient::Encounters::V4::Types::BillableStatusType] Defines if the Encounter is to be billed by Candid to the responsible_party.
380
+ # Examples for when this should be set to NOT_BILLABLE include
381
+ # if the Encounter has not occurred yet or if there is no intention of ever
382
+ # billing the responsible_party.
383
+ # @param additional_information [String] Defines additional information on the claim needed by the payer.
384
+ # Box 19 on the CMS-1500 claim form or Form Locator 80 on a UB-04 claim form.
385
+ # @param service_authorization_exception_code [CandidApiClient::Encounters::V4::Types::ServiceAuthorizationExceptionCode] 837p Loop2300 REF*4N
386
+ # Required when mandated by government law or regulation to obtain authorization
387
+ # for specific service(s) but, for the
388
+ # reasons listed in one of the enum values of ServiceAuthorizationExceptionCode,
389
+ # the service was performed without
390
+ # obtaining the authorization.
391
+ # @param admission_date [Date] 837p Loop2300 DTP*435, CMS-1500 Box 18 or UB-04 Form Locator 12.
392
+ # Required on all ambulance claims when the patient was known to be admitted to
393
+ # the hospital.
394
+ # OR
395
+ # Required on all claims involving inpatient medical visits.
396
+ # @param discharge_date [Date] 837p Loop2300 DTP*096, CMS-1500 Box 18 Required for inpatient claims when the
397
+ # patient was discharged from the facility and the discharge date is known. Not
398
+ # used on an institutional claim.
399
+ # @param onset_of_current_illness_or_symptom_date [Date] 837p Loop2300 DTP*431, CMS-1500 Box 14
400
+ # Required for the initial medical service or visit performed in response to a
401
+ # medical emergency when the date is available and is different than the date of
402
+ # service.
403
+ # OR
404
+ # This date is the onset of acute symptoms for the current illness or condition.
405
+ # For UB-04 claims, this is populated separately via occurrence codes.
406
+ # @param last_menstrual_period_date [Date] 837p Loop2300 DTP*484, CMS-1500 Box 14
407
+ # Required when, in the judgment of the provider, the services on this claim are
408
+ # related to the patient's pregnancy.
409
+ # This field is populated separately via occurrence codes for UB-04 claim forms.
410
+ # @param delay_reason_code [CandidApiClient::Commons::Types::DelayReasonCode] 837i Loop2300, CLM-1300 Box 20
411
+ # Code indicating the reason why a request was delayed
412
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
413
+ # @return [CandidApiClient::Encounters::V4::Types::EncounterCreate]
414
+ def initialize(billing_provider:, diagnoses:, place_of_service_code:, rendering_provider:, patient:, responsible_party:, external_id:, patient_authorized_release:, benefits_assigned_to_provider:, provider_accepts_assignment:, billable_status:,
415
+ service_lines: OMIT, referring_provider: OMIT, initial_referring_provider: OMIT, supervising_provider: OMIT, service_facility: OMIT, subscriber_primary: OMIT, subscriber_secondary: OMIT, subscriber_tertiary: OMIT, prior_authorization_number: OMIT, clinical_notes: OMIT, billing_notes: OMIT, patient_histories: OMIT, guarantor: OMIT, external_claim_submission: OMIT, tag_ids: OMIT, schema_instances: OMIT, referral_number: OMIT, epsdt_referral: OMIT, claim_supplemental_information: OMIT, secondary_payer_carrier_code: OMIT, date_of_service: OMIT, end_date_of_service: OMIT, appointment_type: OMIT, existing_medications: OMIT, interventions: OMIT, pay_to_address: OMIT, synchronicity: OMIT, vitals: OMIT, additional_information: OMIT, service_authorization_exception_code: OMIT, admission_date: OMIT, discharge_date: OMIT, onset_of_current_illness_or_symptom_date: OMIT, last_menstrual_period_date: OMIT, delay_reason_code: OMIT, additional_properties: nil)
416
+ @billing_provider = billing_provider
417
+ @diagnoses = diagnoses
418
+ @place_of_service_code = place_of_service_code
419
+ @rendering_provider = rendering_provider
420
+ @service_lines = service_lines if service_lines != OMIT
421
+ @patient = patient
422
+ @referring_provider = referring_provider if referring_provider != OMIT
423
+ @initial_referring_provider = initial_referring_provider if initial_referring_provider != OMIT
424
+ @supervising_provider = supervising_provider if supervising_provider != OMIT
425
+ @service_facility = service_facility if service_facility != OMIT
426
+ @subscriber_primary = subscriber_primary if subscriber_primary != OMIT
427
+ @subscriber_secondary = subscriber_secondary if subscriber_secondary != OMIT
428
+ @subscriber_tertiary = subscriber_tertiary if subscriber_tertiary != OMIT
429
+ @prior_authorization_number = prior_authorization_number if prior_authorization_number != OMIT
430
+ @responsible_party = responsible_party
431
+ @clinical_notes = clinical_notes if clinical_notes != OMIT
432
+ @billing_notes = billing_notes if billing_notes != OMIT
433
+ @patient_histories = patient_histories if patient_histories != OMIT
434
+ @guarantor = guarantor if guarantor != OMIT
435
+ @external_claim_submission = external_claim_submission if external_claim_submission != OMIT
436
+ @tag_ids = tag_ids if tag_ids != OMIT
437
+ @schema_instances = schema_instances if schema_instances != OMIT
438
+ @referral_number = referral_number if referral_number != OMIT
439
+ @epsdt_referral = epsdt_referral if epsdt_referral != OMIT
440
+ @claim_supplemental_information = claim_supplemental_information if claim_supplemental_information != OMIT
441
+ @secondary_payer_carrier_code = secondary_payer_carrier_code if secondary_payer_carrier_code != OMIT
442
+ @external_id = external_id
443
+ @date_of_service = date_of_service if date_of_service != OMIT
444
+ @end_date_of_service = end_date_of_service if end_date_of_service != OMIT
445
+ @patient_authorized_release = patient_authorized_release
446
+ @benefits_assigned_to_provider = benefits_assigned_to_provider
447
+ @provider_accepts_assignment = provider_accepts_assignment
448
+ @appointment_type = appointment_type if appointment_type != OMIT
449
+ @existing_medications = existing_medications if existing_medications != OMIT
450
+ @interventions = interventions if interventions != OMIT
451
+ @pay_to_address = pay_to_address if pay_to_address != OMIT
452
+ @synchronicity = synchronicity if synchronicity != OMIT
453
+ @vitals = vitals if vitals != OMIT
454
+ @billable_status = billable_status
455
+ @additional_information = additional_information if additional_information != OMIT
456
+ if service_authorization_exception_code != OMIT
457
+ @service_authorization_exception_code = service_authorization_exception_code
458
+ end
459
+ @admission_date = admission_date if admission_date != OMIT
460
+ @discharge_date = discharge_date if discharge_date != OMIT
461
+ if onset_of_current_illness_or_symptom_date != OMIT
462
+ @onset_of_current_illness_or_symptom_date = onset_of_current_illness_or_symptom_date
463
+ end
464
+ @last_menstrual_period_date = last_menstrual_period_date if last_menstrual_period_date != OMIT
465
+ @delay_reason_code = delay_reason_code if delay_reason_code != OMIT
466
+ @additional_properties = additional_properties
467
+ @_field_set = {
468
+ "billing_provider": billing_provider,
469
+ "diagnoses": diagnoses,
470
+ "place_of_service_code": place_of_service_code,
471
+ "rendering_provider": rendering_provider,
472
+ "service_lines": service_lines,
473
+ "patient": patient,
474
+ "referring_provider": referring_provider,
475
+ "initial_referring_provider": initial_referring_provider,
476
+ "supervising_provider": supervising_provider,
477
+ "service_facility": service_facility,
478
+ "subscriber_primary": subscriber_primary,
479
+ "subscriber_secondary": subscriber_secondary,
480
+ "subscriber_tertiary": subscriber_tertiary,
481
+ "prior_authorization_number": prior_authorization_number,
482
+ "responsible_party": responsible_party,
483
+ "clinical_notes": clinical_notes,
484
+ "billing_notes": billing_notes,
485
+ "patient_histories": patient_histories,
486
+ "guarantor": guarantor,
487
+ "external_claim_submission": external_claim_submission,
488
+ "tag_ids": tag_ids,
489
+ "schema_instances": schema_instances,
490
+ "referral_number": referral_number,
491
+ "epsdt_referral": epsdt_referral,
492
+ "claim_supplemental_information": claim_supplemental_information,
493
+ "secondary_payer_carrier_code": secondary_payer_carrier_code,
494
+ "external_id": external_id,
495
+ "date_of_service": date_of_service,
496
+ "end_date_of_service": end_date_of_service,
497
+ "patient_authorized_release": patient_authorized_release,
498
+ "benefits_assigned_to_provider": benefits_assigned_to_provider,
499
+ "provider_accepts_assignment": provider_accepts_assignment,
500
+ "appointment_type": appointment_type,
501
+ "existing_medications": existing_medications,
502
+ "interventions": interventions,
503
+ "pay_to_address": pay_to_address,
504
+ "synchronicity": synchronicity,
505
+ "vitals": vitals,
506
+ "billable_status": billable_status,
507
+ "additional_information": additional_information,
508
+ "service_authorization_exception_code": service_authorization_exception_code,
509
+ "admission_date": admission_date,
510
+ "discharge_date": discharge_date,
511
+ "onset_of_current_illness_or_symptom_date": onset_of_current_illness_or_symptom_date,
512
+ "last_menstrual_period_date": last_menstrual_period_date,
513
+ "delay_reason_code": delay_reason_code
514
+ }.reject do |_k, v|
515
+ v == OMIT
516
+ end
517
+ end
518
+
519
+ # Deserialize a JSON object to an instance of EncounterCreate
520
+ #
521
+ # @param json_object [String]
522
+ # @return [CandidApiClient::Encounters::V4::Types::EncounterCreate]
523
+ def self.from_json(json_object:)
524
+ struct = JSON.parse(json_object, object_class: OpenStruct)
525
+ parsed_json = JSON.parse(json_object)
526
+ if parsed_json["billing_provider"].nil?
527
+ billing_provider = nil
528
+ else
529
+ billing_provider = parsed_json["billing_provider"].to_json
530
+ billing_provider = CandidApiClient::EncounterProviders::V2::Types::BillingProvider.from_json(json_object: billing_provider)
531
+ end
532
+ diagnoses = parsed_json["diagnoses"]&.map do |item|
533
+ item = item.to_json
534
+ CandidApiClient::Diagnoses::Types::DiagnosisCreate.from_json(json_object: item)
535
+ end
536
+ place_of_service_code = struct["place_of_service_code"]
537
+ if parsed_json["rendering_provider"].nil?
538
+ rendering_provider = nil
539
+ else
540
+ rendering_provider = parsed_json["rendering_provider"].to_json
541
+ rendering_provider = CandidApiClient::EncounterProviders::V2::Types::RenderingProvider.from_json(json_object: rendering_provider)
542
+ end
543
+ service_lines = parsed_json["service_lines"]&.map do |item|
544
+ item = item.to_json
545
+ CandidApiClient::ServiceLines::V2::Types::ServiceLineCreate.from_json(json_object: item)
546
+ end
547
+ if parsed_json["patient"].nil?
548
+ patient = nil
549
+ else
550
+ patient = parsed_json["patient"].to_json
551
+ patient = CandidApiClient::Individual::Types::PatientCreate.from_json(json_object: patient)
552
+ end
553
+ if parsed_json["referring_provider"].nil?
554
+ referring_provider = nil
555
+ else
556
+ referring_provider = parsed_json["referring_provider"].to_json
557
+ referring_provider = CandidApiClient::EncounterProviders::V2::Types::ReferringProvider.from_json(json_object: referring_provider)
558
+ end
559
+ if parsed_json["initial_referring_provider"].nil?
560
+ initial_referring_provider = nil
561
+ else
562
+ initial_referring_provider = parsed_json["initial_referring_provider"].to_json
563
+ initial_referring_provider = CandidApiClient::EncounterProviders::V2::Types::InitialReferringProvider.from_json(json_object: initial_referring_provider)
564
+ end
565
+ if parsed_json["supervising_provider"].nil?
566
+ supervising_provider = nil
567
+ else
568
+ supervising_provider = parsed_json["supervising_provider"].to_json
569
+ supervising_provider = CandidApiClient::EncounterProviders::V2::Types::SupervisingProvider.from_json(json_object: supervising_provider)
570
+ end
571
+ if parsed_json["service_facility"].nil?
572
+ service_facility = nil
573
+ else
574
+ service_facility = parsed_json["service_facility"].to_json
575
+ service_facility = CandidApiClient::ServiceFacility::Types::EncounterServiceFacilityBase.from_json(json_object: service_facility)
576
+ end
577
+ if parsed_json["subscriber_primary"].nil?
578
+ subscriber_primary = nil
579
+ else
580
+ subscriber_primary = parsed_json["subscriber_primary"].to_json
581
+ subscriber_primary = CandidApiClient::Individual::Types::SubscriberCreate.from_json(json_object: subscriber_primary)
582
+ end
583
+ if parsed_json["subscriber_secondary"].nil?
584
+ subscriber_secondary = nil
585
+ else
586
+ subscriber_secondary = parsed_json["subscriber_secondary"].to_json
587
+ subscriber_secondary = CandidApiClient::Individual::Types::SubscriberCreate.from_json(json_object: subscriber_secondary)
588
+ end
589
+ if parsed_json["subscriber_tertiary"].nil?
590
+ subscriber_tertiary = nil
591
+ else
592
+ subscriber_tertiary = parsed_json["subscriber_tertiary"].to_json
593
+ subscriber_tertiary = CandidApiClient::Individual::Types::SubscriberCreate.from_json(json_object: subscriber_tertiary)
594
+ end
595
+ prior_authorization_number = struct["prior_authorization_number"]
596
+ responsible_party = struct["responsible_party"]
597
+ clinical_notes = parsed_json["clinical_notes"]&.map do |item|
598
+ item = item.to_json
599
+ CandidApiClient::Encounters::V4::Types::ClinicalNoteCategoryCreate.from_json(json_object: item)
600
+ end
601
+ billing_notes = parsed_json["billing_notes"]&.map do |item|
602
+ item = item.to_json
603
+ CandidApiClient::BillingNotes::V2::Types::BillingNoteBase.from_json(json_object: item)
604
+ end
605
+ patient_histories = parsed_json["patient_histories"]&.map do |item|
606
+ item = item.to_json
607
+ CandidApiClient::Encounters::V4::Types::PatientHistoryCategory.from_json(json_object: item)
608
+ end
609
+ if parsed_json["guarantor"].nil?
610
+ guarantor = nil
611
+ else
612
+ guarantor = parsed_json["guarantor"].to_json
613
+ guarantor = CandidApiClient::Guarantor::V1::Types::GuarantorCreate.from_json(json_object: guarantor)
614
+ end
615
+ if parsed_json["external_claim_submission"].nil?
616
+ external_claim_submission = nil
617
+ else
618
+ external_claim_submission = parsed_json["external_claim_submission"].to_json
619
+ external_claim_submission = CandidApiClient::ClaimSubmission::V1::Types::ExternalClaimSubmissionCreate.from_json(json_object: external_claim_submission)
620
+ end
621
+ tag_ids = struct["tag_ids"]
622
+ schema_instances = parsed_json["schema_instances"]&.map do |item|
623
+ item = item.to_json
624
+ CandidApiClient::CustomSchemas::V1::Types::SchemaInstance.from_json(json_object: item)
625
+ end
626
+ referral_number = struct["referral_number"]
627
+ if parsed_json["epsdt_referral"].nil?
628
+ epsdt_referral = nil
629
+ else
630
+ epsdt_referral = parsed_json["epsdt_referral"].to_json
631
+ epsdt_referral = CandidApiClient::Encounters::V4::Types::EpsdtReferral.from_json(json_object: epsdt_referral)
632
+ end
633
+ claim_supplemental_information = parsed_json["claim_supplemental_information"]&.map do |item|
634
+ item = item.to_json
635
+ CandidApiClient::Encounters::V4::Types::ClaimSupplementalInformation.from_json(json_object: item)
636
+ end
637
+ secondary_payer_carrier_code = struct["secondary_payer_carrier_code"]
638
+ external_id = struct["external_id"]
639
+ date_of_service = (Date.parse(parsed_json["date_of_service"]) unless parsed_json["date_of_service"].nil?)
640
+ end_date_of_service = unless parsed_json["end_date_of_service"].nil?
641
+ Date.parse(parsed_json["end_date_of_service"])
642
+ end
643
+ patient_authorized_release = struct["patient_authorized_release"]
644
+ benefits_assigned_to_provider = struct["benefits_assigned_to_provider"]
645
+ provider_accepts_assignment = struct["provider_accepts_assignment"]
646
+ appointment_type = struct["appointment_type"]
647
+ existing_medications = parsed_json["existing_medications"]&.map do |item|
648
+ item = item.to_json
649
+ CandidApiClient::Encounters::V4::Types::Medication.from_json(json_object: item)
650
+ end
651
+ interventions = parsed_json["interventions"]&.map do |item|
652
+ item = item.to_json
653
+ CandidApiClient::Encounters::V4::Types::Intervention.from_json(json_object: item)
654
+ end
655
+ if parsed_json["pay_to_address"].nil?
656
+ pay_to_address = nil
657
+ else
658
+ pay_to_address = parsed_json["pay_to_address"].to_json
659
+ pay_to_address = CandidApiClient::Commons::Types::StreetAddressLongZip.from_json(json_object: pay_to_address)
660
+ end
661
+ synchronicity = struct["synchronicity"]
662
+ if parsed_json["vitals"].nil?
663
+ vitals = nil
664
+ else
665
+ vitals = parsed_json["vitals"].to_json
666
+ vitals = CandidApiClient::Encounters::V4::Types::Vitals.from_json(json_object: vitals)
667
+ end
668
+ billable_status = struct["billable_status"]
669
+ additional_information = struct["additional_information"]
670
+ service_authorization_exception_code = struct["service_authorization_exception_code"]
671
+ admission_date = (Date.parse(parsed_json["admission_date"]) unless parsed_json["admission_date"].nil?)
672
+ discharge_date = (Date.parse(parsed_json["discharge_date"]) unless parsed_json["discharge_date"].nil?)
673
+ onset_of_current_illness_or_symptom_date = unless parsed_json["onset_of_current_illness_or_symptom_date"].nil?
674
+ Date.parse(parsed_json["onset_of_current_illness_or_symptom_date"])
675
+ end
676
+ last_menstrual_period_date = unless parsed_json["last_menstrual_period_date"].nil?
677
+ Date.parse(parsed_json["last_menstrual_period_date"])
678
+ end
679
+ delay_reason_code = struct["delay_reason_code"]
680
+ new(
681
+ billing_provider: billing_provider,
682
+ diagnoses: diagnoses,
683
+ place_of_service_code: place_of_service_code,
684
+ rendering_provider: rendering_provider,
685
+ service_lines: service_lines,
686
+ patient: patient,
687
+ referring_provider: referring_provider,
688
+ initial_referring_provider: initial_referring_provider,
689
+ supervising_provider: supervising_provider,
690
+ service_facility: service_facility,
691
+ subscriber_primary: subscriber_primary,
692
+ subscriber_secondary: subscriber_secondary,
693
+ subscriber_tertiary: subscriber_tertiary,
694
+ prior_authorization_number: prior_authorization_number,
695
+ responsible_party: responsible_party,
696
+ clinical_notes: clinical_notes,
697
+ billing_notes: billing_notes,
698
+ patient_histories: patient_histories,
699
+ guarantor: guarantor,
700
+ external_claim_submission: external_claim_submission,
701
+ tag_ids: tag_ids,
702
+ schema_instances: schema_instances,
703
+ referral_number: referral_number,
704
+ epsdt_referral: epsdt_referral,
705
+ claim_supplemental_information: claim_supplemental_information,
706
+ secondary_payer_carrier_code: secondary_payer_carrier_code,
707
+ external_id: external_id,
708
+ date_of_service: date_of_service,
709
+ end_date_of_service: end_date_of_service,
710
+ patient_authorized_release: patient_authorized_release,
711
+ benefits_assigned_to_provider: benefits_assigned_to_provider,
712
+ provider_accepts_assignment: provider_accepts_assignment,
713
+ appointment_type: appointment_type,
714
+ existing_medications: existing_medications,
715
+ interventions: interventions,
716
+ pay_to_address: pay_to_address,
717
+ synchronicity: synchronicity,
718
+ vitals: vitals,
719
+ billable_status: billable_status,
720
+ additional_information: additional_information,
721
+ service_authorization_exception_code: service_authorization_exception_code,
722
+ admission_date: admission_date,
723
+ discharge_date: discharge_date,
724
+ onset_of_current_illness_or_symptom_date: onset_of_current_illness_or_symptom_date,
725
+ last_menstrual_period_date: last_menstrual_period_date,
726
+ delay_reason_code: delay_reason_code,
727
+ additional_properties: struct
728
+ )
729
+ end
730
+
731
+ # Serialize an instance of EncounterCreate to a JSON object
732
+ #
733
+ # @return [String]
734
+ def to_json(*_args)
735
+ @_field_set&.to_json
736
+ end
737
+
738
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
739
+ # hash and check each fields type against the current object's property
740
+ # definitions.
741
+ #
742
+ # @param obj [Object]
743
+ # @return [Void]
744
+ def self.validate_raw(obj:)
745
+ CandidApiClient::EncounterProviders::V2::Types::BillingProvider.validate_raw(obj: obj.billing_provider)
746
+ obj.diagnoses.is_a?(Array) != false || raise("Passed value for field obj.diagnoses is not the expected type, validation failed.")
747
+ obj.place_of_service_code.is_a?(CandidApiClient::Commons::Types::FacilityTypeCode) != false || raise("Passed value for field obj.place_of_service_code is not the expected type, validation failed.")
748
+ CandidApiClient::EncounterProviders::V2::Types::RenderingProvider.validate_raw(obj: obj.rendering_provider)
749
+ obj.service_lines&.is_a?(Array) != false || raise("Passed value for field obj.service_lines is not the expected type, validation failed.")
750
+ CandidApiClient::Individual::Types::PatientCreate.validate_raw(obj: obj.patient)
751
+ obj.referring_provider.nil? || CandidApiClient::EncounterProviders::V2::Types::ReferringProvider.validate_raw(obj: obj.referring_provider)
752
+ obj.initial_referring_provider.nil? || CandidApiClient::EncounterProviders::V2::Types::InitialReferringProvider.validate_raw(obj: obj.initial_referring_provider)
753
+ obj.supervising_provider.nil? || CandidApiClient::EncounterProviders::V2::Types::SupervisingProvider.validate_raw(obj: obj.supervising_provider)
754
+ obj.service_facility.nil? || CandidApiClient::ServiceFacility::Types::EncounterServiceFacilityBase.validate_raw(obj: obj.service_facility)
755
+ obj.subscriber_primary.nil? || CandidApiClient::Individual::Types::SubscriberCreate.validate_raw(obj: obj.subscriber_primary)
756
+ obj.subscriber_secondary.nil? || CandidApiClient::Individual::Types::SubscriberCreate.validate_raw(obj: obj.subscriber_secondary)
757
+ obj.subscriber_tertiary.nil? || CandidApiClient::Individual::Types::SubscriberCreate.validate_raw(obj: obj.subscriber_tertiary)
758
+ obj.prior_authorization_number&.is_a?(String) != false || raise("Passed value for field obj.prior_authorization_number is not the expected type, validation failed.")
759
+ obj.responsible_party.is_a?(CandidApiClient::Encounters::V4::Types::ResponsiblePartyType) != false || raise("Passed value for field obj.responsible_party is not the expected type, validation failed.")
760
+ obj.clinical_notes&.is_a?(Array) != false || raise("Passed value for field obj.clinical_notes is not the expected type, validation failed.")
761
+ obj.billing_notes&.is_a?(Array) != false || raise("Passed value for field obj.billing_notes is not the expected type, validation failed.")
762
+ obj.patient_histories&.is_a?(Array) != false || raise("Passed value for field obj.patient_histories is not the expected type, validation failed.")
763
+ obj.guarantor.nil? || CandidApiClient::Guarantor::V1::Types::GuarantorCreate.validate_raw(obj: obj.guarantor)
764
+ obj.external_claim_submission.nil? || CandidApiClient::ClaimSubmission::V1::Types::ExternalClaimSubmissionCreate.validate_raw(obj: obj.external_claim_submission)
765
+ obj.tag_ids&.is_a?(Array) != false || raise("Passed value for field obj.tag_ids is not the expected type, validation failed.")
766
+ obj.schema_instances&.is_a?(Array) != false || raise("Passed value for field obj.schema_instances is not the expected type, validation failed.")
767
+ obj.referral_number&.is_a?(String) != false || raise("Passed value for field obj.referral_number is not the expected type, validation failed.")
768
+ obj.epsdt_referral.nil? || CandidApiClient::Encounters::V4::Types::EpsdtReferral.validate_raw(obj: obj.epsdt_referral)
769
+ obj.claim_supplemental_information&.is_a?(Array) != false || raise("Passed value for field obj.claim_supplemental_information is not the expected type, validation failed.")
770
+ obj.secondary_payer_carrier_code&.is_a?(String) != false || raise("Passed value for field obj.secondary_payer_carrier_code is not the expected type, validation failed.")
771
+ obj.external_id.is_a?(String) != false || raise("Passed value for field obj.external_id is not the expected type, validation failed.")
772
+ obj.date_of_service&.is_a?(Date) != false || raise("Passed value for field obj.date_of_service is not the expected type, validation failed.")
773
+ obj.end_date_of_service&.is_a?(Date) != false || raise("Passed value for field obj.end_date_of_service is not the expected type, validation failed.")
774
+ obj.patient_authorized_release.is_a?(Boolean) != false || raise("Passed value for field obj.patient_authorized_release is not the expected type, validation failed.")
775
+ obj.benefits_assigned_to_provider.is_a?(Boolean) != false || raise("Passed value for field obj.benefits_assigned_to_provider is not the expected type, validation failed.")
776
+ obj.provider_accepts_assignment.is_a?(Boolean) != false || raise("Passed value for field obj.provider_accepts_assignment is not the expected type, validation failed.")
777
+ obj.appointment_type&.is_a?(String) != false || raise("Passed value for field obj.appointment_type is not the expected type, validation failed.")
778
+ obj.existing_medications&.is_a?(Array) != false || raise("Passed value for field obj.existing_medications is not the expected type, validation failed.")
779
+ obj.interventions&.is_a?(Array) != false || raise("Passed value for field obj.interventions is not the expected type, validation failed.")
780
+ obj.pay_to_address.nil? || CandidApiClient::Commons::Types::StreetAddressLongZip.validate_raw(obj: obj.pay_to_address)
781
+ obj.synchronicity&.is_a?(CandidApiClient::Encounters::V4::Types::SynchronicityType) != false || raise("Passed value for field obj.synchronicity is not the expected type, validation failed.")
782
+ obj.vitals.nil? || CandidApiClient::Encounters::V4::Types::Vitals.validate_raw(obj: obj.vitals)
783
+ obj.billable_status.is_a?(CandidApiClient::Encounters::V4::Types::BillableStatusType) != false || raise("Passed value for field obj.billable_status is not the expected type, validation failed.")
784
+ obj.additional_information&.is_a?(String) != false || raise("Passed value for field obj.additional_information is not the expected type, validation failed.")
785
+ obj.service_authorization_exception_code&.is_a?(CandidApiClient::Encounters::V4::Types::ServiceAuthorizationExceptionCode) != false || raise("Passed value for field obj.service_authorization_exception_code is not the expected type, validation failed.")
786
+ obj.admission_date&.is_a?(Date) != false || raise("Passed value for field obj.admission_date is not the expected type, validation failed.")
787
+ obj.discharge_date&.is_a?(Date) != false || raise("Passed value for field obj.discharge_date is not the expected type, validation failed.")
788
+ obj.onset_of_current_illness_or_symptom_date&.is_a?(Date) != false || raise("Passed value for field obj.onset_of_current_illness_or_symptom_date is not the expected type, validation failed.")
789
+ obj.last_menstrual_period_date&.is_a?(Date) != false || raise("Passed value for field obj.last_menstrual_period_date is not the expected type, validation failed.")
790
+ obj.delay_reason_code&.is_a?(CandidApiClient::Commons::Types::DelayReasonCode) != false || raise("Passed value for field obj.delay_reason_code is not the expected type, validation failed.")
791
+ end
792
+ end
793
+ end
794
+ end
795
+ end
796
+ end