use of com.salaboy.jbpm5.dev.guide.model.ConceptCode in project jBPM5-Developer-Guide by Salaboy.
the class RatesServiceWorkItemHandler method executeWorkItem.
public void executeWorkItem(WorkItem wi, WorkItemManager wim) {
String patientId = (String) wi.getParameter("rates_patientName");
BigDecimal finalAmount = BigDecimal.ZERO;
//Mock Data
List<ConceptCode> concepts = new ArrayList<ConceptCode>(2);
concepts.add(new ConceptCode("CO-123", new BigDecimal(125), "Dialy Hospital Bed Rate", 4));
concepts.add(new ConceptCode("CO-123", new BigDecimal(100), "Nurse Service", 1));
InsuranceService client = getClient();
//Fixed rate for insured patients
finalAmount = client.calculateHospitalRates(patientId, concepts);
Map<String, Object> result = new HashMap<String, Object>();
result.put("rates_finalAmount", finalAmount);
result.put("rates_concepts", concepts);
wim.completeWorkItem(wi.getId(), result);
}
use of com.salaboy.jbpm5.dev.guide.model.ConceptCode in project jBPM5-Developer-Guide by Salaboy.
the class InsuranceServiceImpl method notifyAndChargePatient.
public boolean notifyAndChargePatient(Patient patient, BigDecimal amount, List<ConceptCode> concepts) {
System.out.println("+--------------------------------------------------------------+");
System.out.println("| ### Hospital Invoice |");
System.out.println("+--------------------------------------------------------------+");
DateFormat df = new SimpleDateFormat("EEE, MMM d, yyyy", Locale.UK);
System.out.println("| Date: " + df.format(new Date()) + "|");
System.out.println("|--------------------------------------------------------------|");
System.out.println("| Patient: " + patient.getFirstName() + "," + patient.getLastName() + "|");
System.out.println("|--------------------------------------------------------------|");
//System.out.println("| Insured: "++" |");
System.out.println("|--------------------------------------------------------------|");
System.out.println("| Concepts: |");
System.out.println("|--------------------------------------------------------------|");
for (ConceptCode code : concepts) {
System.out.println("| -> Concept: " + code.getDesc() + " --------- | " + code.getUnits() + " X |" + code.getRate() + "");
}
System.out.println("|--------------------------------------------------+-----------|");
System.out.println("| Total | " + amount + "|");
System.out.println("|--------------------------------------------------+-----------|");
System.out.println(" -> Sending Invoce Via Email to: " + patient.getEmail());
System.out.println(" -> Charging Credit Card (" + patient.getCreditCardNumber() + ") - Total: " + amount);
return true;
}
use of com.salaboy.jbpm5.dev.guide.model.ConceptCode in project jBPM5-Developer-Guide by Salaboy.
the class InsuranceServiceImpl method calculateHospitalRates.
public BigDecimal calculateHospitalRates(String patientId, List<ConceptCode> concepts) {
BigDecimal lastAmount = BigDecimal.ZERO;
BigDecimal total = BigDecimal.ZERO;
for (ConceptCode concept : concepts) {
for (int i = 0; i < concept.getUnits(); i++) {
total = lastAmount.add(concept.getRate());
lastAmount = total;
}
}
return total;
}
use of com.salaboy.jbpm5.dev.guide.model.ConceptCode in project jBPM5-Developer-Guide by Salaboy.
the class HospitalInsuranceServiceTest method patientNotInsuredTest.
@Test
public void patientNotInsuredTest() {
Patient patient = this.service.getPatientData(testPatients.get("brotha").getId());
assertNotNull(patient);
boolean isPatientInsured = this.service.isPatientInsured(patient.getId());
assertFalse(isPatientInsured);
List<ConceptCode> concepts = new ArrayList<ConceptCode>(2);
concepts.add(new ConceptCode("CO-123", new BigDecimal(125), "Dialy Hospital Bed Rate", 4));
concepts.add(new ConceptCode("CO-123", new BigDecimal(100), "Nurse Service", 1));
BigDecimal nonInsuredAmount = this.service.calculateHospitalRates(patient.getId(), concepts);
assertEquals(600, nonInsuredAmount.intValue());
boolean notifyAndChargePatient = this.service.notifyAndChargePatient(patient, nonInsuredAmount, concepts);
assertTrue(notifyAndChargePatient);
}
use of com.salaboy.jbpm5.dev.guide.model.ConceptCode in project jBPM5-Developer-Guide by Salaboy.
the class NotifyAndChargePatientCommand method execute.
public ExecutionResults execute(CommandContext ctx) {
Patient patient = (Patient) ctx.getData("invoice_patient");
BigDecimal finalAmount = (BigDecimal) ctx.getData("invoice_finalAmount");
List<ConceptCode> concepts = (List<ConceptCode>) ctx.getData("invoice_concepts");
boolean patientNotified = false;
try {
InsuranceService client = getClient();
patientNotified = client.notifyAndChargePatient(patient, finalAmount, concepts);
} catch (MalformedURLException ex) {
ex.printStackTrace();
}
System.out.println(" >>> Patient Notified = " + patientNotified);
ExecutionResults results = new ExecutionResults();
results.setData("invoice_patientNotified", patientNotified);
return results;
}
Aggregations