Skip to content

Commit

Permalink
chore: added controllers
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 bb40c09 commit cafd380
Show file tree
Hide file tree
Showing 24 changed files with 364 additions and 2 deletions.
16 changes: 15 additions & 1 deletion .idea/workspace.xml

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

11 changes: 11 additions & 0 deletions app/controllers/central_entity_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class CentralEntityController < ApplicationController

def get_health_record
# from id
end

def add_data_to_health_record # create or update api

end

end
51 changes: 51 additions & 0 deletions app/controllers/claim_status_histories_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
class ClaimStatusHistoriesController < ApplicationController
before_action :set_claim_status_history, only: %i[ show update destroy ]

# GET /claim_status_histories
def index
@claim_status_histories = ClaimStatusHistory.all

render json: @claim_status_histories
end

# GET /claim_status_histories/1
def show
render json: @claim_status_history
end

# POST /claim_status_histories
def create
@claim_status_history = ClaimStatusHistory.new(claim_status_history_params)

if @claim_status_history.save
render json: @claim_status_history, status: :created, location: @claim_status_history
else
render json: @claim_status_history.errors, status: :unprocessable_entity
end
end

# PATCH/PUT /claim_status_histories/1
def update
if @claim_status_history.update(claim_status_history_params)
render json: @claim_status_history
else
render json: @claim_status_history.errors, status: :unprocessable_entity
end
end

# DELETE /claim_status_histories/1
def destroy
@claim_status_history.destroy
end

private
# Use callbacks to share common setup or constraints between actions.
def set_claim_status_history
@claim_status_history = ClaimStatusHistory.find(params[:id])
end

# Only allow a list of trusted parameters through.
def claim_status_history_params
params.fetch(:claim_status_history, {})
end
end
19 changes: 19 additions & 0 deletions app/controllers/health_care_provider_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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)
end

def send_pre_auth_request
amount = params[:amount].to_i
end

def send_claim_request

end

end
51 changes: 51 additions & 0 deletions app/controllers/notifications_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
class NotificationsController < ApplicationController
before_action :set_notification, only: %i[ show update destroy ]

# GET /notifications
def index
@notifications = Notification.all

render json: @notifications
end

# GET /notifications/1
def show
render json: @notification
end

# POST /notifications
def create
@notification = Notification.new(notification_params)

if @notification.save
render json: @notification, status: :created, location: @notification
else
render json: @notification.errors, status: :unprocessable_entity
end
end

# PATCH/PUT /notifications/1
def update
if @notification.update(notification_params)
render json: @notification
else
render json: @notification.errors, status: :unprocessable_entity
end
end

# DELETE /notifications/1
def destroy
@notification.destroy
end

private
# Use callbacks to share common setup or constraints between actions.
def set_notification
@notification = Notification.find(params[:id])
end

# Only allow a list of trusted parameters through.
def notification_params
params.fetch(:notification, {})
end
end
2 changes: 2 additions & 0 deletions app/controllers/people_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ def destroy
@person.destroy
end



private
# Use callbacks to share common setup or constraints between actions.
def set_person
Expand Down
21 changes: 21 additions & 0 deletions app/helpers/central_entity_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class CentralEntityHelper
class << self

def get_eligibility(claim_amount, claim_type, customer_id)
health_record = HealthReport.find_by_person_id(customer_id)
return false unless health_record
health_record.insurance_policies.each do |policy|
if policy.covers.contains(claim_type) && claim_amount <= policy.coverage.to_i
return true
end
end
false
# get uhid of customer
# get health record
# check insurances and it's active status
# get claim amount, check if policy sum insured and
# particular claim_type is under covers
end

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

def process_pre_auth(amount, claim_type, customer_id)
# check for customer consent on a loop - long polling/while true
# if consent doesn't exist - register customer consent
# if approved, store customer health data [later can be made accessible via api only for a limited time]
# and register claim in database with pre-auth status
end
end
end
3 changes: 3 additions & 0 deletions app/models/claim_status_history.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class ClaimStatusHistory < ApplicationRecord
belongs_to :claim
end
3 changes: 3 additions & 0 deletions app/models/notification.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Notification < ApplicationRecord
belongs_to :person
end
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Rails.application.routes.draw do
resources :claim_status_histories
resources :notifications
resources :claims
resources :health_reports
resources :prescriptions
Expand Down
8 changes: 8 additions & 0 deletions db/migrate/20230527092830_create_notifications.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class CreateNotifications < ActiveRecord::Migration[7.0]
def change
create_table :notifications do |t|
t.references :person, index: true, foreign_key: true
t.timestamps
end
end
end
5 changes: 5 additions & 0 deletions db/migrate/20230527093517_add_status_to_claims.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddStatusToClaims < ActiveRecord::Migration[7.0]
def change
add_column :claims, :status, :string
end
end
10 changes: 10 additions & 0 deletions db/migrate/20230527093708_create_claim_status_histories.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class CreateClaimStatusHistories < ActiveRecord::Migration[7.0]
def change
create_table :claim_status_histories do |t|
t.references :claim, index: true, foreign_key: true
t.string :transition_from
t.string :transition_to
t.timestamps
end
end
end
5 changes: 5 additions & 0 deletions db/migrate/20230527100527_add_coverage_to_insurance_policy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddCoverageToInsurancePolicy < ActiveRecord::Migration[7.0]
def change
add_column :insurance_policies, :coverage, :string
end
end
22 changes: 21 additions & 1 deletion db/schema.rb

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

7 changes: 7 additions & 0 deletions test/controllers/central_entity_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require "test_helper"

class CentralEntityControllerTest < ActionDispatch::IntegrationTest
# test "the truth" do
# assert true
# end
end
38 changes: 38 additions & 0 deletions test/controllers/claim_status_histories_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
require "test_helper"

class ClaimStatusHistoriesControllerTest < ActionDispatch::IntegrationTest
setup do
@claim_status_history = claim_status_histories(:one)
end

test "should get index" do
get claim_status_histories_url, as: :json
assert_response :success
end

test "should create claim_status_history" do
assert_difference("ClaimStatusHistory.count") do
post claim_status_histories_url, params: { claim_status_history: { } }, as: :json
end

assert_response :created
end

test "should show claim_status_history" do
get claim_status_history_url(@claim_status_history), as: :json
assert_response :success
end

test "should update claim_status_history" do
patch claim_status_history_url(@claim_status_history), params: { claim_status_history: { } }, as: :json
assert_response :success
end

test "should destroy claim_status_history" do
assert_difference("ClaimStatusHistory.count", -1) do
delete claim_status_history_url(@claim_status_history), as: :json
end

assert_response :no_content
end
end
7 changes: 7 additions & 0 deletions test/controllers/health_care_provider_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require "test_helper"

class HealthCareProviderControllerTest < ActionDispatch::IntegrationTest
# test "the truth" do
# assert true
# end
end
Loading

0 comments on commit cafd380

Please sign in to comment.