diff --git a/pom.xml b/pom.xml
index bfc3a0055a..b8a147087e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2,11 +2,11 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
com.divudi
-
- horizon
+
+ coop
3.0.0
war
- horizon
+ coop
${project.build.directory}/endorsed
@@ -314,7 +314,17 @@
tomcat-catalina
9.0.83
-
+
+ com.github.hmislk
+ lims-middleware-libraries
+ 1.1.1
+
+
+ com.google.code.gson
+ gson
+ 2.8.9
+ jar
+
@@ -368,6 +378,11 @@
false
+
+
+ jitpack.io
+ https://jitpack.io
+
\ No newline at end of file
diff --git a/src/main/java/com/divudi/bean/cashTransaction/CashBookController.java b/src/main/java/com/divudi/bean/cashTransaction/CashBookController.java
new file mode 100644
index 0000000000..a461afe3c9
--- /dev/null
+++ b/src/main/java/com/divudi/bean/cashTransaction/CashBookController.java
@@ -0,0 +1,101 @@
+/*
+ * Open Hospital Management Information System
+ * Dr M H B Ariyaratne
+ * buddhika.ari@gmail.com
+ */
+package com.divudi.bean.cashTransaction;
+
+import com.divudi.bean.common.SessionController;
+import com.divudi.entity.cashTransaction.CashBook;
+import com.divudi.facade.CashBookFacade;
+import java.io.Serializable;
+import javax.ejb.EJB;
+import javax.enterprise.context.SessionScoped;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.FacesConverter;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+/**
+ *
+ * @author Lawan Chaamindu
+ */
+@Named
+@SessionScoped
+public class CashBookController implements Serializable {
+
+ @EJB
+ private CashBookFacade CashbookFacade;
+ @EJB
+ private CashBook cashBook;
+
+ @Inject
+ private SessionController sessionController;
+
+
+ public CashBookController() {
+ }
+
+ public CashBookFacade getCashbookFacade() {
+ return CashbookFacade;
+ }
+
+ public void setCashbookFacade(CashBookFacade CashbookFacade) {
+ this.CashbookFacade = CashbookFacade;
+ }
+
+ public CashBook getCashBook() {
+ return cashBook;
+ }
+
+ public void setCashBook(CashBook cashBook) {
+ this.cashBook = cashBook;
+ }
+
+
+ /**
+ *
+ */
+ @FacesConverter(forClass = CashBook.class)
+ public static class CashBookConverter implements Converter {
+
+ @Override
+ public Object getAsObject(FacesContext facesContext, UIComponent component, String value) {
+ if (value == null || value.length() == 0) {
+ return null;
+ }
+ CashBookController controller = (CashBookController) facesContext.getApplication().getELResolver().
+ getValue(facesContext.getELContext(), null, "CashBookController");
+ return controller.getCashbookFacade().find(getKey(value));
+ }
+
+ java.lang.Long getKey(String value) {
+ java.lang.Long key;
+ key = Long.valueOf(value);
+ return key;
+ }
+
+ String getStringKey(java.lang.Long value) {
+ StringBuilder sb = new StringBuilder();
+ sb.append(value);
+ return sb.toString();
+ }
+
+ @Override
+ public String getAsString(FacesContext facesContext, UIComponent component, Object object) {
+ if (object == null) {
+ return null;
+ }
+ if (object instanceof CashBook) {
+ CashBook o = (CashBook) object;
+ return getStringKey(o.getId());
+ } else {
+ throw new IllegalArgumentException("object " + object + " is of type "
+ + object.getClass().getName() + "; expected type: " + CashBook.class.getName());
+ }
+ }
+ }
+
+}
diff --git a/src/main/java/com/divudi/bean/cashTransaction/CashBookEntryController.java b/src/main/java/com/divudi/bean/cashTransaction/CashBookEntryController.java
new file mode 100644
index 0000000000..cb5ee49179
--- /dev/null
+++ b/src/main/java/com/divudi/bean/cashTransaction/CashBookEntryController.java
@@ -0,0 +1,103 @@
+/*
+ * Open Hospital Management Information System
+ * Dr M H B Ariyaratne
+ * buddhika.ari@gmail.com
+ */
+package com.divudi.bean.cashTransaction;
+
+import com.divudi.bean.common.SessionController;
+import com.divudi.entity.cashTransaction.CashBook;
+import com.divudi.entity.cashTransaction.CashBookEntry;
+import com.divudi.facade.CashBookEntryFacade;
+import com.divudi.facade.CashBookFacade;
+import java.io.Serializable;
+import javax.ejb.EJB;
+import javax.enterprise.context.SessionScoped;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.FacesConverter;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+/**
+ *
+ * @author Lawan Chaamindu
+ */
+@Named
+@SessionScoped
+public class CashBookEntryController implements Serializable {
+
+ @EJB
+ private CashBookEntryFacade CashbookEntryFacade;
+ @EJB
+ private CashBook cashBook;
+
+ @Inject
+ private SessionController sessionController;
+
+
+ public CashBookEntryController() {
+ }
+
+ public CashBookEntryFacade getCashbookEntryFacade() {
+ return CashbookEntryFacade;
+ }
+
+ public void setCashbookEntryFacade(CashBookEntryFacade CashbookEntryFacade) {
+ this.CashbookEntryFacade = CashbookEntryFacade;
+ }
+
+ public CashBook getCashBook() {
+ return cashBook;
+ }
+
+ public void setCashBook(CashBook cashBook) {
+ this.cashBook = cashBook;
+ }
+
+
+ /**
+ *
+ */
+ @FacesConverter(forClass = CashBookEntry.class)
+ public static class CashBookEntryConverter implements Converter {
+
+ @Override
+ public Object getAsObject(FacesContext facesContext, UIComponent component, String value) {
+ if (value == null || value.length() == 0) {
+ return null;
+ }
+ CashBookEntryController controller = (CashBookEntryController) facesContext.getApplication().getELResolver().
+ getValue(facesContext.getELContext(), null, "CashBookEntryController");
+ return controller.getCashbookEntryFacade().find(getKey(value));
+ }
+
+ java.lang.Long getKey(String value) {
+ java.lang.Long key;
+ key = Long.valueOf(value);
+ return key;
+ }
+
+ String getStringKey(java.lang.Long value) {
+ StringBuilder sb = new StringBuilder();
+ sb.append(value);
+ return sb.toString();
+ }
+
+ @Override
+ public String getAsString(FacesContext facesContext, UIComponent component, Object object) {
+ if (object == null) {
+ return null;
+ }
+ if (object instanceof CashBookEntry) {
+ CashBookEntry o = (CashBookEntry) object;
+ return getStringKey(o.getId());
+ } else {
+ throw new IllegalArgumentException("object " + object + " is of type "
+ + object.getClass().getName() + "; expected type: " + CashBookEntry.class.getName());
+ }
+ }
+ }
+
+}
diff --git a/src/main/java/com/divudi/bean/channel/BookingController.java b/src/main/java/com/divudi/bean/channel/BookingController.java
index 379c260081..424496d915 100644
--- a/src/main/java/com/divudi/bean/channel/BookingController.java
+++ b/src/main/java/com/divudi/bean/channel/BookingController.java
@@ -10,6 +10,7 @@
import com.divudi.bean.common.CommonController;
import com.divudi.bean.common.ConfigOptionApplicationController;
import com.divudi.bean.common.ConfigOptionController;
+import com.divudi.bean.common.ControllerWithMultiplePayments;
import com.divudi.bean.common.ControllerWithPatient;
import com.divudi.bean.common.DoctorSpecialityController;
import com.divudi.bean.common.ItemForItemController;
@@ -72,6 +73,16 @@
import com.divudi.data.BillFinanceType;
import com.divudi.data.BillTypeAtomic;
import com.divudi.data.OptionScope;
+import static com.divudi.data.PaymentMethod.Card;
+import static com.divudi.data.PaymentMethod.Cash;
+import static com.divudi.data.PaymentMethod.Cheque;
+import static com.divudi.data.PaymentMethod.Credit;
+import static com.divudi.data.PaymentMethod.OnlineSettlement;
+import static com.divudi.data.PaymentMethod.PatientDeposit;
+import static com.divudi.data.PaymentMethod.Slip;
+import static com.divudi.data.PaymentMethod.Staff;
+import static com.divudi.data.PaymentMethod.Staff_Welfare;
+import static com.divudi.data.PaymentMethod.ewallet;
import com.divudi.data.dataStructure.ComponentDetail;
import com.divudi.entity.Fee;
import com.divudi.entity.Payment;
@@ -108,7 +119,7 @@
*/
@Named
@SessionScoped
-public class BookingController implements Serializable, ControllerWithPatient {
+public class BookingController implements Serializable, ControllerWithPatient, ControllerWithMultiplePayments {
/**
* EJBs
@@ -265,6 +276,10 @@ public class BookingController implements Serializable, ControllerWithPatient {
private List sessionInstancesToday;
private String sessionInstanceFilter;
private List sessionInstancesFiltered;
+ private double tenderedAmount = 0.0;
+ private double balance = 0.0;
+ private double total;
+ private double remainAmount;
public void filterSessionInstances() {
sessionInstancesToday = getSessionInstances();
@@ -339,6 +354,71 @@ private Integer getStatusOrder(SessionInstance si) {
}
}
+ public double calculatRemainForMultiplePaymentTotal() {
+ total = getFeeTotalForSelectedBill();
+ if (paymentMethod == PaymentMethod.MultiplePaymentMethods) {
+ double multiplePaymentMethodTotalValue = 0.0;
+ for (ComponentDetail cd : paymentMethodData.getPaymentMethodMultiple().getMultiplePaymentMethodComponentDetails()) {
+ multiplePaymentMethodTotalValue += cd.getPaymentMethodData().getCash().getTotalValue();
+ multiplePaymentMethodTotalValue += cd.getPaymentMethodData().getCreditCard().getTotalValue();
+ multiplePaymentMethodTotalValue += cd.getPaymentMethodData().getCheque().getTotalValue();
+ multiplePaymentMethodTotalValue += cd.getPaymentMethodData().getEwallet().getTotalValue();
+ multiplePaymentMethodTotalValue += cd.getPaymentMethodData().getPatient_deposit().getTotalValue();
+ multiplePaymentMethodTotalValue += cd.getPaymentMethodData().getSlip().getTotalValue();
+ multiplePaymentMethodTotalValue += cd.getPaymentMethodData().getStaffCredit().getTotalValue();
+
+ }
+ remainAmount = total - multiplePaymentMethodTotalValue;
+ return total - multiplePaymentMethodTotalValue;
+
+ }
+ remainAmount = total;
+ return total;
+ }
+
+ public void recieveRemainAmountAutomatically() {
+ //double remainAmount = calculatRemainForMultiplePaymentTotal();
+ if (paymentMethod == PaymentMethod.MultiplePaymentMethods) {
+ int arrSize = paymentMethodData.getPaymentMethodMultiple().getMultiplePaymentMethodComponentDetails().size();
+ ComponentDetail pm = paymentMethodData.getPaymentMethodMultiple().getMultiplePaymentMethodComponentDetails().get(arrSize - 1);
+ switch (pm.getPaymentMethod()) {
+ case Cash:
+ pm.getPaymentMethodData().getCash().setTotalValue(remainAmount);
+ break;
+ case Card:
+ pm.getPaymentMethodData().getCreditCard().setTotalValue(remainAmount);
+ break;
+ case Cheque:
+ pm.getPaymentMethodData().getCheque().setTotalValue(remainAmount);
+ break;
+ case Slip:
+ pm.getPaymentMethodData().getSlip().setTotalValue(remainAmount);
+ break;
+ case ewallet:
+ pm.getPaymentMethodData().getEwallet().setTotalValue(remainAmount);
+ break;
+ case PatientDeposit:
+ if (patient != null) {
+ pm.getPaymentMethodData().getPatient_deposit().setPatient(patient);
+ }
+ pm.getPaymentMethodData().getPatient_deposit().setTotalValue(remainAmount);
+ break;
+ case Credit:
+ pm.getPaymentMethodData().getCredit().setTotalValue(remainAmount);
+ break;
+ case Staff:
+ pm.getPaymentMethodData().getStaffCredit().setTotalValue(remainAmount);
+ break;
+ default:
+ throw new IllegalArgumentException("Unexpected value: " + pm.getPaymentMethod());
+ }
+ }
+ }
+
+ public void calculateBalance() {
+ balance = getTenderedAmount() - getFeeTotalForSelectedBill();
+ }
+
public void sessionInstanceSelected() {
sortSessions();
}
@@ -717,7 +797,6 @@ public String smsBody(BillSession r) {
}
// ALREADY DEFIENED in line 629
-
// public void sendChannellingStatusUpdateNotificationSms(BillSession methodBillSession) {
// if (methodBillSession == null) {
// JsfUtil.addErrorMessage("Nothing to send");
@@ -780,6 +859,14 @@ public String smsBody(BillSession r) {
// + url;
// return b;
// }
+ public void makeNull() {
+ institution = null;
+ paymentMethod = null;
+ paymentMethodData = null;
+ agentRefNo = null;
+ tenderedAmount = 0.0;
+ balance = 0.0;
+ }
public String navigateToAddBooking() {
if (staff == null) {
@@ -2447,8 +2534,10 @@ public void completeSelectedBillSession() {
return;
}
selectedBillSession.setCompleted(true);
+ selectedBillSession.getPaidBillSession().setCompleted(true);
selectedBillSession.setCurrentlyConsulted(false);
billSessionFacade.edit(selectedBillSession);
+ billSessionFacade.edit(selectedBillSession.getPaidBillSession());
selectedSessionInstance.setLastCompletedBillSession(selectedBillSession);
sessionInstanceFacade.edit(selectedSessionInstance);
sendSmsOnChannelBookedCompleted();
@@ -2765,8 +2854,7 @@ public void fillBillSessions() {
BillType.ChannelStaff,
BillType.ChannelCredit,
BillType.ChannelResheduleWithOutPayment,
- BillType.ChannelResheduleWithPayment,
- };
+ BillType.ChannelResheduleWithPayment,};
List bts = Arrays.asList(billTypes);
String sql = "Select bs "
+ " From BillSession bs "
@@ -3080,7 +3168,8 @@ private Bill saveBilledBill(boolean forReservedNumbers) {
savingBill.setBalance(0.0);
savingBillSession.setPaidBillSession(savingBillSession);
} else if (savingBill.getBillType() == BillType.ChannelCash) {
- savingBill.setBalance(0.0);
+ savingBill.setTenderedAmount(tenderedAmount);
+ savingBill.setBalance(balance);
savingBillSession.setPaidBillSession(savingBillSession);
} else if (savingBill.getBillType() == BillType.ChannelOnCall) {
savingBill.setBalance(savingBill.getNetTotal());
@@ -3628,30 +3717,41 @@ private Bill createBill() {
case Cash:
bill.setBillType(BillType.ChannelCash);
bill.setBillTypeAtomic(BillTypeAtomic.CHANNEL_BOOKING_WITH_PAYMENT);
+ bill.setBillPaymentCompletelySettled(true);
break;
case Card:
bill.setBillType(BillType.ChannelCash);
bill.setBillTypeAtomic(BillTypeAtomic.CHANNEL_BOOKING_WITH_PAYMENT);
+ bill.setBillPaymentCompletelySettled(true);
break;
case Cheque:
bill.setBillType(BillType.ChannelCash);
bill.setBillTypeAtomic(BillTypeAtomic.CHANNEL_BOOKING_WITH_PAYMENT);
+ bill.setBillPaymentCompletelySettled(true);
break;
case Slip:
bill.setBillType(BillType.ChannelCash);
bill.setBillTypeAtomic(BillTypeAtomic.CHANNEL_BOOKING_WITH_PAYMENT);
+ bill.setBillPaymentCompletelySettled(true);
break;
case Agent:
bill.setBillType(BillType.ChannelAgent);
bill.setCreditCompany(institution);
bill.setBillTypeAtomic(BillTypeAtomic.CHANNEL_BOOKING_WITH_PAYMENT);
+ bill.setBillPaymentCompletelySettled(true);
break;
case Staff:
bill.setBillType(BillType.ChannelStaff);
- bill.setBillTypeAtomic(BillTypeAtomic.CHANNEL_BOOKING_WITHOUT_PAYMENT);
+ bill.setBillTypeAtomic(BillTypeAtomic.CHANNEL_BOOKING_WITH_PAYMENT);
+ bill.setBillPaymentCompletelySettled(true);
+ break;
+ case Staff_Welfare:
+ bill.setBillType(BillType.ChannelStaff);
+ bill.setBillTypeAtomic(BillTypeAtomic.CHANNEL_BOOKING_WITH_PAYMENT);
+ bill.setBillPaymentCompletelySettled(true);
break;
case Credit:
bill.setBillType(BillType.ChannelCredit);
@@ -3660,56 +3760,15 @@ private Bill createBill() {
case OnlineSettlement:
bill.setBillType(BillType.ChannelCash);
bill.setBillTypeAtomic(BillTypeAtomic.CHANNEL_BOOKING_WITH_PAYMENT_ONLINE);
+ bill.setBillPaymentCompletelySettled(true);
+ break;
+ case MultiplePaymentMethods:
+ bill.setBillType(BillType.ChannelCash);
+ bill.setBillTypeAtomic(BillTypeAtomic.CHANNEL_BOOKING_WITH_PAYMENT);
+ bill.setBillPaymentCompletelySettled(true);
break;
}
-// String insId = generateBillNumberInsId(bill);
-//
-// if (insId.equals("")) {
-// return null;
-// }
-// bill.setInsId(insId);
-// String insId = generateBillNumberInsId(bill);
-//
-// if (insId.equals("")) {
-// return null;
-// }
-// bill.setInsId(insId);
-// String insId = generateBillNumberInsId(bill);
-//
-// if (insId.equals("")) {
-// return null;
-// }
-// bill.setInsId(insId);
-// String insId = generateBillNumberInsId(bill);
-//
-// if (insId.equals("")) {
-// return null;
-// }
-// bill.setInsId(insId);
-// String insId = generateBillNumberInsId(bill);
-//
-// if (insId.equals("")) {
-// return null;
-// }
-// bill.setInsId(insId);
-// String insId = generateBillNumberInsId(bill);
-//
-// if (insId.equals("")) {
-// return null;
-// }
-// bill.setInsId(insId);
-// String insId = generateBillNumberInsId(bill);
-//
-// if (insId.equals("")) {
-// return null;
-// }
-// bill.setInsId(insId);
-// String insId = generateBillNumberInsId(bill);
-//
-// if (insId.equals("")) {
-// return null;
-// }
-// bill.setInsId(insId);
+
String deptId = generateBillNumberDeptId(bill);
if (deptId.equals("")) {
@@ -3736,7 +3795,7 @@ private Bill createBill() {
getBillFacade().create(bill);
- if (bill.getBillType() == BillType.ChannelCash || bill.getBillType() == BillType.ChannelAgent) {
+ if (bill.isBillPaymentCompletelySettled()) {
bill.setPaidBill(bill);
getBillFacade().edit(bill);
}
@@ -3751,7 +3810,6 @@ private String generateBillNumberDeptId(Bill bill) {
BillType billType = null;
String deptId = null;
if (bill instanceof BilledBill) {
-
billClassType = BillClassType.BilledBill;
if (bill.getBillType() == BillType.ChannelOnCall || bill.getBillType() == BillType.ChannelStaff) {
billType = bill.getBillType();
@@ -3778,7 +3836,6 @@ private String generateBillNumberDeptId(Bill bill) {
billClassType = BillClassType.RefundBill;
deptId = billNumberBean.departmentBillNumberGenerator(getSessionController().getInstitution(), getSessionController().getDepartment(), bts, billClassType, suffix);
}
-
return deptId;
}
@@ -4622,4 +4679,36 @@ public void setSessionInstancesFiltered(List sessionInstancesFi
this.sessionInstancesFiltered = sessionInstancesFiltered;
}
+ public double getBalance() {
+ return balance;
+ }
+
+ public void setBalance(double balance) {
+ this.balance = balance;
+ }
+
+ public double getTenderedAmount() {
+ return tenderedAmount;
+ }
+
+ public void setTenderedAmount(double tenderedAmount) {
+ this.tenderedAmount = tenderedAmount;
+ }
+
+ public double getTotal() {
+ return total;
+ }
+
+ public void setTotal(double total) {
+ this.total = total;
+ }
+
+ public double getRemainAmount() {
+ return remainAmount;
+ }
+
+ public void setRemainAmount(double remainAmount) {
+ this.remainAmount = remainAmount;
+ }
+
}
diff --git a/src/main/java/com/divudi/bean/channel/BookingControllerViewScope.java b/src/main/java/com/divudi/bean/channel/BookingControllerViewScope.java
index 1e30a114df..d53045c87f 100644
--- a/src/main/java/com/divudi/bean/channel/BookingControllerViewScope.java
+++ b/src/main/java/com/divudi/bean/channel/BookingControllerViewScope.java
@@ -70,6 +70,7 @@
import com.divudi.facade.SmsFacade;
import com.divudi.facade.StaffFacade;
import com.divudi.bean.common.util.JsfUtil;
+import com.divudi.bean.hr.StaffController;
import com.divudi.bean.membership.PaymentSchemeController;
import com.divudi.bean.opd.OpdBillController;
import com.divudi.data.BillFinanceType;
@@ -89,9 +90,13 @@
import com.divudi.facade.PaymentFacade;
import com.divudi.facade.SessionInstanceFacade;
import com.divudi.java.CommonFunctions;
+import com.divudi.data.channel.ChannelScheduleEvent;
+import com.divudi.data.channel.SessionInstanceEvent;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
@@ -104,6 +109,7 @@
import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
+import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.view.ViewScoped;
import javax.inject.Inject;
@@ -111,7 +117,11 @@
import javax.persistence.TemporalType;
import org.primefaces.event.RowEditEvent;
import org.primefaces.event.SelectEvent;
+import org.primefaces.event.schedule.ScheduleEntryMoveEvent;
+import org.primefaces.event.schedule.ScheduleEntryResizeEvent;
+import org.primefaces.model.DefaultScheduleEvent;
import org.primefaces.model.DefaultScheduleModel;
+import org.primefaces.model.ScheduleEvent;
import org.primefaces.model.ScheduleModel;
/**
@@ -222,6 +232,8 @@ public class BookingControllerViewScope implements Serializable, ControllerWithP
private CommonController commonController;
@Inject
SecurityController securityController;
+ @Inject
+ StaffController staffController;
/**
* Properties
*/
@@ -339,9 +351,167 @@ public class BookingControllerViewScope implements Serializable, ControllerWithP
private boolean listCompleted;
private boolean listAll;
private boolean sessionInstanceStartedEdited;
-
- boolean billingStarted=false;
+ boolean billingStarted = false;
+
+ //----------------------------------------------
+ private Staff consultant;
+ private ScheduleModel channelModel;
+ private String serverTimeZone = ZoneId.systemDefault().toString();
+ private List selectedServiceSessions;
+ private ScheduleEvent> sEvent = new DefaultScheduleEvent<>();
+
+ public void makeNull() {
+ consultant = null;
+ speciality = null;
+ channelModel = null;
+ }
+
+ public String navigateToScheduleCalendarFromMenu() {
+ makeNull();
+ return "/channel/schedule_calendar?faces-redirect=true";
+ }
+
+ public List specialityStaff() {
+ consultants = staffController.getSpecialityStaff(speciality);
+ System.out.println("consultants = " + consultants.size());
+ return consultants;
+ }
+
+ public void findSessionsForCalendar() {
+ System.out.println("Speciality = " + speciality);
+ System.out.println("Doctor = " + consultant);
+ findSessions();
+ System.out.println("Sessions Calendar OK");
+ }
+
+ /**
+ *
+ * @param selectEvent
+ */
+ public void onEventSelectCal(SelectEvent> selectEvent) {
+ sEvent = selectEvent.getObject();
+ }
+
+ public void onDateSelect(SelectEvent selectEvent) {
+ System.out.println("onDateSelect Start");
+ event = (ChannelScheduleEvent) DefaultScheduleEvent.builder()
+ .startDate(selectEvent.getObject())
+ .endDate(selectEvent.getObject().plusHours(1))
+ .build();
+ }
+
+ public void onEventMove(ScheduleEntryMoveEvent event) {
+ FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "Event moved",
+ "Delta:" + event.getDeltaAsDuration());
+
+ addMessage(message);
+ }
+
+ public void onEventResize(ScheduleEntryResizeEvent event) {
+ FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "Event resized",
+ "Start-Delta:" + event.getDeltaStartAsDuration() + ", End-Delta: " + event.getDeltaEndAsDuration());
+
+ addMessage(message);
+ }
+
+ private void addMessage(FacesMessage message) {
+ FacesContext.getCurrentInstance().addMessage(null, message);
+ }
+
+ public void findSessions() {
+ System.out.println("findSessions Start");
+ if (getSpeciality() == null) {
+ JsfUtil.addErrorMessage("Please Select the Speciality.");
+ return;
+ }
+ sessionInstances = new ArrayList<>();
+ selectedServiceSessions = new ArrayList<>();
+ String jpql;
+ Map params = new HashMap();
+
+ jpql = "Select s From ServiceSession s "
+ + " where s.retired=false "
+ + " and s.originatingSession is null"
+ + " and type(s)=:class "
+ + " and s.staff.speciality=:speciality";
+
+ params.put("speciality", getSpeciality());
+
+ params.put("class", ServiceSession.class);
+
+ if (consultant != null) {
+ jpql += " and s.staff=:staff ";
+ params.put("staff", getConsultant());
+ }
+
+ boolean listChannelSessionsForLoggedDepartmentOnly = configOptionApplicationController.getBooleanValueByKey("List Channel Sessions For Logged Department Only", false);
+ boolean listChannelSessionsForLoggedInstitutionOnly = configOptionApplicationController.getBooleanValueByKey("List Channel Sessions For Logged Institution Only", false);
+ if (listChannelSessionsForLoggedDepartmentOnly) {
+ jpql += " and s.department=:dept ";
+ params.put("dept", sessionController.getDepartment());
+ }
+ if (listChannelSessionsForLoggedInstitutionOnly) {
+ jpql += " and s.institution=:ins ";
+ params.put("ins", sessionController.getInstitution());
+ }
+ jpql += " order by s.sessionWeekday";
+ selectedServiceSessions = getServiceSessionFacade().findByJpql(jpql, params);
+ System.out.println("selectedServiceSessions = " + selectedServiceSessions.size());
+ calculateFee(selectedServiceSessions, channelBillController.getPaymentMethod());
+
+ try {
+ System.out.println("try");
+ sessionInstances = getChannelBean().generateSesionInstancesFromServiceSessions(selectedServiceSessions);
+ System.out.println("sessionInstances = " + sessionInstances.size());
+ } catch (Exception e) {
+ System.out.println("Error = " + e);
+ }
+ System.out.println("Ending Error");
+ generateChaneelSessionEvents(sessionInstances);
+ }
+
+ public void generateChaneelSessionEvents(List lsi) {
+ System.out.println("generateChaneelSessionEvents Start");
+ channelModel = new DefaultScheduleModel();
+ for (SessionInstance si : lsi) {
+ System.out.println("Name = " + si.getName());
+
+ Calendar sdt = Calendar.getInstance();
+ sdt.setTime(si.getSessionDate());
+
+ Calendar st = Calendar.getInstance();
+ st.setTime(si.getStartingTime());
+
+ sdt.set(Calendar.HOUR, st.get(Calendar.HOUR));
+ sdt.set(Calendar.MINUTE, st.get(Calendar.MINUTE));
+
+ Calendar edt = Calendar.getInstance();
+ sdt.setTime(si.getSessionDate());
+
+ Calendar et = Calendar.getInstance();
+ st.setTime(si.getStartingTime());
+
+ edt.set(Calendar.HOUR, et.get(Calendar.HOUR));
+ edt.set(Calendar.MINUTE, et.get(Calendar.MINUTE));
+
+ DefaultScheduleEvent event = new DefaultScheduleEvent().builder()
+ .title(si.getName()+" - " + si.getStaff().getPerson().getName())
+ .borderColor("#27AE60")
+ .backgroundColor("#BDE8CA")
+ .startDate(CommonFunctions.convertDateToLocalDateTime(sdt.getTime()))
+ .endDate(CommonFunctions.convertDateToLocalDateTime(edt.getTime()))
+ .data(si)
+ .build();
+
+ channelModel.addEvent(event);
+ System.out.println(si.getName() + " Add");
+ System.out.println("channelModel = " + channelModel.getEventCount());
+ }
+ System.out.println("channelModel = " + channelModel);
+ }
+
+ //----------------------------------------------
public void sessionReschedule() {
if (getSelectedSessionInstanceForRechedule() == null) {
JsfUtil.addErrorMessage("Pleace Select Session For Rechedule");
@@ -432,7 +602,7 @@ private void createBillSessionForReschedule(BillSession bs, SessionInstance si)
return;
}
- Bill printingBill = createBillForChannelReshedule(selectedBillSession);
+ Bill printingBill = createBillForChannelReshedule(bs);
BillItem savingBillItem = createSessionItemForReshedule(printingBill);
if (printingBill.getBillType() == BillType.ChannelResheduleWithPayment) {
createPayment(printingBill, paymentMethod);
@@ -449,6 +619,9 @@ private void createBillSessionForReschedule(BillSession bs, SessionInstance si)
newBillSession.setSessionTime(getSelectedSessionInstanceForRechedule().getSessionTime());
newBillSession.setStaff(getSelectedSessionInstanceForRechedule().getStaff());
newBillSession.setSerialNo(0);
+
+ newBillSession.setPaidBillSession(bs.getPaidBillSession());
+
getBillSessionFacade().create(newBillSession);
printingBill.setSingleBillSession(newBillSession);
@@ -458,10 +631,11 @@ private void createBillSessionForReschedule(BillSession bs, SessionInstance si)
newBillSession.setBill(printingBill);
PriceMatrix priceMatrix;
- List savingBillFees = new ArrayList<>();
priceMatrix = priceMatrixController.fetchChannellingMemberShipDiscount(paymentMethod, paymentScheme, getSelectedSessionInstanceForRechedule().getOriginatingSession().getCategory());
- System.out.println("priceMatrix = " + priceMatrix);
+// System.out.println("priceMatrix = " + priceMatrix);
+
+ ArrayList savingBillFees = new ArrayList<>();
List savingBillFeesFromSession = createBillFeeForSessions(printingBill, savingBillItem, true, priceMatrix);
@@ -469,6 +643,38 @@ private void createBillSessionForReschedule(BillSession bs, SessionInstance si)
savingBillFees.addAll(savingBillFeesFromSession);
}
+ Map billItemsByItem = new HashMap<>();
+
+ for (BillFee originalBillFee : bs.getBill().getBillFees()) {
+ BillItem originalBillItem = originalBillFee.getBillItem();
+ if (originalBillItem.getItem() instanceof ServiceSession) {
+ continue; // do not create. it's created above
+ }
+
+ if (!billItemsByItem.containsKey(originalBillItem.getId())) {
+ BillItem bi = new BillItem();
+ bi.copy(originalBillItem);
+ bi.setBill(printingBill);
+ bi.setSessionDate(si.getSessionAt());
+ bi.setBillSession(newBillSession);
+ bi.setBillFees(new ArrayList<>());
+ getBillItemFacade().create(bi);
+ billItemsByItem.put(originalBillItem.getId(), bi);
+ }
+
+ BillItem newBillItem = billItemsByItem.get(originalBillItem.getId());
+ BillFee bf = new BillFee();
+ bf.copy(originalBillFee);
+ bf.setBillItem(newBillItem);
+ bf.setBill(printingBill);
+ getBillFeeFacade().create(bf);
+ savingBillFees.add(bf);
+
+ newBillItem.getBillFees().add(bf);
+ getBillItemFacade().edit(newBillItem);
+ }
+ printingBill.getBillItems().addAll(billItemsByItem.values());
+
savingBillItem.setHospitalFee(billBeanController.calFeeValue(FeeType.OwnInstitution, savingBillItem));
savingBillItem.setStaffFee(billBeanController.calFeeValue(FeeType.Staff, savingBillItem));
savingBillItem.setBillSession(newBillSession);
@@ -493,7 +699,7 @@ private void createBillSessionForReschedule(BillSession bs, SessionInstance si)
return;
}
for (Integer rn : lastSessionReservedNumbers) {
- System.out.println("rn = " + rn);
+// System.out.println("rn = " + rn);
if (bs.getSerialNo() == rn) {
count = serviceSessionBean.getNextAvailableReservedNumber(getSelectedSessionInstanceForRechedule(), reservedNumbers, selectedReserverdBookingNumber);
if (count == null) {
@@ -508,23 +714,23 @@ private void createBillSessionForReschedule(BillSession bs, SessionInstance si)
}
if (count != null) {
newBillSession.setSerialNo(count);
- System.out.println("count = " + count);
+// System.out.println("count = " + count);
} else {
newBillSession.setSerialNo(1);
- System.out.println("count serial number= " + bs.getSerialNo());
+// System.out.println("count serial number= " + bs.getSerialNo());
}
getBillSessionFacade().edit(newBillSession);
bs.setRecheduledSession(true);
bs.setRescheduledToBillSession(newBillSession);
getBillSessionFacade().edit(bs);
newBillSessionForSMS = newBillSession;
- System.out.println("newBillSessionForSMS = " + newBillSessionForSMS);
- printingBill.setSingleBillSession(newBillSession);
+// System.out.println("newBillSessionForSMS = " + newBillSessionForSMS);
+// printingBill.setSingleBillSession(newBillSession);
billFacade.edit(printingBill);
- for (BillItem bi : printingBill.getBillItems()) {
- bi.setBillSession(newBillSession);
- billItemFacade.edit(bi);
- }
+// for (BillItem bi : printingBill.getBillItems()) {
+// bi.setBillSession(newBillSession);
+// billItemFacade.edit(bi);
+// }
}
private Bill createBillForChannelReshedule(BillSession bs) {
@@ -595,10 +801,9 @@ private Bill createBillForChannelReshedule(BillSession bs) {
bill.setDeptId(deptId);
bill.setInsId(deptId);
- if (bill.getBillTypeAtomic() == BillTypeAtomic.CHANNEL_RESHEDULE_WITH_PAYMENT) {
- bill.setPaidAmount(getSelectedSessionInstanceForRechedule().getOriginatingSession().getTotal());
- bill.setPaidAt(new Date());
- }
+ bill.setPaidAmount(bs.getBill().getPaidAmount());
+ bill.setPaidAt(bs.getBill().getPaidAt());
+ bill.setPaidBill(bs.getBill().getPaidBill());
bill.setBillDate(new Date());
bill.setBillTime(new Date());
@@ -650,16 +855,20 @@ public void fillSessionInstanceByDoctor() {
calendar.add(Calendar.DAY_OF_MONTH, 2);
Map m = new HashMap<>();
selectedConsultant = selectedBillSession.getSessionInstance().getStaff();
- String jpql = "select i from SessionInstance i where i.retired = :ret and i.sessionDate >=:cd";
+ String jpql = "select i from SessionInstance i where i.retired = :ret and i.sessionDate >=:cd and i.id != :currentSession";
if (selectedConsultant != null) {
jpql += " and i.originatingSession.staff =:staff";
m.put("staff", selectedConsultant);
}
+
+ jpql += " order by i.sessionDate, i.sessionTime";
+
m.put("ret", false);
m.put("cd", currentDate);
+ m.put("currentSession", selectedSessionInstance.getId());
sessionInstanceByDoctor = sessionInstanceFacade.findByJpql(jpql.toString(), m, TemporalType.DATE);
- System.out.println("sessionInstanceByDoctor = " + sessionInstanceByDoctor.size());
+// System.out.println("sessionInstanceByDoctor = " + sessionInstanceByDoctor.size());
}
public void removeAddedAditionalItems(Item item) {
@@ -702,15 +911,15 @@ public void toPrintOnlineBill() {
}
public void markSettlingBillAsPrinted() {
- System.out.println("markSettlingBillAsPrinted");
- System.out.println("selectedBillSession.getBillItem().getBill() = " + selectedBillSession.getBillItem().getBill());
+// System.out.println("markSettlingBillAsPrinted");
+// System.out.println("selectedBillSession.getBillItem().getBill() = " + selectedBillSession.getBillItem().getBill());
if (selectedBillSession != null && selectedBillSession.getBillItem() != null && selectedBillSession.getBillItem().getBill() != null) {
selectedBillSession.getBillItem().getBill().setPrinted(true);
selectedBillSession.getBillItem().getBill().setPrintedAt(new Date());
selectedBillSession.getBillItem().getBill().setPrintedUser(sessionController.getLoggedUser());
billFacade.edit(selectedBillSession.getBillItem().getBill());
} else {
- System.out.println("Can not mark as Printed = " + selectedBillSession.getBillItem().getBill());
+// System.out.println("Can not mark as Printed = " + selectedBillSession.getBillItem().getBill());
}
if (selectedBillSession != null && selectedBillSession.getBillItem() != null && selectedBillSession.getBillItem().getBill() != null
&& selectedBillSession.getBillItem().getBill().getPaidBill() != null) {
@@ -719,7 +928,7 @@ public void markSettlingBillAsPrinted() {
selectedBillSession.getBillItem().getBill().getPaidBill().setPrintedUser(sessionController.getLoggedUser());
billFacade.edit(selectedBillSession.getBillItem().getBill().getPaidBill());
} else {
- System.out.println("Can not mark Paid Bill as Printed = " + selectedBillSession.getBillItem().getBill().getPaidBill());
+// System.out.println("Can not mark Paid Bill as Printed = " + selectedBillSession.getBillItem().getBill().getPaidBill());
}
}
@@ -730,7 +939,7 @@ public void markBillAsRePrinted() {
selectedBillSession.getBillItem().getBill().setDuplicatePrintedUser(sessionController.getLoggedUser());
billFacade.edit(selectedBillSession.getBillItem().getBill());
} else {
- System.out.println("Can not mark as Printed = " + selectedBillSession.getBillItem().getBill());
+// System.out.println("Can not mark as Printed = " + selectedBillSession.getBillItem().getBill());
}
if (selectedBillSession != null && selectedBillSession.getBillItem() != null && selectedBillSession.getBillItem().getBill() != null
&& selectedBillSession.getBillItem().getBill().getPaidBill() != null) {
@@ -739,7 +948,7 @@ public void markBillAsRePrinted() {
selectedBillSession.getBillItem().getBill().getPaidBill().setDuplicatePrintedUser(sessionController.getLoggedUser());
billFacade.edit(selectedBillSession.getBillItem().getBill().getPaidBill());
} else {
- System.out.println("Can not mark Paid Bill as Printed = " + selectedBillSession.getBillItem().getBill().getPaidBill());
+// System.out.println("Can not mark Paid Bill as Printed = " + selectedBillSession.getBillItem().getBill().getPaidBill());
}
}
@@ -799,7 +1008,7 @@ public String navigateToManageSessionInstance(SessionInstance sessionInstance) {
viewScopeDataTransferController.setNeedToFillSessionInstances(false);
viewScopeDataTransferController.setNeedToFillBillSessions(true);
viewScopeDataTransferController.setNeedToFillSessionInstanceDetails(true);
- viewScopeDataTransferController.setNeedToFillBillSessionDetails(false);
+ viewScopeDataTransferController.setNeedToFillBillSessionDetails(true);
viewScopeDataTransferController.setNeedToFillMembershipDetails(false);
viewScopeDataTransferController.setNeedToPrepareForNewBooking(false);
@@ -1247,13 +1456,14 @@ public void loadSessionInstances() {
if (sessionInstanceFilter != null && !sessionInstanceFilter.trim().isEmpty()) {
String[] filterKeywords = sessionInstanceFilter.trim().toLowerCase().split("\\s+");
List filterConditions = new ArrayList<>();
- for (String keyword : filterKeywords) {
- filterConditions.add("(lower(i.originatingSession.name) like :keyword"
- + " or lower(i.originatingSession.staff.person.name) like :keyword"
- + " or lower(i.originatingSession.staff.speciality.name) like :keyword)");
+ for (int i = 0; i < filterKeywords.length; i++) {
+ String keyword = filterKeywords[i];
+ filterConditions.add("(lower(i.originatingSession.name) like :keyword" + i
+ + " or lower(i.originatingSession.staff.person.name) like :keyword" + i
+ + " or lower(i.originatingSession.staff.speciality.name) like :keyword" + i + ")");
+ params.put("keyword" + i, "%" + keyword.trim().toLowerCase() + "%");
}
jpql.append(" and (").append(String.join(" or ", filterConditions)).append(")");
- params.put("keyword", "%" + sessionInstanceFilter.trim().toLowerCase() + "%");
}
// Adding sorting to JPQL with custom order
@@ -1343,6 +1553,9 @@ public void fillSessionInstanceDetails() {
if (selectedSessionInstance.getOriginatingSession() == null) {
return;
}
+ if (sessionController.getDepartmentPreference() == null) {
+ return;
+ }
fillItemAvailableToAdd();
fillFees();
fillReservedNumbers();
@@ -1395,7 +1608,7 @@ public void markSessionInstanceAsStarted() {
for (BillSession bs : billSessions) {
if (configOptionApplicationController.getBooleanValueByKey("Sent Channelling Status Update Notification SMS on Channel Session Start", true)) {
sendChannellingStatusUpdateNotificationSms(bs);
- System.out.println("bs = " + bs);
+// System.out.println("bs = " + bs);
}
if (!firstIncompleteFound && !bs.isCompleted()) {
bs.setNextInLine(true);
@@ -1539,6 +1752,24 @@ public String navigateToAddBooking() {
return "/channel/add_booking?faces-redirect=true";
}
+ /**
+ * When a booking is done with additional items, total needs to consider
+ * additional items in the bill
+ */
+ public void fillAdditionalFeesFromSelectedBillSession() {
+ if (selectedBillSession != null) { // at manage booking
+ for (BillFee billFee : selectedBillSession.getBill().getBillFees()) {
+ if (billFee.getFee().getServiceSession() == null) { // adding additional items which are not service session bound
+ if (foriegn) {
+ feeTotalForSelectedBill += billFee.getFee().getFfee();
+ } else {
+ feeTotalForSelectedBill += billFee.getFee().getFee();
+ }
+ }
+ }
+ }
+ }
+
public void fillFees() {
selectedItemFees = new ArrayList<>();
sessionFees = new ArrayList<>();
@@ -1546,6 +1777,7 @@ public void fillFees() {
if (selectedSessionInstance == null || selectedSessionInstance.getOriginatingSession() == null) {
return;
}
+
String sql;
Map m = new HashMap<>();
sql = "Select f from ItemFee f where f.retired=false and f.serviceSession=:ses order by f.id";
@@ -1581,6 +1813,7 @@ public void fillFees() {
public void init() {
fromDate = new Date();
toDate = new Date();
+ channelModel = new DefaultScheduleModel();
Date tmpfromDate = viewScopeDataTransferController.getFromDate();
Date tmptoDate = viewScopeDataTransferController.getToDate();
@@ -1610,6 +1843,8 @@ public void init() {
selectedBillSession = viewScopeDataTransferController.getSelectedBillSession();
needToFillBillSessionDetails = viewScopeDataTransferController.getNeedToFillBillSessionDetails();
+ fillAdditionalFeesFromSelectedBillSession();
+
if (Boolean.TRUE.equals(needToFillBillSessionDetails) && selectedBillSession != null) {
fillBillSessionDetails();
fillFees();
@@ -1807,7 +2042,7 @@ public void loadSessionInstance() {
}
public String navigateToManageBooking(BillSession bs) {
- System.out.println("bs = " + bs);
+// System.out.println("bs = " + bs);
selectedBillSession = bs;
if (selectedBillSession == null) {
JsfUtil.addErrorMessage("Please select a Patient");
@@ -2149,7 +2384,6 @@ public void cancelBookingBill() {
}
// System.out.println("Error check End");
-
CancelledBill cb = createCancelBill1(getBillSession().getBill());
BillItem cItem = cancelBillItems(getBillSession().getBillItem(), cb);
BillSession cbs = cancelBillSession(getBillSession(), cb, cItem);
@@ -2165,7 +2399,7 @@ public void cancelBookingBill() {
getBillSession().getBill().getToStaff().setCurrentCreditValue(Math.abs(getBillSession().getBill().getToStaff().getCurrentCreditValue()) - Math.abs(getBillSession().getBill().getNetTotal()));
staffFacade.edit(getBillSession().getBill().getToStaff());
// System.out.println("Before Balance = " + getBillSession().getBill().getToStaff().getCurrentCreditValue());
- System.out.println("Staff Credit Balance Updated");
+// System.out.println("Staff Credit Balance Updated");
}
System.out.println("****");
@@ -3098,25 +3332,25 @@ private boolean paymentMethodErrorPresent() {
}
public void addNormalChannelBooking() {
- if(billingStarted){
+ if (billingStarted) {
return;
}
- billingStarted=true;
+ billingStarted = true;
if (selectedSessionInstance == null) {
JsfUtil.addErrorMessage("Please select a Session");
- billingStarted=false;
+ billingStarted = false;
return;
}
addChannelBooking(false);
fillBillSessions();
- billingStarted=false;
+ billingStarted = false;
}
public void addReservedChannelBooking() {
- if(billingStarted){
+ if (billingStarted) {
return;
}
- billingStarted=true;
+ billingStarted = true;
if (selectedSessionInstance == null) {
JsfUtil.addErrorMessage("Please select a Session Instance");
return;
@@ -3124,7 +3358,7 @@ public void addReservedChannelBooking() {
boolean reservedBooking = true;
addChannelBooking(reservedBooking);
fillBillSessions();
- billingStarted=false;
+ billingStarted = false;
}
public void addChannelBooking(boolean reservedBooking) {
@@ -4758,21 +4992,21 @@ public void fillBillSessions(List sessionInstances) {
}
// Prepare the SQL query
- String sql = "SELECT bs.SESSIONINSTANCE_ID, " +
- "COUNT(bs.ID) AS bookedPatientCount, " +
- "SUM(CASE WHEN bs.PAIDBILLSESSION_ID IS NOT NULL THEN 1 ELSE 0 END) AS paidPatientCount, " +
- "SUM(CASE WHEN bs.COMPLETED = TRUE THEN 1 ELSE 0 END) AS completedPatientCount, " +
- "SUM(CASE WHEN b.CANCELLED = TRUE THEN 1 ELSE 0 END) AS cancelPatientCount, " +
- "SUM(CASE WHEN b.REFUNDED = TRUE THEN 1 ELSE 0 END) AS refundedPatientCount, " +
- "SUM(CASE WHEN bs.PAIDBILLSESSION_ID IS NULL AND b.CANCELLED = FALSE THEN 1 ELSE 0 END) AS onCallPatientCount, " +
- "SUM(CASE WHEN bs.RESERVEDBOOKING = TRUE THEN 1 ELSE 0 END) AS reservedBookingCount " +
- "FROM billsession bs " +
- "JOIN bill b ON bs.BILL_ID = b.ID " +
- "WHERE bs.RETIRED = FALSE " +
- "AND b.BILLTYPE IN ('ChannelAgent', 'ChannelCash', 'ChannelOnCall', 'ChannelStaff', 'ChannelCredit', 'ChannelResheduleWithPayment', 'ChannelResheduleWithOutPayment') " +
- "AND b.DTYPE = 'BilledBill' " +
- "AND bs.SESSIONINSTANCE_ID IN (:ids) " +
- "GROUP BY bs.SESSIONINSTANCE_ID";
+ String sql = "SELECT bs.SESSIONINSTANCE_ID, "
+ + "COUNT(bs.ID) AS bookedPatientCount, "
+ + "SUM(CASE WHEN (bs.PAIDBILLSESSION_ID IS NOT NULL and bs.RESCHEDULEDTOBILLSESSION_ID is NULL) THEN 1 ELSE 0 END) AS paidPatientCount, "
+ + "SUM(CASE WHEN bs.COMPLETED = TRUE THEN 1 ELSE 0 END) AS completedPatientCount, "
+ + "SUM(CASE WHEN b.CANCELLED = TRUE THEN 1 ELSE 0 END) AS cancelPatientCount, "
+ + "SUM(CASE WHEN b.REFUNDED = TRUE THEN 1 ELSE 0 END) AS refundedPatientCount, "
+ + "SUM(CASE WHEN bs.PAIDBILLSESSION_ID IS NULL AND b.CANCELLED = FALSE THEN 1 ELSE 0 END) AS onCallPatientCount, "
+ + "SUM(CASE WHEN bs.RESERVEDBOOKING = TRUE THEN 1 ELSE 0 END) AS reservedBookingCount "
+ + "FROM billsession bs "
+ + "JOIN bill b ON bs.BILL_ID = b.ID "
+ + "WHERE bs.RETIRED = FALSE "
+ + "AND b.BILLTYPE IN ('ChannelAgent', 'ChannelCash', 'ChannelOnCall', 'ChannelStaff', 'ChannelCredit', 'ChannelResheduleWithPayment', 'ChannelResheduleWithOutPayment') "
+ + "AND b.DTYPE = 'BilledBill' "
+ + "AND bs.SESSIONINSTANCE_ID IN (:ids) "
+ + "GROUP BY bs.SESSIONINSTANCE_ID";
// Prepare the parameters
List sessionInstanceIds = sessionInstances.stream()
@@ -5014,7 +5248,7 @@ private Bill saveBilledBill(boolean forReservedNumbers) {
List savingBillFees = new ArrayList<>();
priceMatrix = priceMatrixController.fetchChannellingMemberShipDiscount(paymentMethod, paymentScheme, selectedSessionInstance.getOriginatingSession().getCategory());
- System.out.println("priceMatrix = " + priceMatrix);
+// System.out.println("priceMatrix = " + priceMatrix);
List savingBillFeesFromSession = createBillFeeForSessions(savingBill, savingBillItem, false, priceMatrix);
@@ -5581,22 +5815,22 @@ private List createBillFeeForSessionsForPatientPortal(Bill bill, BillIt
}
private void calculateBillTotalsFromBillFees(Bill billToCaclculate, List billfeesAvailable) {
- System.out.println("calculateBillTotalsFromBillFees");
- System.out.println("billToCaclculate = " + billToCaclculate);
- System.out.println("billfeesAvailable = " + billfeesAvailable);
+// System.out.println("calculateBillTotalsFromBillFees");
+// System.out.println("billToCaclculate = " + billToCaclculate);
+// System.out.println("billfeesAvailable = " + billfeesAvailable);
double calculatingGrossBillTotal = 0.0;
double calculatingNetBillTotal = 0.0;
for (BillFee iteratingBillFee : billfeesAvailable) {
- System.out.println("iteratingBillFee = " + iteratingBillFee);
+// System.out.println("iteratingBillFee = " + iteratingBillFee);
if (iteratingBillFee.getFee() == null) {
continue;
}
calculatingGrossBillTotal += iteratingBillFee.getFeeGrossValue();
- System.out.println("calculatingGrossBillTotal = " + calculatingGrossBillTotal);
+// System.out.println("calculatingGrossBillTotal = " + calculatingGrossBillTotal);
calculatingNetBillTotal += iteratingBillFee.getFeeValue();
- System.out.println("calculatingNetBillTotal = " + calculatingNetBillTotal);
+// System.out.println("calculatingNetBillTotal = " + calculatingNetBillTotal);
}
billToCaclculate.setDiscount(calculatingGrossBillTotal - calculatingNetBillTotal);
@@ -6531,6 +6765,11 @@ private boolean errorCheckForSettle() {
return true;
}
+ if (selectedBillSession.isRecheduledSession()) {
+ JsfUtil.addErrorMessage("This session has already been rescheduled. Please pay to the active session.");
+ return true;
+ }
+
if (getBillSession().getBill().getPaymentMethod() == PaymentMethod.Credit) {
if (getBillSession().getBill().getFromInstitution() != null
&& getBillSession().getBill().getFromInstitution().getBallance()
@@ -6781,10 +7020,10 @@ private boolean errorChecksettle() {
multiplePaymentMethodTotalValue += cd.getPaymentMethodData().getSlip().getTotalValue();
multiplePaymentMethodTotalValue += cd.getPaymentMethodData().getStaffCredit().getTotalValue();
}
- System.out.println("multiplePaymentMethodTotalValue = " + multiplePaymentMethodTotalValue);
+// System.out.println("multiplePaymentMethodTotalValue = " + multiplePaymentMethodTotalValue);
double differenceOfBillTotalAndPaymentValue = getSelectedBillSession().getBillItem().getBill().getNetTotal() - multiplePaymentMethodTotalValue;
differenceOfBillTotalAndPaymentValue = Math.abs(differenceOfBillTotalAndPaymentValue);
- System.out.println("differenceOfBillTotalAndPaymentValue = " + differenceOfBillTotalAndPaymentValue);
+// System.out.println("differenceOfBillTotalAndPaymentValue = " + differenceOfBillTotalAndPaymentValue);
if (differenceOfBillTotalAndPaymentValue > 1.0) {
JsfUtil.addErrorMessage("Mismatch in differences of multiple payment method total and bill total");
return true;
@@ -7459,7 +7698,7 @@ public void calculateSelectedBillSessionTotal() {
feeNetTotalForSelectedBill = 0.0;
if (paymentSchemeDiscount != null) {
for (ItemFee itmf : getSelectedItemFees()) {
- System.out.println("itmf = " + itmf);
+// System.out.println("itmf = " + itmf);
if (foriegn) {
feeTotalForSelectedBill += itmf.getFfee();
if (itmf.isDiscountAllowed()) {
@@ -7467,8 +7706,8 @@ public void calculateSelectedBillSessionTotal() {
}
} else {
feeTotalForSelectedBill += itmf.getFee();
- System.out.println("itmf = " + itmf.getFee());
- System.out.println("feeTotalForSelectedBill = " + feeTotalForSelectedBill);
+// System.out.println("itmf = " + itmf.getFee());
+// System.out.println("feeTotalForSelectedBill = " + feeTotalForSelectedBill);
if (itmf.isDiscountAllowed()) {
feeDiscountForSelectedBill += itmf.getFee() * (paymentSchemeDiscount.getDiscountPercent() / 100);
}
@@ -7476,47 +7715,47 @@ public void calculateSelectedBillSessionTotal() {
}
} else {
for (ItemFee itmf : getSelectedItemFees()) {
- System.out.println("itmf = " + itmf);
+// System.out.println("itmf = " + itmf);
if (foriegn) {
feeTotalForSelectedBill += itmf.getFfee();
- System.out.println("itmf = " + itmf);
+// System.out.println("itmf = " + itmf);
} else {
feeTotalForSelectedBill += itmf.getFee();
- System.out.println("itmf 2 = " + itmf);
+// System.out.println("itmf 2 = " + itmf);
}
}
}
- System.out.println("feeTotalForSelectedBill = " + feeTotalForSelectedBill);
- System.out.println("feeDiscountForSelectedBill = " + feeDiscountForSelectedBill);
- System.out.println("feeNetTotalForSelectedBill 3 = " + feeNetTotalForSelectedBill);
+// System.out.println("feeTotalForSelectedBill = " + feeTotalForSelectedBill);
+// System.out.println("feeDiscountForSelectedBill = " + feeDiscountForSelectedBill);
+// System.out.println("feeNetTotalForSelectedBill 3 = " + feeNetTotalForSelectedBill);
feeNetTotalForSelectedBill = feeTotalForSelectedBill - feeDiscountForSelectedBill;
- System.out.println("feeNetTotalForSelectedBill 4 = " + feeNetTotalForSelectedBill);
+// System.out.println("feeNetTotalForSelectedBill 4 = " + feeNetTotalForSelectedBill);
}
public void calculateSelectedBillSessionTotalForSettling() {
- System.out.println("calculateSelectedBillSessionTotalForSettling");
+// System.out.println("calculateSelectedBillSessionTotalForSettling");
Category cat = getBillSession().getSessionInstance().getOriginatingSession().getCategory();
PaymentSchemeDiscount paymentSchemeDiscount = priceMatrixController.fetchChannellingMemberShipDiscount(settlePaymentMethod, paymentScheme, cat);
feeTotalForSelectedBill = 0.0;
feeDiscountForSelectedBill = 0.0;
feeNetTotalForSelectedBill = 0.0;
- System.out.println("paymentSchemeDiscount = " + paymentSchemeDiscount);
- System.out.println("settlePaymentMethod = " + settlePaymentMethod);
- System.out.println("paymentScheme = " + paymentScheme);
+// System.out.println("paymentSchemeDiscount = " + paymentSchemeDiscount);
+// System.out.println("settlePaymentMethod = " + settlePaymentMethod);
+// System.out.println("paymentScheme = " + paymentScheme);
List billFees = getBillSession().getBill().getBillFees();
- System.out.println("billFees = " + billFees);
+// System.out.println("billFees = " + billFees);
if (billFees == null) {
billFees = billBeanController.getBillFee(getBillSession().getBill());
}
- System.out.println("billFees = " + billFees);
+// System.out.println("billFees = " + billFees);
if (paymentSchemeDiscount != null) {
for (BillFee bf : billFees) {
ItemFee itmf = (ItemFee) bf.getFee();
- System.out.println("itmf = " + itmf);
+// System.out.println("itmf = " + itmf);
if (foriegn) {
feeTotalForSelectedBill += itmf.getFfee();
if (itmf.isDiscountAllowed()) {
@@ -7524,8 +7763,8 @@ public void calculateSelectedBillSessionTotalForSettling() {
}
} else {
feeTotalForSelectedBill += itmf.getFee();
- System.out.println("itmf = " + itmf.getFee());
- System.out.println("feeTotalForSelectedBill = " + feeTotalForSelectedBill);
+// System.out.println("itmf = " + itmf.getFee());
+// System.out.println("feeTotalForSelectedBill = " + feeTotalForSelectedBill);
if (itmf.isDiscountAllowed()) {
feeDiscountForSelectedBill += itmf.getFee() * (paymentSchemeDiscount.getDiscountPercent() / 100);
}
@@ -7533,23 +7772,23 @@ public void calculateSelectedBillSessionTotalForSettling() {
}
} else {
for (ItemFee itmf : getSelectedItemFees()) {
- System.out.println("itmf = " + itmf);
+// System.out.println("itmf = " + itmf);
if (foriegn) {
feeTotalForSelectedBill += itmf.getFfee();
- System.out.println("itmf = " + itmf);
+// System.out.println("itmf = " + itmf);
} else {
feeTotalForSelectedBill += itmf.getFee();
- System.out.println("itmf 2 = " + itmf);
+// System.out.println("itmf 2 = " + itmf);
}
}
}
- System.out.println("feeTotalForSelectedBill = " + feeTotalForSelectedBill);
- System.out.println("feeDiscountForSelectedBill = " + feeDiscountForSelectedBill);
- System.out.println("feeNetTotalForSelectedBill 3 = " + feeNetTotalForSelectedBill);
+// System.out.println("feeTotalForSelectedBill = " + feeTotalForSelectedBill);
+// System.out.println("feeDiscountForSelectedBill = " + feeDiscountForSelectedBill);
+// System.out.println("feeNetTotalForSelectedBill 3 = " + feeNetTotalForSelectedBill);
feeNetTotalForSelectedBill = feeTotalForSelectedBill - feeDiscountForSelectedBill;
- System.out.println("feeNetTotalForSelectedBill 4 = " + feeNetTotalForSelectedBill);
+// System.out.println("feeNetTotalForSelectedBill 4 = " + feeNetTotalForSelectedBill);
getBillSession().getBill().setNetTotal(feeNetTotalForSelectedBill);
getBillSession().getBill().setDiscount(feeDiscountForSelectedBill);
}
@@ -7681,7 +7920,7 @@ public List getSortedSessionInstances() {
if (sortedSessionInstances == null) {
if (sessionInstancesFiltered != null) {
sessionInstances = channelBean.listSessionInstances(fromDate, toDate, null, null, null);
- System.out.println("sortedSessionInstances == null");
+// System.out.println("sortedSessionInstances == null");
filterSessionInstances();
sortSessions();
}
@@ -7690,7 +7929,7 @@ public List getSortedSessionInstances() {
if (oldSessionInstancesFiltered != sessionInstancesFiltered) {
if (sessionInstancesFiltered != null) {
sessionInstances = channelBean.listSessionInstances(fromDate, toDate, null, null, null);
- System.out.println("sortedSessionInstances == null");
+// System.out.println("sortedSessionInstances == null");
filterSessionInstances();
sortSessions();
}
@@ -7897,10 +8136,14 @@ public void quickSearchPatientLongPhoneNumber() {
Map m = new HashMap();
j = "select p from Patient p where p.retired=false and (p.patientPhoneNumber=:pp or p.patientMobileNumber=:pp)";
Long searchedPhoneNumber = CommonFunctions.removeSpecialCharsInPhonenumber(quickSearchPhoneNumber);
+ if (searchedPhoneNumber == null) {
+ JsfUtil.addErrorMessage("Please enter the phone number");
+ return;
+ }
m.put("pp", searchedPhoneNumber);
quickSearchPatientList = patientFacade.findByJpql(j, m);
if (quickSearchPatientList == null) {
- JsfUtil.addErrorMessage("No Patient found !");
+ JsfUtil.addErrorMessage("No Patient found for " + quickSearchPhoneNumber);
setPatientDetailsEditable(true);
setPatient(null);
getPatient().setPhoneNumberStringTransient(quickSearchPhoneNumber);
@@ -7908,7 +8151,7 @@ public void quickSearchPatientLongPhoneNumber() {
setPatientDetailsEditable(true);
return;
} else if (quickSearchPatientList.isEmpty()) {
- JsfUtil.addErrorMessage("No Patient found !");
+ JsfUtil.addErrorMessage("No Patient found for " + quickSearchPhoneNumber);
setPatient(null);
getPatient().setPhoneNumberStringTransient(quickSearchPhoneNumber);
getPatient().setMobileNumberStringTransient(quickSearchPhoneNumber);
@@ -7990,13 +8233,13 @@ public void setCashPaid(double cashPaid) {
public double getCashBalance() {
if (feeTotalForSelectedBill != null) {
- System.out.println("feeNetTotalForSelectedBill = " + feeNetTotalForSelectedBill);
- System.out.println("cashPaid = " + cashPaid);
+// System.out.println("feeNetTotalForSelectedBill = " + feeNetTotalForSelectedBill);
+// System.out.println("cashPaid = " + cashPaid);
if (feeNetTotalForSelectedBill == null) {
feeNetTotalForSelectedBill = 0.0;
}
cashBalance = feeNetTotalForSelectedBill - cashPaid;
- System.out.println("cashBalance = " + cashBalance);
+// System.out.println("cashBalance = " + cashBalance);
}
return cashBalance;
}
@@ -8253,4 +8496,44 @@ public void setSessionInstanceStartedEdited(boolean sessionInstanceStartedEdited
this.sessionInstanceStartedEdited = sessionInstanceStartedEdited;
}
+ public ScheduleModel getChannelModel() {
+ return channelModel;
+ }
+
+ public void setChannelModel(ScheduleModel channelModel) {
+ this.channelModel = channelModel;
+ }
+
+ public String getServerTimeZone() {
+ return serverTimeZone;
+ }
+
+ public void setServerTimeZone(String serverTimeZone) {
+ this.serverTimeZone = serverTimeZone;
+ }
+
+ public Staff getConsultant() {
+ return consultant;
+ }
+
+ public void setConsultant(Staff consultant) {
+ this.consultant = consultant;
+ }
+
+ public List getSelectedServiceSessions() {
+ return selectedServiceSessions;
+ }
+
+ public void setSelectedServiceSessions(List selectedServiceSessions) {
+ this.selectedServiceSessions = selectedServiceSessions;
+ }
+
+ public ScheduleEvent> getsEvent() {
+ return sEvent;
+ }
+
+ public void setsEvent(ScheduleEvent> sEvent) {
+ this.sEvent = sEvent;
+ }
+
}
diff --git a/src/main/java/com/divudi/bean/channel/ChannelBillController.java b/src/main/java/com/divudi/bean/channel/ChannelBillController.java
index 012cb3f8da..b3836d876b 100644
--- a/src/main/java/com/divudi/bean/channel/ChannelBillController.java
+++ b/src/main/java/com/divudi/bean/channel/ChannelBillController.java
@@ -290,6 +290,9 @@ public void settleCredit() {
b.setSingleBillItem(bi);
b.setSingleBillSession(bs);
getBillFacade().edit(b);
+
+ getBillSession().getBill().setBillPaymentCompletelySettled(true);
+ getBillFacade().edit(getBillSession().getBill());
createPayment(b, settlePaymentMethod);
@@ -608,7 +611,7 @@ private Bill savePaidBill() {
temp.setBillTime(new Date());
temp.setCreatedAt(new Date());
temp.setCreater(getSessionController().getLoggedUser());
-
+ temp.setBillPaymentCompletelySettled(true);
getBillFacade().create(temp);
return temp;
diff --git a/src/main/java/com/divudi/bean/channel/ChannelReportTemplateController.java b/src/main/java/com/divudi/bean/channel/ChannelReportTemplateController.java
index 01ed9d96f1..b744805614 100644
--- a/src/main/java/com/divudi/bean/channel/ChannelReportTemplateController.java
+++ b/src/main/java/com/divudi/bean/channel/ChannelReportTemplateController.java
@@ -642,6 +642,7 @@ public void fillBillSessions(SessionInstance sessionInstance) {
long refundedPatientCount = 0;
long onCallPatientCount = 0;
long reservedBookingCount = 0;
+ long paidToDoctorCount = 0;
if (billSessions == null || billSessions.isEmpty()) {
sessionInstance.setBookedPatientCount(0L);
@@ -685,6 +686,7 @@ public void fillBillSessions(SessionInstance sessionInstance) {
onCallPatientCount++;
}
}
+
}
// Set calculated counts to sessionInstance
@@ -695,33 +697,141 @@ public void fillBillSessions(SessionInstance sessionInstance) {
sessionInstance.setRefundedPatientCount(refundedPatientCount);
sessionInstance.setOnCallPatientCount(onCallPatientCount);
sessionInstance.setReservedBookingCount(reservedBookingCount);
-
- // Assuming remainingPatientCount is calculated as booked - completed
+ sessionInstance.setPaidToDoctorPatientCount(calculateSessionDoneFees(sessionInstance));
sessionInstance.setRemainingPatientCount(bookedPatientCount - completedPatientCount);
sessionInstanceFacade.edit(sessionInstance);
}
+ public Long calculateSessionDoneFees(SessionInstance si) {
+ if (si == null) {
+ JsfUtil.addErrorMessage("Select Specility");
+ return 0l;
+ }
+ BillType[] billTypes = {BillType.ChannelAgent, BillType.ChannelCash, BillType.ChannelPaid};
+ List bts = Arrays.asList(billTypes);
+ HashMap hm = new HashMap();
+ String sql = " SELECT count(DISTINCT b.bill.paidBill) "
+ + " FROM BillFee b "
+ + " WHERE b.bill.retired = false "
+ + " AND b.fee.feeType = :ftp "
+ + " AND b.bill.refunded = false "
+ + " AND b.bill.cancelled = false "
+ + " AND ABS(ABS(b.feeValue) - ABS(b.paidValue)) < 1 "
+ // + " AND b.bill.billType IN :bt "
+ + " AND b.bill.singleBillSession.sessionInstance = :si";
+
+ hm.put("si", si);
+// hm.put("bt", bts);
+ hm.put("ftp", FeeType.Staff);
+// hm.put("class", BilledBill.class);
+ System.out.println("sql = " + sql);
+ System.out.println("hm = " + hm);
+ Long count = billFeeFacade.findLongByJpql(sql, hm, TemporalType.TIMESTAMP);
+ System.out.println("count = " + count);
+ return count;
+ }
+
public void processAndfillDailySessionCounts() {
+ System.out.println("Starting processAndfillDailySessionCounts...");
+
String j;
- Map m = new HashMap();
+ Map m = new HashMap<>();
rows = new ArrayList<>();
- j = "select si "
+
+ System.out.println("Preparing JPQL query...");
+ j = "select new com.divudi.data.ReportTemplateRow(si) "
+ " from SessionInstance si "
+ " where si.retired=false "
+ " and si.sessionDate between :fd and :td ";
+
if (institution != null) {
+ System.out.println("Institution is not null: " + institution);
m.put("ins", institution);
j += " and si.institution=:ins ";
+ } else {
+ System.out.println("Institution is null.");
+ }
+
+ if (fromDate == null || toDate == null) {
+ System.out.println("fromDate or toDate is null. Exiting method.");
+ return; // or throw an appropriate exception
}
-
+
+ System.out.println("Setting date parameters: fromDate = " + fromDate + ", toDate = " + toDate);
m.put("fd", fromDate);
m.put("td", toDate);
-
- sessionInstances = sessionInstanceFacade.findByJpql(j, m);
- System.out.println("sessionInstance = " + sessionInstances);
- for (SessionInstance si : sessionInstances) {
- fillBillSessions(si);
+
+ System.out.println("Executing query...");
+ List rs = (List) billFacade.findLightsByJpql(j, m, TemporalType.DATE);
+
+ if (rs == null || rs.isEmpty()) {
+ System.out.println("No results found.");
+ return;
+ } else {
+ System.out.println("Results found: " + rs.size());
+ }
+
+ Long long1 = 0L;
+ Long long2 = 0L;
+ Long long3 = 0L;
+ Long long4 = 0L;
+ Long long5 = 0L;
+ Long long6 = 0L;
+ Long long7 = 0L;
+
+ System.out.println("Processing result rows...");
+ for (ReportTemplateRow r : rs) {
+ if (r == null) {
+ System.out.println("Encountered null ReportTemplateRow. Skipping...");
+ continue;
+ }
+
+ SessionInstance si = r.getSessionInstance();
+ if (si == null) {
+ System.out.println("SessionInstance is null. Skipping...");
+ continue;
+ }
+
+ System.out.println("Processing SessionInstance: " + si);
+ fillBillSessions(si); // Make sure fillBillSessions() can handle null fields inside `si`
+
+ long bookedCount = si.getBookedPatientCount() != null ? si.getBookedPatientCount() : 0;
+ long paidCount = si.getPaidPatientCount() != null ? si.getPaidPatientCount() : 0;
+ long completedCount = si.getCompletedPatientCount() != null ? si.getCompletedPatientCount() : 0;
+ long cancelCount = si.getCancelPatientCount() != null ? si.getCancelPatientCount() : 0;
+ long refundedCount = si.getRefundedPatientCount() != null ? si.getRefundedPatientCount() : 0;
+ long remainingCount = si.getRemainingPatientCount() != null ? si.getRemainingPatientCount() : 0;
+ long paidToDoctorCount = si.getPaidToDoctorPatientCount() != null ? si.getPaidToDoctorPatientCount() : 0;
+ System.out.println("Booked: " + bookedCount + ", Paid: " + paidCount + ", Completed: " + completedCount
+ + ", Cancelled: " + cancelCount + ", Refunded: " + refundedCount + ", Remaining: " + remainingCount);
+
+ long1 += bookedCount;
+ long2 += paidCount;
+ long3 += completedCount;
+ long4 += cancelCount;
+ long5 += refundedCount;
+ long6 += remainingCount;
+ long7 += paidToDoctorCount;
+ }
+
+ System.out.println("Final counts: long1=" + long1 + ", long2=" + long2 + ", long3=" + long3
+ + ", long4=" + long4 + ", long5=" + long5 + ", long6=" + long6 + ", long7=" + long7);
+
+ if (bundle != null) {
+ System.out.println("Setting values in bundle...");
+ bundle.setReportTemplateRows(rs);
+ bundle.setLong1(long1);
+ bundle.setLong2(long2);
+ bundle.setLong3(long3);
+ bundle.setLong4(long4);
+ bundle.setLong5(long5);
+ bundle.setLong6(long6);
+ bundle.setLong7(long7);
+ } else {
+ System.out.println("Bundle is null.");
}
+
+ System.out.println("Completed processAndfillDailySessionCounts.");
}
public void fillCategorySessionCounts() {
@@ -853,6 +963,7 @@ public void fillDailyDoctorCounts() {
+ "sum(si.completedPatientCount),"
+ "sum(si.cancelPatientCount),"
+ "sum(si.refundedPatientCount),"
+ + "sum(si.paidToDoctorPatientCount),"
+ "sum(si.remainingPatientCount)"
+ ") "
+ " from SessionInstance si "
@@ -879,27 +990,28 @@ public void fillDailyDoctorCounts() {
List rs = (List) billFacade.findLightsByJpql(j, m, TemporalType.DATE);
bundle.setReportTemplateRows(rs);
- bundle.setLong1(0l);
- bundle.setLong2(0l);
- bundle.setLong3(0l);
- bundle.setLong4(0l);
- bundle.setLong5(0l);
- bundle.setLong6(0l);
+ bundle.setLong1(0L);
+ bundle.setLong2(0L);
+ bundle.setLong3(0L);
+ bundle.setLong4(0L);
+ bundle.setLong5(0L);
+ bundle.setLong6(0L);
+ bundle.setLong7(0L);
long idCounter = 1;
for (ReportTemplateRow row : rs) {
if (row != null) {
row.setId(idCounter++);
- SessionInstance sessionInstance = row.getSessionInstance();
- if (sessionInstance != null) {
- bundle.setLong1(bundle.getLong1() + (row.getLong1() != null ? row.getLong1() : 0));
- bundle.setLong2(bundle.getLong2() + (sessionInstance.getPaidPatientCount() != null ? sessionInstance.getPaidPatientCount() : 0));
- bundle.setLong3(bundle.getLong3() + (sessionInstance.getCompletedPatientCount() != null ? sessionInstance.getCompletedPatientCount() : 0));
- bundle.setLong4(bundle.getLong4() + (sessionInstance.getCancelPatientCount() != null ? sessionInstance.getCancelPatientCount() : 0));
- bundle.setLong5(bundle.getLong5() + (sessionInstance.getRefundedPatientCount() != null ? sessionInstance.getRefundedPatientCount() : 0));
- bundle.setLong6(bundle.getLong6() + (sessionInstance.getRemainingPatientCount() != null ? sessionInstance.getRemainingPatientCount() : 0));
- }
+
+ // Directly sum the values from the aggregated query results
+ bundle.setLong1(bundle.getLong1() + (row.getLong1() != null ? row.getLong1() : 0)); // Booked Patient Count
+ bundle.setLong2(bundle.getLong2() + (row.getLong2() != null ? row.getLong2() : 0)); // Paid Patient Count
+ bundle.setLong3(bundle.getLong3() + (row.getLong3() != null ? row.getLong3() : 0)); // Completed Patient Count
+ bundle.setLong4(bundle.getLong4() + (row.getLong4() != null ? row.getLong4() : 0)); // Cancel Patient Count
+ bundle.setLong5(bundle.getLong5() + (row.getLong5() != null ? row.getLong5() : 0)); // Refunded Patient Count
+ bundle.setLong6(bundle.getLong6() + (row.getLong6() != null ? row.getLong6() : 0)); // Paid to Doctor Patient Count
+ bundle.setLong7(bundle.getLong7() + (row.getLong7() != null ? row.getLong7() : 0)); // Remaining Patient Count
}
}
diff --git a/src/main/java/com/divudi/bean/channel/ChannelScheduleController.java b/src/main/java/com/divudi/bean/channel/ChannelScheduleController.java
index 86231495e9..b6acee072c 100644
--- a/src/main/java/com/divudi/bean/channel/ChannelScheduleController.java
+++ b/src/main/java/com/divudi/bean/channel/ChannelScheduleController.java
@@ -54,6 +54,7 @@
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@@ -63,6 +64,7 @@
import javax.inject.Inject;
import javax.inject.Named;
import javax.persistence.TemporalType;
+import static org.apache.commons.lang3.StringUtils.isNumeric;
import org.primefaces.model.DefaultScheduleModel;
import org.primefaces.model.ScheduleModel;
@@ -165,6 +167,25 @@ public void channelSheduleForAllDoctor(Staff stf) {
}
+ public void updateSessionEndTime() {
+ String sessionDuration = configOptionApplicationController.getShortTextValueByKey("Default Channel Session Duration","2");
+ int duration = 0;
+ if(isNumeric(sessionDuration)){
+ duration = Integer.parseInt(sessionDuration);
+ }else{
+ duration = 2;
+ }
+
+ if (getCurrent().getStartingTime() == null) {
+ getCurrent().setEndingTime(null);
+ } else {
+ Calendar e = Calendar.getInstance();
+ e.setTime(getCurrent().getStartingTime());
+ e.add(Calendar.HOUR, duration);
+ getCurrent().setEndingTime(e.getTime());
+ }
+ }
+
public void generateSessions(Staff st) {
sessionInstances = new ArrayList<>();
String jpql;
diff --git a/src/main/java/com/divudi/bean/channel/ChannelStaffPaymentBillController.java b/src/main/java/com/divudi/bean/channel/ChannelStaffPaymentBillController.java
index e51a5b84f8..f6ec42457b 100644
--- a/src/main/java/com/divudi/bean/channel/ChannelStaffPaymentBillController.java
+++ b/src/main/java/com/divudi/bean/channel/ChannelStaffPaymentBillController.java
@@ -1,6 +1,7 @@
package com.divudi.bean.channel;
import com.divudi.bean.common.CommonController;
+import com.divudi.bean.common.ConfigOptionApplicationController;
import com.divudi.bean.common.SessionController;
import com.divudi.bean.common.util.JsfUtil;
@@ -90,6 +91,8 @@ public class ChannelStaffPaymentBillController implements Serializable {
SessionController sessionController;
@Inject
CommonController commonController;
+ @Inject
+ ConfigOptionApplicationController configOptionApplicationController;
/////////////////////
private List billItems;
List selectedItems;
@@ -532,28 +535,64 @@ public void calculateSessionDueFees() {
return;
}
+// BillType[] billTypes = {BillType.ChannelAgent, BillType.ChannelCash, BillType.ChannelPaid};
+// List bts = Arrays.asList(billTypes);
+// HashMap hm = new HashMap();
+// String sql = " SELECT b "
+// + " FROM BillFee b "
+// + " where type(b.bill)=:class "
+// + " and b.bill.retired=false "
+// + " and b.bill.paidAmount!=0 "
+// + " and b.fee.feeType=:ftp"
+// + " and b.bill.refunded=false "
+// + " and b.bill.cancelled=false "
+// + " and abs(abs(b.feeValue) - abs(b.paidValue)) > 1 "
+// + " and b.bill.billType in :bt "
+// + " and b.bill.singleBillSession.sessionInstance=:si"
+//
+// if(configOptionApplicationController.getBooleanValueByKey("Only Show Completed Channel Bookings On Doctor Payments")) {
+// sql +=" and b.bill.singleBillSession.completed=:com";
+// hm.put("com", true);
+// }
+//
+// sql += " order by b.bill.singleBillSession.serialNo ";
+// hm.put("si", getSessionInstance());
+// hm.put("bt", bts);
+// hm.put("ftp", FeeType.Staff);
+// hm.put("class", BilledBill.class);
+// dueBillFees = billFeeFacade.findByJpql(sql, hm, TemporalType.TIMESTAMP);
+
BillType[] billTypes = {BillType.ChannelAgent, BillType.ChannelCash, BillType.ChannelPaid};
List bts = Arrays.asList(billTypes);
- HashMap hm = new HashMap();
+ HashMap hm = new HashMap<>();
String sql = " SELECT b "
+ " FROM BillFee b "
- + " where type(b.bill)=:class "
+ + " where type(b.bill) in :classes "
+ " and b.bill.retired=false "
+ + " and b.fee.feeType=:ftp "
+ + " and b.bill.paymentMethod!=:pay"
+ " and b.bill.paidAmount!=0 "
- + " and b.fee.feeType=:ftp"
+ " and b.bill.refunded=false "
+ " and b.bill.cancelled=false "
- + " and (b.feeValue - b.paidValue) > 0 "
- + " and b.bill.billType in :bt "
- + " and b.bill.singleBillSession.sessionInstance=:si"
- + " and b.bill.singleBillSession.completed=:com";
+ + " and abs(abs(b.feeValue) - abs(b.paidValue)) > 0 "
+ + " and b.bill.singleBillSession.sessionInstance=:si ";
+ if(configOptionApplicationController.getBooleanValueByKey("Only Show Completed Channel Bookings On Doctor Payments")) {
+ sql +=" and b.bill.singleBillSession.completed=:com ";
+ hm.put("com", true);
+ }
sql += " order by b.bill.singleBillSession.serialNo ";
+ List> classes = new ArrayList<>();
+ classes.add(BilledBill.class);
+
hm.put("si", getSessionInstance());
- hm.put("bt", bts);
+ hm.put("pay", paymentMethod.OnCall);
hm.put("ftp", FeeType.Staff);
- hm.put("com", true);
- hm.put("class", BilledBill.class);
+ hm.put("classes", classes);
+// System.out.println("sql = " + sql);
+// System.out.println("hm = " + hm);
dueBillFees = billFeeFacade.findByJpql(sql, hm, TemporalType.TIMESTAMP);
+// System.out.println("dueBillFees = " + dueBillFees);
+
HashMap m = new HashMap();
sql = " SELECT b "
@@ -580,7 +619,6 @@ public void calculateSessionDueFees() {
}
public void calculateSessionDoneFees() {
- Date startTime = new Date();
if (getSessionInstance() == null) {
JsfUtil.addErrorMessage("Select Specility");
return;
@@ -594,19 +632,17 @@ public void calculateSessionDoneFees() {
+ " where type(b.bill)=:class "
+ " and b.bill.retired=false "
+ " and b.bill.paidAmount!=0 "
- + " and b.fee.feeType=:ftp"
+ + " and b.fee.feeType=:ftp "
+ " and b.bill.refunded=false "
+ " and b.bill.cancelled=false "
- + " and b.bill.singleBillSession.absent=false"
- + " and (b.feeValue - b.paidValue) > 0 "
+ + " and b.bill.singleBillSession.absent=false "
+ + " and abs(abs(b.feeValue) - abs(b.paidValue))= 0 "
+ " and b.bill.billType in :bt "
- + " and b.bill.singleBillSession.sessionInstance=:si"
- + " and b.bill.singleBillSession.completed=:com";
+ + " and b.bill.singleBillSession.sessionInstance=:si";
sql += " order by b.bill.singleBillSession.serialNo ";
hm.put("si", getSessionInstance());
hm.put("bt", bts);
hm.put("ftp", FeeType.Staff);
- hm.put("com", true);
hm.put("class", BilledBill.class);
dueBillFees = billFeeFacade.findByJpql(sql, hm, TemporalType.TIMESTAMP);
@@ -616,10 +652,10 @@ public void calculateSessionDoneFees() {
+ " where type(b.bill)=:class "
+ " and b.bill.retired=false "
+ " and b.bill.paidAmount!=0 "
- + " and b.fee.feeType=:ftp"
- + " and b.bill.refunded=false "
+ + " and b.fee.feeType=:ftp "
+ + " and b.bill.refunded=false "
+ " and b.bill.cancelled=false "
- + " and (b.feeValue - b.paidValue) > 0 "
+ + " and abs(abs(b.feeValue) - abs(b.paidValue))=0 "
+ " and b.bill.billType in :bt "
+ " and b.bill.singleBillSession.sessionInstance=:si "
+ " and b.bill.singleBillSession.absent=true "
@@ -647,7 +683,8 @@ public void calculateSessionAllFees() {
+ " FROM BillFee b "
+ " where type(b.bill) in :classes "
+ " and b.bill.retired=false "
- + " and b.fee.feeType=:ftp"
+ + " and b.fee.feeType=:ftp "
+ + " and b.bill.paymentMethod!=:pay"
+ " and b.bill.singleBillSession.sessionInstance=:si";
sql += " order by b.bill.singleBillSession.serialNo ";
List> classes = new ArrayList<>();
@@ -656,6 +693,7 @@ public void calculateSessionAllFees() {
hm.put("si", getSessionInstance());
hm.put("ftp", FeeType.Staff);
hm.put("classes", classes);
+ hm.put("pay", paymentMethod.OnCall);
System.out.println("sql = " + sql);
System.out.println("hm = " + hm);
dueBillFees = billFeeFacade.findByJpql(sql, hm, TemporalType.TIMESTAMP);
diff --git a/src/main/java/com/divudi/bean/collectingCentre/CollectingCentreBillController.java b/src/main/java/com/divudi/bean/collectingCentre/CollectingCentreBillController.java
index 8effa74c87..d1146cd621 100644
--- a/src/main/java/com/divudi/bean/collectingCentre/CollectingCentreBillController.java
+++ b/src/main/java/com/divudi/bean/collectingCentre/CollectingCentreBillController.java
@@ -66,6 +66,8 @@
import com.divudi.facade.PaymentFacade;
import com.divudi.facade.PersonFacade;
import com.divudi.bean.common.util.JsfUtil;
+import com.divudi.data.InstitutionType;
+import com.divudi.entity.Fee;
import com.divudi.java.CommonFunctions;
import java.io.Serializable;
import java.util.ArrayList;
@@ -210,6 +212,8 @@ public class CollectingCentreBillController implements Serializable, ControllerW
private List opdItems;
private List agentReferenceBooks;
private List bookSummeryRows;
+ private double collectingCentrePrecentage;
+ private List billFeesForCollectingCenters;
public List getAgentReferenceBooks() {
return agentReferenceBooks;
@@ -1275,7 +1279,7 @@ public void addToBill() {
BillEntry addingEntry = new BillEntry();
addingEntry.setBillItem(bi);
addingEntry.setLstBillComponents(getBillBean().billComponentsFromBillItem(bi));
- addingEntry.setLstBillFees(getBillBean().billFeefromBillItem(bi, collectingCentre, collectingCentre.getFeeListType()));
+ addingEntry.setLstBillFees(getBillBean().billFeefromBillItemForCollectingCenter(bi, collectingCentre));
addingEntry.setLstBillSessions(getBillBean().billSessionsfromBillItem(bi));
getLstBillEntries().add(addingEntry);
bi.setRate(getBillBean().billItemRate(addingEntry));
@@ -1292,6 +1296,25 @@ public void addToBill() {
JsfUtil.addSuccessMessage("Item Added");
}
+ public void createBillFeeForCollectingCenterPrecentage(BillItem bi, Double netTotal) {
+ System.out.println("netTotal = " + netTotal);
+ double total = 0.0;
+ collectingCentrePrecentage = collectingCentre.getPercentage();
+
+ if (collectingCentrePrecentage != 0.0) {
+ System.out.println("collectingCentrePrecentage = " + collectingCentrePrecentage);
+ total = netTotal * collectingCentrePrecentage / 100;
+ System.out.println("total = " + total);
+ BillFee bf = new BillFee();
+ bf.setBillItem(bi);
+ bf.setFeeValue(total);
+ bf.setInstitution(collectingCentre);
+ bf.setCreatedAt(new Date());
+ bf.setCreater(sessionController.getCurrent());
+ }
+
+ }
+
public void clearBillItemValues() {
currentBillItem = null;
recreateBillItems();
@@ -1352,6 +1375,10 @@ public void setPriceMatrixController(PriceMatrixController priceMatrixController
MembershipSchemeController membershipSchemeController;
public void calTotals() {
+ double hospitalFee = 0.0;
+ double collectingcCenterFee = 0.0;
+ double staffFee = 0.0;
+ double otherFee = 0.0;
double billDiscount = 0.0;
double billGross = 0.0;
@@ -1372,10 +1399,23 @@ public void calTotals() {
entryNet += bf.getFeeValue();
entryDis += bf.getFeeDiscount();
entryVat += bf.getFeeVat();
+ System.out.println("bf.getInstitution().getInstitutionType() = " + bf.getInstitution().getInstitutionType());
+ if (bf.getInstitution().getInstitutionType() == InstitutionType.CollectingCentre) {
+ collectingcCenterFee += bf.getFeeValue();
+ } else if (bf.getStaff() != null) {
+ staffFee += bf.getFeeValue();
+ } else if (bf.getInstitution().getInstitutionType() == InstitutionType.Company) {
+ hospitalFee += bf.getFeeValue();
+ }else{
+ otherFee+=bf.getFeeValue();
+ }
//////// // System.out.println("fee net is " + bf.getFeeValue());
}
-
+ bi.setCollectingCentreFee(collectingcCenterFee);
+ bi.setHospitalFee(hospitalFee);
+ bi.setStaffFee(staffFee);
+ bi.setOtherFee(otherFee);
bi.setDiscount(entryDis);
bi.setGrossValue(entryGross);
bi.setNetValue(entryNet);
@@ -2242,6 +2282,22 @@ public void setBookSummeryRows(List bookSummeryR
this.bookSummeryRows = bookSummeryRows;
}
+ public double getCollectingCentrePrecentage() {
+ return collectingCentrePrecentage;
+ }
+
+ public void setCollectingCentrePrecentage(double collectingCentrePrecentage) {
+ this.collectingCentrePrecentage = collectingCentrePrecentage;
+ }
+
+ public List getBillFeesForCollectingCenters() {
+ return billFeesForCollectingCenters;
+ }
+
+ public void setBillFeesForCollectingCenters(List billFeesForCollectingCenters) {
+ this.billFeesForCollectingCenters = billFeesForCollectingCenters;
+ }
+
public class CollectingCenterBookSummeryRow {
private String bookName;
diff --git a/src/main/java/com/divudi/bean/common/BillBeanController.java b/src/main/java/com/divudi/bean/common/BillBeanController.java
index 9632c88c2e..165a243e21 100644
--- a/src/main/java/com/divudi/bean/common/BillBeanController.java
+++ b/src/main/java/com/divudi/bean/common/BillBeanController.java
@@ -2559,7 +2559,7 @@ public void setPaymentMethodData(Bill b, PaymentMethod paymentMethod, PaymentMet
b.setChequeDate(paymentMethodData.getCheque().getDate());
b.setComments(paymentMethodData.getCheque().getComment());
}
-
+
if (paymentMethod.equals(PaymentMethod.Slip)) {
b.setBank(paymentMethodData.getSlip().getInstitution());
b.setChequeDate(paymentMethodData.getSlip().getDate());
@@ -3387,9 +3387,8 @@ private void savePatientInvestigation(BillEntry e, BillComponent bc, WebUser wu)
ptIx.setCreatedAt(Calendar.getInstance().getTime());
ptIx.setCreater(wu);
-
+
ptIx.setStatus(PatientInvestigationStatus.ORDERED);
-
ptIx.setBillItem(e.getBillItem());
ptIx.setBillComponent(bc);
@@ -3621,6 +3620,10 @@ public List billFeefromBillItem(BillItem billItem) {
return baseBillFeefromBillItem(billItem);
}
+ public List BillFeefromBillItemByForInstitution(BillItem billItem) {
+ return forInstitutionBillFeefromBillItem(billItem, sessionController.getInstitution());
+ }
+
public List billFeefromBillItem(BillItem billItem, Institution forInstitution, Category forCategory) {
List billFees = billFeefromBillItem(billItem, forInstitution);
@@ -3908,6 +3911,182 @@ public List billFeefromBillItem(BillItem billItem, Institution forInsti
return t;
}
+ public List billFeefromBillItemForCollectingCenter(BillItem billItem, Institution collectingCenter) {
+ System.out.println("collectingCenter = " + collectingCenter);
+ System.out.println("billItem = " + billItem);
+ List t = new ArrayList<>();
+ BillFee feeForCollectingCenter;
+ BillFee feeForInstitution;
+ String jpql;
+
+ Map params = new HashMap();
+ if (billItem.getItem() instanceof Packege) {
+ System.out.println("Packege ..........");
+ jpql = "Select i from PackageItem p join p.item i where p.retired=false and p.packege.id = " + billItem.getItem().getId();
+ List- packageItems = getItemFacade().findByJpql(jpql);
+ for (Item pi : packageItems) {
+ jpql = "Select f "
+ + " from PackageFee f "
+ + " where f.retired=:ret"
+ + " and f.packege=:packege"
+ + " and f.item=:item ";
+ if (collectingCenter != null) {
+ jpql += " and f.forInstitution=:fi ";
+ params.put("fi", collectingCenter);
+ } else {
+ jpql += " and f.forInstitution is null ";
+ }
+ jpql += " and f.forCategory is null ";
+ params.put("ret", false);
+ params.put("packege", billItem.getItem());
+ params.put("item", billItem.getItem());
+ List packFee = getPackageFeeFacade().findByJpql(jpql, params);
+ System.out.println("packFee jpql = " +jpql);
+ System.out.println("packFee m = " +params);
+ for (Fee i : packFee) {
+ double originalFeeValue;
+ double institutionFeeValue;
+ double collectingCenterFeeValue;
+ originalFeeValue = i.getFee();
+ collectingCenterFeeValue = originalFeeValue * collectingCenter.getPercentage() / 100;
+ institutionFeeValue = originalFeeValue - collectingCenterFeeValue;
+
+ feeForCollectingCenter = new BillFee();
+ feeForCollectingCenter.setFee(i);
+ feeForCollectingCenter.setFeeValue(collectingCenterFeeValue);
+ feeForCollectingCenter.setFeeGrossValue(collectingCenterFeeValue);
+ // f.setBill(billItem.getBill());
+ feeForCollectingCenter.setBillItem(billItem);
+ feeForCollectingCenter.setCreatedAt(new Date());
+ if (pi.getDepartment() != null) {
+ if (i.getFeeType() == FeeType.CollectingCentre && collectingCentreBillController.getCollectingCentre() != null) {
+ feeForCollectingCenter.setDepartment(departmentController.getDefaultDepatrment(collectingCentreBillController.getCollectingCentre()));
+ } else {
+ feeForCollectingCenter.setDepartment(pi.getDepartment());
+ }
+
+ } else {
+ // f.setDepartment(billItem.getBill().getDepartment());
+ }
+ if (pi.getInstitution() != null) {
+ if (i.getFeeType() == FeeType.CollectingCentre && collectingCentreBillController.getCollectingCentre() != null) {
+ feeForCollectingCenter.setInstitution(collectingCentreBillController.getCollectingCentre());
+ } else {
+ feeForCollectingCenter.setInstitution(pi.getInstitution());
+ }
+
+ } else {
+ // f.setInstitution(billItem.getBill().getDepartment().getInstitution());
+ }
+ if (i.getStaff() != null) {
+ feeForCollectingCenter.setStaff(i.getStaff());
+ } else {
+ feeForCollectingCenter.setStaff(null);
+ }
+ feeForCollectingCenter.setSpeciality(i.getSpeciality());
+ feeForCollectingCenter.setStaff(i.getStaff());
+
+ if (feeForCollectingCenter.getBillItem().getItem().isVatable()) {
+ if (!(feeForCollectingCenter.getFee().getFeeType() == FeeType.CollectingCentre && collectingCentreBillController.getCollectingCentre() != null)) {
+ feeForCollectingCenter.setFeeVat(feeForCollectingCenter.getFeeValue() * feeForCollectingCenter.getBillItem().getItem().getVatPercentage() / 100);
+ }
+ }
+
+ feeForCollectingCenter.setFeeVatPlusValue(feeForCollectingCenter.getFeeValue() + feeForCollectingCenter.getFeeVat());
+
+ t.add(feeForCollectingCenter);
+
+ }
+ }
+ } else {
+ System.out.println("else ");
+ jpql = "Select f "
+ + " from ItemFee f "
+ + " where f.retired=:ret "
+ + " and f.item=:item ";
+ if (collectingCenter != null) {
+ jpql += " and f.forInstitution=:fi ";
+ params.put("fi", collectingCenter);
+ } else {
+ jpql += " and f.forInstitution is null ";
+ }
+ jpql += " and f.forCategory is null ";
+ params.put("ret", false);
+ params.put("item", billItem.getItem());
+ System.out.println("jpql = " + jpql);
+ System.out.println("params = " + params);
+ List itemFee = getItemFeeFacade().findByJpql(jpql, params);
+ for (Fee i : itemFee) {
+ System.out.println("i = " + i);
+ double originalFeeValue;
+ double institutionFeeValue;
+ double collectingCenterFeeValue;
+ originalFeeValue = i.getFee();
+ collectingCenterFeeValue = originalFeeValue * collectingCenter.getPercentage() / 100;
+ institutionFeeValue = originalFeeValue - collectingCenterFeeValue;
+
+ System.out.println("originalFeeValue = " + originalFeeValue);
+ System.out.println("institutionFeeValue = " + institutionFeeValue);
+
+ feeForCollectingCenter = new BillFee();
+ feeForCollectingCenter.setFee(i);
+ feeForCollectingCenter.setFeeValue(collectingCenterFeeValue * billItem.getQty());
+ feeForCollectingCenter.setFeeGrossValue(collectingCenterFeeValue * billItem.getQty());
+ feeForCollectingCenter.setInstitution(collectingCenter);
+ feeForCollectingCenter.setBillItem(billItem);
+ feeForCollectingCenter.setCreatedAt(new Date());
+
+
+ feeForInstitution = new BillFee();
+ feeForInstitution.setFee(i);
+ feeForInstitution.setFeeValue(i.getFee()-collectingCenterFeeValue);
+ feeForInstitution.setFeeGrossValue(i.getFee()-collectingCenterFeeValue);
+ feeForInstitution.setInstitution(i.getInstitution());
+ feeForInstitution.setDepartment(i.getDepartment());
+ feeForInstitution.setBillItem(billItem);
+ feeForInstitution.setCreatedAt(new Date());
+
+ System.out.println("collectingCenterFeeValue = " + collectingCenterFeeValue);
+ if (billItem.getItem().getDepartment() != null) {
+ if (i.getFeeType() == FeeType.CollectingCentre && collectingCentreBillController.getCollectingCentre() != null) {
+ feeForCollectingCenter.setDepartment(departmentController.getDefaultDepatrment(collectingCentreBillController.getCollectingCentre()));
+ } else {
+ feeForCollectingCenter.setDepartment(billItem.getItem().getDepartment());
+ }
+ } else {
+ // f.setDepartment(billItem.getBill().getDepartment());
+ }
+ if (billItem.getItem().getInstitution() != null) {
+ if (i.getFeeType() == FeeType.CollectingCentre && collectingCentreBillController.getCollectingCentre() != null) {
+ feeForCollectingCenter.setInstitution(collectingCentreBillController.getCollectingCentre());
+ } else {
+ feeForCollectingCenter.setInstitution(billItem.getItem().getInstitution());
+ }
+ } else {
+ // f.setInstitution(billItem.getBill().getDepartment().getInstitution());
+ }
+ if (i.getStaff() != null) {
+ feeForCollectingCenter.setStaff(i.getStaff());
+ } else {
+ feeForCollectingCenter.setStaff(null);
+ }
+ feeForCollectingCenter.setSpeciality(i.getSpeciality());
+
+ if (feeForCollectingCenter.getBillItem().getItem().isVatable()) {
+ if (!(feeForCollectingCenter.getFee().getFeeType() == FeeType.CollectingCentre && collectingCentreBillController.getCollectingCentre() != null)) {
+ feeForCollectingCenter.setFeeVat(feeForCollectingCenter.getFeeValue() * feeForCollectingCenter.getBillItem().getItem().getVatPercentage() / 100);
+ }
+ }
+
+ feeForCollectingCenter.setFeeVatPlusValue(feeForCollectingCenter.getFeeValue() + feeForCollectingCenter.getFeeVat());
+
+ t.add(feeForCollectingCenter);
+ t.add(feeForInstitution);
+ }
+ }
+ return t;
+ }
+
public List baseBillFeefromBillItem(BillItem billItem) {
List t = new ArrayList<>();
BillFee f;
@@ -4035,6 +4214,134 @@ public List baseBillFeefromBillItem(BillItem billItem) {
return t;
}
+ public List forInstitutionBillFeefromBillItem(BillItem billItem, Institution forIns) {
+ List t = new ArrayList<>();
+ BillFee f;
+ String jpql;
+ Map params = new HashMap();
+ if (billItem.getItem() instanceof Packege) {
+ jpql = "Select i from PackageItem p join p.item i where p.retired=false and p.packege.id = " + billItem.getItem().getId();
+ List
- packageItems = getItemFacade().findByJpql(jpql);
+ for (Item pi : packageItems) {
+ jpql = "Select f "
+ + " from PackageFee f "
+ + " where f.retired=:ret"
+ + " and f.packege=:packege"
+ + " and f.item=:item "
+ + " and f.forCategory is null "
+ + " and f.forInstitution is null ";
+ params.put("ret", false);
+ params.put("packege", billItem.getItem());
+ params.put("item", billItem.getItem());
+ List packFee = getPackageFeeFacade().findByJpql(jpql, params);
+ for (Fee i : packFee) {
+ f = new BillFee();
+ f.setFee(i);
+ f.setFeeValue(i.getFee());
+ f.setFeeGrossValue(i.getFee());
+ // f.setBill(billItem.getBill());
+ f.setBillItem(billItem);
+ f.setCreatedAt(new Date());
+ if (pi.getDepartment() != null) {
+ if (i.getFeeType() == FeeType.CollectingCentre && collectingCentreBillController.getCollectingCentre() != null) {
+ f.setDepartment(departmentController.getDefaultDepatrment(collectingCentreBillController.getCollectingCentre()));
+ } else {
+ f.setDepartment(pi.getDepartment());
+ }
+
+ } else {
+ // f.setDepartment(billItem.getBill().getDepartment());
+ }
+ if (pi.getInstitution() != null) {
+ if (i.getFeeType() == FeeType.CollectingCentre && collectingCentreBillController.getCollectingCentre() != null) {
+ f.setInstitution(collectingCentreBillController.getCollectingCentre());
+ } else {
+ f.setInstitution(pi.getInstitution());
+ }
+
+ } else {
+ // f.setInstitution(billItem.getBill().getDepartment().getInstitution());
+ }
+ if (i.getStaff() != null) {
+ f.setStaff(i.getStaff());
+ } else {
+ f.setStaff(null);
+ }
+ f.setSpeciality(i.getSpeciality());
+ f.setStaff(i.getStaff());
+
+ if (f.getBillItem().getItem().isVatable()) {
+ if (!(f.getFee().getFeeType() == FeeType.CollectingCentre && collectingCentreBillController.getCollectingCentre() != null)) {
+ f.setFeeVat(f.getFeeValue() * f.getBillItem().getItem().getVatPercentage() / 100);
+ }
+ }
+
+ f.setFeeVatPlusValue(f.getFeeValue() + f.getFeeVat());
+
+ t.add(f);
+
+ }
+ }
+ } else {
+ jpql = "Select f "
+ + " from ItemFee f "
+ + " where f.retired=:ret "
+ + " and f.item=:item "
+ + " and f.forCategory is null "
+ + " and f.forInstitution=:forIns ";
+ params.put("ret", false);
+ params.put("item", billItem.getItem());
+ params.put("forIns", forIns);
+
+ List itemFee = getItemFeeFacade().findByJpql(jpql, params);
+ for (Fee i : itemFee) {
+ f = new BillFee();
+ f.setFee(i);
+ f.setFeeValue(i.getFee() * billItem.getQty());
+ f.setFeeGrossValue(i.getFee() * billItem.getQty());
+ //////System.out.println("Fee Value is " + f.getFeeValue());
+ // f.setBill(billItem.getBill());
+ f.setBillItem(billItem);
+ f.setCreatedAt(new Date());
+ if (billItem.getItem().getDepartment() != null) {
+ if (i.getFeeType() == FeeType.CollectingCentre && collectingCentreBillController.getCollectingCentre() != null) {
+ f.setDepartment(departmentController.getDefaultDepatrment(collectingCentreBillController.getCollectingCentre()));
+ } else {
+ f.setDepartment(billItem.getItem().getDepartment());
+ }
+ } else {
+ // f.setDepartment(billItem.getBill().getDepartment());
+ }
+ if (billItem.getItem().getInstitution() != null) {
+ if (i.getFeeType() == FeeType.CollectingCentre && collectingCentreBillController.getCollectingCentre() != null) {
+ f.setInstitution(collectingCentreBillController.getCollectingCentre());
+ } else {
+ f.setInstitution(billItem.getItem().getInstitution());
+ }
+ } else {
+ // f.setInstitution(billItem.getBill().getDepartment().getInstitution());
+ }
+ if (i.getStaff() != null) {
+ f.setStaff(i.getStaff());
+ } else {
+ f.setStaff(null);
+ }
+ f.setSpeciality(i.getSpeciality());
+
+ if (f.getBillItem().getItem().isVatable()) {
+ if (!(f.getFee().getFeeType() == FeeType.CollectingCentre && collectingCentreBillController.getCollectingCentre() != null)) {
+ f.setFeeVat(f.getFeeValue() * f.getBillItem().getItem().getVatPercentage() / 100);
+ }
+ }
+
+ f.setFeeVatPlusValue(f.getFeeValue() + f.getFeeVat());
+
+ t.add(f);
+ }
+ }
+ return t;
+ }
+
public double totalFeeforItem(Item item) {
List t = new ArrayList<>();
Double bf = 0.0;
diff --git a/src/main/java/com/divudi/bean/common/BillController.java b/src/main/java/com/divudi/bean/common/BillController.java
index 4290c03409..2960013b15 100644
--- a/src/main/java/com/divudi/bean/common/BillController.java
+++ b/src/main/java/com/divudi/bean/common/BillController.java
@@ -1618,6 +1618,8 @@ public List findBillFees(Staff staff, Date fromDate, Date toDate) {
+ " from BillFee bf"
+ " where bf.retired=:ret"
+ " and bf.staff=:staff "
+ + " and bf.bill.cancelled=:can"
+ + " and bf.billItem.refunded=:ret"
+ " and (bf.feeValue - bf.paidValue) > 0 "
+ " and bf.bill.billTypeAtomic in :btcs "
+ " and bf.fee.feeType=:ft";
@@ -1632,6 +1634,8 @@ public List findBillFees(Staff staff, Date fromDate, Date toDate) {
m.put("toDate", toDate);
}
+ m.put("ret", false);
+ m.put("can", false);
m.put("btcs", btcs);
m.put("staff", staff);
m.put("ret", false);
@@ -1639,22 +1643,22 @@ public List findBillFees(Staff staff, Date fromDate, Date toDate) {
tmpFees = billFeeFacade.findByJpql(jpql, m, TemporalType.TIMESTAMP);
- List removingBillFees = new ArrayList<>();
- for (BillFee bf : tmpFees) {
- m = new HashMap<>();
- jpql = "SELECT bi FROM BillItem bi where "
- + " bi.retired=false"
- + " and bi.bill.cancelled=false "
- + " and type(bi.bill)=:class "
- + " and bi.referanceBillItem=:rbi";
- m.put("class", RefundBill.class);
- m.put("rbi", bf.getBillItem());
- BillItem rbi = getBillItemFacade().findFirstByJpql(jpql, m);
- if (rbi != null) {
- removingBillFees.add(bf);
- }
- }
- tmpFees.removeAll(removingBillFees);
+// List removingBillFees = new ArrayList<>();
+// for (BillFee bf : tmpFees) {
+// m = new HashMap<>();
+// jpql = "SELECT bi FROM BillItem bi where "
+// + " bi.retired=false"
+// + " and bi.bill.cancelled=false "
+// + " and type(bi.bill)=:class "
+// + " and bi.referanceBillItem=:rbi";
+// m.put("class", RefundBill.class);
+// m.put("rbi", bf.getBillItem());
+// BillItem rbi = getBillItemFacade().findFirstByJpql(jpql, m);
+// if (rbi != null) {
+// removingBillFees.add(bf);
+// }
+// }
+// tmpFees.removeAll(removingBillFees);
return tmpFees;
}
diff --git a/src/main/java/com/divudi/bean/common/CommonController.java b/src/main/java/com/divudi/bean/common/CommonController.java
index 7b76aadd24..8a018e2519 100644
--- a/src/main/java/com/divudi/bean/common/CommonController.java
+++ b/src/main/java/com/divudi/bean/common/CommonController.java
@@ -5,6 +5,7 @@
*/
package com.divudi.bean.common;
+import com.divudi.entity.channel.SessionInstance;
import java.io.Serializable;
import java.text.DateFormat;
import java.text.DecimalFormat;
@@ -123,6 +124,20 @@ public boolean sameDate(Date date1, Date date2) {
LocalDate secondDate = second.toLocalDate();
return firstDate.equals(secondDate);
}
+
+ public SessionInstance convertToSessionInstance(Object ob){
+ if(ob instanceof SessionInstance){
+ return (SessionInstance) ob;
+ }
+ return null;
+ }
+
+ public SessionInstance getSessionInstance(Object ob){
+ if(ob instanceof SessionInstance){
+ return (SessionInstance) ob;
+ }
+ return null;
+ }
public Date retiermentDate(Date dob) {
if (dob == null) {
diff --git a/src/main/java/com/divudi/bean/common/FeeValueController.java b/src/main/java/com/divudi/bean/common/FeeValueController.java
new file mode 100644
index 0000000000..4b2da9c5b9
--- /dev/null
+++ b/src/main/java/com/divudi/bean/common/FeeValueController.java
@@ -0,0 +1,236 @@
+/*
+ * Open Hospital Management Information System
+ *
+ * Dr M H B Ariyaratne
+ * Consultant (Health Informatics)
+ * (94) 71 5812399
+ * (94) 71 5812399
+ */
+package com.divudi.bean.common;
+
+import com.divudi.bean.common.util.JsfUtil;
+import com.divudi.entity.Category;
+import com.divudi.entity.Department;
+import com.divudi.entity.FeeValue;
+import com.divudi.entity.Institution;
+import com.divudi.entity.Item;
+import com.divudi.entity.Service;
+import com.divudi.entity.lab.Investigation;
+import com.divudi.facade.FeeValueFacade;
+import java.io.Serializable;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.ejb.EJB;
+import javax.enterprise.context.SessionScoped;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.FacesConverter;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+@Named
+@SessionScoped
+public class FeeValueController implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+ @Inject
+ SessionController sessionController;
+ @EJB
+ private FeeValueFacade ejbFacade;
+
+ public void save(FeeValue feeValue) {
+ if (feeValue == null) {
+ return;
+ }
+ if (feeValue.getId() != null) {
+ getFacade().edit(feeValue);
+ } else {
+ feeValue.setCreatedAt(new Date());
+ feeValue.setCreater(getSessionController().getLoggedUser());
+ getFacade().create(feeValue);
+ }
+ }
+
+ public Double getFeeForLocals(Service item, Institution institution) {
+ return getFeeForLocals((Item) item, institution); // Calls the original method for Item
+ }
+
+ public Double getFeeForForeigners(Service item, Institution institution) {
+ return getFeeForForeigners((Item) item, institution); // Calls the original method for Item
+ }
+
+ public Double getFeeForLocals(Investigation item, Institution institution) {
+ return getFeeForLocals((Item) item, institution); // Calls the original method for Item
+ }
+
+ public Double getFeeForForeigners(Investigation item, Institution institution) {
+ return getFeeForForeigners((Item) item, institution); // Calls the original method for Item
+ }
+
+ public Double getFeeForLocals(Item item, Institution institution) {
+ FeeValue feeValue = getFeeValue(item, institution);
+ return feeValue != null ? feeValue.getTotalValueForLocals() : 0.0;
+ }
+
+ public Double getFeeForForeigners(Item item, Institution institution) {
+ FeeValue feeValue = getFeeValue(item, institution);
+ return feeValue != null ? feeValue.getTotalValueForLocals() : 0.0;
+ }
+
+ public FeeValue getFeeValue(Item item, Department department) {
+ String jpql = "SELECT f FROM FeeValue f WHERE f.item = :item AND f.department = :department";
+ Map params = new HashMap<>();
+ params.put("item", item);
+ params.put("department", department);
+
+ return getFacade().findFirstByJpql(jpql, params);
+ }
+
+ public FeeValue getFeeValue(Item item, Institution institution) {
+ String jpql = "SELECT f FROM FeeValue f WHERE f.item = :item AND f.institution = :institution";
+ Map params = new HashMap<>();
+ params.put("item", item);
+ params.put("institution", institution);
+
+ return getFacade().findFirstByJpql(jpql, params);
+ }
+
+ public FeeValue getFeeValue(Item item, Category category) {
+ String jpql = "SELECT f FROM FeeValue f WHERE f.item = :item AND f.category = :category";
+ Map params = new HashMap<>();
+ params.put("item", item);
+ params.put("category", category);
+
+ return getFacade().findFirstByJpql(jpql, params);
+ }
+
+ public FeeValue getFeeValue(Item item, Department dept, Institution ins, Category category) {
+ String jpql = "SELECT f FROM FeeValue f WHERE f.item = :item AND f.department = :dept AND f.institution = :ins AND f.category = :category";
+ Map params = new HashMap<>();
+ params.put("item", item);
+ params.put("dept", dept);
+ params.put("ins", ins);
+ params.put("category", category);
+
+ FeeValue fvals = getFacade().findFirstByJpql(jpql, params);
+ if (fvals == null) {
+ fvals = new FeeValue();
+ fvals.setItem(item);
+ fvals.setDepartment(dept);
+ fvals.setInstitution(ins);
+ fvals.setCategory(category);
+ }
+ return fvals;
+ }
+
+ public void updateFeeValue(Item item, Department dept, Double feeValueForLocals, Double feeValueForForeigners) {
+ FeeValue feeValue = getFeeValue(item, dept);
+ if (feeValue == null) {
+ feeValue = new FeeValue();
+ feeValue.setItem(item);
+ feeValue.setDepartment(dept);
+ feeValue.setCreatedAt(new Date());
+ feeValue.setCreater(getSessionController().getLoggedUser());
+ }
+ feeValue.setTotalValueForLocals(feeValueForLocals);
+ feeValue.setTotalValueForLocals(feeValueForForeigners);
+ save(feeValue);
+ }
+
+ public void updateFeeValue(Item item, Institution ins, Double feeValueForLocals, Double feeValueForForeigners) {
+ FeeValue feeValue = getFeeValue(item, ins);
+ if (feeValue == null) {
+ feeValue = new FeeValue();
+ feeValue.setItem(item);
+ feeValue.setInstitution(ins);
+ feeValue.setCreatedAt(new Date());
+ feeValue.setCreater(getSessionController().getLoggedUser());
+ }
+ feeValue.setTotalValueForLocals(feeValueForLocals);
+ feeValue.setTotalValueForForeigners(feeValueForForeigners);
+ save(feeValue);
+ }
+
+ public Double getFeeValueForLocals(Item item, Department dept, Institution ins, Category category) {
+ FeeValue feeValue = getFeeValue(item, dept, ins, category);
+ if (feeValue != null) {
+ return feeValue.getTotalValueForLocals(); // Assuming `getFee()` returns the fee for locals
+ }
+ return null; // Or return 0.0 if you prefer to return a default value
+ }
+
+ public Double getFeeValueForForeigners(Item item, Department dept, Institution ins, Category category) {
+ FeeValue feeValue = getFeeValue(item, dept, ins, category);
+ if (feeValue != null) {
+ return feeValue.getTotalValueForForeigners(); // Assuming `getFfee()` returns the fee for foreigners
+ }
+ return null; // Or return 0.0 if you prefer to return a default value
+ }
+
+ public void updateFeeValue(Item item, Category cat, Double feeValueForLocals, Double feeValueForForeigners) {
+ FeeValue feeValue = getFeeValue(item, cat);
+ if (feeValue == null) {
+ feeValue = new FeeValue();
+ feeValue.setItem(item);
+ feeValue.setCategory(cat);
+ feeValue.setCreatedAt(new Date());
+ feeValue.setCreater(getSessionController().getLoggedUser());
+ }
+ feeValue.setTotalValueForLocals(feeValueForLocals);
+ feeValue.setTotalValueForForeigners(feeValueForForeigners);
+ save(feeValue);
+ }
+
+ public FeeValueFacade getEjbFacade() {
+ return ejbFacade;
+ }
+
+ public SessionController getSessionController() {
+ return sessionController;
+ }
+
+ public FeeValueController() {
+ }
+
+ private FeeValueFacade getFacade() {
+ return ejbFacade;
+ }
+
+ @FacesConverter(forClass = FeeValue.class)
+ public static class FeeValueConverter implements Converter {
+
+ @Override
+ public Object getAsObject(FacesContext facesContext, UIComponent component, String value) {
+ if (value == null || value.length() == 0) {
+ return null;
+ }
+ FeeValueController controller = (FeeValueController) facesContext.getApplication().getELResolver().
+ getValue(facesContext.getELContext(), null, "feeValueController");
+ return controller.getEjbFacade().find(getKey(value));
+ }
+
+ java.lang.Long getKey(String value) {
+ return Long.valueOf(value);
+ }
+
+ String getStringKey(java.lang.Long value) {
+ return value.toString();
+ }
+
+ @Override
+ public String getAsString(FacesContext facesContext, UIComponent component, Object object) {
+ if (object == null) {
+ return null;
+ }
+ if (object instanceof FeeValue) {
+ FeeValue o = (FeeValue) object;
+ return getStringKey(o.getId());
+ } else {
+ throw new IllegalArgumentException("object " + object + " is of type " + object.getClass().getName() + "; expected type: " + FeeValue.class.getName());
+ }
+ }
+ }
+}
diff --git a/src/main/java/com/divudi/bean/common/InstitutionController.java b/src/main/java/com/divudi/bean/common/InstitutionController.java
index 9aaa57d819..a2bcfce79e 100644
--- a/src/main/java/com/divudi/bean/common/InstitutionController.java
+++ b/src/main/java/com/divudi/bean/common/InstitutionController.java
@@ -262,6 +262,11 @@ public List completeInstitution(String qry, InstitutionType type) {
public List completeCompany(String qry) {
return completeInstitution(qry, InstitutionType.Company);
}
+
+ public List completeSite(String qry) {
+ //Sites
+ return completeInstitution(qry, InstitutionType.Site);
+ }
public List completeCollectingCenter(String qry) {
return completeInstitution(qry, InstitutionType.CollectingCentre);
diff --git a/src/main/java/com/divudi/bean/common/ItemController.java b/src/main/java/com/divudi/bean/common/ItemController.java
index 671d7e528e..59cf5d4f27 100644
--- a/src/main/java/com/divudi/bean/common/ItemController.java
+++ b/src/main/java/com/divudi/bean/common/ItemController.java
@@ -35,7 +35,9 @@
import com.divudi.data.Sex;
import com.divudi.entity.UserPreference;
import com.divudi.facade.DepartmentFacade;
+import com.divudi.facade.InvestigationFacade;
import com.divudi.facade.ItemMappingFacade;
+import com.divudi.facade.ServiceFacade;
import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
@@ -75,8 +77,12 @@ public class ItemController implements Serializable {
@EJB
private ItemFacade itemFacade;
@EJB
+ private InvestigationFacade investigationFacade;
+ @EJB
private ItemFeeFacade itemFeeFacade;
@EJB
+ private ServiceFacade serviceFacade;
+ @EJB
ItemMappingFacade itemMappingFacade;
@EJB
DepartmentFacade departmentFacade;
@@ -575,23 +581,6 @@ public Item findItemByCode(String code) {
m.put("ret", false);
m.put("code", code);
Item item = getFacade().findFirstByJpql(jpql, m);
- if (item == null) {
- jpql = "select i "
- + " from Item i "
- + " where i.code=:code";
- m = new HashMap();
- m.put("code", code);
- item = getFacade().findFirstByJpql(jpql, m);
- if (item != null) {
- item.setRetired(false);
- getFacade().edit(item);
- } else {
- item = new Item();
- item.setName(code);
- item.setCode(code);
- getFacade().create(item);
- }
- }
return item;
}
@@ -713,6 +702,60 @@ public Item findAndCreateItemByName(String name, Department dept) {
return null;
}
}
+
+ public Investigation findAndCreateInvestigationByNameAndCode(String name, String code) {
+ try {
+ String jpql;
+ Map m = new HashMap();
+ jpql = "select i "
+ + " from Investigation i "
+ + " where i.retired=:ret "
+ + " and i.code=:code "
+ + " and i.name=:name";
+ m.put("ret", false);
+ m.put("name", name);
+ m.put("code", code);
+ Investigation item = investigationFacade.findFirstByJpql(jpql, m);
+ System.out.println("item = " + item);
+ if (item == null) {
+ item = new Investigation();
+ item.setName(name);
+ item.setCode(code);
+ getFacade().create(item);
+ }
+ System.out.println("findAndCreateItemByNameAndCode (item) = " + item.getId());
+ return item;
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ public Service findAndCreateServiceByNameAndCode(String name, String code) {
+ try {
+ String jpql;
+ Map m = new HashMap();
+ jpql = "select i "
+ + " from Service i "
+ + " where i.retired=:ret "
+ + " and i.code=:code "
+ + " and i.name=:name";
+ m.put("ret", false);
+ m.put("name", name);
+ m.put("code", code);
+ Service item = serviceFacade.findFirstByJpql(jpql, m);
+ System.out.println("item = " + item);
+ if (item == null) {
+ item = new Service();
+ item.setName(name);
+ item.setCode(code);
+ getFacade().create(item);
+ }
+ System.out.println("findAndCreateItemByNameAndCode (item) = " + item.getId());
+ return item;
+ } catch (Exception e) {
+ return null;
+ }
+ }
public Item findItemByName(String name, String code, Department dept) {
try {
@@ -915,7 +958,12 @@ public void fillMachineTests() {
JsfUtil.addErrorMessage("Select a machine");
return;
}
- String j = "select i from Item i where i.itemType=:t and i.machine=:m and i.retired=:r order by i.code";
+ String j = "select i "
+ + " from Item i "
+ + " where i.itemType=:t "
+ + " and i.machine=:m "
+ + " and i.retired=:r "
+ + " order by i.code";
Map m = new HashMap();
m.put("t", ItemType.AnalyzerTest);
m.put("m", machine);
diff --git a/src/main/java/com/divudi/bean/common/ItemFeeController.java b/src/main/java/com/divudi/bean/common/ItemFeeController.java
index 5f1fe9b97f..87e2100fc8 100644
--- a/src/main/java/com/divudi/bean/common/ItemFeeController.java
+++ b/src/main/java/com/divudi/bean/common/ItemFeeController.java
@@ -18,6 +18,8 @@
import com.divudi.facade.InvestigationFacade;
import com.divudi.facade.ItemFeeFacade;
import com.divudi.facade.StaffFacade;
+import java.io.IOException;
+import java.io.OutputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
@@ -31,6 +33,17 @@
import javax.faces.convert.FacesConverter;
import javax.inject.Inject;
import javax.inject.Named;
+import javax.servlet.http.HttpServletResponse;
+import org.apache.poi.ss.SpreadsheetVersion;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.Font;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.util.AreaReference;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.apache.poi.xssf.usermodel.XSSFTable;
+import org.apache.poi.xssf.usermodel.XSSFTableStyleInfo;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
/**
*
@@ -249,12 +262,29 @@ public List getFees(Item i) {
}
public ItemFee findItemFeeFromItemFeeId(Long id) {
+ if (id == null) {
+ return null;
+ }
return getItemFeeFacade().find(id);
}
+ public ItemFee findItemFeeFromItemFeeId(String id) {
+ if (id == null || id.isEmpty()) {
+ return null;
+ }
+ try {
+ Long longId = Long.parseLong(id);
+ return findItemFeeFromItemFeeId(longId);
+ } catch (NumberFormatException e) {
+ return null;
+ }
+ }
+
public List getCharges() {
return fees;
}
+
+
public void setCharges(List charges) {
this.fees = charges;
diff --git a/src/main/java/com/divudi/bean/common/ItemFeeManager.java b/src/main/java/com/divudi/bean/common/ItemFeeManager.java
index ccd1856f3c..8fc906d2ed 100644
--- a/src/main/java/com/divudi/bean/common/ItemFeeManager.java
+++ b/src/main/java/com/divudi/bean/common/ItemFeeManager.java
@@ -17,6 +17,8 @@
import com.divudi.bean.common.util.JsfUtil;
import com.divudi.entity.Category;
import com.divudi.entity.Institution;
+import java.io.IOException;
+import java.io.OutputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
@@ -26,8 +28,20 @@
import java.util.Objects;
import javax.ejb.EJB;
import javax.enterprise.context.SessionScoped;
+import javax.faces.context.FacesContext;
import javax.inject.Inject;
import javax.inject.Named;
+import javax.servlet.http.HttpServletResponse;
+import org.apache.poi.ss.SpreadsheetVersion;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.Font;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.util.AreaReference;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.apache.poi.xssf.usermodel.XSSFTable;
+import org.apache.poi.xssf.usermodel.XSSFTableStyleInfo;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
/**
*
@@ -47,10 +61,13 @@ public ItemFeeManager() {
ItemFee itemFee;
ItemFee removingFee;
private Institution collectingCentre;
+ private Institution forSite;
private Category feeListType;
List itemFees;
+ @Inject
+ FeeValueController feeValueController;
@EJB
ItemFeeFacade itemFeeFacade;
@EJB
@@ -72,6 +89,10 @@ public ItemFeeManager() {
private Double totalItemFee;
private Double totalItemFeeForForeigners;
+ public String navigateToInstitutionItemFeeUpload() {
+ return "/admin/pricing/institution_item_fee_upload?faces-redirect=true";
+ }
+
public String navigateItemFeeList() {
return "/admin/pricing/item_fee_list?faces-redirect=true";
}
@@ -87,15 +108,44 @@ public String navigateToCorrectItemFees() {
public String navigateToUploadItemFees() {
return "/admin/pricing/item_fee_upload?faces-redirect=true";
}
-
- public String navigateToUploadFeeListType(){
+
+ public String navigateToDownloadBaseItemFees() {
+ itemFees = new ArrayList<>();
+ return "/admin/pricing/download_base_item_fees?faces-redirect=true";
+ }
+
+ public String navigateToDownloadItemFeesForSites() {
+ itemFees = new ArrayList<>();
+ return "/admin/pricing/download_item_fees_for_sites?faces-redirect=true";
+ }
+
+ public String navigateToDownloadItemFeesForCollectingCentres() {
+ itemFees = new ArrayList<>();
+ return "/admin/pricing/download_item_fees_for_collecting_centres?faces-redirect=true";
+ }
+
+ public String navigateToUploadFeeListItemFees() {
+ return "";
+ }
+
+ public String navigateToDownloadItemFeesForLists() {
+ itemFees = new ArrayList<>();
+ return "/admin/pricing/download_item_fees_for_lists?faces-redirect=true";
+ }
+
+ public String navigateToUploadChangedItemFees() {
+ itemFees = new ArrayList<>();
+ return "/admin/pricing/upload_changed_item_fees?faces-redirect=true";
+ }
+
+ public String navigateToUploadFeeListType() {
return "/admin/pricing/feelist_type_upload?faces-redirect=true";
}
-
- public String navigateToUploadFeeListItemFees(){
+
+ public String navigateToUploadInstitutionItemFees() {
return "/admin/pricing/feelist_item_fees_upload?faces-redirect=true";
}
-
+
public String navigateToUploadCollectingCentreFeeList() {
return "/admin/pricing/collecting_centre_price_list_upload?faces-redirect=true";
}
@@ -108,6 +158,171 @@ public String navigateItemViseFeeList() {
return "/admin/pricing/manage_item_fees_bulk?faces-redirect=true";
}
+ public void fillBaseItemFees() {
+ itemFees = fillFees(null, null, null);
+ }
+
+ public void fillFeeListItemFees() {
+ itemFees = fillFees(null, null, feeListType);
+ }
+
+ public void fillSiteItemFees() {
+ itemFees = fillFees(null, forSite, null);
+ }
+
+ public void downloadBaseItemFeesAsExcel() throws IOException {
+ // Check if itemFees is null or empty
+ if (itemFees == null || itemFees.isEmpty()) {
+ JsfUtil.addErrorMessage("Please fill item fees first to download them.");
+ return;
+ }
+
+ // Create a workbook and a sheet
+ XSSFWorkbook workbook = new XSSFWorkbook();
+ XSSFSheet sheet = workbook.createSheet("Base Item Fees");
+
+ // Create the header row
+ Row headerRow = sheet.createRow(0);
+ String[] headers = {"ID", "Item Code", "Item Name", "Fee Name", "Fee Type", "Discount Allowed", "Retired", "Institution", "Department", "Staff", "Value for Locals", "Value for Foreigners"};
+
+ // Apply header formatting
+ CellStyle headerStyle = workbook.createCellStyle();
+ Font headerFont = workbook.createFont();
+ headerFont.setBold(true);
+ headerStyle.setFont(headerFont);
+
+ for (int i = 0; i < headers.length; i++) {
+ Cell headerCell = headerRow.createCell(i);
+ headerCell.setCellValue(headers[i]);
+ headerCell.setCellStyle(headerStyle);
+ }
+
+ // Fill the data into the sheet
+ int rowNum = 1;
+ for (ItemFee fee : itemFees) {
+ if (fee == null) {
+ continue; // Skip null entries
+ }
+
+ Row row = sheet.createRow(rowNum++);
+
+ // Lock all cells except fee, foreignFee, feeName, retired, and discountAllowed
+ boolean unlock = (rowNum - 1) > 0; // Avoid unlocking headers
+
+ // Null checks for each field to avoid NullPointerException
+ createLockedCell(row, 0, fee.getId(), unlock, workbook);
+
+ if (fee.getItem() != null) {
+ createLockedCell(row, 1, fee.getItem().getCode(), unlock, workbook);
+ createLockedCell(row, 2, fee.getItem().getName(), unlock, workbook);
+ } else {
+ createLockedCell(row, 1, "", unlock, workbook); // Fallback for null item code
+ createLockedCell(row, 2, "", unlock, workbook); // Fallback for null item name
+ }
+
+ createUnlockedCell(row, 3, fee.getName(), workbook); // Fee Name - Unlocked
+
+ if (fee.getFeeType() != null) {
+ createLockedCell(row, 4, fee.getFeeType().getLabel(), unlock, workbook);
+ } else {
+ createLockedCell(row, 4, "", unlock, workbook); // Fallback for null fee type
+ }
+
+ createUnlockedCell(row, 5, fee.isDiscountAllowed() ? "Yes" : "No", workbook); // Discount Allowed - Unlocked
+ createUnlockedCell(row, 6, fee.isRetired() ? "Yes" : "No", workbook); // Retired - Unlocked
+
+ if (fee.getInstitution() != null) {
+ createLockedCell(row, 7, fee.getInstitution().getName(), unlock, workbook);
+ } else {
+ createLockedCell(row, 7, "", unlock, workbook); // Fallback for null institution
+ }
+
+ if (fee.getDepartment() != null) {
+ createLockedCell(row, 8, fee.getDepartment().getName(), unlock, workbook);
+ } else {
+ createLockedCell(row, 8, "", unlock, workbook); // Fallback for null department
+ }
+
+ if (fee.getStaff() != null && fee.getStaff().getPerson() != null) {
+ createLockedCell(row, 9, fee.getStaff().getPerson().getNameWithTitle(), unlock, workbook);
+ } else {
+ createLockedCell(row, 9, "", unlock, workbook); // Fallback for null staff
+ }
+
+ createUnlockedCell(row, 10, fee.getFee(), workbook); // Value for Locals - Unlocked
+ createUnlockedCell(row, 11, fee.getFfee(), workbook); // Value for Foreigners - Unlocked
+ }
+
+ // Apply a table format, ensuring there are enough rows and columns for the table
+ if (rowNum > 1) { // Ensure there are rows beyond the header
+ AreaReference area = new AreaReference("A1:L" + rowNum, SpreadsheetVersion.EXCEL2007);
+ XSSFTable table = sheet.createTable(area);
+ table.setName("BaseItemFeesTable");
+ table.setDisplayName("BaseItemFeesTable");
+
+ // Set the table style, with a null check to avoid the NullPointerException
+ XSSFTableStyleInfo style = (XSSFTableStyleInfo) table.getStyle();
+ if (style != null) {
+ style.setName("TableStyleMedium9");
+ style.setShowColumnStripes(true);
+ style.setShowRowStripes(true);
+ } else {
+ // Optionally log or handle the case where the style is not applied
+ System.out.println("Table style could not be applied.");
+ }
+ } else {
+ // Log or handle the case where no data is present for the table
+ System.out.println("No data available to create a table.");
+ }
+
+ // Lock the sheet except for the unlocked cells
+ sheet.protectSheet("password"); // Replace with your desired password
+
+ // Write the output to the response
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
+ response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+ response.setHeader("Content-Disposition", "attachment; filename=\"base_item_fees.xlsx\"");
+ OutputStream outputStream = response.getOutputStream();
+ workbook.write(outputStream);
+ workbook.close();
+ outputStream.flush();
+ outputStream.close();
+
+ facesContext.responseComplete();
+ }
+
+// Method to create locked cells
+ private void createLockedCell(Row row, int column, Object value, boolean unlock, XSSFWorkbook workbook) {
+ Cell cell = row.createCell(column);
+ if (value instanceof String) {
+ cell.setCellValue((String) value);
+ } else if (value instanceof Number) {
+ cell.setCellValue(((Number) value).doubleValue());
+ }
+ CellStyle style = workbook.createCellStyle();
+ style.setLocked(!unlock); // Lock unless specified to unlock
+ cell.setCellStyle(style);
+ }
+
+// Method to create unlocked cells
+ private void createUnlockedCell(Row row, int column, Object value, XSSFWorkbook workbook) {
+ createLockedCell(row, column, value, true, workbook); // Call with unlock true
+ }
+
+ public void uploadToReplaceItemFees() {
+
+ itemFees = fillFees(null, null, null);
+ }
+
+ public void fillForCollectingCentreItemFees() {
+ itemFees = fillFees(null, collectingCentre, null);
+ }
+
+ public void fillForSiteItemFees() {
+ itemFees = fillFees(null, forSite, null);
+ }
+
public void createItemFessForSelectedItems() {
if (selectedList == null || selectedList.isEmpty()) {
JsfUtil.addErrorMessage("Nothing is selected");
@@ -225,17 +440,25 @@ public String navigateToItemFees() {
public String navigateToCollectingCentreItemFees() {
collectingCentre = null;
- item=null;
- feeListType=null;
- fillForInstitutionFees();
+ item = null;
+ feeListType = null;
+ fillForCollectingCentreFees();
return "/admin/pricing/manage_collecting_centre_item_fees?faces-redirect=true";
}
-
+
+ public String navigateToForSiteItemFees() {
+ collectingCentre = null;
+ item = null;
+ feeListType = null;
+ fillForCollectingCentreFees();
+ return "/admin/pricing/manage_for_site_item_fees?faces-redirect=true";
+ }
+
public String navigateToFeeListFees() {
collectingCentre = null;
- item=null;
- feeListType=null;
- fillForInstitutionFees();
+ item = null;
+ feeListType = null;
+ fillForCollectingCentreFees();
return "/admin/pricing/manage_fee_list_item_fees?faces-redirect=true";
}
@@ -285,7 +508,7 @@ public void fillFees() {
itemFees = fillFees(item);
}
- public void fillForInstitutionFees() {
+ public void fillForCollectingCentreFees() {
if (collectingCentre == null) {
itemFees = null;
totalItemFee = 0.0;
@@ -301,8 +524,31 @@ public void fillForInstitutionFees() {
.filter(Objects::nonNull)
.mapToDouble(ItemFee::getFfee)
.sum();
+
+ feeValueController.updateFeeValue(item, collectingCentre, totalItemFee, totalItemFeeForForeigners);
+
}
-
+
+ public void fillForSiteFees() {
+ if (forSite == null) {
+ itemFees = null;
+ totalItemFee = 0.0;
+ totalItemFeeForForeigners = 0.0;
+ return;
+ }
+ itemFees = fillFees(item, forSite);
+ totalItemFee = itemFees.stream()
+ .filter(Objects::nonNull)
+ .mapToDouble(ItemFee::getFee)
+ .sum();
+ totalItemFeeForForeigners = itemFees.stream()
+ .filter(Objects::nonNull)
+ .mapToDouble(ItemFee::getFfee)
+ .sum();
+ feeValueController.updateFeeValue(item, forSite, totalItemFee, totalItemFeeForForeigners);
+
+ }
+
public void fillForForCategoryFees() {
if (feeListType == null) {
itemFees = null;
@@ -342,10 +588,17 @@ public List fillFees(Item i, Category cat) {
return fillFees(i, null, cat);
}
- public List fillFees(Item i, Institution forInstitution, Category cat) {
- String jpql = "select f from ItemFee f where f.retired=false and f.item=:i";
+ public List fillFees(Item i, Institution forInstitution, Category forCategory) {
+ String jpql = "select f "
+ + " from ItemFee f "
+ + " where f.retired=:ret ";
Map m = new HashMap<>();
- m.put("i", i);
+ m.put("ret", false);
+
+ if (i != null) {
+ jpql += " and f.item=:i";
+ m.put("i", i);
+ }
if (forInstitution != null) {
jpql += " and f.forInstitution=:ins";
@@ -354,9 +607,9 @@ public List fillFees(Item i, Institution forInstitution, Category cat)
jpql += " and f.forInstitution is null";
}
- if (cat != null) {
+ if (forCategory != null) {
jpql += " and f.forCategory=:cat";
- m.put("cat", cat);
+ m.put("cat", forCategory);
} else {
jpql += " and f.forCategory is null";
}
@@ -460,16 +713,65 @@ public void addNewCollectingCentreFee() {
getItemFee().setCreater(sessionController.getLoggedUser());
getItemFee().setForInstitution(collectingCentre);
itemFeeFacade.create(itemFee);
-
getItemFee().setItem(item);
itemFeeFacade.edit(itemFee);
+ itemFee = new ItemFee();
+ itemFees = null;
+ fillForCollectingCentreFees();
+ JsfUtil.addSuccessMessage("New Fee Added for Collecting Centre");
+ }
+ public void addNewForSiteFee() {
+ if (forSite == null) {
+ JsfUtil.addErrorMessage("Select a Site ?");
+ return;
+ }
+ if (item == null) {
+ JsfUtil.addErrorMessage("Select an Item ?");
+ return;
+ }
+ if (itemFee == null) {
+ JsfUtil.addErrorMessage("Select Item Fee");
+ return;
+ }
+ if (itemFee.getName() == null || itemFee.getName().trim().equals("")) {
+ JsfUtil.addErrorMessage("Please Fill Fee Name");
+ return;
+ }
+
+ if (itemFee.getFeeType() == null) {
+ JsfUtil.addErrorMessage("Please Fill Fee Type");
+ return;
+ }
+
+ if (itemFee.getFeeType() == FeeType.OtherInstitution || itemFee.getFeeType() == FeeType.OwnInstitution || itemFee.getFeeType() == FeeType.Referral) {
+ if (itemFee.getDepartment() == null) {
+ JsfUtil.addErrorMessage("Please Select Department");
+ return;
+ }
+ }
+ if (itemFee.getFee() == 0.00) {
+ JsfUtil.addErrorMessage("Please Enter Local Fee Value");
+ return;
+ }
+
+ if (itemFee.getFfee() == 0.00) {
+ JsfUtil.addErrorMessage("Please Enter Foreign Fee Value");
+ return;
+ }
+ getItemFee().setCreatedAt(new Date());
+ getItemFee().setCreater(sessionController.getLoggedUser());
+ getItemFee().setForInstitution(forSite);
+ itemFeeFacade.create(itemFee);
+ getItemFee().setItem(item);
+ itemFeeFacade.edit(itemFee);
itemFee = new ItemFee();
itemFees = null;
- fillForInstitutionFees();
+
+ fillForSiteFees();
JsfUtil.addSuccessMessage("New Fee Added for Collecting Centre");
}
-
+
public void addNewFeeForFeeListType() {
if (feeListType == null) {
JsfUtil.addErrorMessage("Select Collecting Centre ?");
@@ -652,7 +954,13 @@ public Category getFeeListType() {
public void setFeeListType(Category feeListType) {
this.feeListType = feeListType;
}
-
-
+
+ public Institution getForSite() {
+ return forSite;
+ }
+
+ public void setForSite(Institution forSite) {
+ this.forSite = forSite;
+ }
}
diff --git a/src/main/java/com/divudi/bean/common/OpdPreBillController.java b/src/main/java/com/divudi/bean/common/OpdPreBillController.java
index 3bd2d8cd7c..11242b7e39 100644
--- a/src/main/java/com/divudi/bean/common/OpdPreBillController.java
+++ b/src/main/java/com/divudi/bean/common/OpdPreBillController.java
@@ -1284,11 +1284,21 @@ public void addToBill() {
// New Session
// getCurrentBillItem().setBillSession(getServiceSessionBean().createBillSession(getCurrentBillItem()));
lastBillItem = getCurrentBillItem();
+ boolean addAllBillFees = configOptionApplicationController.getBooleanValueByKey("OPD Bill Fees are the same for all departments, institutions and sites.", true);
+ boolean siteBasedBillFees = configOptionApplicationController.getBooleanValueByKey("OPD Bill Fees are based on the site", false);
BillEntry addingEntry = new BillEntry();
addingEntry.setBillItem(getCurrentBillItem());
addingEntry.setLstBillComponents(getBillBean().billComponentsFromBillItem(getCurrentBillItem()));
- addingEntry.setLstBillFees(getBillBean().billFeefromBillItem(getCurrentBillItem()));
-
+
+ if (addAllBillFees) {
+ addingEntry.setLstBillFees(getBillBean().billFeefromBillItem(getCurrentBillItem()));
+ } else if (siteBasedBillFees) {
+ addingEntry.setLstBillFees(getBillBean().forInstitutionBillFeefromBillItem(lastBillItem, sessionController.getDepartment().getSite()));
+ } else {
+ addingEntry.setLstBillFees(getBillBean().billFeefromBillItem(getCurrentBillItem()));
+ }
+
+
addStaffToBillFees(addingEntry.getLstBillFees());
addingEntry.setLstBillSessions(getBillBean().billSessionsfromBillItem(getCurrentBillItem()));
diff --git a/src/main/java/com/divudi/bean/common/SearchController.java b/src/main/java/com/divudi/bean/common/SearchController.java
index 8788245f80..5dc44fcc6f 100644
--- a/src/main/java/com/divudi/bean/common/SearchController.java
+++ b/src/main/java/com/divudi/bean/common/SearchController.java
@@ -7178,6 +7178,17 @@ public void searchOpdProfessionalPaymentBillFees() {
createTableByKeywordForBillFees(billTypesAtomics, institution, department, null, null, null, null, category);
}
+
+ public String searchOpdProfessionalPayments() {
+ List billTypesAtomics = new ArrayList<>();
+ billTypesAtomics.add(BillTypeAtomic.OPD_PROFESSIONAL_PAYMENT_BILL);
+ billTypesAtomics.add(BillTypeAtomic.OPD_PROFESSIONAL_PAYMENT_BILL_RETURN);
+ billTypesAtomics.add(BillTypeAtomic.PROFESSIONAL_PAYMENT_FOR_STAFF_FOR_OPD_SERVICES);
+ billTypesAtomics.add(BillTypeAtomic.PROFESSIONAL_PAYMENT_FOR_STAFF_FOR_OPD_SERVICES_RETURN);
+ createTableByKeywordForBillFee(billTypesAtomics, institution, department, null, null, null, null, staff);
+ createTableByKeywords(billTypesAtomics, institution, department, null, null, null, null, staff);
+ return "/opd/opd_doctor_payments_done";
+ }
public void listOpdBatcuBills() {
Date startTime = new Date();
@@ -7582,9 +7593,7 @@ public List listBillsLights(
@Deprecated
public void createTableByKeyword(BillType billType, Institution ins, Department dep) {
-
createTableByKeyword(billType, ins, dep, null, null, null, null);
-
}
public void createTableByKeyword(List billTypesAtomics,
@@ -7668,6 +7677,68 @@ public void createTableByKeyword(List billTypesAtomics,
}
+ public void createTableByKeywords(List billTypesAtomics,
+ Institution ins, Department dep,
+ Institution fromIns,
+ Department fromDep,
+ Institution toIns,
+ Department toDep,
+ Staff stf) {
+ bills = null;
+ String sql;
+ Map temMap = new HashMap();
+
+ sql = "select b "
+ + " from Bill b "
+ + " where b.billTypeAtomic in :billTypesAtomics "
+ + " and b.createdAt between :fromDate and :toDate "
+ + " and b.retired=false ";
+
+ if (ins != null) {
+ sql += " and b.institution=:ins ";
+ temMap.put("ins", ins);
+ }
+
+ if (dep != null) {
+ sql += " and b.department=:dep ";
+ temMap.put("dep", dep);
+ }
+
+ if (toDep != null) {
+ sql += " and b.toDepartment=:todep ";
+ temMap.put("todep", toDep);
+ }
+
+ if (fromDep != null) {
+ sql += " and b.fromDepartment=:fromdep ";
+ temMap.put("fromdep", fromDep);
+ }
+
+ if (fromIns != null) {
+ sql += " and b.fromInstitution=:fromins ";
+ temMap.put("fromins", fromIns);
+ }
+
+ if (toIns != null) {
+ sql += " and b.toInstitution=:toins ";
+ temMap.put("toins", toIns);
+ }
+
+ if (stf != null) {
+ sql += " and b.toStaff=:staff ";
+ temMap.put("staff", stf);
+ }
+
+ sql += " order by b.createdAt desc ";
+//
+ temMap.put("billTypesAtomics", billTypesAtomics);
+ temMap.put("toDate", getToDate());
+ temMap.put("fromDate", getFromDate());
+
+ bills = getBillFacade().findByJpql(sql, temMap, TemporalType.TIMESTAMP);
+
+ }
+
public void createTableByKeywordForBillFees(List billTypesAtomics,
Institution ins, Department dep,
Institution fromIns,
@@ -7763,6 +7834,78 @@ public void createTableByKeywordForBillFees(List billTypesAtomic
billFees = getBillFeeFacade().findByJpql(sql, temMap, TemporalType.TIMESTAMP);
System.out.println("Bill fees retrieved: " + billFees.size());
}
+
+ public void createTableByKeywordForBillFee(List billTypesAtomics,
+ Institution ins, Department dep,
+ Institution fromIns,
+ Department fromDep,
+ Institution toIns,
+ Department toDep,
+ Staff stf){
+ createTableByKeywordBillFee(billTypesAtomics, ins, dep, fromIns, fromDep, toIns, toDep, stf);
+ }
+
+ public void createTableByKeywordBillFee(List billTypesAtomics,
+ Institution ins, Department dep,
+ Institution fromIns,
+ Department fromDep,
+ Institution toIns,
+ Department toDep,
+ Staff stf) {
+
+ String sql;
+ Map temMap = new HashMap();
+
+ sql = "select bf "
+ + " from BillFee bf "
+ + " where bf.bill.billTypeAtomic in :billTypesAtomics "
+ + " and bf.bill.createdAt between :fromDate and :toDate "
+ + " and bf.bill.retired=false ";
+
+ if (ins != null) {
+ sql += " and bf.bill.institution=:ins ";
+ temMap.put("ins", ins);
+ }
+
+ if (dep != null) {
+ sql += " and bf.bill.department=:dep ";
+ temMap.put("dep", dep);
+ }
+
+ if (toDep != null) {
+ sql += " and bf.bill.toDepartment=:todep ";
+ temMap.put("todep", toDep);
+ }
+
+ if (fromDep != null) {
+ sql += " and bf.bill.fromDepartment=:fromdep ";
+ temMap.put("fromdep", fromDep);
+ }
+
+ if (fromIns != null) {
+ sql += " and bf.bill.fromInstitution=:fromins ";
+ temMap.put("fromins", fromIns);
+ }
+
+ if (toIns != null) {
+ sql += " and bf.bill.toInstitution=:toins ";
+ temMap.put("toins", toIns);
+ }
+
+ if (stf != null) {
+ sql += " and bf.bill.toStaff=:staff ";
+ temMap.put("staff", stf);
+ }
+
+ sql += " order by bf.bill.createdAt desc ";
+
+ temMap.put("billTypesAtomics", billTypesAtomics);
+ temMap.put("toDate", getToDate());
+ temMap.put("fromDate", getFromDate());
+
+ billFees = getBillFeeFacade().findByJpql(sql, temMap, TemporalType.TIMESTAMP);
+ System.out.println("Bill fees retrieved: " + billFees.size());
+ }
public void createTableByKeywordForBillsWithoutToStaff(List billTypesAtomics,
Institution ins, Department dep,
diff --git a/src/main/java/com/divudi/bean/common/SpecialityController.java b/src/main/java/com/divudi/bean/common/SpecialityController.java
index 2794af541e..97cb68131e 100644
--- a/src/main/java/com/divudi/bean/common/SpecialityController.java
+++ b/src/main/java/com/divudi/bean/common/SpecialityController.java
@@ -152,6 +152,10 @@ public List completeDoctorSpeciality(String qry) {
selectedItems = getFacade().findByJpql("select c from Speciality c where c.retired=false and type(c)=:class and (c.name) like '%" + qry.toUpperCase() + "%' order by c.name", m);
return selectedItems;
}
+
+ public List completeDoctorSpeciality() {
+ return completeDoctorSpeciality("");
+ }
public Speciality findSpeciality(String name, boolean createNewIfNotExists) {
String j;
diff --git a/src/main/java/com/divudi/bean/common/StoreController.java b/src/main/java/com/divudi/bean/common/StoreController.java
index 550bd69dea..842f456dd8 100644
--- a/src/main/java/com/divudi/bean/common/StoreController.java
+++ b/src/main/java/com/divudi/bean/common/StoreController.java
@@ -7,6 +7,7 @@
* (94) 71 5812399
*/
package com.divudi.bean.common;
+
import com.divudi.bean.common.util.JsfUtil;
import com.divudi.data.DepartmentType;
import com.divudi.entity.Department;
@@ -25,8 +26,8 @@
/**
*
- * @author Dr. M. H. B. Ariyaratne, MBBS, MSc, MD(Health Informatics)
- * Acting Consultant (Health Informatics)
+ * @author Dr. M. H. B. Ariyaratne, MBBS, MSc, MD(Health Informatics) Acting
+ * Consultant (Health Informatics)
*/
@Named
@SessionScoped
@@ -43,6 +44,35 @@ public class StoreController implements Serializable {
String selectText = "";
@EJB
StockFacade stockFacade;
+ private int storeTabIndex;
+
+ public String navigateToConsumableCategory() {
+ return "/store/consumable_category/List.xhtml?faces-redirect=true";
+ }
+
+ public String navigateToManageMakes() {
+ return "/store/make_list.xhtml?faces-redirect=true";
+ }
+
+ public String navigateToItemMaster() {
+ return "/store/store_item_master.xhtml?faces-redirect=true";
+ }
+
+ public String navigateToImportFromExcel() {
+ return "store_item_import.xhtml?faces-redirect=true";
+ }
+
+ public String navigateToImportWithStock() {
+ return "store_item_import_with_stock.xhtml?faces-redirect=true";
+ }
+
+ public String navigateToImportWithCategory() {
+ return "store_item_import_with_category.xhtml?faces-redirect=true";
+ }
+
+ public String navigateToManufacturers() {
+ return "/pharmacy/pharmacy_manufacturer.xhtml?faces-redirect=true";
+ }
public List getSelectedItems() {
selectedItems = getFacade().findByJpql("select c from Department c where c.retired=false and i.departmentType = com.divudi.data.DepartmentType.Store and (c.name) like '%" + getSelectText().toUpperCase() + "%' order by c.name");
@@ -102,7 +132,7 @@ public List completeAllStocks(String qry) {
return items;
}
-
+
public List completeAllStocksWithZero(String qry) {
List items;
String sql;
@@ -115,7 +145,7 @@ public List completeAllStocksWithZero(String qry) {
m.put("n", "%" + qry.toUpperCase() + "%");
sql = "select i from Stock i where i.department=:d "
+ " and i.itemBatch.item.departmentType=:dtp1"
-// + " and i.stock > :stk "
+ // + " and i.stock > :stk "
+ " and ((i.itemBatch.item.name) like :n or "
+ " (i.itemBatch.item.code) like :n or "
+ " (i.itemBatch.item.barcode) like :n ) "
@@ -196,4 +226,14 @@ public List getItems() {
}
return items;
}
+
+ public int getStoreTabIndex() {
+ return storeTabIndex;
+ }
+
+ public void setStoreTabIndex(int storeTabIndex) {
+ this.storeTabIndex = storeTabIndex;
+ }
+
+
}
diff --git a/src/main/java/com/divudi/bean/emr/DataUploadController.java b/src/main/java/com/divudi/bean/emr/DataUploadController.java
index 865d1f25d7..0dfb104181 100644
--- a/src/main/java/com/divudi/bean/emr/DataUploadController.java
+++ b/src/main/java/com/divudi/bean/emr/DataUploadController.java
@@ -21,6 +21,7 @@
import com.divudi.bean.common.DoctorSpecialityController;
import com.divudi.bean.common.EnumController;
import com.divudi.bean.common.FeeController;
+import com.divudi.bean.common.FeeValueController;
import com.divudi.bean.common.InstitutionController;
import com.divudi.bean.common.ItemController;
import com.divudi.bean.common.ItemFeeController;
@@ -116,6 +117,21 @@
import org.primefaces.model.StreamedContent;
import org.primefaces.model.file.UploadedFile;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.ss.util.AreaReference;
+import org.apache.poi.xssf.usermodel.XSSFTable;
+import org.apache.poi.xssf.usermodel.XSSFTableStyleInfo;
+
+import javax.faces.context.FacesContext;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.List;
+import org.apache.poi.ss.SpreadsheetVersion;
+
@Named
@ViewScoped
public class DataUploadController implements Serializable {
@@ -184,6 +200,8 @@ public class DataUploadController implements Serializable {
DoctorController doctorController;
@Inject
ClinicalEntityController clinicalEntityController;
+ @Inject
+ FeeValueController feeValueController;
@EJB
PatientFacade patientFacade;
@@ -194,6 +212,8 @@ public class DataUploadController implements Serializable {
@EJB
ItemFeeFacade itemFeeFacade;
@EJB
+ FeeFacade feeFacade;
+ @EJB
ItemFacade itemFacade;
@EJB
CategoryFacade categoryFacade;
@@ -209,6 +229,7 @@ public class DataUploadController implements Serializable {
private List suppliers;
private List departments;
private List areas;
+ private List routes;
private StreamedContent templateForItemWithFeeUpload;
private StreamedContent templateForCollectingCentreUpload;
private StreamedContent templateForsupplierUpload;
@@ -233,8 +254,6 @@ public class DataUploadController implements Serializable {
List departmentsSaved;
private List consultantsToSave;
private List creditCompanies;
- private List routes;
- private ListfeeListTypes;
private List doctorsTosave;
private List staffToSave;
@@ -245,9 +264,9 @@ public class DataUploadController implements Serializable {
private List surgeries;
private List surgeriesToSave;
private List surgeriesToSkiped;
-
-
- public String navigateToRouteUpload(){
+
+ public String navigateToRouteUpload() {
+ uploadComplete = false;
return "/admin/institutions/route_upload?faces-redirect=true";
}
@@ -260,28 +279,100 @@ public String navigateToDepartmentUpload() {
uploadComplete = false;
return "/admin/institutions/department_upload?faces-redirect=true";
}
-
+
public String navigateToSupplierUpload() {
uploadComplete = false;
- return "/admin/institutions/route_upload?faces-redirect=true";
+ return "/admin/institutions/supplier_upload?faces-redirect=true";
}
+ public void uploadRoutes() {
+ routes = new ArrayList<>();
+ if (file != null) {
+ try (InputStream inputStream = file.getInputStream()) {
+ System.out.println("inputStream = " + inputStream);
+ routes = readRoutesFromExcel(inputStream);
+ } catch (IOException e) {
+ e.printStackTrace();
+ uploadComplete = false;
+ JsfUtil.addErrorMessage("Error in Uploading. " + e.getMessage());
+ }
+ }
+ uploadComplete = true;
+ JsfUtil.addSuccessMessage("Successfully Uploaded");
+ }
+
+ private List readRoutesFromExcel(InputStream inputStream) throws IOException {
+ Workbook workbook = new XSSFWorkbook(inputStream);
+ Sheet sheet = workbook.getSheetAt(0);
+ Iterator
rowIterator = sheet.rowIterator();
+
+ List routes = new ArrayList<>();
+ Institution institution;
+
+ // Assuming the first row contains headers, skip it
+ if (rowIterator.hasNext()) {
+ rowIterator.next();
+ }
+
+ while (rowIterator.hasNext()) {
+ Row row = rowIterator.next();
+ Route route = null;
+
+ String routeCode=null;
+ String name = null;
+ String institutionName = null;
+
+ Cell routeCodeCell = row.getCell(0);
+ if (routeCodeCell != null && routeCodeCell.getCellType() == CellType.STRING) {
+ routeCode = routeCodeCell.getStringCellValue();
+ }
+
+ Cell nameCell = row.getCell(1);
+ if (nameCell != null && nameCell.getCellType() == CellType.STRING) {
+ name = nameCell.getStringCellValue();
+ }
+
+ Cell institutionCell = row.getCell(2);
+ if (institutionCell != null && institutionCell.getCellType() == CellType.STRING) {
+ institutionName = institutionCell.getStringCellValue();
+ }
+ if (institutionName == null || institutionName.trim().equals("")) {
+ institution = sessionController.getInstitution();
+ }
+ institution = institutionController.findAndSaveInstitutionByName(institutionName);
+
+ Route r = routeController.findRouteByName(name);
+ if (r == null) {
+ r = new Route();
+ r.setName(name);
+ r.setInstitution(institution);
+ r.setCreatedAt(new Date());
+ r.setCreater(sessionController.getLoggedUser());
+ routeController.save(r);
+ }
+ }
+
+ return routes;
+
+ }
+
+
public void uploadPatientAreas() {
areas = new ArrayList<>();
if (file != null) {
- try ( InputStream inputStream = file.getInputStream()) {
+ try (InputStream inputStream = file.getInputStream()) {
areas = readAreasFromExcel(inputStream);
} catch (IOException e) {
e.printStackTrace();
}
}
}
-
- public void uploadFeeListTypes() {
- feeListTypes = new ArrayList<>();
+
+ public void uploadInstitutionItemFees() {
+ itemFees = new ArrayList<>();
if (file != null) {
- try ( InputStream inputStream = file.getInputStream()) {
- feeListTypes = readFeeListTypesFromExcel(inputStream);
+ try (InputStream inputStream = file.getInputStream()) {
+ itemFees = readInstitutionItemFeeFromXcel(inputStream);
} catch (IOException e) {
e.printStackTrace();
}
@@ -411,14 +502,12 @@ public String toUploadAmpsMin() {
public String toUploadVmps() {
return "/pharmacy/admin/upload_vmps?faces-redirect=true";
}
-
-
public void uploadPatients() {
List patients;
if (file != null) {
- try ( InputStream inputStream = file.getInputStream()) {
+ try (InputStream inputStream = file.getInputStream()) {
patients = readPatientDataFromExcel(inputStream);
int i = 0;
for (Patient p : patients) {
@@ -439,7 +528,7 @@ public void uploadPatients() {
public void uploadVisits() {
if (file != null) {
- try ( InputStream inputStream = file.getInputStream()) {
+ try (InputStream inputStream = file.getInputStream()) {
readVisitDataFromExcel(inputStream);
} catch (IOException e) {
e.printStackTrace();
@@ -450,7 +539,7 @@ public void uploadVisits() {
public void uploadVtms() {
List vtms;
if (file != null) {
- try ( InputStream inputStream = file.getInputStream()) {
+ try (InputStream inputStream = file.getInputStream()) {
vtms = readVtmsFromExcel(inputStream);
for (Vtm v : vtms) {
vtmController.findAndSaveVtmByNameAndCode(v);
@@ -464,7 +553,7 @@ public void uploadVtms() {
public void uploadAtms() {
List atms;
if (file != null) {
- try ( InputStream inputStream = file.getInputStream()) {
+ try (InputStream inputStream = file.getInputStream()) {
atms = readAtmsFromExcel(inputStream);
for (Atm v : atms) {
atmController.findAndSaveAtmByNameAndCode(v, v.getVtm());
@@ -478,7 +567,7 @@ public void uploadAtms() {
public void uploadAmps() {
List amps;
if (file != null) {
- try ( InputStream inputStream = file.getInputStream()) {
+ try (InputStream inputStream = file.getInputStream()) {
readAmpsFromExcel(inputStream);
} catch (IOException e) {
e.printStackTrace();
@@ -489,7 +578,7 @@ public void uploadAmps() {
public void uploadItemsAndHospitalFees() {
items = new ArrayList<>();
if (file != null) {
- try ( InputStream inputStream = file.getInputStream()) {
+ try (InputStream inputStream = file.getInputStream()) {
items = readOpdItemsAndFeesFromExcel(inputStream);
} catch (IOException e) {
e.printStackTrace();
@@ -500,7 +589,7 @@ public void uploadItemsAndHospitalFees() {
public void uploadItemsAndDoctorFees() {
items = new ArrayList<>();
if (file != null) {
- try ( InputStream inputStream = file.getInputStream()) {
+ try (InputStream inputStream = file.getInputStream()) {
items = readOpdItemsAndDoctorFeesFromExcel(inputStream);
} catch (IOException e) {
e.printStackTrace();
@@ -511,7 +600,7 @@ public void uploadItemsAndDoctorFees() {
public void uploadSurgeries() {
surgeries = new ArrayList<>();
if (file != null) {
- try ( InputStream inputStream = file.getInputStream()) {
+ try (InputStream inputStream = file.getInputStream()) {
surgeries = readSurgeriesFromExcel(inputStream);
System.out.println("surgeries = " + surgeries.size());
} catch (IOException e) {
@@ -523,7 +612,7 @@ public void uploadSurgeries() {
public void uploadAddProfessionalFees() {
itemFees = new ArrayList<>();
if (file != null) {
- try ( InputStream inputStream = file.getInputStream()) {
+ try (InputStream inputStream = file.getInputStream()) {
itemFees = addProfessionalFeesFromExcel(inputStream);
} catch (IOException e) {
e.printStackTrace();
@@ -531,11 +620,22 @@ public void uploadAddProfessionalFees() {
}
}
+ public void uploadAddReplaceFeesFromId() {
+ itemFees = new ArrayList<>();
+ if (file != null) {
+ try (InputStream inputStream = file.getInputStream()) {
+ itemFees = replaceFeesFromExcel(inputStream);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
public void uploadCollectingCentreItemsAndFees() {
pollActive = true;
items = new ArrayList<>();
if (file != null) {
- try ( InputStream inputStream = file.getInputStream()) {
+ try (InputStream inputStream = file.getInputStream()) {
items = readCollectingCentreItemsAndFeesFromExcel(inputStream);
} catch (IOException e) {
e.printStackTrace();
@@ -548,7 +648,7 @@ public void uploadCollectingCentreSpecialFeeUpload() {
pollActive = true;
items = new ArrayList<>();
if (file != null) {
- try ( InputStream inputStream = file.getInputStream()) {
+ try (InputStream inputStream = file.getInputStream()) {
itemFees = readCollectingCentreSpecialFeeUploadFromExcel(inputStream);
} catch (IOException e) {
e.printStackTrace();
@@ -561,7 +661,7 @@ public void uploadOutSourceDepartmentItemsAndFees() {
pollActive = true;
items = new ArrayList<>();
if (file != null) {
- try ( InputStream inputStream = file.getInputStream()) {
+ try (InputStream inputStream = file.getInputStream()) {
items = readOutSourceDepartmentItemsAndFeesFromExcel(inputStream);
} catch (IOException e) {
e.printStackTrace();
@@ -575,7 +675,7 @@ public void uploadConsultants() {
pollActive = true;
items = new ArrayList<>();
if (file != null) {
- try ( InputStream inputStream = file.getInputStream()) {
+ try (InputStream inputStream = file.getInputStream()) {
consultantsToSave = readConsultantsFromExcel(inputStream);
} catch (IOException e) {
e.printStackTrace();
@@ -588,7 +688,7 @@ public void uploadDoctors() {
pollActive = true;
items = new ArrayList<>();
if (file != null) {
- try ( InputStream inputStream = file.getInputStream()) {
+ try (InputStream inputStream = file.getInputStream()) {
doctorsTosave = readDoctorsFromExcel(inputStream);
} catch (IOException e) {
e.printStackTrace();
@@ -601,7 +701,7 @@ public void uploadStaff() {
pollActive = true;
items = new ArrayList<>();
if (file != null) {
- try ( InputStream inputStream = file.getInputStream()) {
+ try (InputStream inputStream = file.getInputStream()) {
staffToSave = readStaffFromExcel(inputStream);
} catch (IOException e) {
e.printStackTrace();
@@ -609,181 +709,6 @@ public void uploadStaff() {
}
pollActive = false;
}
-
- public void uploadFeeListItemFees() {
- itemFees = new ArrayList<>();
- if (file != null) {
- try ( InputStream inputStream = file.getInputStream()) {
- itemFees = readFeeListItemFeesFromExcel(inputStream);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- }
-
- public List readFeeListTypesFromExcel(InputStream inputStream)throws IOException {
- List feeListTypes = new ArrayList<>();
- Workbook workbook = new XSSFWorkbook(inputStream);
- Sheet sheet = workbook.getSheetAt(0);
- Iterator rowIterator = sheet.rowIterator();
-
- if (rowIterator.hasNext()) {
- rowIterator.next();
- }
-
- Category category = null;
-
- while (rowIterator.hasNext()) {
- Row row = rowIterator.next();
-
-
- String feeListName = null;
- String description=null;
-
- Cell feeListNameCell = row.getCell(0);
- if (feeListNameCell != null && feeListNameCell.getCellType() == CellType.STRING) {
- feeListName = feeListNameCell.getStringCellValue();
- }
-
-
- if (feeListName != null || !feeListName.trim().equals("")) {
- category=categoryController.findCategoryByName(feeListName);
- }
-
- if (category == null) {
- category= new Category();
- category.setName(feeListName);
- category.setSymanticType(SymanticHyrachi.Fee_List_Type);
- category.setCreatedAt(new Date());
- category.setCreater(sessionController.getCurrent());
- categoryController.save(category);
- feeListTypes.add(category);
- }
-
- }
- JsfUtil.addSuccessMessage("FeeList Types Uploaded");
- return feeListTypes;
- }
-
- private List readFeeListItemFeesFromExcel(InputStream inputStream) throws IOException{
- List itemFees = new ArrayList<>();
- Workbook workbook = new XSSFWorkbook(inputStream);
- Sheet sheet = workbook.getSheetAt(0);
- Iterator rowIterator = sheet.rowIterator();
-
- // Assuming the first row contains headers, skip it
- if (rowIterator.hasNext()) {
- rowIterator.next();
- }
-
- while (rowIterator.hasNext()) {
- Row row = rowIterator.next();
- String itemCode=null;
- String itemName = null;
- String forCategoryName=null;
- String institutionName=null;
- String discountAllowed=null;
- String ffeeValue=null;
- String fffeeValue=null;
-
- boolean disAllowd;
- double fee=0.0;
- double ffee=0.0;
-
- Item item;
- Category category;
- Institution institution;
-
- Cell itemCodeCell = row.getCell(0);
- if (itemCodeCell != null && itemCodeCell.getCellType() == CellType.STRING) {
- itemCode = itemCodeCell.getStringCellValue();
- }
-
- Cell itemNameCell = row.getCell(1);
- if (itemNameCell != null && itemNameCell.getCellType() == CellType.STRING) {
- itemName = itemNameCell.getStringCellValue();
- }
-
- Cell forCategoryCell = row.getCell(2);
- if (forCategoryCell != null && forCategoryCell.getCellType() == CellType.STRING) {
- forCategoryName = forCategoryCell.getStringCellValue();
- }
-
- Cell institutionCell = row.getCell(3);
- if (institutionCell != null && institutionCell.getCellType() == CellType.STRING) {
- institutionName = forCategoryCell.getStringCellValue();
- }
-
- Cell feeCell = row.getCell(4);
- if (feeCell != null && feeCell.getCellType() == CellType.NUMERIC) {
- fee = feeCell.getNumericCellValue();
- }
-
- Cell ffeeCell = row.getCell(5);
- if (ffeeCell != null && ffeeCell.getCellType() == CellType.NUMERIC) {
- ffee = ffeeCell.getNumericCellValue();
- }
-
-
- Cell discountAllowedCell = row.getCell(6);
- if (discountAllowedCell != null && discountAllowedCell.getCellType() == CellType.STRING) {
- discountAllowed = discountAllowedCell.getStringCellValue();
- }
- if (discountAllowed!= null || !discountAllowed.trim().equals("")) {
- disAllowd=true;
- }else{
- disAllowd=false;
- }
-
- if (institutionName==null || institutionName.trim().equals("")) {
- institution=sessionController.getInstitution();
- }else{
- institution=institutionController.findAndSaveInstitutionByName(institutionName);
- }
-
-
- if (itemName == null || itemCode==null) {
- JsfUtil.addErrorMessage("Item Name and Item Code cannot be null.");
- return itemFees;
- }
-
- if (forCategoryName == null || forCategoryName.trim().equals("")) {
- JsfUtil.addErrorMessage("Fee List types cannot be null.");
- return itemFees;
- }
-
- category=categoryController.findCategoryByName(forCategoryName);
- if (category==null) {
- JsfUtil.addErrorMessage("Fee List type Not found.");
- return itemFees;
- }
-
- item= itemController.findItemByNameAndCode(itemName, itemCode);
- if (item==null) {
- JsfUtil.addErrorMessage("Item cannot be null.");
- return itemFees;
- }
- ItemFee Itemfee= new ItemFee();
- Itemfee.setCreatedAt(new Date());
- Itemfee.setName(forCategoryName);
- Itemfee.setCreater(sessionController.getLoggedUser());
- Itemfee.setForInstitution(null);
- Itemfee.setForCategory(category);
- Itemfee.setItem(item);
- Itemfee.setFeeType(FeeType.OwnInstitution);
- Itemfee.setInstitution(institution);
- Itemfee.setFee(fee);
- Itemfee.setFfee(ffee);
- Itemfee.setDiscountAllowed(disAllowd);
- itemFeeFacade.create(Itemfee);
-
-
- }
- JsfUtil.addSuccessMessage("Upload Success");
- return itemFees;
-
- }
private List readConsultantsFromExcel(InputStream inputStream) throws IOException {
List cons = new ArrayList<>();
@@ -1052,11 +977,11 @@ public List readStaffFromExcel(InputStream inputStream) throws IOExceptio
String branchName = null;
String acNo = null;
String bankName = null;
-
- Department department=null;
- Institution institution=null;
- Institution bank=null;
- Sex gender=null;
+
+ Department department = null;
+ Institution institution = null;
+ Institution bank = null;
+ Sex gender = null;
Cell epfNoCell = row.getCell(0);
if (epfNoCell != null) {
@@ -1095,7 +1020,7 @@ public List readStaffFromExcel(InputStream inputStream) throws IOExceptio
Cell sexCell = row.getCell(6);
if (sexCell != null && sexCell.getCellType() == CellType.STRING) {
sex = sexCell.getStringCellValue();
- gender=Sex.valueOf(sex);
+ gender = Sex.valueOf(sex);
}
Cell nicNoCell = row.getCell(7);
@@ -1105,34 +1030,34 @@ public List readStaffFromExcel(InputStream inputStream) throws IOExceptio
Cell dobCell = row.getCell(8);
-if (dobCell != null) {
- if (dobCell.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(dobCell)) {
- dob = dobCell.getDateCellValue();
- } else if (dobCell.getCellType() == CellType.STRING) {
- String dobString = dobCell.getStringCellValue();
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); // Adjust the date format as needed
- try {
- dob = dateFormat.parse(dobString);
- } catch (ParseException e) {
- dob = null;
- }
- }
-}
+ if (dobCell != null) {
+ if (dobCell.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(dobCell)) {
+ dob = dobCell.getDateCellValue();
+ } else if (dobCell.getCellType() == CellType.STRING) {
+ String dobString = dobCell.getStringCellValue();
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); // Adjust the date format as needed
+ try {
+ dob = dateFormat.parse(dobString);
+ } catch (ParseException e) {
+ dob = null;
+ }
+ }
+ }
Cell retiredCell = row.getCell(9);
-if (retiredCell != null) {
- if (retiredCell.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(retiredCell)) {
- retired = retiredCell.getDateCellValue();
- } else if (retiredCell.getCellType() == CellType.STRING) {
- String retiredString = retiredCell.getStringCellValue();
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
- try {
- retired = dateFormat.parse(retiredString);
- } catch (ParseException e) {
- retired = null;
- }
- }
-}
+ if (retiredCell != null) {
+ if (retiredCell.getCellType() == CellType.NUMERIC && DateUtil.isCellDateFormatted(retiredCell)) {
+ retired = retiredCell.getDateCellValue();
+ } else if (retiredCell.getCellType() == CellType.STRING) {
+ String retiredString = retiredCell.getStringCellValue();
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+ try {
+ retired = dateFormat.parse(retiredString);
+ } catch (ParseException e) {
+ retired = null;
+ }
+ }
+ }
Cell departmentCell = row.getCell(10);
if (departmentCell != null && departmentCell.getCellType() == CellType.STRING) {
@@ -1160,7 +1085,7 @@ public List readStaffFromExcel(InputStream inputStream) throws IOExceptio
bankName = bankCell.getStringCellValue();
}
if (bank != null) {
- bank=institutionController.findAndSaveInstitutionByName(bankName);
+ bank = institutionController.findAndSaveInstitutionByName(bankName);
bank.setInstitutionType(InstitutionType.Bank);
institutionController.save(bank);
}
@@ -1231,12 +1156,12 @@ public void saveDepartments() {
}
private List- readOpdItemsAndFeesFromExcel(InputStream inputStream) throws IOException {
+ System.out.println("readOpdItemsAndFeesFromExcel");
Workbook workbook = new XSSFWorkbook(inputStream);
Sheet sheet = workbook.getSheetAt(0);
Iterator
rowIterator = sheet.rowIterator();
itemsToSave = new ArrayList<>();
-// masterItemsToSave = new ArrayList<>();
itemFeesToSave = new ArrayList<>();
categoriesSaved = new ArrayList<>();
institutionsSaved = new ArrayList<>();
@@ -1244,395 +1169,260 @@ private List- readOpdItemsAndFeesFromExcel(InputStream inputStream) throws
itemsSkipped = new ArrayList<>();
Item item;
- // New running financial category
// Assuming the first row contains headers, skip it
if (rowIterator.hasNext()) {
rowIterator.next();
}
+ System.out.println("Reading rows from Excel...");
+
while (rowIterator.hasNext()) {
- Institution runningIns = null;
- Department runningDept = null;
- Category runningCategory = null;
- Category runningFinancialCategory = null;
+ Category category = null;
+ Category financialCategory = null;
+ Category feeList = null;
Row row = rowIterator.next();
- Category category;
- Category financialCategory; // New financial category
Institution institution;
Department department;
- InwardChargeType iwct = null;
-
+ String institutionName = null;
+ String departmentName = null;
String name = null;
- String comments = "";
- String printingName = null;
- String fullName = null;
String code = null;
+ Double hospitalFee = 0.0;
+ String feeName = "Hospital Fee";
+ String siteName = null; // New site column
+ String financialCategoryName = null;
String categoryName = null;
- String financialCategoryName = null; // New financial category name
- String institutionName = null;
- String departmentName = null;
- String inwardName = null;
+ String feeListName = null;
- String itemType = "Investigation";
- String feeName = "Hospital Fee";
- Double hospitalFee = 0.0;
+ System.out.println("Reading data from row " + row.getRowNum());
+ // Column 0: Name (Required)
+ Cell nameCell = row.getCell(0);
+ if (nameCell.getCellType() == CellType.STRING) {
+ name = nameCell.getStringCellValue();
+ System.out.println("Name: " + name);
+ if (name == null || name.trim().equals("")) {
+ System.out.println("Skipping row due to missing name.");
+ continue; // Skip row if name is missing
+ }
+ }
+
+ // Column 4: Category (Required)
+ Cell catCell = row.getCell(4);
+ if (catCell != null && catCell.getCellType() == CellType.STRING) {
+ categoryName = catCell.getStringCellValue();
+ System.out.println("Category Name: " + categoryName);
+ if (categoryName != null && !categoryName.trim().equals("")) {
+ category = categoryController.findCategoryByName(categoryName);
+ System.out.println("Category found: " + category);
+ }
+ }
+
+ // Column 5: Financial Category (Optional)
+ Cell fcatCell = row.getCell(5);
+ if (fcatCell != null && fcatCell.getCellType() == CellType.STRING) {
+ financialCategoryName = fcatCell.getStringCellValue();
+ System.out.println("Financial Category Name: " + financialCategoryName);
+ if (financialCategoryName != null && !financialCategoryName.trim().equals("")) {
+ financialCategory = categoryController.findCategoryByName(financialCategoryName);
+ System.out.println("Financial Category found: " + financialCategory);
+ }
+ }
+
+ // Column 6: Institution (Optional)
Cell insCell = row.getCell(6);
if (insCell != null && insCell.getCellType() == CellType.STRING) {
institutionName = insCell.getStringCellValue();
+ System.out.println("Institution Name: " + institutionName);
}
if (institutionName == null || institutionName.trim().equals("")) {
institutionName = sessionController.getInstitution().getName();
+ System.out.println("Using logged institution: " + institutionName);
}
- if (runningIns == null) {
- institution = institutionController.findAndSaveInstitutionByName(institutionName);
- institutionsSaved.add(institution);
- runningIns = institution;
- } else if (runningIns.getName().equals(institutionName)) {
- institution = runningIns;
- } else {
- institution = institutionController.findAndSaveInstitutionByName(institutionName);
- institutionsSaved.add(institution);
- runningIns = institution;
- }
-
+ // Column 7: Department (Optional)
Cell deptCell = row.getCell(7);
if (deptCell != null && deptCell.getCellType() == CellType.STRING) {
departmentName = deptCell.getStringCellValue();
+ System.out.println("Department Name: " + departmentName);
}
if (departmentName == null || departmentName.trim().equals("")) {
departmentName = sessionController.getDepartment().getName();
- }
- if (runningDept == null) {
- department = departmentController.findAndSaveDepartmentByName(departmentName, institution);
- runningDept = department;
- departmentsSaved.add(department);
- } else if (runningDept.getName().equals(departmentName)) {
- department = runningDept;
- } else {
- department = departmentController.getDefaultDepatrment(institution);
- runningDept = department;
- departmentsSaved.add(department);
+ System.out.println("Using logged department: " + departmentName);
}
- Cell nameCell = row.getCell(0);
- if (nameCell != null && nameCell.getCellType() == CellType.STRING) {
- name = nameCell.getStringCellValue();
- if (name == null || name.trim().equals("")) {
- continue;
- }
- }
-
- comments = name;
- name = CommonFunctions.sanitizeStringForDatabase(name);
-
- item = itemController.findItemByName(name, code, department);
- if (item != null) {
- itemsSkipped.add(item);
- continue;
- }
-
-// Item masterItem = itemController.findMasterItemByName(name);
- Cell printingNameCell = row.getCell(1);
- if (printingNameCell != null && printingNameCell.getCellType() == CellType.STRING) {
- printingName = printingNameCell.getStringCellValue();
- }
- if (printingName == null || printingName.trim().equals("")) {
- printingName = name;
- }
-
- Cell fullNameCell = row.getCell(2);
- if (fullNameCell != null && fullNameCell.getCellType() == CellType.STRING) {
- fullName = fullNameCell.getStringCellValue();
- }
- if (fullName == null || fullName.trim().equals("")) {
- fullName = name;
+ // Column 10: Fee Name (Optional, default "Hospital Fee")
+ Cell feeNameCell = row.getCell(10);
+ if (feeNameCell != null && feeNameCell.getCellType() == CellType.STRING) {
+ feeName = feeNameCell.getStringCellValue();
+ System.out.println("Fee Name: " + feeName);
}
- Cell codeCell = row.getCell(3);
- if (codeCell != null && codeCell.getCellType() == CellType.STRING) {
- code = codeCell.getStringCellValue();
- } else if (codeCell != null && codeCell.getCellType() == CellType.NUMERIC) {
- code = codeCell.getNumericCellValue() + "";
- }
- if (code == null || code.trim().equals("")) {
- code = serviceController.generateShortCode(name);
+ // Column 11: Hospital Fee (Optional, for logged institution and department)
+ Cell hospitalFeeTypeCell = row.getCell(11);
+ if (hospitalFeeTypeCell != null) {
+ hospitalFee = extractHospitalFee(hospitalFeeTypeCell);
+ System.out.println("Hospital Fee: " + hospitalFee);
}
- Cell categoryCell = row.getCell(4);
- if (categoryCell != null && categoryCell.getCellType() == CellType.STRING) {
- categoryName = categoryCell.getStringCellValue();
- }
- if (categoryName == null || categoryName.trim().equals("")) {
- continue;
+ // Column 12: Site or Collecting Centre (Optional)
+ Cell siteCell = row.getCell(12);
+ if (siteCell != null && siteCell.getCellType() == CellType.STRING) {
+ siteName = siteCell.getStringCellValue();
+ System.out.println("Site Name: " + siteName);
}
- if (runningCategory == null) {
- category = categoryController.findCategoryByName(categoryName);
- if (category == null) {
- category = new Category();
- category.setName(categoryName);
- categoryFacade.create(category);
- categoriesSaved.add(category);
- }
- runningCategory = category;
- } else if (runningCategory.getName() == null) {
- category = runningCategory;
- } else if (runningCategory.getName().equals(categoryName)) {
- category = runningCategory;
- } else {
- category = categoryController.findCategoryByName(categoryName);
- if (category == null) {
- category = new Category();
- category.setName(categoryName);
- categoryFacade.create(category);
- categoriesSaved.add(category);
+ // Column 13: Fee List (Optional)
+ Cell feeListCell = row.getCell(13);
+ if (feeListCell != null && feeListCell.getCellType() == CellType.STRING) {
+ feeListName = feeListCell.getStringCellValue();
+ System.out.println("Fee List Name: " + feeListName);
+ if (feeListName != null && !feeListName.trim().equals("")) {
+ feeList = categoryController.findCategoryByName(feeListName);
+ System.out.println("Fee List found: " + feeList);
}
- runningCategory = category;
}
- // Handle financial category
- Cell financialCategoryCell = row.getCell(5);
- if (financialCategoryCell != null && financialCategoryCell.getCellType() == CellType.STRING) {
- financialCategoryName = financialCategoryCell.getStringCellValue();
- }
- if (financialCategoryName == null || financialCategoryName.trim().equals("")) {
- financialCategoryName = "Default Financial Category"; // Default value if needed
- }
+ // Handle institution and department
+ institution = institutionController.findAndSaveInstitutionByName(institutionName);
+ System.out.println("Institution: " + institution);
+ department = departmentController.findAndSaveDepartmentByName(departmentName, institution);
+ System.out.println("Department: " + department);
- if (runningFinancialCategory == null) {
- financialCategory = categoryController.findCategoryByName(financialCategoryName);
- if (financialCategory == null) {
- financialCategory = new Category();
- financialCategory.setName(financialCategoryName);
- categoryFacade.create(financialCategory);
- categoriesSaved.add(financialCategory);
- }
- runningFinancialCategory = financialCategory;
- } else if (runningFinancialCategory.getName() == null) {
- financialCategory = runningFinancialCategory;
- } else if (runningFinancialCategory.getName().equals(financialCategoryName)) {
- financialCategory = runningFinancialCategory;
+ // Handle code and item lookup
+ code = row.getCell(3) != null ? row.getCell(3).getStringCellValue() : serviceController.generateShortCode(name);
+ System.out.println("Item Code: " + code);
+ item = itemController.findItemByCode(code);
+ if (item == null) {
+ System.out.println("Creating new item for code: " + code);
+ item = createItem(row, code, name, institution, department, category, financialCategory);
} else {
- financialCategory = categoryController.findCategoryByName(financialCategoryName);
- if (financialCategory == null) {
- financialCategory = new Category();
- financialCategory.setName(financialCategoryName);
- categoryFacade.create(financialCategory);
- categoriesSaved.add(financialCategory);
- }
- runningFinancialCategory = financialCategory;
+ System.out.println("Item found for code: " + code);
}
- Cell inwardCcCell = row.getCell(8);
- if (inwardCcCell != null && inwardCcCell.getCellType() == CellType.STRING) {
- inwardName = inwardCcCell.getStringCellValue();
- }
- if (inwardName != null && !inwardName.trim().equals("")) {
- iwct = enumController.getInaChargeType(inwardName);
- }
- if (iwct == null) {
- iwct = InwardChargeType.OtherCharges;
- }
-
- Cell feeNameCell = row.getCell(10);
- if (feeNameCell != null && feeNameCell.getCellType() == CellType.STRING) {
- feeName = feeNameCell.getStringCellValue();
- }
-
- Cell itemTypeCell = row.getCell(9);
- if (itemTypeCell != null && itemTypeCell.getCellType() == CellType.STRING) {
- itemType = itemTypeCell.getStringCellValue();
- }
- if (itemType == null || itemType.trim().equals("")) {
- itemType = "Investigation";
+ // Save or update the item
+ if (item.getId() == null) {
+ itemFacade.create(item);
+ System.out.println("Item created: " + item);
+ } else {
+ itemFacade.edit(item);
+ System.out.println("Item updated: " + item);
}
- if (itemType.equals("Service")) {
-// if (masterItem == null) {
-// masterItem = new Service();
-// masterItem.setName(name);
-// masterItem.setPrintName(printingName);
-// masterItem.setFullName(fullName);
-// masterItem.setCode(code);
-// masterItem.setCategory(category);
-// masterItem.setFinancialCategory(financialCategory);
-// masterItem.setIsMasterItem(true);
-// masterItem.setInwardChargeType(iwct);
-// masterItem.setCreater(sessionController.getLoggedUser());
-// masterItem.setCreatedAt(new Date());
-// masterItemsToSave.add(masterItem);
-// }
-
- Service service = new Service();
- service.setName(name);
- service.setPrintName(printingName);
- service.setFullName(fullName);
- service.setCode(code);
- service.setCategory(category);
- service.setFinancialCategory(financialCategory);
-// service.setMasterItemReference(masterItem);
- service.setInstitution(institution);
- service.setDepartment(department);
- service.setInwardChargeType(iwct);
- service.setCreater(sessionController.getLoggedUser());
- service.setCreatedAt(new Date());
- item = service;
- } else if (itemType.equals("Investigation")) {
-
-// if (masterItem == null) {
-// masterItem = new Investigation();
-// masterItem.setName(name);
-// masterItem.setPrintName(printingName);
-// masterItem.setFullName(fullName);
-// masterItem.setCode(code);
-// masterItem.setIsMasterItem(true);
-// masterItem.setCategory(category);
-// masterItem.setFinancialCategory(financialCategory);
-// masterItem.setInwardChargeType(iwct);
-// masterItem.setCreater(sessionController.getLoggedUser());
-// masterItem.setCreatedAt(new Date());
-// masterItemsToSave.add(masterItem);
-// }
- Investigation ix = new Investigation();
- ix.setName(name);
- ix.setPrintName(printingName);
- ix.setFullName(fullName);
- ix.setCode(code);
- ix.setCategory(category);
- ix.setFinancialCategory(financialCategory);
- ix.setInstitution(institution);
- ix.setDepartment(department);
- ix.setInwardChargeType(iwct);
-// ix.setMasterItemReference(masterItem);
- ix.setCreater(sessionController.getLoggedUser());
- ix.setCreatedAt(new Date());
- item = ix;
- } else if (itemType.equals("InwardService")) {
-
-// if (masterItem == null) {
-// masterItem = new Investigation();
-// masterItem.setName(name);
-// masterItem.setPrintName(printingName);
-// masterItem.setFullName(fullName);
-// masterItem.setCode(code);
-// masterItem.setIsMasterItem(true);
-// masterItem.setCategory(category);
-// masterItem.setFinancialCategory(financialCategory);
-// masterItem.setInwardChargeType(iwct);
-// masterItem.setCreater(sessionController.getLoggedUser());
-// masterItem.setCreatedAt(new Date());
-// masterItemsToSave.add(masterItem);
-// }
- InwardService iwdService = new InwardService();
- iwdService.setName(name);
- iwdService.setPrintName(printingName);
- iwdService.setFullName(fullName);
- iwdService.setCode(code);
- iwdService.setCategory(category);
- iwdService.setFinancialCategory(financialCategory);
- iwdService.setInstitution(institution);
- iwdService.setDepartment(department);
- iwdService.setInwardChargeType(iwct);
-// iwdService.setMasterItemReference(masterItem);
- iwdService.setCreater(sessionController.getLoggedUser());
- iwdService.setCreatedAt(new Date());
- item = iwdService;
- } else if (itemType.equals("Surgery")) {
-// if (masterItem == null) {
-// masterItem = new Service();
-// masterItem.setName(name);
-// masterItem.setPrintName(printingName);
-// masterItem.setFullName(fullName);
-// masterItem.setCode(code);
-// masterItem.setCategory(category);
-// masterItem.setFinancialCategory(financialCategory);
-// masterItem.setIsMasterItem(true);
-// masterItem.setInwardChargeType(iwct);
-// masterItem.setSymanticType(SymanticType.Therapeutic_Procedure);
-// masterItem.setCreater(sessionController.getLoggedUser());
-// masterItem.setCreatedAt(new Date());
-// masterItemsToSave.add(masterItem);
-// }
- ClinicalEntity cli = new ClinicalEntity();
- cli.setName(name);
- cli.setPrintName(printingName);
- cli.setFullName(fullName);
- cli.setCode(code);
- cli.setCategory(category);
- cli.setFinancialCategory(financialCategory);
-// cli.setMasterItemReference(masterItem);
- cli.setInstitution(institution);
- cli.setDepartment(department);
- cli.setInwardChargeType(iwct);
- cli.setSymanticType(SymanticType.Therapeutic_Procedure);
- cli.setCreater(sessionController.getLoggedUser());
- cli.setCreatedAt(new Date());
- item = cli;
- }
+ // Create and save the ItemFee object
+ ItemFee itf = new ItemFee();
+ itf.setName(feeName);
+ itf.setItem(item);
+ itf.setInstitution(institution);
+ itf.setDepartment(department);
+ itf.setFeeType(FeeType.OwnInstitution);
+ itf.setFee(hospitalFee);
+ itf.setFfee(hospitalFee);
+ itf.setCreatedAt(new Date());
+ itf.setCreater(sessionController.getLoggedUser());
+ itf.setForCategory(feeList);
- if (item == null) {
- continue;
+ if (siteName != null && !siteName.trim().isEmpty()) {
+ Institution siteInstitution = institutionController.findAndSaveInstitutionByName(siteName);
+ itf.setForInstitution(siteInstitution);
+ System.out.println("Set site institution for ItemFee: " + siteInstitution);
}
- Cell hospitalFeeTypeCell = row.getCell(11);
- if (hospitalFeeTypeCell != null) {
- if (hospitalFeeTypeCell.getCellType() == CellType.NUMERIC) {
- // If it's a numeric value
- hospitalFee = hospitalFeeTypeCell.getNumericCellValue();
- } else if (hospitalFeeTypeCell.getCellType() == CellType.FORMULA) {
- // If it's a formula, evaluate it
- Workbook wb = hospitalFeeTypeCell.getSheet().getWorkbook();
- CreationHelper createHelper = wb.getCreationHelper();
- FormulaEvaluator evaluator = createHelper.createFormulaEvaluator();
- CellValue cellValue = evaluator.evaluate(hospitalFeeTypeCell);
-
- // Check the type of the evaluated value
- if (cellValue.getCellType() == CellType.NUMERIC) {
- hospitalFee = cellValue.getNumberValue();
- } else {
- // Handle other types if needed
- }
- } else if (hospitalFeeTypeCell.getCellType() == CellType.STRING) {
- // If it's a numeric value
- String strhospitalFee = hospitalFeeTypeCell.getStringCellValue();
- hospitalFee = CommonFunctions.stringToDouble(strhospitalFee);
- }
-
- if (hospitalFee == null || hospitalFee < 0) {
- hospitalFee = 0.0;
- }
-
- ItemFee itf = new ItemFee();
- itf.setName(feeName);
- itf.setItem(item);
- itf.setInstitution(institution);
- itf.setDepartment(department);
- itf.setFeeType(FeeType.OwnInstitution);
- itf.setFee(hospitalFee);
- itf.setFfee(hospitalFee);
- itf.setCreatedAt(new Date());
- itf.setCreater(sessionController.getLoggedUser());
- // itemFeeFacade.create(itf);
- itemFeesToSave.add(itf);
+ if (itf.getId() == null) {
+ itemFeeFacade.create(itf);
+ System.out.println("ItemFee created: " + itf);
+ } else {
+ itemFeeFacade.edit(itf);
+ System.out.println("ItemFee updated: " + itf);
}
- item.setTotal(hospitalFee);
- item.setTotalForForeigner((hospitalFee) * 2);
- item.setDblValue(hospitalFee);
+ // Save the fee to the list
+ itemFeesToSave.add(itf);
itemsToSave.add(item);
+ System.out.println("Item and ItemFee added to save list.");
}
-// itemFacade.batchCreate(masterItemsToSave, 5000);
- itemFacade.batchCreate(itemsToSave, 5000);
- itemFeeFacade.batchCreate(itemFeesToSave, 10000);
-
+ workbook.close(); // Always close the workbook to prevent memory leaks
+ System.out.println("Finished reading and processing Excel data.");
return itemsToSave;
}
+ private Double extractHospitalFee(Cell hospitalFeeTypeCell) {
+ Double hospitalFee = 0.0;
+ if (hospitalFeeTypeCell.getCellType() == CellType.NUMERIC) {
+ hospitalFee = hospitalFeeTypeCell.getNumericCellValue();
+ } else if (hospitalFeeTypeCell.getCellType() == CellType.FORMULA) {
+ FormulaEvaluator evaluator = hospitalFeeTypeCell.getSheet().getWorkbook().getCreationHelper().createFormulaEvaluator();
+ CellValue cellValue = evaluator.evaluate(hospitalFeeTypeCell);
+ if (cellValue.getCellType() == CellType.NUMERIC) {
+ hospitalFee = cellValue.getNumberValue();
+ }
+ } else if (hospitalFeeTypeCell.getCellType() == CellType.STRING) {
+ hospitalFee = CommonFunctions.stringToDouble(hospitalFeeTypeCell.getStringCellValue());
+ }
+ return hospitalFee == null || hospitalFee < 0 ? 0.0 : hospitalFee;
+ }
+
+ private Item createItem(Row row, String code, String name, Institution institution, Department department) {
+ System.out.println("createItem = ");
+ String itemType = row.getCell(9) != null ? row.getCell(9).getStringCellValue() : "Investigation";
+ Item item = null;
+ System.out.println("itemType = " + itemType);
+ if (itemType.equals("Service")) {
+ item = new Service();
+ } else if (itemType.equals("Investigation")) {
+ item = new Investigation();
+ } else if (itemType.equals("InwardService")) {
+ item = new InwardService();
+ } else if (itemType.equals("Surgery")) {
+ item = new ClinicalEntity();
+ ((ClinicalEntity) item).setSymanticType(SymanticType.Therapeutic_Procedure);
+ }
+
+ if (item != null) {
+ item.setName(name);
+ item.setCode(code);
+ item.setInstitution(institution);
+ item.setDepartment(department);
+ item.setCreater(sessionController.getLoggedUser());
+ item.setCreatedAt(new Date());
+ }
+
+ return item;
+ }
+
+ private Item createItem(Row row, String code, String name, Institution institution, Department department, Category category, Category financialCategory) {
+ System.out.println("createItem = ");
+ String itemType = row.getCell(9) != null ? row.getCell(9).getStringCellValue() : "Investigation";
+ Item item = null;
+ System.out.println("itemType = " + itemType);
+ if (itemType.equals("Service")) {
+ item = new Service();
+ } else if (itemType.equals("Investigation")) {
+ item = new Investigation();
+ } else if (itemType.equals("InwardService")) {
+ item = new InwardService();
+ } else if (itemType.equals("Surgery")) {
+ item = new ClinicalEntity();
+ ((ClinicalEntity) item).setSymanticType(SymanticType.Therapeutic_Procedure);
+ }
+
+ if (item != null) {
+ item.setName(name);
+ item.setCode(code);
+ item.setInstitution(institution);
+ item.setDepartment(department);
+ item.setCategory(category);
+ item.setFinancialCategory(financialCategory);
+ item.setCreater(sessionController.getLoggedUser());
+ item.setCreatedAt(new Date());
+ }
+
+ return item;
+ }
+
private List
- readOpdItemsAndDoctorFeesFromExcel(InputStream inputStream) throws IOException {
Workbook workbook = new XSSFWorkbook(inputStream);
Sheet sheet = workbook.getSheetAt(0);
@@ -1740,7 +1530,7 @@ private List
- readOpdItemsAndDoctorFeesFromExcel(InputStream inputStream) t
continue;
}
}
-
+
name = CommonFunctions.sanitizeStringForDatabase(name);
item = itemController.findItemByCode(code);
@@ -1794,7 +1584,6 @@ private List
- readOpdItemsAndDoctorFeesFromExcel(InputStream inputStream) t
}
-
System.out.println("item = 2 " + item);
if (item != null) {
itemsSaved.add(item);
@@ -2017,45 +1806,156 @@ private List addProfessionalFeesFromExcel(InputStream inputStream) thro
FormulaEvaluator evaluator = createHelper.createFormulaEvaluator();
CellValue cellValue = evaluator.evaluate(professionalFeeCell);
- // Check the type of the evaluated value
+ // Check the type of the evaluated value
+ if (cellValue.getCellType() == CellType.NUMERIC) {
+ professionalFee = cellValue.getNumberValue();
+ } else {
+ // Handle other types if needed
+ }
+ } else if (professionalFeeCell.getCellType() == CellType.STRING) {
+ // If it's a numeric value
+ String strhospitalFee = professionalFeeCell.getStringCellValue();
+ professionalFee = CommonFunctions.stringToDouble(strhospitalFee);
+ }
+
+ // Rest of your code remains the same
+ ItemFee itf = new ItemFee();
+ itf.setName("Professional Fee");
+ itf.setItem(item);
+ itf.setFeeType(FeeType.Staff);
+ itf.setFee(professionalFee);
+ itf.setFfee(professionalFee);
+ itf.setCreatedAt(new Date());
+ itf.setCreater(sessionController.getLoggedUser());
+ itf.setSpeciality(speciality);
+ itf.setStaff(staff);
+ itemFeeFacade.create(itf);
+ itemFeesToSave.add(itf);
+ Double total = item.getTotal();
+ if (total == null) {
+ total = 0.0;
+ }
+
+ item.setTotal(total + professionalFee);
+ item.setTotalForForeigner((total + professionalFee) * 2);
+ item.setDblValue(total + professionalFee);
+ itemFacade.edit(item);
+ itemsToSave.add(item);
+
+ }
+
+ }
+ return itemFeesToSave;
+ }
+
+ private List replaceFeesFromExcel(InputStream inputStream) throws IOException {
+ Workbook workbook = new XSSFWorkbook(inputStream);
+ Sheet sheet = workbook.getSheetAt(0);
+ Iterator
rowIterator = sheet.rowIterator();
+
+ itemFeesToSave = new ArrayList<>();
+
+ // Assuming the first row contains headers, skip it
+ if (rowIterator.hasNext()) {
+ rowIterator.next();
+ }
+
+ while (rowIterator.hasNext()) {
+ Row row = rowIterator.next();
+ ItemFee fee = null; // Ensure fee is initialized correctly
+ String feeIdString = null;
+ String feeName = null;
+ Long feeIdLong = null;
+ Double feeValue = 0.0;
+ Double foreignFeeValue = 0.0;
+ boolean retired = false;
+ boolean discountAllowed = true;
+
+ // Column 0: Fee ID
+ Cell idCell = row.getCell(0);
+ if (idCell != null) {
+ if (idCell.getCellType() == CellType.STRING) {
+ feeIdString = idCell.getStringCellValue();
+ fee = itemFeeController.findItemFeeFromItemFeeId(feeIdString);
+ } else if (idCell.getCellType() == CellType.NUMERIC) {
+ feeIdLong = (long) idCell.getNumericCellValue();
+ fee = itemFeeController.findItemFeeFromItemFeeId(feeIdLong);
+ }
+ }
+
+ if (fee == null) {
+ continue; // Skip if fee not found
+ }
+
+ // Column 3: Fee Name
+ Cell feeNameCell = row.getCell(3);
+ if (feeNameCell != null && feeNameCell.getCellType() == CellType.STRING) {
+ feeName = feeNameCell.getStringCellValue();
+ }
+
+ // Column 10: Fee Value for Locals
+ Cell feeValueCell = row.getCell(10);
+ if (feeValueCell != null) {
+ if (feeValueCell.getCellType() == CellType.NUMERIC) {
+ feeValue = feeValueCell.getNumericCellValue();
+ } else if (feeValueCell.getCellType() == CellType.FORMULA) {
+ FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
+ CellValue cellValue = evaluator.evaluate(feeValueCell);
if (cellValue.getCellType() == CellType.NUMERIC) {
- professionalFee = cellValue.getNumberValue();
- } else {
- // Handle other types if needed
+ feeValue = cellValue.getNumberValue();
}
- } else if (professionalFeeCell.getCellType() == CellType.STRING) {
- // If it's a numeric value
- String strhospitalFee = professionalFeeCell.getStringCellValue();
- professionalFee = CommonFunctions.stringToDouble(strhospitalFee);
+ } else if (feeValueCell.getCellType() == CellType.STRING) {
+ feeValue = CommonFunctions.stringToDouble(feeValueCell.getStringCellValue());
}
+ }
- // Rest of your code remains the same
- ItemFee itf = new ItemFee();
- itf.setName("Professional Fee");
- itf.setItem(item);
- itf.setFeeType(FeeType.Staff);
- itf.setFee(professionalFee);
- itf.setFfee(professionalFee);
- itf.setCreatedAt(new Date());
- itf.setCreater(sessionController.getLoggedUser());
- itf.setSpeciality(speciality);
- itf.setStaff(staff);
- itemFeeFacade.create(itf);
- itemFeesToSave.add(itf);
- Double total = item.getTotal();
- if (total == null) {
- total = 0.0;
+ // Column 11: Fee Value for Foreigners
+ Cell foreignFeeValueCell = row.getCell(11);
+ if (foreignFeeValueCell != null) {
+ if (foreignFeeValueCell.getCellType() == CellType.NUMERIC) {
+ foreignFeeValue = foreignFeeValueCell.getNumericCellValue();
+ } else if (foreignFeeValueCell.getCellType() == CellType.FORMULA) {
+ FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
+ CellValue cellValue = evaluator.evaluate(foreignFeeValueCell);
+ if (cellValue.getCellType() == CellType.NUMERIC) {
+ foreignFeeValue = cellValue.getNumberValue();
+ }
+ } else if (foreignFeeValueCell.getCellType() == CellType.STRING) {
+ foreignFeeValue = CommonFunctions.stringToDouble(foreignFeeValueCell.getStringCellValue());
}
+ }
- item.setTotal(total + professionalFee);
- item.setTotalForForeigner((total + professionalFee) * 2);
- item.setDblValue(total + professionalFee);
- itemFacade.edit(item);
- itemsToSave.add(item);
+ // Column 6: Retired (Yes/No)
+ Cell retiredCell = row.getCell(6);
+ if (retiredCell != null && retiredCell.getCellType() == CellType.STRING) {
+ String retiredString = retiredCell.getStringCellValue();
+ retired = retiredString.equalsIgnoreCase("Yes");
+ }
+
+ // Column 5: Discount Allowed (Yes/No)
+ Cell discountAllowedCell = row.getCell(5);
+ if (discountAllowedCell != null && discountAllowedCell.getCellType() == CellType.STRING) {
+ String discountAllowedString = discountAllowedCell.getStringCellValue();
+ discountAllowed = discountAllowedString.equalsIgnoreCase("Yes");
+ }
+ // Update fee details
+ fee.setName(feeName);
+ fee.setFee(feeValue);
+ fee.setFfee(foreignFeeValue);
+ fee.setRetired(retired);
+ if (retired) {
+ fee.setRetiredAt(new Date());
+ fee.setRetirer(sessionController.getLoggedUser());
}
+ fee.setDiscountAllowed(discountAllowed);
+ // Save the fee
+ itemFeesToSave.add(fee);
+ feeFacade.edit(fee);
}
+
+ workbook.close(); // Always close the workbook to prevent memory leaks
return itemFeesToSave;
}
@@ -2967,7 +2867,7 @@ private List- readOutSourceDepartmentItemsAndFeesFromExcel(InputStream inpu
public void uploadCollectingCentres() {
collectingCentres = new ArrayList<>();
if (file != null) {
- try ( InputStream inputStream = file.getInputStream()) {
+ try (InputStream inputStream = file.getInputStream()) {
collectingCentres = readCollectingCentresFromExcel(inputStream);
} catch (IOException e) {
e.printStackTrace();
@@ -2978,11 +2878,11 @@ public void uploadCollectingCentres() {
uploadComplete = true;
JsfUtil.addSuccessMessage("Successfully Uploaded");
}
-
+
public void uploadSuppliers() {
suppliers = new ArrayList<>();
if (file != null) {
- try ( InputStream inputStream = file.getInputStream()) {
+ try (InputStream inputStream = file.getInputStream()) {
System.out.println("inputStream = " + inputStream);
suppliers = readSuppliersFromExcel(inputStream);
} catch (IOException e) {
@@ -2994,28 +2894,11 @@ public void uploadSuppliers() {
uploadComplete = true;
JsfUtil.addSuccessMessage("Successfully Uploaded");
}
-
- public void uploadRoutes() {
- routes = new ArrayList<>();
- if (file != null) {
- try ( InputStream inputStream = file.getInputStream()) {
- System.out.println("inputStream = " + inputStream);
- routes = readRoutesFromExcel(inputStream);
- } catch (IOException e) {
- e.printStackTrace();
- uploadComplete = false;
- JsfUtil.addErrorMessage("Error in Uploading. " + e.getMessage());
- }
- }
- uploadComplete = true;
- JsfUtil.addSuccessMessage("Successfully Uploaded");
- }
-
public void uploadDepartments() {
departments = new ArrayList<>();
if (file != null) {
- try ( InputStream inputStream = file.getInputStream()) {
+ try (InputStream inputStream = file.getInputStream()) {
departments = readDepartmentFromExcel(inputStream);
} catch (IOException e) {
e.printStackTrace();
@@ -3030,61 +2913,13 @@ public void uploadDepartments() {
public void uploadCreditCOmpanies() {
creditCompanies = new ArrayList<>();
if (file != null) {
- try ( InputStream inputStream = file.getInputStream()) {
+ try (InputStream inputStream = file.getInputStream()) {
creditCompanies = readCreditCOmpanyFromExcel(inputStream);
} catch (IOException e) {
e.printStackTrace();
}
}
}
-
- private List readRoutesFromExcel(InputStream inputStream) throws IOException{
- Workbook workbook = new XSSFWorkbook(inputStream);
- Sheet sheet = workbook.getSheetAt(0);
- Iterator
rowIterator = sheet.rowIterator();
-
- List routes = new ArrayList<>();
- Institution institution;
-
- // Assuming the first row contains headers, skip it
- if (rowIterator.hasNext()) {
- rowIterator.next();
- }
-
- while (rowIterator.hasNext()) {
- Row row = rowIterator.next();
- Route route = null;
- String name = null;
- String institutionName=null;
-
- Cell nameCell = row.getCell(0);
- if (nameCell != null && nameCell.getCellType() == CellType.STRING) {
- name = nameCell.getStringCellValue();
- }
-
- Cell institutionCell = row.getCell(1);
- if (institutionCell != null && institutionCell.getCellType() == CellType.STRING) {
- institutionName = institutionCell.getStringCellValue();
- }
- if (institutionName == null || institutionName.trim().equals("")) {
- institution=sessionController.getInstitution();
- }
- institution=institutionController.findAndSaveInstitutionByName(institutionName);
-
- Route r = routeController.findRouteByName(name);
- if(r==null){
- r = new Route();
- r.setName(name);
- r.setInstitution(institution);
- r.setCreatedAt(new Date());
- r.setCreater(sessionController.getLoggedUser());
- routeController.save(r);
- }
- }
-
- return routes;
-
- }
private List readCollectingCentresFromExcel(InputStream inputStream) throws IOException {
Workbook workbook = new XSSFWorkbook(inputStream);
@@ -3321,7 +3156,7 @@ private List readCollectingCentresFromExcel(InputStream inputStream
return collectingCentresList;
}
-
+
private List readSuppliersFromExcel(InputStream inputStream) throws IOException {
Workbook workbook = new XSSFWorkbook(inputStream);
Sheet sheet = workbook.getSheetAt(0);
@@ -3344,52 +3179,44 @@ private List readSuppliersFromExcel(InputStream inputStream) throws
String supplierPrintingName = null;
String phone = null;
String email = null;
- String fax=null;
- String web=null;
- String mobilenumber=null;
+ String fax = null;
+ String web = null;
+ String mobilenumber = null;
String ownerName = null;
String address = null;
-
-
+
Cell faxCell = row.getCell(5);
if (faxCell != null && faxCell.getCellType() == CellType.STRING) {
fax = faxCell.getStringCellValue();
}
-
-
Cell emailCell = row.getCell(6);
if (emailCell != null && emailCell.getCellType() == CellType.STRING) {
email = emailCell.getStringCellValue();
}
-
-
Cell webCell = row.getCell(7);
if (webCell != null && webCell.getCellType() == CellType.STRING) {
web = webCell.getStringCellValue();
}
-
Cell mobCell = row.getCell(8);
if (mobCell != null && mobCell.getCellType() == CellType.STRING) {
mobilenumber = mobCell.getStringCellValue();
}
-
Cell codeCell = row.getCell(0);
if (codeCell != null && codeCell.getCellType() == CellType.STRING) {
code = codeCell.getStringCellValue();
}
-
// Item masterItem = itemController.findMasterItemByName(code);
Cell agentNameCell = row.getCell(1);
if (agentNameCell != null && agentNameCell.getCellType() == CellType.STRING) {
supplierName = agentNameCell.getStringCellValue();
}
-
+
Cell agentPrintingNameCell = row.getCell(2);
if (agentPrintingNameCell != null && agentPrintingNameCell.getCellType() == CellType.STRING) {
@@ -3423,7 +3250,7 @@ private List readSuppliersFromExcel(InputStream inputStream) throws
if (phone == null || phone.trim().equals("")) {
phone = null;
}
-
+
Cell ownerNameCell = row.getCell(9);
if (ownerNameCell != null && ownerNameCell.getCellType() == CellType.STRING) {
@@ -3442,7 +3269,7 @@ private List readSuppliersFromExcel(InputStream inputStream) throws
}
supplier = institutionController.findAndSaveInstitutionByCode(code);
-
+
if (supplier == null) {
supplier = new Institution();
}
@@ -3465,8 +3292,8 @@ private List readSuppliersFromExcel(InputStream inputStream) throws
return suppliersList;
}
-
- private List readCollectingCentrePriceListFromXcel(InputStream inputStream) throws IOException {
+
+ private List readCollectingCentrePriceListFromXcel(InputStream inputStream) throws IOException {
Workbook workbook = new XSSFWorkbook(inputStream);
Sheet sheet = workbook.getSheetAt(0);
Iterator rowIterator = sheet.rowIterator();
@@ -3481,18 +3308,21 @@ private List readCollectingCentrePriceListFromXcel(InputStream inputStr
Department runningDept = null;
while (rowIterator.hasNext()) {
Row row = rowIterator.next();
- Institution institution;
+ Institution institution;
Department department;
- Item item=null;
- String departmentName=null;
+ Item item = null;
Category category = null;
+
+ String departmentName = null;
+
String institutionName = null;
- String itemCode =null;
- String itemName=null;
- String feeListType=null;
- Double price=0.0;
-
- Cell insCell = row.getCell(4);
+ String itemCode = null;
+ String itemName = null;
+ String itemTypeName = null;
+ String feeListType = null;
+ Double price = 0.0;
+
+ Cell insCell = row.getCell(5);
if (insCell != null && insCell.getCellType() == CellType.STRING) {
institutionName = insCell.getStringCellValue();
}
@@ -3508,8 +3338,8 @@ private List readCollectingCentrePriceListFromXcel(InputStream inputStr
institution = institutionController.findAndSaveInstitutionByName(institutionName);
runningIns = institution;
}
-
- Cell deptCell = row.getCell(5);
+
+ Cell deptCell = row.getCell(6);
if (deptCell != null && deptCell.getCellType() == CellType.STRING) {
departmentName = deptCell.getStringCellValue();
}
@@ -3525,14 +3355,13 @@ private List readCollectingCentrePriceListFromXcel(InputStream inputStr
department = departmentController.getDefaultDepatrment(institution);
runningDept = department;
}
-
+
// Column A: Department Code (Required)
Cell itemCodeCell = row.getCell(0);
if (itemCodeCell != null && itemCodeCell.getCellType() == CellType.STRING) {
itemCode = itemCodeCell.getStringCellValue();
}
if (itemCode != null) {
- item=itemController.findItemByCode(itemCode);
}
if (itemCode == null || itemCode.trim().isEmpty()) {
continue;
@@ -3547,24 +3376,48 @@ private List readCollectingCentrePriceListFromXcel(InputStream inputStr
continue;
}
+ Cell itemTypeCell = row.getCell(3);
+ if (itemTypeCell != null && itemTypeCell.getCellType() == CellType.STRING) {
+ itemTypeName = itemTypeCell.getStringCellValue();
+ }
+
+ if (itemTypeName != null) {
+ switch (itemTypeName) {
+ case "Investigation":
+ item = itemController.findAndCreateInvestigationByNameAndCode(itemName, itemCode);
+ System.out.println("itemTypeCell = " + itemTypeName);
+ break;
+
+ case "Service":
+ item = itemController.findAndCreateServiceByNameAndCode(itemName, itemCode);
+ System.out.println("itemTypeCell = " + itemTypeName);
+ break;
+
+ default:
+ throw new AssertionError();
+ }
+ }
+
// Column C: Bill Prefix (Optional)
- Cell priceCell = row.getCell(3);
+ Cell priceCell = row.getCell(4);
if (priceCell != null && priceCell.getCellType() == CellType.NUMERIC) {
price = priceCell.getNumericCellValue();
}
-
+
Cell itemFeeListCell = row.getCell(2);
if (itemFeeListCell != null && itemFeeListCell.getCellType() == CellType.STRING) {
feeListType = itemFeeListCell.getStringCellValue();
}
if (feeListType != null) {
- System.out.println("itemFeeListCell = " + feeListType);
- category=categoryController.findAndCreateCategoryByName(feeListType);
- category.setSymanticType(SymanticHyrachi.Fee_List_Type);
+ category = categoryController.findAndCreateCategoryByName(feeListType);
+ if (category.getSymanticType() == SymanticHyrachi.Fee_List_Type) {
+ category.setSymanticType(SymanticHyrachi.Fee_List_Type);
+ }
categoryFacade.edit(category);
}
-
- ItemFee fee=new ItemFee();
+
+ ItemFee fee = new ItemFee();
+ fee.setName(itemName);
fee.setCreatedAt(new Date());
fee.setCreater(sessionController.getLoggedUser());
fee.setForInstitution(null);
@@ -3573,12 +3426,151 @@ private List readCollectingCentrePriceListFromXcel(InputStream inputStr
fee.setFee(price);
fee.setInstitution(institution);
fee.setDepartment(department);
+ fee.setFeeType(FeeType.OwnInstitution);
itemFeeFacade.create(fee);
-
+ System.out.println("fee = " + fee.getId());
+
}
-
return itemFees;
+ }
+
+ private List readInstitutionItemFeeFromXcel(InputStream inputStream) throws IOException {
+ Workbook workbook = new XSSFWorkbook(inputStream);
+ Sheet sheet = workbook.getSheetAt(0);
+ Iterator rowIterator = sheet.rowIterator();
+
+ itemFees = new ArrayList<>();
+
+ // Assuming the first row contains headers, skip it
+ if (rowIterator.hasNext()) {
+ rowIterator.next();
+ }
+ Institution runningIns = null;
+ Department runningDept = null;
+ while (rowIterator.hasNext()) {
+ Row row = rowIterator.next();
+ Institution institution;
+ Department department;
+ Item item = null;
+ Institution forInstitution = null;
+
+ String departmentName = null;
+
+ String institutionName = null;
+ String itemCode = null;
+ String itemName = null;
+ String itemTypeName = null;
+ String feeListType = null;
+ Double price = 0.0;
+ String forInstitutionName = null;
+
+ Cell insCell = row.getCell(5);
+ if (insCell != null && insCell.getCellType() == CellType.STRING) {
+ institutionName = insCell.getStringCellValue();
+ }
+ if (institutionName == null || institutionName.trim().equals("")) {
+ institutionName = "Other";
+ }
+ if (runningIns == null) {
+ institution = institutionController.findAndSaveInstitutionByName(institutionName);
+ runningIns = institution;
+ } else if (runningIns.getName().equals(institutionName)) {
+ institution = runningIns;
+ } else {
+ institution = institutionController.findAndSaveInstitutionByName(institutionName);
+ runningIns = institution;
+ }
+
+ Cell deptCell = row.getCell(6);
+ if (deptCell != null && deptCell.getCellType() == CellType.STRING) {
+ departmentName = deptCell.getStringCellValue();
+ }
+ if (departmentName == null || departmentName.trim().equals("")) {
+ departmentName = institutionName;
+ }
+ if (runningDept == null) {
+ department = departmentController.findAndSaveDepartmentByName(departmentName);
+ runningDept = department;
+ } else if (runningDept.getName().equals(departmentName)) {
+ department = runningDept;
+ } else {
+ department = departmentController.getDefaultDepatrment(institution);
+ runningDept = department;
+ }
+
+ // Column A: Department Code (Required)
+ Cell itemCodeCell = row.getCell(0);
+ if (itemCodeCell != null && itemCodeCell.getCellType() == CellType.STRING) {
+ itemCode = itemCodeCell.getStringCellValue();
+ }
+ if (itemCode != null) {
+ }
+ if (itemCode == null || itemCode.trim().isEmpty()) {
+ continue;
+ }
+
+ // Column B: Department Name (Required)
+ Cell itemNameCell = row.getCell(1);
+ if (itemNameCell != null && itemNameCell.getCellType() == CellType.STRING) {
+ itemName = itemNameCell.getStringCellValue();
+ }
+ if (itemName == null || itemName.trim().isEmpty()) {
+ continue;
+ }
+
+ Cell itemTypeCell = row.getCell(3);
+ if (itemTypeCell != null && itemTypeCell.getCellType() == CellType.STRING) {
+ itemTypeName = itemTypeCell.getStringCellValue();
+ }
+
+ if (itemTypeName != null) {
+ switch (itemTypeName) {
+ case "Investigation":
+ item = itemController.findAndCreateInvestigationByNameAndCode(itemName, itemCode);
+ System.out.println("itemTypeCell = " + itemTypeName);
+ break;
+ case "Service":
+ item = itemController.findAndCreateServiceByNameAndCode(itemName, itemCode);
+ System.out.println("itemTypeCell = " + itemTypeName);
+ break;
+
+ default:
+ throw new AssertionError();
+ }
+ }
+
+ // Column C: Bill Prefix (Optional)
+ Cell priceCell = row.getCell(4);
+ if (priceCell != null && priceCell.getCellType() == CellType.NUMERIC) {
+ price = priceCell.getNumericCellValue();
+ }
+
+ Cell forInstitutionCell = row.getCell(2);
+ if (forInstitutionCell != null && forInstitutionCell.getCellType() == CellType.STRING) {
+ forInstitutionName = forInstitutionCell.getStringCellValue();
+ }
+ if (forInstitutionName != null) {
+ forInstitution = institutionController.findAndSaveInstitutionByName(forInstitutionName);
+ System.out.println("forInstitution = " + forInstitution);
+ }
+
+ ItemFee fee = new ItemFee();
+ fee.setName(itemName);
+ fee.setCreatedAt(new Date());
+ fee.setCreater(sessionController.getLoggedUser());
+ fee.setForInstitution(forInstitution);
+ fee.setForCategory(null);
+ fee.setItem(item);
+ fee.setFee(price);
+ fee.setInstitution(institution);
+ fee.setDepartment(department);
+ fee.setFeeType(FeeType.OwnInstitution);
+ itemFeeFacade.create(fee);
+ System.out.println("fee = " + fee.getId());
+
+ }
+ return itemFees;
}
private List readDepartmentFromExcel(InputStream inputStream) throws IOException {
@@ -3808,31 +3800,29 @@ private List readCreditCOmpanyFromExcel(InputStream inputStream) th
public void uploadItemFeesToUpdateFees() {
itemFees = new ArrayList<>();
if (file != null) {
- try ( InputStream inputStream = file.getInputStream()) {
+ try (InputStream inputStream = file.getInputStream()) {
itemFees = replaceItemFeesFromExcel(inputStream);
} catch (IOException e) {
e.printStackTrace();
}
}
}
-
+
public void uploadCollectingCentrePriceList() {
itemFees = new ArrayList<>();
if (file != null) {
- try ( InputStream inputStream = file.getInputStream()) {
+ try (InputStream inputStream = file.getInputStream()) {
itemFees = readCollectingCentrePriceListFromXcel(inputStream);
} catch (IOException e) {
e.printStackTrace();
}
}
}
-
-
public void uploadInvestigations() {
List investigations;
if (file != null) {
- try ( InputStream inputStream = file.getInputStream()) {
+ try (InputStream inputStream = file.getInputStream()) {
readInvestigationsFromExcel(inputStream);
} catch (IOException e) {
e.printStackTrace();
@@ -3857,7 +3847,7 @@ public void uploadVmps() {
outputString += "uploadVmps\n";
List vmps;
if (file != null) {
- try ( InputStream inputStream = file.getInputStream()) {
+ try (InputStream inputStream = file.getInputStream()) {
vmps = readVmpsFromExcel(inputStream);
} catch (IOException e) {
e.printStackTrace();
@@ -5523,7 +5513,7 @@ public StreamedContent getTemplateForCollectingCentreUpload() {
}
return templateForCollectingCentreUpload;
}
-
+
public StreamedContent getTemplateForSupplierUpload() {
try {
createTemplateForSupplierUpload();
@@ -5566,7 +5556,7 @@ public void createTemplateForCollectingCentreUpload() throws IOException {
.stream(() -> inputStream)
.build();
}
-
+
public void createTemplateForSupplierUpload() throws IOException {
XSSFWorkbook workbook = new XSSFWorkbook();
@@ -5575,7 +5565,7 @@ public void createTemplateForSupplierUpload() throws IOException {
// Create header row in data sheet
Row headerRow = dataSheet.createRow(0);
- String[] columnHeaders = {"Code", "Supplier Name", "Supplier Printing Name", "Active","Supplier Contact No","Fax", "Email Address","web","mobile no","Owner Name","Agent Address"};
+ String[] columnHeaders = {"Code", "Supplier Name", "Supplier Printing Name", "Active", "Supplier Contact No", "Fax", "Email Address", "web", "mobile no", "Owner Name", "Agent Address"};
for (int i = 0; i < columnHeaders.length; i++) {
Cell cell = headerRow.createCell(i);
cell.setCellValue(columnHeaders[i]);
@@ -5793,12 +5783,4 @@ public void setRoutes(List routes) {
this.routes = routes;
}
- public List getFeeListTypes() {
- return feeListTypes;
- }
-
- public void setFeeListTypes(List feeListTypes) {
- this.feeListTypes = feeListTypes;
- }
-
}
diff --git a/src/main/java/com/divudi/bean/inward/InwardStaffPaymentBillController.java b/src/main/java/com/divudi/bean/inward/InwardStaffPaymentBillController.java
index 50160ed43a..23db46c637 100644
--- a/src/main/java/com/divudi/bean/inward/InwardStaffPaymentBillController.java
+++ b/src/main/java/com/divudi/bean/inward/InwardStaffPaymentBillController.java
@@ -923,7 +923,7 @@ public void setTotalPaying(double totalPaying) {
this.totalPaying = totalPaying;
}
- public void calculateDueFees() {
+ public String calculateDueFees() {
dueBillFees = new ArrayList<>();
payingBillFees = new ArrayList<>();
@@ -964,6 +964,7 @@ public void calculateDueFees() {
}
dueBillFees.removeAll(removeingBillFees);
calculateTotalPay();
+ return "/inward/inward_bill_staff_payment";
}
public void calculateTotalDue() {
diff --git a/src/main/java/com/divudi/bean/lab/InvestigationCategoryController.java b/src/main/java/com/divudi/bean/lab/InvestigationCategoryController.java
index 7aa222fc6d..53dc4cbd1d 100644
--- a/src/main/java/com/divudi/bean/lab/InvestigationCategoryController.java
+++ b/src/main/java/com/divudi/bean/lab/InvestigationCategoryController.java
@@ -68,6 +68,7 @@ public class InvestigationCategoryController implements Serializable {
private UploadedFile file;
String selectText = "";
int manageItemIndex=-1;
+
public List getSelectedItems() {
selectedItems = getFacade().findByJpql("select c from InvestigationCategory c where c.retired=false and (c.name) like '%" + getSelectText().toUpperCase() + "%' order by c.name");
diff --git a/src/main/java/com/divudi/bean/lab/InvestigationController.java b/src/main/java/com/divudi/bean/lab/InvestigationController.java
index a7f49980ed..b36588d3ee 100644
--- a/src/main/java/com/divudi/bean/lab/InvestigationController.java
+++ b/src/main/java/com/divudi/bean/lab/InvestigationController.java
@@ -42,6 +42,9 @@
import com.divudi.facade.SpecialityFacade;
import com.divudi.facade.WorksheetItemFacade;
import com.divudi.bean.common.util.JsfUtil;
+import com.divudi.entity.lab.InvestigationTube;
+import com.divudi.entity.lab.Machine;
+import com.divudi.entity.lab.Sample;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.BufferedReader;
@@ -132,6 +135,10 @@ public class InvestigationController implements Serializable {
boolean reportedAs;
Boolean listMasterItemsOnly = false;//if boolean is true list only institution null
InvestigationCategory category;
+ private Sample sample;
+ private Machine machine;
+ private InvestigationTube investigationTube;
+ private Item itemForReported;
List catIxs;
List allIxs;
List itemsToRemove;
@@ -143,6 +150,7 @@ public class InvestigationController implements Serializable {
List ixWithoutSamples;
List investigationWithInvestigationItemses;
List itemWithFees;
+
private List investigationWithSelectedFormat;
private Category categoryForFormat;
private UploadedFile file;
@@ -188,6 +196,34 @@ public String navigateToManageInvestigationForLab() {
return "/lab/manage_investigation?faces-redirect=true";
}
+ public void updateSelectedInvestigations() {
+ if (selectedInvestigations.isEmpty()) {
+ JsfUtil.addErrorMessage("Pleace select Investigations !");
+ return;
+ }
+
+ for (Investigation selectedInvestigation : selectedInvestigations) {
+ if (category != null) {
+ selectedInvestigation.setInvestigationCategory(category);
+ }
+ if (sample != null) {
+ selectedInvestigation.setSample(sample);
+ }
+ if (machine != null) {
+ selectedInvestigation.setMachine(machine);
+ }
+ if (investigationTube != null) {
+ selectedInvestigation.setInvestigationTube(investigationTube);
+ }
+ if (itemForReported != null) {
+ selectedInvestigation.setReportedAs(itemForReported);
+ }
+
+ getFacade().edit(selectedInvestigation);
+
+ }
+ }
+
// Method to generate the Excel file and initiate the download
public void downloadAsExcelForEmr() {
getItems();
@@ -660,7 +696,6 @@ public void prepareSelectedReportSamples() {
}
}
-
}
public List getSelectedPatientReports() {
@@ -1079,7 +1114,6 @@ public void deleteSelectedItems() {
JsfUtil.addSuccessMessage("Successfully Deleted");
selectedInvestigations = null;
-
}
public void unDeleteSelectedItems() {
@@ -1101,7 +1135,6 @@ public void unDeleteSelectedItems() {
JsfUtil.addSuccessMessage("Successfully Deleted");
selectedInvestigations = null;
-
}
public void markSelectedActive() {
@@ -1122,8 +1155,6 @@ public void markSelectedActive() {
JsfUtil.addSuccessMessage("Successfully Actived");
selectedInvestigations = null;
-
-
}
public void markSelectedInactive() {
@@ -1144,7 +1175,6 @@ public void markSelectedInactive() {
JsfUtil.addSuccessMessage("Successfully Inactived");
selectedInvestigations = null;
-
}
public Institution getInstitution() {
@@ -1221,6 +1251,12 @@ public String navigateToListInvestigation() {
return "/admin/lims/investigation_list?faces-redirect=true";
}
+ public String navigateToMultipleInvestigationUpdate() {
+ selectedInvestigations = new ArrayList<>();
+ listAllIxs();
+ return "/admin/lims/multiple_investigation_update?faces-redirect=true";
+ }
+
public String navigateToManageReportTemplateNames() {
listAllIxs();
return "/admin/lims/investigation_list?faces-redirect=true";
@@ -1335,7 +1371,6 @@ public void saveSelected() {
if (getCurrent() == null) {
return;
}
-
getCurrent().setSymanticType(SymanticType.Laboratory_Procedure);
if (getCurrent().getInwardChargeType() == null) {
@@ -1436,7 +1471,6 @@ public void createInvestigationWithDynamicLables() {
investigationWithInvestigationItemses.add(items);
}
-
}
public List fetchFlags(Investigation i) {
@@ -1549,6 +1583,38 @@ public void setAdminTabIndex(int adminTabIndex) {
this.adminTabIndex = adminTabIndex;
}
+ public Sample getSample() {
+ return sample;
+ }
+
+ public void setSample(Sample sample) {
+ this.sample = sample;
+ }
+
+ public Machine getMachine() {
+ return machine;
+ }
+
+ public void setMachine(Machine machine) {
+ this.machine = machine;
+ }
+
+ public InvestigationTube getInvestigationTube() {
+ return investigationTube;
+ }
+
+ public void setInvestigationTube(InvestigationTube investigationTube) {
+ this.investigationTube = investigationTube;
+ }
+
+ public Item getItemForReported() {
+ return itemForReported;
+ }
+
+ public void setItemForReported(Item itemForReported) {
+ this.itemForReported = itemForReported;
+ }
+
public class InvestigationWithInvestigationItems {
Investigation i;
@@ -1717,7 +1783,6 @@ public void createInvestigationWithFees() {
itemWithFees.add(iwf);
}
-
}
public class ItemWithFee {
diff --git a/src/main/java/com/divudi/bean/lab/PatientInvestigationController.java b/src/main/java/com/divudi/bean/lab/PatientInvestigationController.java
index 3ddff8c49a..f1c865ba0f 100644
--- a/src/main/java/com/divudi/bean/lab/PatientInvestigationController.java
+++ b/src/main/java/com/divudi/bean/lab/PatientInvestigationController.java
@@ -176,6 +176,7 @@ public class PatientInvestigationController implements Serializable {
private List lstToPrint = null;
private List lstForSampleManagement = null;
List patientSamples;
+ private List selectedPatientSamples;
String selectText = "";
private Institution orderedInstitution;
private Department orderedDepartment;
@@ -1213,17 +1214,21 @@ public void prepareToSample() {
public void generateBarcodesForSelectedBills() {
System.out.println("generateBarcodesForSelectedBills");
System.out.println("selectedBillBarcodes = " + selectedBillBarcodes);
- if (selectedBillBarcodes == null) {
+ selectedBillBarcodes = new ArrayList<>();
+ billBarcodes = new ArrayList<>();
+ if (selectedBills == null) {
JsfUtil.addErrorMessage("No Bills Seelcted");
return;
}
- if (selectedBillBarcodes.isEmpty()) {
+ if (selectedBills.isEmpty()) {
JsfUtil.addErrorMessage("No Bills Seelcted");
return;
}
- for (BillBarcode bb : selectedBillBarcodes) {
- System.out.println("bb = " + bb);
- List bs = billBeanController.findValidBillsForSampleCollection(bb.getBill());
+ listingEntity = ListingEntity.BILL_BARCODES;
+ for (Bill b : selectedBills) {
+ BillBarcode bb = new BillBarcode(b);
+ System.out.println("bb = " + b);
+ List bs = billBeanController.findValidBillsForSampleCollection(b);
System.out.println("bs = " + bs);
List psws = new ArrayList<>();
List pss = prepareSampleCollectionByBillsForPhlebotomyRoom(bs, sessionController.getLoggedUser());
@@ -1243,8 +1248,9 @@ public void generateBarcodesForSelectedBills() {
}
System.out.println("psws = " + psws);
bb.setPatientSampleWrappers(psws);
+ billBarcodes.add(bb);
}
-
+ selectedBillBarcodes = billBarcodes;
}
public void generateBarcodesForSelectedPatientInvestigations() {
@@ -1257,7 +1263,8 @@ public void generateBarcodesForSelectedPatientInvestigations() {
return;
}
listingEntity = ListingEntity.BILL_BARCODES;
-
+ billBarcodes = new ArrayList<>();
+ selectedBillBarcodes = new ArrayList<>();
Map billBarcodeMap = new HashMap<>();
for (PatientInvestigation pi : selectedItems) {
@@ -1282,6 +1289,8 @@ public void generateBarcodesForSelectedPatientInvestigations() {
System.out.println("bb = " + bb.getPatientSampleWrappers());
}
+ billBarcodes = selectedBillBarcodes;
+
}
public void collectSamples() {
@@ -2530,6 +2539,8 @@ public void setInvestigationItemController(InvestigationItemController investiga
public PatientSampleComponantFacade getPatientSampleComponantFacade() {
return patientSampleComponantFacade;
}
+
+
public ItemFacade getItemFacade() {
return itemFacade;
@@ -2890,6 +2901,14 @@ public void setSelectedBills(List selectedBills) {
this.selectedBills = selectedBills;
}
+ public List getSelectedPatientSamples() {
+ return selectedPatientSamples;
+ }
+
+ public void setSelectedPatientSamples(List selectedPatientSamples) {
+ this.selectedPatientSamples = selectedPatientSamples;
+ }
+
/**
*
*/
diff --git a/src/main/java/com/divudi/bean/lab/PatientSampleController.java b/src/main/java/com/divudi/bean/lab/PatientSampleController.java
index d63fc591a0..aadeb0168f 100644
--- a/src/main/java/com/divudi/bean/lab/PatientSampleController.java
+++ b/src/main/java/com/divudi/bean/lab/PatientSampleController.java
@@ -85,6 +85,21 @@ public void saveSelected() {
recreateModel();
getItems();
}
+
+ public void savePatientSample(PatientSample pts) {
+ if(pts==null){
+ return;
+ }
+ if (pts.getId() != null) {
+ getFacade().edit(pts);
+ JsfUtil.addSuccessMessage("Updated Successfully.");
+ } else {
+ pts.setCreatedAt(new Date());
+ pts.setCreater(getSessionController().getLoggedUser());
+ getFacade().create(pts);
+ JsfUtil.addSuccessMessage("Saved Successfully");
+ }
+ }
public PatientSample findAndCreatePatientSampleByName(String qry) {
PatientSample s;
diff --git a/src/main/java/com/divudi/bean/opd/OpdBillController.java b/src/main/java/com/divudi/bean/opd/OpdBillController.java
index e7316e8972..7be611e35c 100644
--- a/src/main/java/com/divudi/bean/opd/OpdBillController.java
+++ b/src/main/java/com/divudi/bean/opd/OpdBillController.java
@@ -294,7 +294,7 @@ public class OpdBillController implements Serializable, ControllerWithPatient, C
private Double totalSaffFee;
private boolean canChangeSpecialityAndDoctorInAddedBillItem;
private String localNumber;
-
+
private String refNo;
private double remainAmount;
@@ -2101,7 +2101,6 @@ private Bill saveBill(Department bt, Bill newBill) {
newBill.setCollectingCentre(collectingCentre);
newBill.setIpOpOrCc("OP");
newBill.setComments(comment);
-
getBillBean().setPaymentMethodData(newBill, paymentMethod, getPaymentMethodData());
@@ -2259,11 +2258,11 @@ public double calculatRemainForMultiplePaymentTotal() {
multiplePaymentMethodTotalValue += cd.getPaymentMethodData().getStaffCredit().getTotalValue();
}
- remainAmount=total- multiplePaymentMethodTotalValue;
+ remainAmount = total - multiplePaymentMethodTotalValue;
return total - multiplePaymentMethodTotalValue;
-
+
}
- remainAmount=total;
+ remainAmount = total;
return total;
}
@@ -2272,37 +2271,37 @@ public void recieveRemainAmountAutomatically() {
if (paymentMethod == PaymentMethod.MultiplePaymentMethods) {
int arrSize = paymentMethodData.getPaymentMethodMultiple().getMultiplePaymentMethodComponentDetails().size();
ComponentDetail pm = paymentMethodData.getPaymentMethodMultiple().getMultiplePaymentMethodComponentDetails().get(arrSize - 1);
- switch (pm.getPaymentMethod()) {
- case Cash:
- pm.getPaymentMethodData().getCash().setTotalValue(remainAmount);
- break;
- case Card:
- pm.getPaymentMethodData().getCreditCard().setTotalValue(remainAmount);
- break;
- case Cheque:
- pm.getPaymentMethodData().getCheque().setTotalValue(remainAmount);
- break;
- case Slip:
- pm.getPaymentMethodData().getSlip().setTotalValue(remainAmount);
- break;
- case ewallet:
- pm.getPaymentMethodData().getEwallet().setTotalValue(remainAmount);
- break;
- case PatientDeposit:
- if (patient != null) {
- pm.getPaymentMethodData().getPatient_deposit().setPatient(patient);
+ switch (pm.getPaymentMethod()) {
+ case Cash:
+ pm.getPaymentMethodData().getCash().setTotalValue(remainAmount);
+ break;
+ case Card:
+ pm.getPaymentMethodData().getCreditCard().setTotalValue(remainAmount);
+ break;
+ case Cheque:
+ pm.getPaymentMethodData().getCheque().setTotalValue(remainAmount);
+ break;
+ case Slip:
+ pm.getPaymentMethodData().getSlip().setTotalValue(remainAmount);
+ break;
+ case ewallet:
+ pm.getPaymentMethodData().getEwallet().setTotalValue(remainAmount);
+ break;
+ case PatientDeposit:
+ if (patient != null) {
+ pm.getPaymentMethodData().getPatient_deposit().setPatient(patient);
+ }
+ pm.getPaymentMethodData().getPatient_deposit().setTotalValue(remainAmount);
+ break;
+ case Credit:
+ pm.getPaymentMethodData().getCredit().setTotalValue(remainAmount);
+ break;
+ case Staff:
+ pm.getPaymentMethodData().getStaffCredit().setTotalValue(remainAmount);
+ break;
+ default:
+ throw new IllegalArgumentException("Unexpected value: " + pm.getPaymentMethod());
}
- pm.getPaymentMethodData().getPatient_deposit().setTotalValue(remainAmount);
- break;
- case Credit:
- pm.getPaymentMethodData().getCredit().setTotalValue(remainAmount);
- break;
- case Staff:
- pm.getPaymentMethodData().getStaffCredit().setTotalValue(remainAmount);
- break;
- default:
- throw new IllegalArgumentException("Unexpected value: " + pm.getPaymentMethod());
- }
}
}
@@ -2429,13 +2428,13 @@ private boolean errorCheck() {
JsfUtil.addErrorMessage("Patient has not account. Can't proceed with Patient Deposits");
return true;
}
- double creditLimitAbsolute = 0.0;
- if(getPatient().getCreditLimit()==null){
+ double creditLimitAbsolute = 0.0;
+ if (getPatient().getCreditLimit() == null) {
creditLimitAbsolute = 0.0;
- }else{
+ } else {
creditLimitAbsolute = Math.abs(getPatient().getCreditLimit());
}
-
+
double runningBalance;
if (getPatient().getRunningBalance() != null) {
runningBalance = getPatient().getRunningBalance();
@@ -2657,7 +2656,19 @@ public void addToBill() {
addingEntry.setBillItem(bi);
addingEntry.setLstBillComponents(getBillBean().billComponentsFromBillItem(bi));
- List allBillFees = getBillBean().billFeefromBillItem(bi);
+ List allBillFees;
+
+ boolean addAllBillFees = configOptionApplicationController.getBooleanValueByKey("OPD Bill Fees are the same for all departments, institutions and sites.", true);
+ boolean siteBasedBillFees = configOptionApplicationController.getBooleanValueByKey("OPD Bill Fees are based on the site", false);
+
+ if (addAllBillFees) {
+ allBillFees = getBillBean().billFeefromBillItem(bi);
+ } else if (siteBasedBillFees) {
+ allBillFees = getBillBean().forInstitutionBillFeefromBillItem(bi, sessionController.getDepartment().getSite());
+ } else {
+ allBillFees = getBillBean().billFeefromBillItem(bi);
+ }
+
List billItemBillFeeBundleEntries = getBillBean().bundleFeesByName(allBillFees);
addingEntry.setLstBillFees(allBillFees);
@@ -4164,7 +4175,7 @@ public void setSelectedOpdItemDepartment(Department selectedOpdItemDepartment) {
public void fillDepartmentOpdItems() {
departmentOpdItems = null;
- opdItems=null;
+ opdItems = null;
itemApplicationController.reloadItems();
getDepartmentOpdItems();
}
@@ -4209,7 +4220,7 @@ public void setLocalNumber(String localNumber) {
}
public String getRefNo() {
- if(refNo == null){
+ if (refNo == null) {
refNo = getPaymentMethodData().getCredit().getReferralNo();
}
return refNo;
@@ -4234,7 +4245,5 @@ public String getReferredByName() {
public void setReferredByName(String referredByName) {
this.referredByName = referredByName;
}
-
-
}
diff --git a/src/main/java/com/divudi/data/InstitutionType.java b/src/main/java/com/divudi/data/InstitutionType.java
index 5b1f441431..5a7d4e03f3 100644
--- a/src/main/java/com/divudi/data/InstitutionType.java
+++ b/src/main/java/com/divudi/data/InstitutionType.java
@@ -8,6 +8,7 @@ public enum InstitutionType {
Agency("Agency"),
Bank("Bank"),
+ Site("Site"),
branch("Branch"), // Original enum spelling retained
CollectingCentre("Collecting Centre"),
Company("Company"),
diff --git a/src/main/java/com/divudi/data/ReportItemType.java b/src/main/java/com/divudi/data/ReportItemType.java
index 30b54f1757..80b67dca6f 100644
--- a/src/main/java/com/divudi/data/ReportItemType.java
+++ b/src/main/java/com/divudi/data/ReportItemType.java
@@ -45,6 +45,7 @@ public enum ReportItemType {
DataEntered,
DateTime,
Fax,
+ @Deprecated
Institution,
InvestigationName,
Item,
@@ -75,6 +76,14 @@ public enum ReportItemType {
Speciman,
Surname,
Ward,
+
+ MRN,
+ SampledID,
+ BillingDepartment,
+ PerformDepartment,
+ BillingInstitution,
+ PerformInstitution,
+ VisitType,
;
public String getLabel() {
@@ -199,7 +208,20 @@ public String getLabel() {
return "Printed Time";
case ReceivedAt:
return "Sample Received Time";
-
+ case MRN:
+ return "Patient MRN No";
+ case SampledID:
+ return "Sample ID";
+ case BillingDepartment:
+ return "Billing Department";
+ case PerformDepartment:
+ return "Perform Department";
+ case BillingInstitution:
+ return "Billing Institution";
+ case PerformInstitution:
+ return "Perform Institution";
+ case VisitType:
+ return "Visit Type";
default:
return this.toString();
}
diff --git a/src/main/java/com/divudi/data/ReportTemplateRow.java b/src/main/java/com/divudi/data/ReportTemplateRow.java
index 5854176be8..43c050750d 100644
--- a/src/main/java/com/divudi/data/ReportTemplateRow.java
+++ b/src/main/java/com/divudi/data/ReportTemplateRow.java
@@ -10,6 +10,7 @@
import com.divudi.entity.channel.SessionInstance;
import java.util.Date;
import java.util.List;
+import java.util.UUID;
/**
*
@@ -17,6 +18,7 @@
*/
public class ReportTemplateRow {
+ private String uuid;
private String feeName;
private String categoryName;
private String toDepartmentName;
@@ -538,7 +540,7 @@ public void setStaff(Staff staff) {
this.staff = staff;
}
- public ReportTemplateRow(Staff staff, Long long1, Long long2, Long long3, Long long4, Long long5, Long long6) {
+ public ReportTemplateRow(Staff staff, Long long1, Long long2, Long long3, Long long4, Long long5, Long long6, Long long7) {
this.staff = staff;
this.long1 = long1;
this.long2 = long2;
@@ -546,6 +548,7 @@ public ReportTemplateRow(Staff staff, Long long1, Long long2, Long long3, Long l
this.long4 = long4;
this.long5 = long5;
this.long6 = long6;
+ this.long7 = long7;
this.staff = staff;
}
@@ -564,5 +567,16 @@ public Staff getReferringStaff() {
public void setReferringStaff(Staff referringStaff) {
this.referringStaff = referringStaff;
}
+
+ public String getUuid() {
+ if (uuid == null) {
+ uuid = UUID.randomUUID().toString();
+ }
+ return uuid;
+ }
+
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
}
diff --git a/src/main/java/com/divudi/data/channel/SessionInstanceEvent.java b/src/main/java/com/divudi/data/channel/SessionInstanceEvent.java
new file mode 100644
index 0000000000..8c4ad14cd3
--- /dev/null
+++ b/src/main/java/com/divudi/data/channel/SessionInstanceEvent.java
@@ -0,0 +1,40 @@
+package com.divudi.data.channel;
+
+import com.divudi.entity.channel.SessionInstance;
+import org.primefaces.model.DefaultScheduleEvent;
+
+public class SessionInstanceEvent extends DefaultScheduleEvent {
+
+ private SessionInstance sessionInstance;
+
+ public SessionInstanceEvent() {
+ }
+
+ // Getter and Setter for SessionInstance
+ public SessionInstance getSessionInstance() {
+ return sessionInstance;
+ }
+
+ public void setSessionInstance(SessionInstance sessionInstance) {
+ this.sessionInstance = sessionInstance;
+ }
+
+ // Builder Class
+ public static final class Builder {
+ private SessionInstance sessionInstance;
+
+ public Builder() {
+ }
+
+ public Builder sessionInstance(SessionInstance sessionInstance) {
+ this.sessionInstance = sessionInstance;
+ return this;
+ }
+
+ public SessionInstanceEvent build() {
+ SessionInstanceEvent event = new SessionInstanceEvent();
+ event.setSessionInstance(sessionInstance);
+ return event;
+ }
+ }
+}
diff --git a/src/main/java/com/divudi/data/lab/Analyzer.java b/src/main/java/com/divudi/data/lab/Analyzer.java
index 82fe2b88c0..b06c191830 100644
--- a/src/main/java/com/divudi/data/lab/Analyzer.java
+++ b/src/main/java/com/divudi/data/lab/Analyzer.java
@@ -6,12 +6,46 @@
package com.divudi.data.lab;
/**
- *
- * @author buddhika_ari
+ * Enum representing various analyzers with a label for each.
*/
public enum Analyzer {
- Sysmex_XS_Series,
- Dimension_Clinical_Chemistry_System,
- Gallery_Indiko,
- Celltac_MEK,
+ Sysmex_XS_Series("Sysmex XS Series"),
+ Dimension_Clinical_Chemistry_System("Dimension Clinical Chemistry System"),
+ Gallery_Indiko("Gallery Indiko"),
+ Celltac_MEK("Celltac MEK"),
+ BA400("BA 400"),
+ IndikoPlus("Indiko Plus"),
+ BioRadD10("Bio-Rad D10"),
+ MindrayBC5150("Mindray BC 5150"),
+ SmartLytePlus("SmartLyte Plus"),
+ MaglumiX3HL7("Maglumi X3 HL7");
+
+ private final String label;
+
+ // Constructor to set the enum labels
+ Analyzer(String label) {
+ this.label = label;
+ }
+
+ // Getter for the label
+ public String getLabel() {
+ return this.label;
+ }
+
+ /**
+ * Converts a string identifier to an Analyzer enum.
+ *
+ * @param text the string representation of the analyzer
+ * @return the corresponding Analyzer enum
+ */
+ public static Analyzer fromString(String text) {
+ if (text != null) {
+ for (Analyzer b : Analyzer.values()) {
+ if (text.equalsIgnoreCase(b.label)) {
+ return b;
+ }
+ }
+ }
+ throw new IllegalArgumentException("No constant with text " + text + " found");
+ }
}
diff --git a/src/main/java/com/divudi/data/lab/Priority.java b/src/main/java/com/divudi/data/lab/Priority.java
index e6be0eddd7..1d80de483e 100644
--- a/src/main/java/com/divudi/data/lab/Priority.java
+++ b/src/main/java/com/divudi/data/lab/Priority.java
@@ -10,7 +10,7 @@ public enum Priority {
Asap("Asap"),
Routeine("Routeine"),
DELAYED("Delayed"),
- OTHER("Other");
+ Other("Other");
private final String label;
diff --git a/src/main/java/com/divudi/ejb/ChannelBean.java b/src/main/java/com/divudi/ejb/ChannelBean.java
index b568ed71ed..6344e758ec 100644
--- a/src/main/java/com/divudi/ejb/ChannelBean.java
+++ b/src/main/java/com/divudi/ejb/ChannelBean.java
@@ -673,11 +673,120 @@ public int compare(SessionInstance s1, SessionInstance s2) {
return sessionInstances;
}
+ public List generateSesionInstancesFromServiceSessions(List inputSessions) {
+ int sessionDayCount = 0;
+ List sessionInstances = new ArrayList<>();
+ if (inputSessions == null || inputSessions.isEmpty()) {
+ return sessionInstances;
+ }
+
+ for (ServiceSession ss : inputSessions) {
+ Date startDate = new Date();
+ Calendar cToDate = Calendar.getInstance();
+ int numberOfDaysInAdvance;
+ if (ss.getNumberOfDaysForAutomaticInstanceCreation() == null) {
+ numberOfDaysInAdvance = 30;
+ } else {
+ numberOfDaysInAdvance = ss.getNumberOfDaysForAutomaticInstanceCreation();
+ }
+ cToDate.add(Calendar.DATE, numberOfDaysInAdvance);
+ Date endDate = cToDate.getTime();
+
+ Calendar cWorkingDate = Calendar.getInstance();
+ cWorkingDate.setTime(startDate);
+
+ // Reset time components for startDate
+ cWorkingDate.set(Calendar.HOUR_OF_DAY, 0);
+ cWorkingDate.set(Calendar.MINUTE, 0);
+ cWorkingDate.set(Calendar.SECOND, 0);
+ cWorkingDate.set(Calendar.MILLISECOND, 0);
+
+ int rowIndex = 0;
+
+ while (cWorkingDate.getTime().before(endDate) || cWorkingDate.getTime().equals(endDate)) {
+ Date workingDate = cWorkingDate.getTime();
+ boolean eligibleDate = false;
+ // Reset time components for sessionDate
+
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(workingDate);
+
+ if (ss.getSessionDate() == null) {
+ int workingDateWeekday = calendar.get(Calendar.DAY_OF_WEEK);
+ if (ss.getSessionWeekday() != null) {
+ if (workingDateWeekday == ss.getSessionWeekday()) {
+ eligibleDate = true;
+ }
+ }
+
+ } else {
+ Calendar cSessionDate = Calendar.getInstance();
+ cSessionDate.setTime(ss.getSessionDate());
+ cSessionDate.set(Calendar.HOUR_OF_DAY, 0);
+ cSessionDate.set(Calendar.MINUTE, 0);
+ cSessionDate.set(Calendar.SECOND, 0);
+ cSessionDate.set(Calendar.MILLISECOND, 0);
+ if (cSessionDate.getTime().equals(workingDate)) {
+ eligibleDate = true;
+ }
+ }
+
+ if (eligibleDate) {
+ String jpql = "select i "
+ + " from SessionInstance i "
+ + " where i.originatingSession=:os "
+ + " and i.retired=:ret "
+ + " and i.sessionDate=:sd";
+
+ Map m = new HashMap();
+ m.put("ret", false);
+ m.put("os", ss);
+ m.put("sd", workingDate);
+
+ SessionInstance si = sessionInstanceFacade.findFirstByJpql(jpql, m, TemporalType.DATE);
+
+ if (si == null) {
+ si = createSessionInstancesForServiceSession(ss, workingDate);
+ if (si.getId() == null) {
+ sessionInstanceFacade.create(si);
+ } else {
+ sessionInstanceFacade.edit(si);
+ }
+ }
+
+// si.setDisplayCount(getBillSessionsCount(si));
+// si.setTransDisplayCountWithoutCancelRefund(getBillSessionsCountWithOutCancelRefund(si));
+// si.setTransCreditBillCount(getBillSessionsCountCrditBill(si));
+ si.setStaff(ss.getStaff());
+ si.setTransRowNumber(rowIndex++);
+
+ sessionInstances.add(si);
+ }
+
+ cWorkingDate.add(Calendar.DATE, 1); // Increment the date
+ }
+ }
+ System.out.println("sessionInstances = " + sessionInstances.size());
+ Collections.sort(sessionInstances, new Comparator() {
+ @Override
+ public int compare(SessionInstance s1, SessionInstance s2) {
+ int dateCompare = s1.getSessionDate().compareTo(s2.getSessionDate());
+ if (dateCompare != 0) {
+ return dateCompare;
+ } else {
+ // Assuming ServiceSession has a method to get a navigateToSessionView identifier or name for comparison
+ return s1.getOriginatingSession().getName().compareTo(s2.getOriginatingSession().getName());
+ }
+ }
+ });
+ return sessionInstances;
+ }
+
public List listTodaysSesionInstances() {
return listTodaysSessionInstances(null, null, null);
}
- public List listTodaysSessionInstances(Boolean ongoing, Boolean completed, Boolean pending) {
+ public List listTodaysSessionInstances(Boolean ongoing, Boolean completed, Boolean pending) {
List sessionInstances = new ArrayList<>();
StringBuilder jpql = new StringBuilder("select i from SessionInstance i where i.retired=:ret and i.sessionDate=:sd");
@@ -720,64 +829,64 @@ public List listTodaysSessionInstances(Boolean ongoing, Boolean
return sessionInstances;
}
-public List listSessionInstancesByDate(Date sessionDate, Boolean ongoing, Boolean completed, Boolean pending) {
- List sessionInstances = new ArrayList<>();
- StringBuilder jpql = new StringBuilder("select i from SessionInstance i where i.retired=:ret and i.sessionDate between :startOfDay and :endOfDay");
-
- // Initializing the parameters map
- Calendar cal = Calendar.getInstance();
- cal.setTime(sessionDate);
- cal.set(Calendar.HOUR_OF_DAY, 0);
- cal.set(Calendar.MINUTE, 0);
- cal.set(Calendar.SECOND, 0);
- cal.set(Calendar.MILLISECOND, 0);
- Date startOfDay = cal.getTime();
-
- cal.set(Calendar.HOUR_OF_DAY, 23);
- cal.set(Calendar.MINUTE, 59);
- cal.set(Calendar.SECOND, 59);
- cal.set(Calendar.MILLISECOND, 999);
- Date endOfDay = cal.getTime();
-
- Map params = new HashMap<>();
- params.put("ret", false);
- params.put("startOfDay", startOfDay);
- params.put("endOfDay", endOfDay);
-
- // Dynamically appending conditions based on parameters
- List conditions = new ArrayList<>();
- if (ongoing != null && ongoing) {
- conditions.add("(i.started = true and i.completed = false)");
- }
- if (completed != null && completed) {
- conditions.add("i.completed = true");
- }
- if (pending != null && pending) {
- conditions.add("(i.started = false and i.completed = false)");
- }
+ public List listSessionInstancesByDate(Date sessionDate, Boolean ongoing, Boolean completed, Boolean pending) {
+ List sessionInstances = new ArrayList<>();
+ StringBuilder jpql = new StringBuilder("select i from SessionInstance i where i.retired=:ret and i.sessionDate between :startOfDay and :endOfDay");
- // Adding the conditions to the JPQL query
- if (!conditions.isEmpty()) {
- jpql.append(" and (").append(String.join(" or ", conditions)).append(")");
- }
+ // Initializing the parameters map
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(sessionDate);
+ cal.set(Calendar.HOUR_OF_DAY, 0);
+ cal.set(Calendar.MINUTE, 0);
+ cal.set(Calendar.SECOND, 0);
+ cal.set(Calendar.MILLISECOND, 0);
+ Date startOfDay = cal.getTime();
+
+ cal.set(Calendar.HOUR_OF_DAY, 23);
+ cal.set(Calendar.MINUTE, 59);
+ cal.set(Calendar.SECOND, 59);
+ cal.set(Calendar.MILLISECOND, 999);
+ Date endOfDay = cal.getTime();
+
+ Map params = new HashMap<>();
+ params.put("ret", false);
+ params.put("startOfDay", startOfDay);
+ params.put("endOfDay", endOfDay);
- // Fetching the session instances based on the constructed JPQL query and parameters
- sessionInstances = sessionInstanceFacade.findByJpql(jpql.toString(), params, TemporalType.TIMESTAMP);
+ // Dynamically appending conditions based on parameters
+ List conditions = new ArrayList<>();
+ if (ongoing != null && ongoing) {
+ conditions.add("(i.started = true and i.completed = false)");
+ }
+ if (completed != null && completed) {
+ conditions.add("i.completed = true");
+ }
+ if (pending != null && pending) {
+ conditions.add("(i.started = false and i.completed = false)");
+ }
- // Sorting logic remains unchanged
- Collections.sort(sessionInstances, new Comparator() {
- @Override
- public int compare(SessionInstance s1, SessionInstance s2) {
- int dateCompare = s1.getSessionDate().compareTo(s2.getSessionDate());
- if (dateCompare != 0) {
- return dateCompare;
- } else {
- return s1.getOriginatingSession().getName().compareTo(s2.getOriginatingSession().getName());
- }
+ // Adding the conditions to the JPQL query
+ if (!conditions.isEmpty()) {
+ jpql.append(" and (").append(String.join(" or ", conditions)).append(")");
}
- });
- return sessionInstances;
-}
+
+ // Fetching the session instances based on the constructed JPQL query and parameters
+ sessionInstances = sessionInstanceFacade.findByJpql(jpql.toString(), params, TemporalType.TIMESTAMP);
+
+ // Sorting logic remains unchanged
+ Collections.sort(sessionInstances, new Comparator() {
+ @Override
+ public int compare(SessionInstance s1, SessionInstance s2) {
+ int dateCompare = s1.getSessionDate().compareTo(s2.getSessionDate());
+ if (dateCompare != 0) {
+ return dateCompare;
+ } else {
+ return s1.getOriginatingSession().getName().compareTo(s2.getOriginatingSession().getName());
+ }
+ }
+ });
+ return sessionInstances;
+ }
public List listSessionInstances(Date fromDate, Date toDate, Boolean ongoing, Boolean completed, Boolean pending) {
return listSessionInstances(fromDate, toDate, ongoing, completed, pending, null);
@@ -826,8 +935,8 @@ public List listSessionInstances(Date fromDate, Date toDate, Bo
if (!conditions.isEmpty()) {
jpql.append(" and (").append(String.join(" or ", conditions)).append(")");
}
-
- // Adding sorting to JPQL with custom order
+
+ // Adding sorting to JPQL with custom order
jpql.append(" order by case when i.completed = true then 1 else 0 end, i.completed asc, i.started desc, i.sessionDate asc, i.startingTime asc");
sessionInstances = sessionInstanceFacade.findByJpql(jpql.toString(), params, TemporalType.DATE);
@@ -881,7 +990,6 @@ public List listSessionInstances(Date fromDate, Date toDate, Bo
// return name1.compareTo(name2);
// }
// });
-
return sessionInstances;
}
diff --git a/src/main/java/com/divudi/ejb/SmsManagerEjb.java b/src/main/java/com/divudi/ejb/SmsManagerEjb.java
index 39b0a39d5d..65be01a96a 100644
--- a/src/main/java/com/divudi/ejb/SmsManagerEjb.java
+++ b/src/main/java/com/divudi/ejb/SmsManagerEjb.java
@@ -73,7 +73,7 @@ public class SmsManagerEjb {
// Schedule sendSmsToDoctorsBeforeSession to run every 30 minutes
@SuppressWarnings("unused")
- @Schedule(second = "0", minute = "*/30", hour = "*", persistent = false)
+ @Schedule(second = "*", minute = "*/1", hour = "*", persistent = false)
public void sendSmsToDoctorsBeforeSessionTimer() {
if (doNotSendAnySms) {
return;
@@ -91,9 +91,6 @@ private void sendSmsToDoctorsBeforeSessionWithChecks() {
if (doNotSendAnySms) {
return;
}
- Date fromDate = CommonFunctions.getStartOfDay();
- Date toDate = CommonFunctions.getEndOfDay();
- List sessions = channelBean.listSessionInstances(fromDate, toDate, null, null, null);
Date fromTime = new Date();
Calendar calf = Calendar.getInstance();
@@ -105,13 +102,29 @@ private void sendSmsToDoctorsBeforeSessionWithChecks() {
cal.setTime(fromTime);
cal.add(Calendar.MINUTE, 60);
Date toTime = cal.getTime();
-
- List upcomingSessions = sessions.stream()
- .filter(session -> {
- Date sessionStartDateTime = getSessionStartDateTime(session);
- return sessionStartDateTime != null && sessionStartDateTime.after(fromTime1) && sessionStartDateTime.before(toTime);
- })
- .collect(Collectors.toList());
+
+ List upcomingSessions;
+ Map m = new HashMap<>();
+ Map temporalTypes = new HashMap<>();
+
+ String jpql = "select i from SessionInstance i "
+ + "where i.retired=:ret "
+ + "and i.originatingSession.retired=:retos "
+ + "and i.sessionDate=:sessionDate "
+ + "and i.startingTime between :startingTime and :endingTime";
+
+ m.put("ret", false);
+ m.put("retos", false);
+ m.put("sessionDate", new Date());
+ temporalTypes.put("sessionDate", TemporalType.DATE);
+
+ m.put("startingTime",fromTime1);
+ m.put("endingTime",toTime);
+ temporalTypes.put("startingTime", TemporalType.TIME);
+ temporalTypes.put("endingTime", TemporalType.TIME);
+
+ upcomingSessions = sessionInstanceFacade.findByJpql(jpql, m, temporalTypes);
+
for (SessionInstance s : upcomingSessions) {
if (s.getBookedPatientCount() != null && !s.isCancelled() && s.getBookedPatientCount() > 0) {
diff --git a/src/main/java/com/divudi/entity/Bill.java b/src/main/java/com/divudi/entity/Bill.java
index bf2d7563b9..f224cb4da3 100644
--- a/src/main/java/com/divudi/entity/Bill.java
+++ b/src/main/java/com/divudi/entity/Bill.java
@@ -52,9 +52,9 @@ public class Bill implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
Long id;
-
+
static final long serialVersionUID = 1L;
-
+
@ManyToOne
private MembershipScheme membershipScheme;
@OneToOne
@@ -87,8 +87,6 @@ public class Bill implements Serializable {
boolean transError;
private String ipOpOrCc;
-
-
@OneToMany(mappedBy = "bill", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private List payments = new ArrayList<>();
@@ -323,7 +321,7 @@ public class Bill implements Serializable {
@Temporal(javax.persistence.TemporalType.TIMESTAMP)
private Date printedAt;
- //Print Information
+ //Print Information
private boolean duplicatedPrinted;
@ManyToOne(fetch = FetchType.LAZY)
private WebUser duplicatePrintedUser;
@@ -358,13 +356,15 @@ public class Bill implements Serializable {
private String ageAtBilledDate;
@Transient
private Bill tmpRefBill;
-
+
private String agentRefNo;
private boolean billClosed;
-
+
private String localNumber;
-
-
+
+ private boolean billPaymentCompletelySettled;
+
+ private double tenderedAmount;
private void generateBillPrintFromBillTemplate() {
billPrint = "";
@@ -562,8 +562,6 @@ private void generateBillPrintFromBillTemplate() {
}
-
-
private String safeReplace(String value) {
return value != null ? value : "";
}
@@ -819,7 +817,7 @@ public void copy(Bill bill) {
vat = bill.getVat();
vatPlusNetTotal = bill.getVatPlusNetTotal();
sessionId = bill.getSessionId();
- ipOpOrCc=bill.getIpOpOrCc();
+ ipOpOrCc = bill.getIpOpOrCc();
// referenceBill=bill.getReferenceBill();
}
@@ -1166,7 +1164,6 @@ public void setPatientEncounter(PatientEncounter patientEncounter) {
this.patientEncounter = patientEncounter;
}
-
public Long getId() {
return id;
}
@@ -1543,8 +1540,8 @@ public void setChequeDate(Date chequeDate) {
}
public List getBillFees() {
- if(billFees==null){
- billFees=new ArrayList<>();
+ if (billFees == null) {
+ billFees = new ArrayList<>();
}
return billFees;
}
@@ -2226,11 +2223,11 @@ public void setLocalNumber(String localNumber) {
}
public String getIpOpOrCc() {
- ipOpOrCc="OP";
- if(this.getPatientEncounter()!=null){
- ipOpOrCc="IP";
- }else if(this.getCollectingCentre()!=null){
- ipOpOrCc="CC";
+ ipOpOrCc = "OP";
+ if (this.getPatientEncounter() != null) {
+ ipOpOrCc = "IP";
+ } else if (this.getCollectingCentre() != null) {
+ ipOpOrCc = "CC";
}
return ipOpOrCc;
}
@@ -2238,8 +2235,21 @@ public String getIpOpOrCc() {
public void setIpOpOrCc(String ipOpOrCc) {
this.ipOpOrCc = ipOpOrCc;
}
-
-
-
+
+ public boolean isBillPaymentCompletelySettled() {
+ return billPaymentCompletelySettled;
+ }
+
+ public void setBillPaymentCompletelySettled(boolean billPaymentCompletelySettled) {
+ this.billPaymentCompletelySettled = billPaymentCompletelySettled;
+ }
+
+ public double getTenderedAmount() {
+ return tenderedAmount;
+ }
+
+ public void setTenderedAmount(double tenderedAmount) {
+ this.tenderedAmount = tenderedAmount;
+ }
}
diff --git a/src/main/java/com/divudi/entity/BillItem.java b/src/main/java/com/divudi/entity/BillItem.java
index 1a534cbe16..2b58459bbf 100644
--- a/src/main/java/com/divudi/entity/BillItem.java
+++ b/src/main/java/com/divudi/entity/BillItem.java
@@ -73,13 +73,14 @@ public class BillItem implements Serializable {
double netValue;
@Transient
private double absoluteNetValue;
- double vatPlusNetValue;
+ private double vatPlusNetValue;
- double marginValue;
+ private double marginValue;
private double adjustedValue;
- double hospitalFee;
+ private double hospitalFee;
private double collectingCentreFee;
- double staffFee;
+ private double staffFee;
+ private double otherFee;
// private double dblValue;
@ManyToOne
Item item;
@@ -958,6 +959,14 @@ public double getTotalProcedureFeeValueTransient() {
return totalProcedureFeeValueTransient;
}
+ public double getOtherFee() {
+ return otherFee;
+ }
+
+ public void setOtherFee(double otherFee) {
+ this.otherFee = otherFee;
+ }
+
}
diff --git a/src/main/java/com/divudi/entity/BillSession.java b/src/main/java/com/divudi/entity/BillSession.java
index e69eb9ef82..b0ddc64b16 100644
--- a/src/main/java/com/divudi/entity/BillSession.java
+++ b/src/main/java/com/divudi/entity/BillSession.java
@@ -49,7 +49,7 @@ public class BillSession implements Serializable {
private WebUser completedBy;
@Temporal(javax.persistence.TemporalType.TIMESTAMP)
private Date completedAt;
-
+
@ManyToOne
private WebUser markedToCancelBy;
@Temporal(javax.persistence.TemporalType.TIMESTAMP)
@@ -58,10 +58,7 @@ public class BillSession implements Serializable {
private WebUser markedToRefundBy;
@Temporal(javax.persistence.TemporalType.TIMESTAMP)
private Date markedToRefundAt;
-
-
-
-
+
//Retairing properties
boolean retired;
@ManyToOne
@@ -91,6 +88,8 @@ public class BillSession implements Serializable {
@Temporal(javax.persistence.TemporalType.TIME)
Date sessionTime;
int serialNo;
+ @Transient
+ private String serialNoStr;
//Present
// Boolean present = true;
//Absent
@@ -129,8 +128,8 @@ public class BillSession implements Serializable {
@OneToOne(fetch = FetchType.LAZY)
BillSession rescheduledToBillSession;
- private boolean reservedBooking=false;
- private boolean recheduledSession=false;
+ private boolean reservedBooking = false;
+ private boolean recheduledSession = false;
public void copy(BillSession billSession) {
packege = billSession.getPackege();
@@ -149,7 +148,6 @@ public void copy(BillSession billSession) {
patientEncounter = billSession.getPatientEncounter();
}
-
public int getSerialNo() {
return serialNo;
}
@@ -157,6 +155,8 @@ public int getSerialNo() {
public void setSerialNo(int serialNo) {
this.serialNo = serialNo;
}
+
+
public Date getSessionDate() {
return sessionDate;
@@ -180,7 +180,6 @@ public ServiceSession getServiceSession() {
return serviceSession;
}
-
@Deprecated
public void setServiceSession(ServiceSession serviceSession) {
//Use SessionInstance instead
@@ -291,7 +290,7 @@ public String getRetireComments() {
public void setRetireComments(String retireComments) {
this.retireComments = retireComments;
}
-
+
public Bill getBill() {
return bill;
}
@@ -577,4 +576,11 @@ public BillSession setRescheduledToBillSession(BillSession rescheduledToBillSess
this.rescheduledToBillSession = rescheduledToBillSession;
return this;
}
+
+ public String getSerialNoStr() {
+ serialNoStr = serialNo + "";
+ return serialNoStr;
+ }
+
+
}
diff --git a/src/main/java/com/divudi/entity/Department.java b/src/main/java/com/divudi/entity/Department.java
index f5ffb3e4aa..683515b97e 100644
--- a/src/main/java/com/divudi/entity/Department.java
+++ b/src/main/java/com/divudi/entity/Department.java
@@ -45,43 +45,46 @@ public class Department implements Serializable {
String telephone2;
String fax;
String email;
+
@ManyToOne
- @JsonIgnore
Institution institution;
+
+ @ManyToOne
+ private Institution site;
+
@ManyToOne
- @JsonIgnore
Department superDepartment;
@Enumerated(EnumType.STRING)
DepartmentType departmentType;
@ManyToOne
- @JsonIgnore
+
Department sampleDepartment;
@ManyToOne
- @JsonIgnore
+
Department labDepartment;
@ManyToOne
- @JsonIgnore
+
Institution sampleInstitution;
@ManyToOne
- @JsonIgnore
+
Institution labInstitution;
// double maxDiscount;
//Created Properties
@ManyToOne
- @JsonIgnore
+
WebUser creater;
- @JsonIgnore
+
@Temporal(javax.persistence.TemporalType.TIMESTAMP)
Date createdAt;
//Retairing properties
- @JsonIgnore
+
boolean retired;
- @JsonIgnore
+
@ManyToOne
WebUser retirer;
- @JsonIgnore
+
@Temporal(javax.persistence.TemporalType.TIMESTAMP)
Date retiredAt;
String retireComments;
@@ -90,9 +93,6 @@ public class Department implements Serializable {
double margin;
double pharmacyMarginFromPurchaseRate;
-
-
-
public double getPharmacyMarginFromPurchaseRate() {
return pharmacyMarginFromPurchaseRate;
}
@@ -355,4 +355,14 @@ public Boolean getActive() {
public void setActive(Boolean active) {
this.active = active;
}
+
+ public Institution getSite() {
+ return site;
+ }
+
+ public void setSite(Institution site) {
+ this.site = site;
+ }
+
+
}
diff --git a/src/main/java/com/divudi/entity/Fee.java b/src/main/java/com/divudi/entity/Fee.java
index 358dde03b2..f7aa1ef2d4 100644
--- a/src/main/java/com/divudi/entity/Fee.java
+++ b/src/main/java/com/divudi/entity/Fee.java
@@ -1,4 +1,3 @@
-
/*
* Dr M H B Ariyaratne
* buddhika.ari@gmail.com
@@ -7,7 +6,6 @@
import com.divudi.data.FeeType;
-import com.fasterxml.jackson.annotation.JsonIgnore;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Entity;
@@ -42,7 +40,7 @@ public class Fee implements Serializable {
double fee = 0.0;
double ffee = 0.0;
private double ccFee = 0.0;
- @JsonIgnore
+
@ManyToOne
Item item; // FBC, ESR, UFR
@ManyToOne
@@ -58,62 +56,56 @@ public class Fee implements Serializable {
@ManyToOne
Staff staff;
@ManyToOne
- @JsonIgnore
+
ServiceSession serviceSession;
private boolean booleanValue;
//Created Properties
@ManyToOne
- @JsonIgnore
WebUser creater;
@Temporal(javax.persistence.TemporalType.TIMESTAMP)
- @JsonIgnore
Date createdAt;
//Created Properties
@ManyToOne
- @JsonIgnore
WebUser editer;
@Temporal(javax.persistence.TemporalType.TIMESTAMP)
- @JsonIgnore
Date editedAt;
//Retairing properties
- @JsonIgnore
+
boolean retired;
@ManyToOne
- @JsonIgnore
WebUser retirer;
@Temporal(javax.persistence.TemporalType.TIMESTAMP)
- @JsonIgnore
Date retiredAt;
- @JsonIgnore
+
String retireComments;
@Enumerated(EnumType.STRING)
FeeType feeType;
@ManyToOne
- @JsonIgnore
+
Item packege; //Ceylinco, LEC ,
@ManyToOne
- @JsonIgnore
+
Department fromDepartment;
@ManyToOne
- @JsonIgnore
+
Department toDepartment;
- @JsonIgnore
+
@ManyToOne
Institution fromInstitution;
- @JsonIgnore
+
@ManyToOne
Institution toInstitution;
- @JsonIgnore
+
@ManyToOne
Staff fromStaff;
@ManyToOne
- @JsonIgnore
+
Staff toStaff;
@ManyToOne
- @JsonIgnore
+
Speciality fromSpeciality;
@ManyToOne
- @JsonIgnore
+
Speciality toSpaciality;
private boolean discountAllowed;
diff --git a/src/main/java/com/divudi/entity/FeeValue.java b/src/main/java/com/divudi/entity/FeeValue.java
new file mode 100644
index 0000000000..cd32e396d5
--- /dev/null
+++ b/src/main/java/com/divudi/entity/FeeValue.java
@@ -0,0 +1,182 @@
+package com.divudi.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+import javax.persistence.Temporal;
+
+/**
+ *
+ * @author Buddhika
+ */
+@Entity
+public class FeeValue implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private Long id;
+
+ @ManyToOne
+ private Item item;
+ @ManyToOne
+ private Institution institution;
+ @ManyToOne
+ private Department department;
+ @ManyToOne
+ private Category category;
+
+ private Double totalValueForLocals;
+ private Double totalValueForForeigners;
+
+ //Created Properties
+ @ManyToOne
+ private WebUser creater;
+ @Temporal(javax.persistence.TemporalType.TIMESTAMP)
+ private Date createdAt;
+ //Retairing properties
+ private boolean retired;
+ @ManyToOne
+ private WebUser retirer;
+ @Temporal(javax.persistence.TemporalType.TIMESTAMP)
+ private Date retiredAt;
+ private String retireComments;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+
+
+ @Override
+ public int hashCode() {
+ int hash = 0;
+ hash += (id != null ? id.hashCode() : 0);
+ return hash;
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ // TODO: Warning - this method won't work in the case the id fields are not set
+ if (!(object instanceof FeeValue)) {
+ return false;
+ }
+ FeeValue other = (FeeValue) object;
+ if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "com.divudi.entity.FeeValue[ id=" + id + " ]";
+ }
+
+
+
+ public Institution getInstitution() {
+ return institution;
+ }
+
+ public void setInstitution(Institution institution) {
+ this.institution = institution;
+ }
+
+ public Department getDepartment() {
+ return department;
+ }
+
+ public void setDepartment(Department department) {
+ this.department = department;
+ }
+
+ public Category getCategory() {
+ return category;
+ }
+
+ public void setCategory(Category category) {
+ this.category = category;
+ }
+
+ public Double getTotalValueForLocals() {
+ return totalValueForLocals;
+ }
+
+ public void setTotalValueForLocals(Double totalValueForLocals) {
+ this.totalValueForLocals = totalValueForLocals;
+ }
+
+ public Double getTotalValueForForeigners() {
+ return totalValueForForeigners;
+ }
+
+ public void setTotalValueForForeigners(Double totalValueForForeigners) {
+ this.totalValueForForeigners = totalValueForForeigners;
+ }
+
+ public WebUser getCreater() {
+ return creater;
+ }
+
+ public void setCreater(WebUser creater) {
+ this.creater = creater;
+ }
+
+ public Date getCreatedAt() {
+ return createdAt;
+ }
+
+ public void setCreatedAt(Date createdAt) {
+ this.createdAt = createdAt;
+ }
+
+ public boolean isRetired() {
+ return retired;
+ }
+
+ public void setRetired(boolean retired) {
+ this.retired = retired;
+ }
+
+ public WebUser getRetirer() {
+ return retirer;
+ }
+
+ public void setRetirer(WebUser retirer) {
+ this.retirer = retirer;
+ }
+
+ public Date getRetiredAt() {
+ return retiredAt;
+ }
+
+ public void setRetiredAt(Date retiredAt) {
+ this.retiredAt = retiredAt;
+ }
+
+ public String getRetireComments() {
+ return retireComments;
+ }
+
+ public void setRetireComments(String retireComments) {
+ this.retireComments = retireComments;
+ }
+
+ public Item getItem() {
+ return item;
+ }
+
+ public void setItem(Item item) {
+ this.item = item;
+ }
+
+}
diff --git a/src/main/java/com/divudi/entity/Item.java b/src/main/java/com/divudi/entity/Item.java
index ac2be13c65..23be4ff161 100644
--- a/src/main/java/com/divudi/entity/Item.java
+++ b/src/main/java/com/divudi/entity/Item.java
@@ -119,6 +119,7 @@ public class Item implements Serializable, Comparable- {
String sname;
String tname;
String code;
+ private String codeSystem;
String barcode;
private Long lastBarcode;
String printName;
@@ -1406,6 +1407,8 @@ public String getForGender() {
return forGender;
}
+
+
public void setForGender(String forGender) {
this.forGender = forGender;
}
@@ -1418,6 +1421,14 @@ public void setExpiryDate(Date expiryDate) {
this.expiryDate = expiryDate;
}
+ public String getCodeSystem() {
+ return codeSystem;
+ }
+
+ public void setCodeSystem(String codeSystem) {
+ this.codeSystem = codeSystem;
+ }
+
static class ReportItemComparator implements Comparator {
@Override
diff --git a/src/main/java/com/divudi/entity/ServiceSession.java b/src/main/java/com/divudi/entity/ServiceSession.java
index c8921cfae7..2b84dd40ff 100644
--- a/src/main/java/com/divudi/entity/ServiceSession.java
+++ b/src/main/java/com/divudi/entity/ServiceSession.java
@@ -53,7 +53,7 @@ public class ServiceSession extends Item implements Serializable {
Date startingTime;
@Temporal(javax.persistence.TemporalType.TIMESTAMP)
Date endingTime;
-
+
private Integer numberOfDaysForAutomaticInstanceCreation;
boolean refundable = false;
@@ -84,7 +84,7 @@ public class ServiceSession extends Item implements Serializable {
@Transient
Boolean arival;
@Transient
- boolean serviceSessionCreateForOriginatingSession=false;
+ boolean serviceSessionCreateForOriginatingSession = false;
//new Adittions
private int recervedNumbers;
@@ -231,7 +231,7 @@ public String toString() {
}
public String getDayString() {
- if (sessionWeekday==null) {
+ if (sessionWeekday == null) {
return "";
}
switch (sessionWeekday) {
@@ -341,16 +341,6 @@ public void setRoomNo(int roomNo) {
}
public Date getEndingTime() {
- if (endingTime == null) {
- if (startingTime == null) {
- endingTime = null;
- } else {
- Calendar e = Calendar.getInstance();
- e.setTime(startingTime);
- e.add(Calendar.HOUR, 2);
- endingTime = e.getTime();
- }
- }
return endingTime;
}
@@ -518,10 +508,4 @@ public void setExcludeFromPatientPortal(boolean excludeFromPatientPortal) {
this.excludeFromPatientPortal = excludeFromPatientPortal;
}
-
-
-
-
-
-
}
diff --git a/src/main/java/com/divudi/entity/cashTransaction/CashBook.java b/src/main/java/com/divudi/entity/cashTransaction/CashBook.java
new file mode 100644
index 0000000000..121b89812f
--- /dev/null
+++ b/src/main/java/com/divudi/entity/cashTransaction/CashBook.java
@@ -0,0 +1,188 @@
+/*
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
+ */
+package com.divudi.entity.cashTransaction;
+
+import com.divudi.entity.Department;
+import com.divudi.entity.Institution;
+import com.divudi.entity.WebUser;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import java.io.Serializable;
+import java.util.Date;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+import javax.persistence.Temporal;
+
+/**
+ *
+ * @author Lawan Chaamindu
+ */
+@Entity
+public class CashBook implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private Long id;
+ private String Name;
+ @ManyToOne
+ private Institution institution;
+ @ManyToOne
+ private Institution site;
+ @ManyToOne
+ private Department department;
+
+ //Created Properties
+ @ManyToOne
+ private WebUser creater;
+ @Temporal(javax.persistence.TemporalType.TIMESTAMP)
+ private Date createdAt;
+
+ //Retairing properties
+ private boolean retired;
+ @ManyToOne
+ private WebUser retirer;
+ @Temporal(javax.persistence.TemporalType.TIMESTAMP)
+ private Date retiredAt;
+ private String retireComments;
+
+ //Editer Properties
+ @ManyToOne
+ private WebUser editer;
+ @Temporal(javax.persistence.TemporalType.TIMESTAMP)
+ private Date editedAt;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 0;
+ hash += (id != null ? id.hashCode() : 0);
+ return hash;
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ // TODO: Warning - this method won't work in the case the id fields are not set
+ if (!(object instanceof CashBook)) {
+ return false;
+ }
+ CashBook other = (CashBook) object;
+ if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "com.divudi.entity.cashTransaction.CashBook[ id=" + id + " ]";
+ }
+
+ public String getName() {
+ return Name;
+ }
+
+ public void setName(String Name) {
+ this.Name = Name;
+ }
+
+ public Institution getInstitution() {
+ return institution;
+ }
+
+ public void setInstitution(Institution institution) {
+ this.institution = institution;
+ }
+
+ public Institution getSite() {
+ return site;
+ }
+
+ public void setSite(Institution site) {
+ this.site = site;
+ }
+
+ public Department getDepartment() {
+ return department;
+ }
+
+ public void setDepartment(Department department) {
+ this.department = department;
+ }
+
+ public WebUser getCreater() {
+ return creater;
+ }
+
+ public void setCreater(WebUser creater) {
+ this.creater = creater;
+ }
+
+ public Date getCreatedAt() {
+ return createdAt;
+ }
+
+ public void setCreatedAt(Date createdAt) {
+ this.createdAt = createdAt;
+ }
+
+ public boolean isRetired() {
+ return retired;
+ }
+
+ public void setRetired(boolean retired) {
+ this.retired = retired;
+ }
+
+ public WebUser getRetirer() {
+ return retirer;
+ }
+
+ public void setRetirer(WebUser retirer) {
+ this.retirer = retirer;
+ }
+
+ public Date getRetiredAt() {
+ return retiredAt;
+ }
+
+ public void setRetiredAt(Date retiredAt) {
+ this.retiredAt = retiredAt;
+ }
+
+ public String getRetireComments() {
+ return retireComments;
+ }
+
+ public void setRetireComments(String retireComments) {
+ this.retireComments = retireComments;
+ }
+
+ public WebUser getEditer() {
+ return editer;
+ }
+
+ public void setEditer(WebUser editer) {
+ this.editer = editer;
+ }
+
+ public Date getEditedAt() {
+ return editedAt;
+ }
+
+ public void setEditedAt(Date editedAt) {
+ this.editedAt = editedAt;
+ }
+
+}
diff --git a/src/main/java/com/divudi/entity/cashTransaction/CashBookEntry.java b/src/main/java/com/divudi/entity/cashTransaction/CashBookEntry.java
new file mode 100644
index 0000000000..cbf5b1af11
--- /dev/null
+++ b/src/main/java/com/divudi/entity/cashTransaction/CashBookEntry.java
@@ -0,0 +1,270 @@
+/*
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
+ */
+package com.divudi.entity.cashTransaction;
+
+import com.divudi.data.PaymentMethod;
+import com.divudi.entity.Bill;
+import com.divudi.entity.Department;
+import com.divudi.entity.Institution;
+import com.divudi.entity.Payment;
+import com.divudi.entity.WebUser;
+import java.io.Serializable;
+import java.util.Date;
+import javax.persistence.Entity;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+import javax.persistence.Temporal;
+
+/**
+ *
+ * @author Buddhika
+ */
+@Entity
+public class CashBookEntry implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private Long id;
+
+ private String name;
+ @ManyToOne
+ private Bill bill;
+ @ManyToOne
+ private Payment payment;
+ @ManyToOne
+ private CashBook cashBook;
+ @Enumerated
+ private PaymentMethod paymentMethod;
+ private Double entryValue;
+ private Double institutionBalance;
+ private Double departmentBalance;
+ private Double siteBalance;
+
+ @ManyToOne
+ private Institution institution;
+ @ManyToOne
+ private Institution site;
+ @ManyToOne
+ private Department department;
+
+
+ //Created Properties
+ @ManyToOne
+ private WebUser creater;
+ @Temporal(javax.persistence.TemporalType.TIMESTAMP)
+ private Date createdAt;
+
+ //Retairing properties
+ private boolean retired;
+ @ManyToOne
+ private WebUser retirer;
+ @Temporal(javax.persistence.TemporalType.TIMESTAMP)
+ private Date retiredAt;
+ private String retireComments;
+
+ //Editer Properties
+ @ManyToOne
+ private WebUser editer;
+ @Temporal(javax.persistence.TemporalType.TIMESTAMP)
+ private Date editedAt;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 0;
+ hash += (id != null ? id.hashCode() : 0);
+ return hash;
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ // TODO: Warning - this method won't work in the case the id fields are not set
+ if (!(object instanceof CashBookEntry)) {
+ return false;
+ }
+ CashBookEntry other = (CashBookEntry) object;
+ if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "com.divudi.entity.cashTransaction.CashBookEntry[ id=" + id + " ]";
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Bill getBill() {
+ return bill;
+ }
+
+ public void setBill(Bill bill) {
+ this.bill = bill;
+ }
+
+ public Payment getPayment() {
+ return payment;
+ }
+
+ public void setPayment(Payment payment) {
+ this.payment = payment;
+ }
+
+ public CashBook getCashBook() {
+ return cashBook;
+ }
+
+ public void setCashBook(CashBook cashBook) {
+ this.cashBook = cashBook;
+ }
+
+ public Institution getInstitution() {
+ return institution;
+ }
+
+ public void setInstitution(Institution institution) {
+ this.institution = institution;
+ }
+
+ public Institution getSite() {
+ return site;
+ }
+
+ public void setSite(Institution site) {
+ this.site = site;
+ }
+
+ public Department getDepartment() {
+ return department;
+ }
+
+ public void setDepartment(Department department) {
+ this.department = department;
+ }
+
+ public WebUser getCreater() {
+ return creater;
+ }
+
+ public void setCreater(WebUser creater) {
+ this.creater = creater;
+ }
+
+ public Date getCreatedAt() {
+ return createdAt;
+ }
+
+ public void setCreatedAt(Date createdAt) {
+ this.createdAt = createdAt;
+ }
+
+ public boolean isRetired() {
+ return retired;
+ }
+
+ public void setRetired(boolean retired) {
+ this.retired = retired;
+ }
+
+ public WebUser getRetirer() {
+ return retirer;
+ }
+
+ public void setRetirer(WebUser retirer) {
+ this.retirer = retirer;
+ }
+
+ public Date getRetiredAt() {
+ return retiredAt;
+ }
+
+ public void setRetiredAt(Date retiredAt) {
+ this.retiredAt = retiredAt;
+ }
+
+ public String getRetireComments() {
+ return retireComments;
+ }
+
+ public void setRetireComments(String retireComments) {
+ this.retireComments = retireComments;
+ }
+
+ public WebUser getEditer() {
+ return editer;
+ }
+
+ public void setEditer(WebUser editer) {
+ this.editer = editer;
+ }
+
+ public Date getEditedAt() {
+ return editedAt;
+ }
+
+ public void setEditedAt(Date editedAt) {
+ this.editedAt = editedAt;
+ }
+
+ public PaymentMethod getPaymentMethod() {
+ return paymentMethod;
+ }
+
+ public void setPaymentMethod(PaymentMethod paymentMethod) {
+ this.paymentMethod = paymentMethod;
+ }
+
+ public Double getEntryValue() {
+ return entryValue;
+ }
+
+ public void setEntryValue(Double entryValue) {
+ this.entryValue = entryValue;
+ }
+
+ public Double getInstitutionBalance() {
+ return institutionBalance;
+ }
+
+ public void setInstitutionBalance(Double institutionBalance) {
+ this.institutionBalance = institutionBalance;
+ }
+
+ public Double getDepartmentBalance() {
+ return departmentBalance;
+ }
+
+ public void setDepartmentBalance(Double departmentBalance) {
+ this.departmentBalance = departmentBalance;
+ }
+
+ public Double getSiteBalance() {
+ return siteBalance;
+ }
+
+ public void setSiteBalance(Double siteBalance) {
+ this.siteBalance = siteBalance;
+ }
+
+}
diff --git a/src/main/java/com/divudi/entity/channel/SessionInstance.java b/src/main/java/com/divudi/entity/channel/SessionInstance.java
index f202cd8385..215c05fe20 100644
--- a/src/main/java/com/divudi/entity/channel/SessionInstance.java
+++ b/src/main/java/com/divudi/entity/channel/SessionInstance.java
@@ -219,6 +219,7 @@ public class SessionInstance implements Serializable {
private Long onCallPatientCount;
private Long completedPatientCount;
private Long remainingPatientCount;
+ private Long paidToDoctorPatientCount;
private Long reservedBookingCount;
private boolean arrived;
@@ -1310,6 +1311,14 @@ public Long getReservedBookingCount() {
public void setReservedBookingCount(Long reservedBookingCount) {
this.reservedBookingCount = reservedBookingCount;
}
+
+ public Long getPaidToDoctorPatientCount() {
+ return paidToDoctorPatientCount;
+ }
+
+ public void setPaidToDoctorPatientCount(Long paidToDoctorPatientCount) {
+ this.paidToDoctorPatientCount = paidToDoctorPatientCount;
+ }
diff --git a/src/main/java/com/divudi/entity/lab/PatientSample.java b/src/main/java/com/divudi/entity/lab/PatientSample.java
index f9601f30dd..6e35ba9365 100644
--- a/src/main/java/com/divudi/entity/lab/PatientSample.java
+++ b/src/main/java/com/divudi/entity/lab/PatientSample.java
@@ -29,7 +29,7 @@
/**
*
* @author buddhika.ari@gmail.com
- *
+ *
*/
@Entity
public class PatientSample implements Serializable {
@@ -39,13 +39,12 @@ public class PatientSample implements Serializable {
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private Long sampleId;
-
+
@ManyToOne
private Institution institution;
@ManyToOne
private Department department;
-
-
+
@ManyToOne
private Patient patient;
@ManyToOne
@@ -86,10 +85,10 @@ public class PatientSample implements Serializable {
private WebUser sampleSentBy;
@Temporal(javax.persistence.TemporalType.TIMESTAMP)
private Date sampleSentAt;
-
+
@Enumerated
private Priority priority;
-
+
//Sent To Analyzer
private Boolean readyTosentToAnalyzer;
@Enumerated(EnumType.STRING)
@@ -153,7 +152,7 @@ public class PatientSample implements Serializable {
@ManyToOne
private Institution sampleReceivedAtLabInstitution;
- @Enumerated
+ @Enumerated
private PatientInvestigationStatus status;
//Cancellation
@@ -175,9 +174,6 @@ public class PatientSample implements Serializable {
private Date retiredAt;
private String retireComments;
-
-
-
public Long getId() {
return id;
}
@@ -186,16 +182,11 @@ public void setId(Long id) {
this.id = id;
}
-
-
-
public String getIdStr() {
String formatted = id + "";
return formatted;
}
-
-
@Override
public int hashCode() {
int hash = 0;
@@ -380,8 +371,6 @@ public Institution getCancellInstitution() {
public void setCancellInstitution(Institution cancellInstitution) {
this.cancellInstitution = cancellInstitution;
}
-
-
public Bill getBill() {
return bill;
@@ -680,6 +669,9 @@ public void setStatus(PatientInvestigationStatus status) {
}
public Long getSampleId() {
+ if (sampleId == null) {
+ sampleId = id;
+ }
return sampleId;
}
diff --git a/src/main/java/com/divudi/facade/AbstractFacade.java b/src/main/java/com/divudi/facade/AbstractFacade.java
index 8eb15793fd..a7693696bc 100644
--- a/src/main/java/com/divudi/facade/AbstractFacade.java
+++ b/src/main/java/com/divudi/facade/AbstractFacade.java
@@ -78,6 +78,24 @@ public T findFirstByJpql(String jpql) {
}
}
+ public List findByJpql(String jpql, Map parameters, Map temporalTypes) {
+ TypedQuery qry = getEntityManager().createQuery(jpql, entityClass);
+
+ for (Map.Entry param : parameters.entrySet()) {
+ String paramName = param.getKey();
+ Object paramValue = param.getValue();
+
+ if (paramValue instanceof Date && temporalTypes.containsKey(paramName)) {
+ TemporalType tt = temporalTypes.get(paramName);
+ qry.setParameter(paramName, (Date) paramValue, tt);
+ } else {
+ qry.setParameter(paramName, paramValue);
+ }
+ }
+
+ return qry.getResultList();
+ }
+
public List