candidhealth 0.24.1 → 0.24.3

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 (25) 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.rb +7 -0
  23. data/lib/requests.rb +2 -2
  24. data/lib/types_export.rb +16 -0
  25. metadata +20 -2
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ostruct"
4
+ require "json"
5
+
6
+ module CandidApiClient
7
+ module CustomSchemas
8
+ module V1
9
+ module Types
10
+ class SchemaInstance
11
+ # @return [String] The schema to which the content must adhere.
12
+ attr_reader :schema_id
13
+ # @return [Hash{String => Object}] A set of key-value pairs that adhere to the naming and type convention of the
14
+ # schema. Not all keys in the schema must be included, but attaching any key that
15
+ # does not exist in the schema or attaching a key with the incorrect value type
16
+ # will result in errors.
17
+ attr_reader :content
18
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
19
+ attr_reader :additional_properties
20
+ # @return [Object]
21
+ attr_reader :_field_set
22
+ protected :_field_set
23
+
24
+ OMIT = Object.new
25
+
26
+ # @param schema_id [String] The schema to which the content must adhere.
27
+ # @param content [Hash{String => Object}] A set of key-value pairs that adhere to the naming and type convention of the
28
+ # schema. Not all keys in the schema must be included, but attaching any key that
29
+ # does not exist in the schema or attaching a key with the incorrect value type
30
+ # will result in errors.
31
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
32
+ # @return [CandidApiClient::CustomSchemas::V1::Types::SchemaInstance]
33
+ def initialize(schema_id:, content:, additional_properties: nil)
34
+ @schema_id = schema_id
35
+ @content = content
36
+ @additional_properties = additional_properties
37
+ @_field_set = { "schema_id": schema_id, "content": content }
38
+ end
39
+
40
+ # Deserialize a JSON object to an instance of SchemaInstance
41
+ #
42
+ # @param json_object [String]
43
+ # @return [CandidApiClient::CustomSchemas::V1::Types::SchemaInstance]
44
+ def self.from_json(json_object:)
45
+ struct = JSON.parse(json_object, object_class: OpenStruct)
46
+ schema_id = struct["schema_id"]
47
+ content = struct["content"]
48
+ new(
49
+ schema_id: schema_id,
50
+ content: content,
51
+ additional_properties: struct
52
+ )
53
+ end
54
+
55
+ # Serialize an instance of SchemaInstance to a JSON object
56
+ #
57
+ # @return [String]
58
+ def to_json(*_args)
59
+ @_field_set&.to_json
60
+ end
61
+
62
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
63
+ # hash and check each fields type against the current object's property
64
+ # definitions.
65
+ #
66
+ # @param obj [Object]
67
+ # @return [Void]
68
+ def self.validate_raw(obj:)
69
+ obj.schema_id.is_a?(String) != false || raise("Passed value for field obj.schema_id is not the expected type, validation failed.")
70
+ obj.content.is_a?(Hash) != false || raise("Passed value for field obj.content is not the expected type, validation failed.")
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,100 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require_relative "schema_with_name_already_exists_error"
5
+ require_relative "key_with_name_already_exists_error"
6
+
7
+ module CandidApiClient
8
+ module CustomSchemas
9
+ module V1
10
+ module Types
11
+ class SchemaValidationError
12
+ # @return [Object]
13
+ attr_reader :member
14
+ # @return [String]
15
+ attr_reader :discriminant
16
+
17
+ private_class_method :new
18
+ alias kind_of? is_a?
19
+
20
+ # @param member [Object]
21
+ # @param discriminant [String]
22
+ # @return [CandidApiClient::CustomSchemas::V1::Types::SchemaValidationError]
23
+ def initialize(member:, discriminant:)
24
+ @member = member
25
+ @discriminant = discriminant
26
+ end
27
+
28
+ # Deserialize a JSON object to an instance of SchemaValidationError
29
+ #
30
+ # @param json_object [String]
31
+ # @return [CandidApiClient::CustomSchemas::V1::Types::SchemaValidationError]
32
+ def self.from_json(json_object:)
33
+ struct = JSON.parse(json_object, object_class: OpenStruct)
34
+ member = case struct.type
35
+ when "schema_name_already_exists"
36
+ CandidApiClient::CustomSchemas::V1::Types::SchemaWithNameAlreadyExistsError.from_json(json_object: json_object)
37
+ when "key_name_already_exists"
38
+ CandidApiClient::CustomSchemas::V1::Types::KeyWithNameAlreadyExistsError.from_json(json_object: json_object)
39
+ else
40
+ CandidApiClient::CustomSchemas::V1::Types::SchemaWithNameAlreadyExistsError.from_json(json_object: json_object)
41
+ end
42
+ new(member: member, discriminant: struct.type)
43
+ end
44
+
45
+ # For Union Types, to_json functionality is delegated to the wrapped member.
46
+ #
47
+ # @return [String]
48
+ def to_json(*_args)
49
+ case @discriminant
50
+ when "schema_name_already_exists"
51
+ { **@member.to_json, type: @discriminant }.to_json
52
+ when "key_name_already_exists"
53
+ { **@member.to_json, type: @discriminant }.to_json
54
+ else
55
+ { "type": @discriminant, value: @member }.to_json
56
+ end
57
+ @member.to_json
58
+ end
59
+
60
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
61
+ # hash and check each fields type against the current object's property
62
+ # definitions.
63
+ #
64
+ # @param obj [Object]
65
+ # @return [Void]
66
+ def self.validate_raw(obj:)
67
+ case obj.type
68
+ when "schema_name_already_exists"
69
+ CandidApiClient::CustomSchemas::V1::Types::SchemaWithNameAlreadyExistsError.validate_raw(obj: obj)
70
+ when "key_name_already_exists"
71
+ CandidApiClient::CustomSchemas::V1::Types::KeyWithNameAlreadyExistsError.validate_raw(obj: obj)
72
+ else
73
+ raise("Passed value matched no type within the union, validation failed.")
74
+ end
75
+ end
76
+
77
+ # For Union Types, is_a? functionality is delegated to the wrapped member.
78
+ #
79
+ # @param obj [Object]
80
+ # @return [Boolean]
81
+ def is_a?(obj)
82
+ @member.is_a?(obj)
83
+ end
84
+
85
+ # @param member [CandidApiClient::CustomSchemas::V1::Types::SchemaWithNameAlreadyExistsError]
86
+ # @return [CandidApiClient::CustomSchemas::V1::Types::SchemaValidationError]
87
+ def self.schema_name_already_exists(member:)
88
+ new(member: member, discriminant: "schema_name_already_exists")
89
+ end
90
+
91
+ # @param member [CandidApiClient::CustomSchemas::V1::Types::KeyWithNameAlreadyExistsError]
92
+ # @return [CandidApiClient::CustomSchemas::V1::Types::SchemaValidationError]
93
+ def self.key_name_already_exists(member:)
94
+ new(member: member, discriminant: "key_name_already_exists")
95
+ end
96
+ end
97
+ end
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "schema_validation_error"
4
+ require "ostruct"
5
+ require "json"
6
+
7
+ module CandidApiClient
8
+ module CustomSchemas
9
+ module V1
10
+ module Types
11
+ class SchemaValidationFailure
12
+ # @return [Array<CandidApiClient::CustomSchemas::V1::Types::SchemaValidationError>]
13
+ attr_reader :errors
14
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
15
+ attr_reader :additional_properties
16
+ # @return [Object]
17
+ attr_reader :_field_set
18
+ protected :_field_set
19
+
20
+ OMIT = Object.new
21
+
22
+ # @param errors [Array<CandidApiClient::CustomSchemas::V1::Types::SchemaValidationError>]
23
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
24
+ # @return [CandidApiClient::CustomSchemas::V1::Types::SchemaValidationFailure]
25
+ def initialize(errors:, additional_properties: nil)
26
+ @errors = errors
27
+ @additional_properties = additional_properties
28
+ @_field_set = { "errors": errors }
29
+ end
30
+
31
+ # Deserialize a JSON object to an instance of SchemaValidationFailure
32
+ #
33
+ # @param json_object [String]
34
+ # @return [CandidApiClient::CustomSchemas::V1::Types::SchemaValidationFailure]
35
+ def self.from_json(json_object:)
36
+ struct = JSON.parse(json_object, object_class: OpenStruct)
37
+ parsed_json = JSON.parse(json_object)
38
+ errors = parsed_json["errors"]&.map do |item|
39
+ item = item.to_json
40
+ CandidApiClient::CustomSchemas::V1::Types::SchemaValidationError.from_json(json_object: item)
41
+ end
42
+ new(errors: errors, additional_properties: struct)
43
+ end
44
+
45
+ # Serialize an instance of SchemaValidationFailure to a JSON object
46
+ #
47
+ # @return [String]
48
+ def to_json(*_args)
49
+ @_field_set&.to_json
50
+ end
51
+
52
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
53
+ # hash and check each fields type against the current object's property
54
+ # definitions.
55
+ #
56
+ # @param obj [Object]
57
+ # @return [Void]
58
+ def self.validate_raw(obj:)
59
+ obj.errors.is_a?(Array) != false || raise("Passed value for field obj.errors is not the expected type, validation failed.")
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ostruct"
4
+ require "json"
5
+
6
+ module CandidApiClient
7
+ module CustomSchemas
8
+ module V1
9
+ module Types
10
+ class SchemaWithNameAlreadyExistsError
11
+ # @return [String]
12
+ attr_reader :name
13
+ # @return [String]
14
+ attr_reader :id
15
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
16
+ attr_reader :additional_properties
17
+ # @return [Object]
18
+ attr_reader :_field_set
19
+ protected :_field_set
20
+
21
+ OMIT = Object.new
22
+
23
+ # @param name [String]
24
+ # @param id [String]
25
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
26
+ # @return [CandidApiClient::CustomSchemas::V1::Types::SchemaWithNameAlreadyExistsError]
27
+ def initialize(name:, id:, additional_properties: nil)
28
+ @name = name
29
+ @id = id
30
+ @additional_properties = additional_properties
31
+ @_field_set = { "name": name, "id": id }
32
+ end
33
+
34
+ # Deserialize a JSON object to an instance of SchemaWithNameAlreadyExistsError
35
+ #
36
+ # @param json_object [String]
37
+ # @return [CandidApiClient::CustomSchemas::V1::Types::SchemaWithNameAlreadyExistsError]
38
+ def self.from_json(json_object:)
39
+ struct = JSON.parse(json_object, object_class: OpenStruct)
40
+ name = struct["name"]
41
+ id = struct["id"]
42
+ new(
43
+ name: name,
44
+ id: id,
45
+ additional_properties: struct
46
+ )
47
+ end
48
+
49
+ # Serialize an instance of SchemaWithNameAlreadyExistsError to a JSON object
50
+ #
51
+ # @return [String]
52
+ def to_json(*_args)
53
+ @_field_set&.to_json
54
+ end
55
+
56
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
57
+ # hash and check each fields type against the current object's property
58
+ # definitions.
59
+ #
60
+ # @param obj [Object]
61
+ # @return [Void]
62
+ def self.validate_raw(obj:)
63
+ obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
64
+ obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -33,6 +33,7 @@ require_relative "types/patient_history_category"
33
33
  require_relative "../../service_lines/v_2/types/service_line_create"
34
34
  require_relative "../../guarantor/v_1/types/guarantor_create"
35
35
  require_relative "../../claim_submission/v_1/types/external_claim_submission_create"
36
+ require_relative "../../custom_schemas/v_1/types/schema_instance"
36
37
  require "async"
37
38
 
38
39
  module CandidApiClient
@@ -552,6 +553,11 @@ module CandidApiClient
552
553
  # * :patient_control_number (String)
553
554
  # * :submission_records (Array<CandidApiClient::ClaimSubmission::V1::Types::ClaimSubmissionRecordCreate>)
554
555
  # @param tag_ids [Array<String>] Names of tags that should be on the encounter.
556
+ # @param schema_instances [Array<Hash>] Key-value pairs that must adhere to a schema created via the Custom Schema API.
557
+ # Multiple schema
558
+ # instances cannot be created for the same schema on an encounter.Request of type Array<CandidApiClient::CustomSchemas::V1::Types::SchemaInstance>, as a Hash
559
+ # * :schema_id (String)
560
+ # * :content (Hash{String => Object})
555
561
  # @param request_options [CandidApiClient::RequestOptions]
556
562
  # @return [CandidApiClient::Encounters::V4::Types::Encounter]
557
563
  # @example
@@ -576,10 +582,11 @@ module CandidApiClient
576
582
  # service_lines: [{ modifiers: [TWENTY_TWO], procedure_code: "string", quantity: "string", units: MJ, charge_amount_cents: 1, diagnosis_pointers: [1], drug_identification: { }, place_of_service_code: PHARMACY, description: "string", date_of_service: DateTime.parse(2023-01-15), end_date_of_service: DateTime.parse(2023-01-15), referring_provider: { npi: "string", taxonomy_code: "string", address: { address_1: "123 Main St", address_2: "Apt 1", city: "New York", state: NY, zip_code: "10001", zip_plus_four_code: "1234" }, first_name: "string", last_name: "string", organization_name: "string" }, initial_referring_provider: { npi: "string", taxonomy_code: "string", address: { address_1: "123 Main St", address_2: "Apt 1", city: "New York", state: NY, zip_code: "10001", zip_plus_four_code: "1234" }, qualifier: DQ, first_name: "string", last_name: "string", organization_name: "string" }, supervising_provider: { npi: "string", taxonomy_code: "string", address: { address_1: "123 Main St", address_2: "Apt 1", city: "New York", state: NY, zip_code: "10001", zip_plus_four_code: "1234" }, first_name: "string", last_name: "string", organization_name: "string" }, ordering_provider: { npi: "string", taxonomy_code: "string", address: { address_1: "123 Main St", address_2: "Apt 1", city: "New York", state: NY, zip_code: "10001", zip_plus_four_code: "1234" }, first_name: "string", last_name: "string", organization_name: "string" } }],
577
583
  # guarantor: { phone_numbers: [{ number: "1234567890", type: HOME }], phone_consent: true, email: "johndoe@joincandidhealth.com", email_consent: true, first_name: "string", last_name: "string", external_id: "string", date_of_birth: DateTime.parse(2023-01-15), address: { address_1: "123 Main St", address_2: "Apt 1", city: "New York", state: NY, zip_code: "10001", zip_plus_four_code: "1234" } },
578
584
  # external_claim_submission: { claim_created_at: DateTime.parse(2023-01-01T12:00:00.000Z), patient_control_number: "PATIENT_CONTROL_NUMBER", submission_records: [{ submitted_at: DateTime.parse(2023-01-01T13:00:00.000Z), claim_frequency_code: ORIGINAL, payer_responsibility: PRIMARY, intended_submission_medium: ELECTRONIC }, { submitted_at: DateTime.parse(2023-01-04T12:00:00.000Z), claim_frequency_code: REPLACEMENT, payer_responsibility: PRIMARY, intended_submission_medium: PAPER }] },
579
- # tag_ids: ["string"]
585
+ # tag_ids: ["string"],
586
+ # schema_instances: [{ schema_id: "ec096b13-f80a-471d-aaeb-54b021c9d582", content: { "provider_category": "internist", "is_urgent_care": true, "bmi": 24.2, "age": 38 } }]
580
587
  # )
581
588
  def create(external_id:, patient_authorized_release:, benefits_assigned_to_provider:,
582
- provider_accepts_assignment:, billable_status:, responsible_party:, patient:, billing_provider:, rendering_provider:, diagnoses:, place_of_service_code:, prior_authorization_number: nil, appointment_type: nil, existing_medications: nil, vitals: nil, interventions: nil, pay_to_address: nil, synchronicity: nil, additional_information: nil, service_authorization_exception_code: nil, admission_date: nil, discharge_date: nil, onset_of_current_illness_or_symptom_date: nil, last_menstrual_period_date: nil, delay_reason_code: nil, additional_properties: nil, _field_set: nil, date_of_service: nil, end_date_of_service: nil, referring_provider: nil, initial_referring_provider: nil, supervising_provider: nil, service_facility: nil, subscriber_primary: nil, subscriber_secondary: nil, clinical_notes: nil, billing_notes: nil, patient_histories: nil, service_lines: nil, guarantor: nil, external_claim_submission: nil, tag_ids: nil, request_options: nil)
589
+ provider_accepts_assignment:, billable_status:, responsible_party:, patient:, billing_provider:, rendering_provider:, diagnoses:, place_of_service_code:, prior_authorization_number: nil, appointment_type: nil, existing_medications: nil, vitals: nil, interventions: nil, pay_to_address: nil, synchronicity: nil, additional_information: nil, service_authorization_exception_code: nil, admission_date: nil, discharge_date: nil, onset_of_current_illness_or_symptom_date: nil, last_menstrual_period_date: nil, delay_reason_code: nil, additional_properties: nil, _field_set: nil, date_of_service: nil, end_date_of_service: nil, referring_provider: nil, initial_referring_provider: nil, supervising_provider: nil, service_facility: nil, subscriber_primary: nil, subscriber_secondary: nil, clinical_notes: nil, billing_notes: nil, patient_histories: nil, service_lines: nil, guarantor: nil, external_claim_submission: nil, tag_ids: nil, schema_instances: nil, request_options: nil)
583
590
  response = @request_client.conn.post do |req|
584
591
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
585
592
  req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
@@ -631,7 +638,8 @@ module CandidApiClient
631
638
  service_lines: service_lines,
632
639
  guarantor: guarantor,
633
640
  external_claim_submission: external_claim_submission,
634
- tag_ids: tag_ids
641
+ tag_ids: tag_ids,
642
+ schema_instances: schema_instances
635
643
  }.compact
636
644
  req.url "#{@request_client.get_url(environment: CandidApi,
637
645
  request_options: request_options)}/api/encounters/v4"
@@ -784,6 +792,15 @@ module CandidApiClient
784
792
  # @param patient_authorized_release [Boolean] Whether this patient has authorized the release of medical information
785
793
  # for billing purpose.
786
794
  # Box 12 on the CMS-1500 claim form.
795
+ # @param schema_instances [Array<Hash>] Key-value pairs that must adhere to a schema created via the Custom Schema API.
796
+ # Multiple schema
797
+ # instances cannot be created for the same schema on an encounter. Updating schema
798
+ # instances utilizes PUT
799
+ # semantics, so the schema instances on the encounter will be set to whatever
800
+ # inputs are provided. If null
801
+ # is provided as an input, then the encounter's schema instances will be cleared.Request of type Array<CandidApiClient::CustomSchemas::V1::Types::SchemaInstance>, as a Hash
802
+ # * :schema_id (String)
803
+ # * :content (Hash{String => Object})
787
804
  # @param request_options [CandidApiClient::RequestOptions]
788
805
  # @return [CandidApiClient::Encounters::V4::Types::Encounter]
789
806
  # @example
@@ -815,10 +832,11 @@ module CandidApiClient
815
832
  # onset_of_current_illness_or_symptom_date: DateTime.parse(2023-01-15),
816
833
  # last_menstrual_period_date: DateTime.parse(2023-01-15),
817
834
  # delay_reason_code: C_1,
818
- # patient_authorized_release: true
835
+ # patient_authorized_release: true,
836
+ # schema_instances: [{ schema_id: "ec096b13-f80a-471d-aaeb-54b021c9d582", content: { "provider_category": "internist", "is_urgent_care": true, "bmi": 24.2, "age": 38 } }]
819
837
  # )
820
838
  def update(encounter_id:, prior_authorization_number: nil, external_id: nil, date_of_service: nil,
821
- diagnosis_ids: nil, tag_ids: nil, clinical_notes: nil, pay_to_address: nil, billable_status: nil, responsible_party: nil, provider_accepts_assignment: nil, benefits_assigned_to_provider: nil, synchronicity: nil, place_of_service_code: nil, place_of_service_code_as_submitted: nil, appointment_type: nil, end_date_of_service: nil, subscriber_primary: nil, subscriber_secondary: nil, additional_information: nil, service_authorization_exception_code: nil, admission_date: nil, discharge_date: nil, onset_of_current_illness_or_symptom_date: nil, last_menstrual_period_date: nil, delay_reason_code: nil, patient_authorized_release: nil, request_options: nil)
839
+ diagnosis_ids: nil, tag_ids: nil, clinical_notes: nil, pay_to_address: nil, billable_status: nil, responsible_party: nil, provider_accepts_assignment: nil, benefits_assigned_to_provider: nil, synchronicity: nil, place_of_service_code: nil, place_of_service_code_as_submitted: nil, appointment_type: nil, end_date_of_service: nil, subscriber_primary: nil, subscriber_secondary: nil, additional_information: nil, service_authorization_exception_code: nil, admission_date: nil, discharge_date: nil, onset_of_current_illness_or_symptom_date: nil, last_menstrual_period_date: nil, delay_reason_code: nil, patient_authorized_release: nil, schema_instances: nil, request_options: nil)
822
840
  response = @request_client.conn.patch do |req|
823
841
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
824
842
  req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
@@ -854,7 +872,8 @@ module CandidApiClient
854
872
  onset_of_current_illness_or_symptom_date: onset_of_current_illness_or_symptom_date,
855
873
  last_menstrual_period_date: last_menstrual_period_date,
856
874
  delay_reason_code: delay_reason_code,
857
- patient_authorized_release: patient_authorized_release
875
+ patient_authorized_release: patient_authorized_release,
876
+ schema_instances: schema_instances
858
877
  }.compact
859
878
  req.url "#{@request_client.get_url(environment: CandidApi,
860
879
  request_options: request_options)}/api/encounters/v4/#{encounter_id}"
@@ -1381,6 +1400,11 @@ module CandidApiClient
1381
1400
  # * :patient_control_number (String)
1382
1401
  # * :submission_records (Array<CandidApiClient::ClaimSubmission::V1::Types::ClaimSubmissionRecordCreate>)
1383
1402
  # @param tag_ids [Array<String>] Names of tags that should be on the encounter.
1403
+ # @param schema_instances [Array<Hash>] Key-value pairs that must adhere to a schema created via the Custom Schema API.
1404
+ # Multiple schema
1405
+ # instances cannot be created for the same schema on an encounter.Request of type Array<CandidApiClient::CustomSchemas::V1::Types::SchemaInstance>, as a Hash
1406
+ # * :schema_id (String)
1407
+ # * :content (Hash{String => Object})
1384
1408
  # @param request_options [CandidApiClient::RequestOptions]
1385
1409
  # @return [CandidApiClient::Encounters::V4::Types::Encounter]
1386
1410
  # @example
@@ -1405,10 +1429,11 @@ module CandidApiClient
1405
1429
  # service_lines: [{ modifiers: [TWENTY_TWO], procedure_code: "string", quantity: "string", units: MJ, charge_amount_cents: 1, diagnosis_pointers: [1], drug_identification: { }, place_of_service_code: PHARMACY, description: "string", date_of_service: DateTime.parse(2023-01-15), end_date_of_service: DateTime.parse(2023-01-15), referring_provider: { npi: "string", taxonomy_code: "string", address: { address_1: "123 Main St", address_2: "Apt 1", city: "New York", state: NY, zip_code: "10001", zip_plus_four_code: "1234" }, first_name: "string", last_name: "string", organization_name: "string" }, initial_referring_provider: { npi: "string", taxonomy_code: "string", address: { address_1: "123 Main St", address_2: "Apt 1", city: "New York", state: NY, zip_code: "10001", zip_plus_four_code: "1234" }, qualifier: DQ, first_name: "string", last_name: "string", organization_name: "string" }, supervising_provider: { npi: "string", taxonomy_code: "string", address: { address_1: "123 Main St", address_2: "Apt 1", city: "New York", state: NY, zip_code: "10001", zip_plus_four_code: "1234" }, first_name: "string", last_name: "string", organization_name: "string" }, ordering_provider: { npi: "string", taxonomy_code: "string", address: { address_1: "123 Main St", address_2: "Apt 1", city: "New York", state: NY, zip_code: "10001", zip_plus_four_code: "1234" }, first_name: "string", last_name: "string", organization_name: "string" } }],
1406
1430
  # guarantor: { phone_numbers: [{ number: "1234567890", type: HOME }], phone_consent: true, email: "johndoe@joincandidhealth.com", email_consent: true, first_name: "string", last_name: "string", external_id: "string", date_of_birth: DateTime.parse(2023-01-15), address: { address_1: "123 Main St", address_2: "Apt 1", city: "New York", state: NY, zip_code: "10001", zip_plus_four_code: "1234" } },
1407
1431
  # external_claim_submission: { claim_created_at: DateTime.parse(2023-01-01T12:00:00.000Z), patient_control_number: "PATIENT_CONTROL_NUMBER", submission_records: [{ submitted_at: DateTime.parse(2023-01-01T13:00:00.000Z), claim_frequency_code: ORIGINAL, payer_responsibility: PRIMARY, intended_submission_medium: ELECTRONIC }, { submitted_at: DateTime.parse(2023-01-04T12:00:00.000Z), claim_frequency_code: REPLACEMENT, payer_responsibility: PRIMARY, intended_submission_medium: PAPER }] },
1408
- # tag_ids: ["string"]
1432
+ # tag_ids: ["string"],
1433
+ # schema_instances: [{ schema_id: "ec096b13-f80a-471d-aaeb-54b021c9d582", content: { "provider_category": "internist", "is_urgent_care": true, "bmi": 24.2, "age": 38 } }]
1409
1434
  # )
1410
1435
  def create(external_id:, patient_authorized_release:, benefits_assigned_to_provider:,
1411
- provider_accepts_assignment:, billable_status:, responsible_party:, patient:, billing_provider:, rendering_provider:, diagnoses:, place_of_service_code:, prior_authorization_number: nil, appointment_type: nil, existing_medications: nil, vitals: nil, interventions: nil, pay_to_address: nil, synchronicity: nil, additional_information: nil, service_authorization_exception_code: nil, admission_date: nil, discharge_date: nil, onset_of_current_illness_or_symptom_date: nil, last_menstrual_period_date: nil, delay_reason_code: nil, additional_properties: nil, _field_set: nil, date_of_service: nil, end_date_of_service: nil, referring_provider: nil, initial_referring_provider: nil, supervising_provider: nil, service_facility: nil, subscriber_primary: nil, subscriber_secondary: nil, clinical_notes: nil, billing_notes: nil, patient_histories: nil, service_lines: nil, guarantor: nil, external_claim_submission: nil, tag_ids: nil, request_options: nil)
1436
+ provider_accepts_assignment:, billable_status:, responsible_party:, patient:, billing_provider:, rendering_provider:, diagnoses:, place_of_service_code:, prior_authorization_number: nil, appointment_type: nil, existing_medications: nil, vitals: nil, interventions: nil, pay_to_address: nil, synchronicity: nil, additional_information: nil, service_authorization_exception_code: nil, admission_date: nil, discharge_date: nil, onset_of_current_illness_or_symptom_date: nil, last_menstrual_period_date: nil, delay_reason_code: nil, additional_properties: nil, _field_set: nil, date_of_service: nil, end_date_of_service: nil, referring_provider: nil, initial_referring_provider: nil, supervising_provider: nil, service_facility: nil, subscriber_primary: nil, subscriber_secondary: nil, clinical_notes: nil, billing_notes: nil, patient_histories: nil, service_lines: nil, guarantor: nil, external_claim_submission: nil, tag_ids: nil, schema_instances: nil, request_options: nil)
1412
1437
  Async do
1413
1438
  response = @request_client.conn.post do |req|
1414
1439
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
@@ -1461,7 +1486,8 @@ module CandidApiClient
1461
1486
  service_lines: service_lines,
1462
1487
  guarantor: guarantor,
1463
1488
  external_claim_submission: external_claim_submission,
1464
- tag_ids: tag_ids
1489
+ tag_ids: tag_ids,
1490
+ schema_instances: schema_instances
1465
1491
  }.compact
1466
1492
  req.url "#{@request_client.get_url(environment: CandidApi,
1467
1493
  request_options: request_options)}/api/encounters/v4"
@@ -1615,6 +1641,15 @@ module CandidApiClient
1615
1641
  # @param patient_authorized_release [Boolean] Whether this patient has authorized the release of medical information
1616
1642
  # for billing purpose.
1617
1643
  # Box 12 on the CMS-1500 claim form.
1644
+ # @param schema_instances [Array<Hash>] Key-value pairs that must adhere to a schema created via the Custom Schema API.
1645
+ # Multiple schema
1646
+ # instances cannot be created for the same schema on an encounter. Updating schema
1647
+ # instances utilizes PUT
1648
+ # semantics, so the schema instances on the encounter will be set to whatever
1649
+ # inputs are provided. If null
1650
+ # is provided as an input, then the encounter's schema instances will be cleared.Request of type Array<CandidApiClient::CustomSchemas::V1::Types::SchemaInstance>, as a Hash
1651
+ # * :schema_id (String)
1652
+ # * :content (Hash{String => Object})
1618
1653
  # @param request_options [CandidApiClient::RequestOptions]
1619
1654
  # @return [CandidApiClient::Encounters::V4::Types::Encounter]
1620
1655
  # @example
@@ -1646,10 +1681,11 @@ module CandidApiClient
1646
1681
  # onset_of_current_illness_or_symptom_date: DateTime.parse(2023-01-15),
1647
1682
  # last_menstrual_period_date: DateTime.parse(2023-01-15),
1648
1683
  # delay_reason_code: C_1,
1649
- # patient_authorized_release: true
1684
+ # patient_authorized_release: true,
1685
+ # schema_instances: [{ schema_id: "ec096b13-f80a-471d-aaeb-54b021c9d582", content: { "provider_category": "internist", "is_urgent_care": true, "bmi": 24.2, "age": 38 } }]
1650
1686
  # )
1651
1687
  def update(encounter_id:, prior_authorization_number: nil, external_id: nil, date_of_service: nil,
1652
- diagnosis_ids: nil, tag_ids: nil, clinical_notes: nil, pay_to_address: nil, billable_status: nil, responsible_party: nil, provider_accepts_assignment: nil, benefits_assigned_to_provider: nil, synchronicity: nil, place_of_service_code: nil, place_of_service_code_as_submitted: nil, appointment_type: nil, end_date_of_service: nil, subscriber_primary: nil, subscriber_secondary: nil, additional_information: nil, service_authorization_exception_code: nil, admission_date: nil, discharge_date: nil, onset_of_current_illness_or_symptom_date: nil, last_menstrual_period_date: nil, delay_reason_code: nil, patient_authorized_release: nil, request_options: nil)
1688
+ diagnosis_ids: nil, tag_ids: nil, clinical_notes: nil, pay_to_address: nil, billable_status: nil, responsible_party: nil, provider_accepts_assignment: nil, benefits_assigned_to_provider: nil, synchronicity: nil, place_of_service_code: nil, place_of_service_code_as_submitted: nil, appointment_type: nil, end_date_of_service: nil, subscriber_primary: nil, subscriber_secondary: nil, additional_information: nil, service_authorization_exception_code: nil, admission_date: nil, discharge_date: nil, onset_of_current_illness_or_symptom_date: nil, last_menstrual_period_date: nil, delay_reason_code: nil, patient_authorized_release: nil, schema_instances: nil, request_options: nil)
1653
1689
  Async do
1654
1690
  response = @request_client.conn.patch do |req|
1655
1691
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
@@ -1686,7 +1722,8 @@ module CandidApiClient
1686
1722
  onset_of_current_illness_or_symptom_date: onset_of_current_illness_or_symptom_date,
1687
1723
  last_menstrual_period_date: last_menstrual_period_date,
1688
1724
  delay_reason_code: delay_reason_code,
1689
- patient_authorized_release: patient_authorized_release
1725
+ patient_authorized_release: patient_authorized_release,
1726
+ schema_instances: schema_instances
1690
1727
  }.compact
1691
1728
  req.url "#{@request_client.get_url(environment: CandidApi,
1692
1729
  request_options: request_options)}/api/encounters/v4/#{encounter_id}"
@@ -17,6 +17,7 @@ require_relative "../../../tags/types/tag"
17
17
  require_relative "coding_attribution_type"
18
18
  require_relative "encounter_owner_of_next_action_type"
19
19
  require_relative "encounter_submission_origin_type"
20
+ require_relative "../../../custom_schemas/v_1/types/schema_instance"
20
21
  require_relative "medication"
21
22
  require_relative "vitals"
22
23
  require_relative "intervention"
@@ -144,6 +145,10 @@ module CandidApiClient
144
145
  # For Encounters created with an external_claim_submission object, this will be
145
146
  # EncounterSubmissionOriginType.EXTERNAL.
146
147
  attr_reader :submission_origin
148
+ # @return [Array<CandidApiClient::CustomSchemas::V1::Types::SchemaInstance>] Key-value pairs that must adhere to a schema created via the Custom Schema API.
149
+ # Multiple schema
150
+ # instances cannot be created for the same schema on an encounter.
151
+ attr_reader :schema_instances
147
152
  # @return [String] A client-specified unique ID to associate with this encounter;
148
153
  # for example, your internal encounter ID or a Dr. Chrono encounter ID.
149
154
  # This field should not contain PHI.
@@ -311,6 +316,9 @@ module CandidApiClient
311
316
  # EncounterSubmissionOriginType.CANDID.
312
317
  # For Encounters created with an external_claim_submission object, this will be
313
318
  # EncounterSubmissionOriginType.EXTERNAL.
319
+ # @param schema_instances [Array<CandidApiClient::CustomSchemas::V1::Types::SchemaInstance>] Key-value pairs that must adhere to a schema created via the Custom Schema API.
320
+ # Multiple schema
321
+ # instances cannot be created for the same schema on an encounter.
314
322
  # @param external_id [String] A client-specified unique ID to associate with this encounter;
315
323
  # for example, your internal encounter ID or a Dr. Chrono encounter ID.
316
324
  # This field should not contain PHI.
@@ -372,7 +380,7 @@ module CandidApiClient
372
380
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
373
381
  # @return [CandidApiClient::Encounters::V4::Types::Encounter]
374
382
  def initialize(date_of_service:, encounter_id:, claims:, patient:, billing_provider:, rendering_provider:,
375
- service_facility:, url:, diagnoses:, clinical_notes:, patient_histories:, patient_payments:, tags:, owner_of_next_action:, submission_origin:, external_id:, patient_authorized_release:, benefits_assigned_to_provider:, provider_accepts_assignment:, billable_status:, responsible_party:, patient_control_number: OMIT, end_date_of_service: OMIT, guarantor: OMIT, referring_provider: OMIT, initial_referring_provider: OMIT, supervising_provider: OMIT, subscriber_primary: OMIT, subscriber_secondary: OMIT, billing_notes: OMIT, place_of_service_code: OMIT, place_of_service_code_as_submitted: OMIT, coding_attribution: OMIT, work_queue_id: OMIT, work_queue_membership_activated_at: OMIT, prior_authorization_number: OMIT, appointment_type: OMIT, existing_medications: OMIT, vitals: OMIT, interventions: OMIT, pay_to_address: OMIT, synchronicity: 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)
383
+ service_facility:, url:, diagnoses:, clinical_notes:, patient_histories:, patient_payments:, tags:, owner_of_next_action:, submission_origin:, schema_instances:, external_id:, patient_authorized_release:, benefits_assigned_to_provider:, provider_accepts_assignment:, billable_status:, responsible_party:, patient_control_number: OMIT, end_date_of_service: OMIT, guarantor: OMIT, referring_provider: OMIT, initial_referring_provider: OMIT, supervising_provider: OMIT, subscriber_primary: OMIT, subscriber_secondary: OMIT, billing_notes: OMIT, place_of_service_code: OMIT, place_of_service_code_as_submitted: OMIT, coding_attribution: OMIT, work_queue_id: OMIT, work_queue_membership_activated_at: OMIT, prior_authorization_number: OMIT, appointment_type: OMIT, existing_medications: OMIT, vitals: OMIT, interventions: OMIT, pay_to_address: OMIT, synchronicity: 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)
376
384
  @patient_control_number = patient_control_number if patient_control_number != OMIT
377
385
  @date_of_service = date_of_service
378
386
  @end_date_of_service = end_date_of_service if end_date_of_service != OMIT
@@ -406,6 +414,7 @@ module CandidApiClient
406
414
  end
407
415
  @owner_of_next_action = owner_of_next_action
408
416
  @submission_origin = submission_origin
417
+ @schema_instances = schema_instances
409
418
  @external_id = external_id
410
419
  @prior_authorization_number = prior_authorization_number if prior_authorization_number != OMIT
411
420
  @patient_authorized_release = patient_authorized_release
@@ -461,6 +470,7 @@ module CandidApiClient
461
470
  "work_queue_membership_activated_at": work_queue_membership_activated_at,
462
471
  "owner_of_next_action": owner_of_next_action,
463
472
  "submission_origin": submission_origin,
473
+ "schema_instances": schema_instances,
464
474
  "external_id": external_id,
465
475
  "prior_authorization_number": prior_authorization_number,
466
476
  "patient_authorized_release": patient_authorized_release,
@@ -597,6 +607,10 @@ module CandidApiClient
597
607
  end
598
608
  owner_of_next_action = struct["owner_of_next_action"]
599
609
  submission_origin = struct["submission_origin"]
610
+ schema_instances = parsed_json["schema_instances"]&.map do |item|
611
+ item = item.to_json
612
+ CandidApiClient::CustomSchemas::V1::Types::SchemaInstance.from_json(json_object: item)
613
+ end
600
614
  external_id = struct["external_id"]
601
615
  prior_authorization_number = struct["prior_authorization_number"]
602
616
  patient_authorized_release = struct["patient_authorized_release"]
@@ -667,6 +681,7 @@ module CandidApiClient
667
681
  work_queue_membership_activated_at: work_queue_membership_activated_at,
668
682
  owner_of_next_action: owner_of_next_action,
669
683
  submission_origin: submission_origin,
684
+ schema_instances: schema_instances,
670
685
  external_id: external_id,
671
686
  prior_authorization_number: prior_authorization_number,
672
687
  patient_authorized_release: patient_authorized_release,
@@ -734,6 +749,7 @@ module CandidApiClient
734
749
  obj.work_queue_membership_activated_at&.is_a?(DateTime) != false || raise("Passed value for field obj.work_queue_membership_activated_at is not the expected type, validation failed.")
735
750
  obj.owner_of_next_action.is_a?(CandidApiClient::Encounters::V4::Types::EncounterOwnerOfNextActionType) != false || raise("Passed value for field obj.owner_of_next_action is not the expected type, validation failed.")
736
751
  obj.submission_origin.is_a?(CandidApiClient::Encounters::V4::Types::EncounterSubmissionOriginType) != false || raise("Passed value for field obj.submission_origin is not the expected type, validation failed.")
752
+ obj.schema_instances.is_a?(Array) != false || raise("Passed value for field obj.schema_instances is not the expected type, validation failed.")
737
753
  obj.external_id.is_a?(String) != false || raise("Passed value for field obj.external_id is not the expected type, validation failed.")
738
754
  obj.prior_authorization_number&.is_a?(String) != false || raise("Passed value for field obj.prior_authorization_number is not the expected type, validation failed.")
739
755
  obj.patient_authorized_release.is_a?(Boolean) != false || raise("Passed value for field obj.patient_authorized_release is not the expected type, validation failed.")
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ostruct"
4
+ require "json"
5
+
6
+ module CandidApiClient
7
+ module Encounters
8
+ module V4
9
+ module Types
10
+ class KeyDoesNotExistError
11
+ # @return [String]
12
+ attr_reader :key
13
+ # @return [String]
14
+ attr_reader :schema_id
15
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
16
+ attr_reader :additional_properties
17
+ # @return [Object]
18
+ attr_reader :_field_set
19
+ protected :_field_set
20
+
21
+ OMIT = Object.new
22
+
23
+ # @param key [String]
24
+ # @param schema_id [String]
25
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
26
+ # @return [CandidApiClient::Encounters::V4::Types::KeyDoesNotExistError]
27
+ def initialize(key:, schema_id:, additional_properties: nil)
28
+ @key = key
29
+ @schema_id = schema_id
30
+ @additional_properties = additional_properties
31
+ @_field_set = { "key": key, "schema_id": schema_id }
32
+ end
33
+
34
+ # Deserialize a JSON object to an instance of KeyDoesNotExistError
35
+ #
36
+ # @param json_object [String]
37
+ # @return [CandidApiClient::Encounters::V4::Types::KeyDoesNotExistError]
38
+ def self.from_json(json_object:)
39
+ struct = JSON.parse(json_object, object_class: OpenStruct)
40
+ key = struct["key"]
41
+ schema_id = struct["schema_id"]
42
+ new(
43
+ key: key,
44
+ schema_id: schema_id,
45
+ additional_properties: struct
46
+ )
47
+ end
48
+
49
+ # Serialize an instance of KeyDoesNotExistError to a JSON object
50
+ #
51
+ # @return [String]
52
+ def to_json(*_args)
53
+ @_field_set&.to_json
54
+ end
55
+
56
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
57
+ # hash and check each fields type against the current object's property
58
+ # definitions.
59
+ #
60
+ # @param obj [Object]
61
+ # @return [Void]
62
+ def self.validate_raw(obj:)
63
+ obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
64
+ obj.schema_id.is_a?(String) != false || raise("Passed value for field obj.schema_id is not the expected type, validation failed.")
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end