Search in sources :

Example 6 with ConceptCode

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);
}
Also used : ConceptCode(com.salaboy.jbpm5.dev.guide.model.ConceptCode) InsuranceService(com.salaboy.jbpm5.dev.guide.webservice.InsuranceService) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) BigDecimal(java.math.BigDecimal)

Example 7 with ConceptCode

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;
}
Also used : ConceptCode(com.salaboy.jbpm5.dev.guide.model.ConceptCode) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 8 with ConceptCode

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;
}
Also used : ConceptCode(com.salaboy.jbpm5.dev.guide.model.ConceptCode) BigDecimal(java.math.BigDecimal)

Example 9 with ConceptCode

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);
}
Also used : ConceptCode(com.salaboy.jbpm5.dev.guide.model.ConceptCode) ArrayList(java.util.ArrayList) Patient(com.salaboy.jbpm5.dev.guide.model.Patient) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 10 with ConceptCode

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;
}
Also used : ConceptCode(com.salaboy.jbpm5.dev.guide.model.ConceptCode) MalformedURLException(java.net.MalformedURLException) InsuranceService(com.salaboy.jbpm5.dev.guide.webservice.InsuranceService) ExecutionResults(org.jbpm.executor.api.ExecutionResults) Patient(com.salaboy.jbpm5.dev.guide.model.Patient) List(java.util.List) BigDecimal(java.math.BigDecimal)

Aggregations

ConceptCode (com.salaboy.jbpm5.dev.guide.model.ConceptCode)10 BigDecimal (java.math.BigDecimal)9 InsuranceService (com.salaboy.jbpm5.dev.guide.webservice.InsuranceService)6 ArrayList (java.util.ArrayList)6 Patient (com.salaboy.jbpm5.dev.guide.model.Patient)4 MalformedURLException (java.net.MalformedURLException)3 HashMap (java.util.HashMap)3 ExecutionResults (org.jbpm.executor.api.ExecutionResults)3 List (java.util.List)2 Test (org.junit.Test)2 PatientDataServiceWorkItemHandler (com.salaboy.jbpm5.dev.guide.workitems.PatientDataServiceWorkItemHandler)1 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1