Skip to content

Commit

Permalink
add docs functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Surabhi Suman authored and Surabhi Suman committed May 27, 2023
1 parent 0a7aad5 commit 3144311
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 16 deletions.
18 changes: 14 additions & 4 deletions .idea/workspace.xml

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

16 changes: 12 additions & 4 deletions app/controllers/health_care_provider_controller.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
class HealthCareProviderController < ApplicationController

# checks eligibility for current medication/to be claim
def check_eligibility
amount = params[:amount].to_i
claim_type = params["claim_type"].to_s
health_id = params[:health_id].to_s
customer = Person.find_by_health_id(health_id)
CentralEntityHelper.get_eligibility(amount, claim_type, customer.id)
resp = CentralEntityHelper.get_eligibility(amount, claim_type, customer.id)
return render json: resp
end

def send_pre_auth_request
Expand All @@ -14,11 +16,17 @@ def send_pre_auth_request
requester_id = params["requester_id"]
health_id = params[:health_id].to_s
customer = Person.find_by_health_id(health_id)
InsuranceHelper.process_pre_auth(amount, claim_type, requester_id, customer.id)
resp = InsuranceHelper.process_pre_auth(amount, claim_type, requester_id, customer.id)
return render json: resp
end

def send_claim_request
InsuranceHelper.send_claim_request(params)
def update_docs_and_send_claim_request
claim_id = params[:claim_id]
amount = params[:claims_amount]
claim_type = params[:claim_type]
CentralEntityHelper.add_data_to_health_record(params[:prescriptions], params[:invoices], params[:person_id])
resp = InsuranceHelper.send_claim_request(claim_id, amount, claim_type)
return render json: resp
end

end
11 changes: 10 additions & 1 deletion app/helpers/central_entity_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class CentralEntityHelper
module CentralEntityHelper
class << self

def get_eligibility(claim_amount, claim_type, customer_id)
Expand All @@ -17,5 +17,14 @@ def get_eligibility(claim_amount, claim_type, customer_id)
# particular claim_type is under covers
end

def add_data_to_health_record(new_prescriptions, new_invoices, customer_id)
health_report = HealthReport.find_by_person_id(customer_id)
invoices = health_report.invoices
invoices.add(new_invoices)
prescriptions = health_report.prescriptions
prescriptions.add(new_prescriptions)
health_report.update(invoices: invoices, prescriptions: prescriptions)
end

end
end
11 changes: 4 additions & 7 deletions app/helpers/insurance_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class InsuranceHelper
module InsuranceHelper
class << self

# check for customer consent on a loop - long polling/while true
Expand All @@ -14,24 +14,21 @@ def process_pre_auth(amount, claim_type, requester_id, customer_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 }
else
data = "Pre auth request from " + requester_id
notification = Notification.create(title: "Pre-auth request", data: data, person_id: customer_id, sender: requester_id)
NotificationHelper.send_notification(requester_id, customer_id, "Pre Auth Request")
# send notification
return {"success": false }
end
end

# submit new invoices and prescriptions to central DB
# check if claim exists
# check claim status if in a valid state
# check eligible limit with insurance policy data
# calls fraud detection engine
# if fraud engine validates
# mark claim as success
# send notif to customer
def send_claim_request(params)
claim_id = params[:claim_id]
amount = params[:claims_amount]
claim_type = params[:claim_type]
def send_claim_request(claim_id, amount, claim_type)
#todo: add claim type to claim model
claim = Claim.find_by(id: claim_id)
if !claim || claim.status != 'pre-auth-approved'
Expand Down
12 changes: 12 additions & 0 deletions app/helpers/notification_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module NotificationHelper

class << self

def send_notification(requester_id, customer_id, context)
data = context + " from " + requester_id
notification = Notification.create(title: context, data: data, person_id: customer_id, sender: requester_id)
# send notification
# todo: figure out how to send
end
end
end

0 comments on commit 3144311

Please sign in to comment.