Last active
January 16, 2018 11:40
-
-
Save machty/67ca047db9daa51c720a634cc8dee86e to your computer and use it in GitHub Desktop.
Insurance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
const { computed } = Ember; | |
function f(v) { | |
return parseFloat(v.toString()); | |
} | |
export default Ember.Component.extend({ | |
tagName: 'tr', | |
bd: computed('p.premium', 'p.deductible', 'p.negotiatedRate', | |
'p.myRate', 'sessionsPerYear', | |
'p.copay', 'p.coinsurance', 'p.oop', | |
function() { | |
let premium = this.fget('p.premium'); | |
let annualPremium = premium * 12; | |
// compute how much until deductible met. | |
// so in this period | |
let ded = this.fget('p.deductible'); | |
let negRate = this.fget('p.negotiatedRate'); | |
let myRate = this.fget('p.myRate'); | |
// what happens when i have $5 left | |
// on deductible and I have another session. | |
// for now, assume that you pay full amount, | |
// and THEN next session it kicks in. | |
let sessionsPerYear = this.fget('sessionsPerYear'); | |
let numDedSess = Math.min(Math.ceil(ded / negRate), sessionsPerYear); | |
let dedMet = numDedSess * negRate; | |
let numCoSess = sessionsPerYear - numDedSess; | |
let remainingPms = Math.max(0, sessionsPerYear - numDedSess); | |
let copay = this.fget('p.copay'); | |
let coins = this.fget('p.coinsurance'); | |
let copayTotal = copay * remainingPms; | |
let coinsTotal = coins * negRate * remainingPms; | |
let coTotal = copayTotal + coinsTotal; | |
let oop = dedMet + coTotal; | |
let oopm = this.fget('p.oop'); | |
let overshoot = dedMet + coTotal - oopm; | |
let uncoveredRate = myRate - negRate; | |
let uncTotal = uncoveredRate * sessionsPerYear; // remainingPms * uncoveredRate; | |
let addls = Math.min(oopm, dedMet + coTotal); | |
let minMedExp = annualPremium + addls + uncTotal; | |
let maxMedExp = annualPremium + oopm + uncTotal; | |
let annTotal; | |
if (minMedExp == maxMedExp) { | |
annTotal = minMedExp.toFixed(0); | |
} else { | |
annTotal = `${minMedExp.toFixed(0)}-${maxMedExp.toFixed(0)}`; | |
} | |
return { | |
coTotal, | |
dedMet, | |
numDedSess, | |
numCoSess, | |
oop, | |
uncTotal, | |
overshoot, | |
annualPremium, | |
annTotal | |
}; | |
// return f(this.get('p.premium'))*12; | |
}), | |
fget(key) { | |
return f(this.get(key)); | |
}, | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
let negotiatedRate = 175; | |
let myRate = 175; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
sessionsPerYear: 95, | |
plans: [ | |
{ | |
name: 'bronze', | |
premium: 729.59, | |
deductible: 5500, | |
oop: 6550, | |
coinsurance: 0.5, | |
copay: 0, | |
negotiatedRate, | |
myRate, | |
}, | |
{ | |
name: 'silver', | |
premium: 882.73, | |
deductible: 2000, | |
oop: 6750, | |
coinsurance: 0, | |
copay: 50, | |
negotiatedRate, | |
myRate, | |
}, | |
{ | |
name: 'gold', | |
premium: 1057.86, | |
deductible: 600, | |
oop: 4000, | |
coinsurance: 0, | |
copay: 40, | |
negotiatedRate, | |
myRate, | |
}, | |
{ | |
name: 'platinum', | |
premium: 1262.04, | |
deductible: 0, | |
oop: 2000, | |
coinsurance: 0, | |
copay: 35, | |
negotiatedRate, | |
myRate, | |
}, | |
], | |
actions: { | |
dup(plan) { | |
let newPlan = Object.assign({}, plan); | |
this.get('plans').pushObject(newPlan); | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
margin: 12px 16px; | |
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
font-size: 12pt; | |
} | |
input { | |
width: 30px; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.13.0", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.16.2", | |
"ember-template-compiler": "2.16.2", | |
"ember-testing": "2.16.2" | |
}, | |
"addons": { | |
"ember-data": "2.16.3" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment