use of com.salaboy.jbpm5.dev.guide.model.Patient in project jBPM5-Developer-Guide by Salaboy.
the class HospitalInsuranceProcessExecutorTest method initializeSession.
private void initializeSession() {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(new ClassPathResource("InsuranceProcessV2.bpmn"), ResourceType.BPMN2);
if (kbuilder.hasErrors()) {
KnowledgeBuilderErrors errors = kbuilder.getErrors();
for (KnowledgeBuilderError error : errors) {
System.out.println(">>> Error:" + error.getMessage());
}
throw new IllegalStateException(">>> Knowledge couldn't be parsed! ");
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
session = kbase.newStatefulKnowledgeSession();
KnowledgeRuntimeLoggerFactory.newConsoleLogger(session);
session.addEventListener(new DefaultAgendaEventListener() {
@Override
public void afterRuleFlowGroupActivated(org.drools.event.rule.RuleFlowGroupActivatedEvent event) {
session.fireAllRules();
}
});
//Registers the same generic handler for all the tasks. The handler will
//schedule commands into the Executor Service. Each task in the process
//is configured to use a different command.
AsyncGenericWorkItemHandler genericHandler = new AsyncGenericWorkItemHandler(executor, session.getId());
session.getWorkItemManager().registerWorkItemHandler("Gather Patient Data", genericHandler);
session.getWorkItemManager().registerWorkItemHandler("Insurance Service", genericHandler);
session.getWorkItemManager().registerWorkItemHandler("External Insurance Company Service", genericHandler);
session.getWorkItemManager().registerWorkItemHandler("Rates Service", genericHandler);
session.getWorkItemManager().registerWorkItemHandler("Invoice Service", genericHandler);
}
use of com.salaboy.jbpm5.dev.guide.model.Patient 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.Patient in project jBPM5-Developer-Guide by Salaboy.
the class HospitalInsuranceProcessExecutorTest method testPatientInsuredProcessWithExecutor.
/**
* Tests the execution path for a patient having a valid insurance.
*/
@Test
public void testPatientInsuredProcessWithExecutor() throws InterruptedException {
HashMap<String, Object> input = new HashMap<String, Object>();
Patient salaboy = testPatients.get("salaboy");
input.put("patientName", salaboy.getId());
SessionStoreUtil.sessionCache.put("sessionId=" + session.getId(), session);
WorkflowProcessInstance pI = (WorkflowProcessInstance) session.startProcess("NewPatientInsuranceCheck", input);
//Our application can continue doing other things, the executor will do the rest
Thread.sleep(25000);
assertEquals(ProcessInstance.STATE_COMPLETED, pI.getState());
assertEquals(Boolean.TRUE, pI.getVariable("patientNotified"));
assertEquals(50, ((BigDecimal) pI.getVariable("finalAmount")).intValue());
}
use of com.salaboy.jbpm5.dev.guide.model.Patient in project jBPM5-Developer-Guide by Salaboy.
the class HospitalInsuranceServiceTest method setUp.
@Before
public void setUp() {
initializeWebService();
Patient salaboy = new Patient(UUID.randomUUID().toString(), "Salaboy", "SalaboyLastName", "salaboy@gmail.com", "555-15151-515151", 28);
testPatients.put("salaboy", salaboy);
Patient nonInsuredBrotha = new Patient(UUID.randomUUID().toString(), "John", "Doe", "gansta1980@gmail.com", "333-333131-13131", 40);
testPatients.put("brotha", nonInsuredBrotha);
this.service.getPatients().put(testPatients.get("salaboy").getId(), testPatients.get("salaboy"));
this.service.getPatients().put(testPatients.get("brotha").getId(), testPatients.get("brotha"));
this.service.getInsuredPatients().put(testPatients.get("salaboy").getId(), Boolean.TRUE);
this.service.getInsuredPatients().put(testPatients.get("brotha").getId(), Boolean.FALSE);
}
use of com.salaboy.jbpm5.dev.guide.model.Patient 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);
}
Aggregations