package estimator import model.Patient import model.Estimate import java.util.Date declare PaymentProfile deductiblePercent: int percentDiscount: int procedure: String caseRate: int patientType: String deductibleAmount: int insurance: String end #from row number: 1 rule "Row 3 Estimates Profile" dialect "mvel" when profile : PaymentProfile( insurance == "Blue Cross" , procedure == "Brain Surgery" ) then profile.setCaseRate( 125000 ); profile.setDeductiblePercent( 20 ); end #from row number: 2 rule "Row 1 Estimates Profile" dialect "mvel" when profile : PaymentProfile( insurance == "Blue Cross" , procedure == "Broken Arm" , patientType == "Outpatient" ) then profile.setPercentDiscount( 25 ); profile.setDeductiblePercent( 10 ); end #from row number: 3 rule "Row 9 Estimates Profile" dialect "mvel" when profile : PaymentProfile( insurance == "Blue Cross" , procedure == "Broken Arm" , patientType == "Inpatient" ) then profile.setCaseRate( 500 ); profile.setDeductiblePercent( 10 ); end #from row number: 4 rule "Row 2 Estimates Profile" dialect "mvel" when profile : PaymentProfile( insurance == "Blue Cross" , procedure == "Bump on Head" ) then profile.setPercentDiscount( 10 ); profile.setDeductibleAmount( 25 ); end #from row number: 5 rule "Row 4 Estimates Profile" dialect "mvel" when profile : PaymentProfile( insurance == "Blue Cross" , procedure == "Heart Surgery" ) then profile.setPercentDiscount( 25 ); profile.setDeductiblePercent( 15 ); end #from row number: 6 rule "Row 7 Estimates Profile" dialect "mvel" when profile : PaymentProfile( insurance == "United" , procedure == "Brain Surgery" ) then profile.setPercentDiscount( 15 ); profile.setDeductiblePercent( 10 ); end #from row number: 7 rule "Row 5 Estimates Profile" dialect "mvel" when profile : PaymentProfile( insurance == "United" , procedure == "Broken Arm" ) then profile.setPercentDiscount( 15 ); profile.setDeductiblePercent( 10 ); end #from row number: 8 rule "Row 6 Estimates Profile" dialect "mvel" when profile : PaymentProfile( insurance == "United" , procedure == "Bump on Head" ) then profile.setPercentDiscount( 15 ); profile.setDeductiblePercent( 10 ); end #from row number: 9 rule "Row 8 Estimates Profile" dialect "mvel" when profile : PaymentProfile( insurance == "United" , procedure == "Heart Surgery" ) then profile.setPercentDiscount( 15 ); profile.setDeductiblePercent( 10 ); end rule 'Create Estimate' dialect 'mvel' when patient : Patient() then Estimate estimate = new Estimate(); estimate.setPatient(patient); estimate.setEstimatedCharges(patient.getEstimatedCharges()); PaymentProfile profile = new PaymentProfile(); profile.setInsurance(patient.getInsurance()); profile.setProcedure(patient.getProcedure()); profile.setPatientType(patient.getPatientType()); insert (estimate); insert (profile); end rule 'Calculate Estimate' dialect 'mvel' salience -1 when estimate : Estimate(timeStamp == null) patient : Patient() from estimate.patient profile : PaymentProfile (insurance == patient.insurance, procedure == patient.procedure) then int charges = estimate.getEstimatedCharges(); int caseRate = profile.getCaseRate(); int pctDiscount = profile.getPercentDiscount(); int deductibleAmount = profile.getDeductibleAmount(); int deductiblePct = profile.getDeductiblePercent(); int insuranceAmt = caseRate + (charges * pctDiscount / 100); int patientPmt = deductibleAmount + (insuranceAmt * deductiblePct / 100); estimate.setInsuranceAmount(insuranceAmt); estimate.setPatientPayment(patientPmt); estimate.setTimeStamp(new Date()); update (estimate); end rule "Patient Payment less than Insurance Amount" dialect "mvel" when estimate : Estimate( patientPayment > ( insuranceAmount ) ) then estimate.setPatientPayment( estimate.getInsuranceAmount() ); update( estimate ); end rule 'display' dialect 'mvel' when then System.out.println("Running estimator package - changed"); end