Some daisyBill models undergo a review process after being created or updated. Objects can fail review if certain attributes are empty or contain invalid input, but can still be successfully created and updated as long as the hard requirements are met.
Let's take a look at this process by creating a patient:
Create Patient
All fields required for creating a patient are met:
DaisybillApi::Models::Patient.create(
billing_provider_id: 25,
first_name: "Beatrice",
last_name: "Kiddo"
)
subsequent response:
{
"created_at":"2015-10-21T14:40:06.637-07:00",
"updated_at":"2015-10-21T14:40:06.637-07:00",
"review_status":"pending",
"review_errors":[],
"review_warnings":[],
"id":48,
"first_name":"Beatrice",
"last_name":"Kiddo",
"links":[
{
"rel":"billing_provider",
"href":"/api/v1/billing_providers/25"
}
]
}
Notice how in the response above, review_status
is pending, and review_errors
is empty. This patient is currently being reviewed. Now let's retrieve this patient to see if the review has completed.
patient = DaisybillApi::Models::Patient.find(48)
{
"created_at":"2015-10-21T14:40:06.637-07:00",
"updated_at":"2015-10-21T14:40:06.637-07:00",
"review_status":"failed",
"review_errors":[
"Address can't be blank",
"Gender can't be blank",
"Date of birth can't be blank",
"SSN can't be blank"
],
"review_warnings":[],
"id":48,
"first_name":"Beatrice",
"last_name":"Kiddo",
"links":[
{
"rel":"billing_provider",
"href":"/api/v1/billing_providers/25"
}
]
}
The review process for this patient is complete. The review_status
has changed from pending
to failed
, and review_errors
shows why the patient failed review. review_warnings
is empty here, but this is used to convey warnings that do not need to be addressed in order for the record to be valid.
Let's update this patient so it will pass review:
address = DaisybillApi::Models::Address.new(
address_1: "123 Moen Dale Rd",
city: "Santa Monica",
state: "CA",
zip_code: "900019988"
)
patient.address = address
patient.gender = "Female"
patient.date_of_birth = "1976-05-24"
patient.ssn = "123456789"
patient.save
After waiting for the patient to get reviewed, we may request it again to view any errors:
DaisybillApi::Models::Patient.find(48)
{
"created_at":"2015-10-21T14:40:06.637-07:00",
"updated_at":"2015-10-21T14:40:06.637-07:00",
"review_status":"passed",
"review_errors":[],
"review_warnings":[],
"id":48,
"first_name":"Beatrice",
"last_name":"Kiddo",
"ssn":"123456789",
"gender": "Female",
"date_of_birth": "1976-05-24",
"links":[
{
"rel":"billing_provider",
"href":"/api/v1/billing_providers/25"
}
]
}
The patient has passed review, and review_errors
is empty.