Skip to content

Commit

Permalink
chore: added seed data and pre auth req
Browse files Browse the repository at this point in the history
  • Loading branch information
surabhisuman committed May 27, 2023
1 parent 3bccf5c commit 1e72dd1
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 37 deletions.
37 changes: 9 additions & 28 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions app/controllers/health_care_provider_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ def send_pre_auth_request
customer = Person.find_by_health_id(health_id)
resp = InsuranceHelper.process_pre_auth(amount, claim_type, requester_id, customer.id)
render json: resp
rescue StandardError => e
puts(e.message)
render json: {msg: "Bad request"}
end

def update_docs_and_send_claim_request
Expand All @@ -30,6 +33,9 @@ def update_docs_and_send_claim_request
CentralEntityHelper.add_data_to_health_record(params[:prescriptions], params[:invoices], params[:person_id])
resp = InsuranceHelper.send_claim_request(claim_id, amount, claim_type)
render json: resp
rescue StandardError => e
puts(e.message)
render json: {msg: "Bad request"}
end

end
8 changes: 5 additions & 3 deletions app/helpers/insurance_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ class << self
# and register claim in database with pre-auth status
def process_pre_auth(amount, claim_type, requester_id, customer_id)
consent = Consent.find_by(person_id: customer_id, requested_by: requester_id)
if consent
# a consent is valid for 2 days
if consent && (Time.now-1.day..Time.now+2.days).cover?(consent.registered_on)
# health_report = HealthReport.find_by_person_id(customer_id)
eligibility = CentralEntityHelper.get_eligibility(amount, claim_type, customer_id).with_indifferent_access
eligible_policy_id = eligibility[:eligible_policy_id]
claim = Claim.create(status: "pre-auth-approved", person_id: customer_id, insurance_policy_id: eligible_policy_id)
return { "success": true, "claim_id": claim.id }
return { "success": true, "claim_id": claim.id, msg: "Pre auth claim registered successfully" }
else
NotificationHelper.send_notification(requester_id, customer_id, "Pre Auth Request")
# send notification
return {"success": false }
return { "success": false, "msg": "Consent pending fom customer" }
end
end

Expand Down Expand Up @@ -44,6 +45,7 @@ def send_claim_request(claim_id, amount, claim_type)
claim.update(status: new_status)
# todo: create notif & notify customer
end
#todo: update claim and max coverage to central DB too
end
end
end
2 changes: 2 additions & 0 deletions app/helpers/notification_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ module NotificationHelper
class << self

def send_notification(requester_id, customer_id, context)
existing_notification = Notification.find_by(sender: requester_id, person_id: customer_id, title: context);
return if existing_notification
data = context + " from " + requester_id
notification = Notification.create(title: context, data: data, person_id: customer_id, sender: requester_id)
# send notification
Expand Down
1 change: 1 addition & 0 deletions app/models/invoice.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
class Invoice < ApplicationRecord
belongs_to :health_report
end
1 change: 1 addition & 0 deletions app/models/prescription.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
class Prescription < ApplicationRecord
belongs_to :health_report
end
23 changes: 17 additions & 6 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,10 @@
aadhar_number: "12332423",
)

consent = Consent.create(
requested_by: "<health-care-provider-id>",
person: person
)

health_report = HealthReport.create(
person: person
)


policy = InsurancePolicy.create(
insurer: "Insure Inc",
start_date: Time.now,
Expand All @@ -35,3 +29,20 @@
coverage: 40000,
health_report_id: health_report.id
)

consent = Consent.create(
person: person,
requested_by: "Insure Inc",
registered_on: Time.now
)

prescription = Prescription.create(
health_report: health_report,
medicines: ["Jalra-OD 100mg (tablet) | Vildagliptin", "Telmis 20 (Tablet)"],
lab_tests: []
)

invoice = Invoice.create(
amount: 1000,
health_report: health_report
)

0 comments on commit 1e72dd1

Please sign in to comment.