Skip to content

Commit

Permalink
Merge pull request #9853 from hmislk/Issue#9824_Grn_Excel_Button
Browse files Browse the repository at this point in the history
Issue#9824 grn excel button Closes #9824
  • Loading branch information
Irani96 authored Dec 26, 2024
2 parents 2d4f048 + e04e4e7 commit 0ac274c
Show file tree
Hide file tree
Showing 9 changed files with 969 additions and 386 deletions.
250 changes: 5 additions & 245 deletions src/main/java/com/divudi/bean/common/ReportsController.java
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ public void setDischargedStatus(String dischargedStatus) {
this.dischargedStatus = dischargedStatus;
}


public PaymentMethod getPaymentMethod() {
return paymentMethod;
}
Expand Down Expand Up @@ -402,7 +403,6 @@ public void setSelectedDateType(String selectedDateType) {
this.selectedDateType = selectedDateType;
}


public Investigation getInvestigation() {
return investigation;
}
Expand Down Expand Up @@ -1652,6 +1652,7 @@ public void generateSampleCarrierReport() {
private ReportTemplateRowBundle generateSampleCarrierBillItems(List<BillTypeAtomic> bts) {
Map<String, Object> parameters = new HashMap<>();


String jpql = "SELECT new com.divudi.data.ReportTemplateRow(pi) "
+ "FROM PatientInvestigation pi "
+ "JOIN pi.billItem billItem "
Expand All @@ -1660,6 +1661,7 @@ private ReportTemplateRowBundle generateSampleCarrierBillItems(List<BillTypeAtom
+ " and billItem.retired=false "
+ " and bill.retired=false ";


jpql += "AND bill.billTypeAtomic in :bts ";
parameters.put("bts", bts);

Expand Down Expand Up @@ -2615,7 +2617,7 @@ public void generateDebtorBalanceReport(final boolean onlyDueBills) {
}

public ReportTemplateRowBundle generateDebtorBalanceReportBills(List<BillTypeAtomic> bts, List<PaymentMethod> billPaymentMethods,
boolean onlyDueBills) {
boolean onlyDueBills) {
Map<String, Object> parameters = new HashMap<>();
String jpql = "SELECT new com.divudi.data.ReportTemplateRow(bill) "
+ "FROM Bill bill "
Expand Down Expand Up @@ -3138,6 +3140,7 @@ private ReportTemplateRowBundle generateExternalLaboratoryWorkloadBillItems(List
// + "LEFT JOIN PatientInvestigation pi ON pi.billItem = billItem "
// + "WHERE bill.billTypeAtomic IN :bts "
// + "AND bill.createdAt BETWEEN :fd AND :td ";

String jpql = "SELECT new com.divudi.data.ReportTemplateRow(billItem) "
+ "FROM PatientInvestigation pi "
+ "JOIN pi.billItem billItem "
Expand Down Expand Up @@ -3628,249 +3631,6 @@ public Double calculateDueAmountNetTotal() {
return dueAmountNetTotal;
}

public Double calculateNetAmountNetTotal() {
double netAmountNetTotal = 0.0;
Map<Institution, List<Bill>> billMap = bundle.getGroupedBillItemsByInstitution();

for (Map.Entry<Institution, List<Bill>> entry : billMap.entrySet()) {
List<Bill> bills = entry.getValue();

netAmountNetTotal += calculateNetAmountSubTotalByBills(bills);
}

return netAmountNetTotal;
}

public Double calculateGrossAmountSubTotalByBills(List<Bill> bills) {
Double billTotal = 0.0;

for (Bill bill : bills) {
billTotal += bill.getBillTotal();
}

return billTotal;
}

public Double calculatePatientShareSubTotalByBills(List<Bill> bills) {
Double settledAmountByPatient = 0.0;

for (Bill bill : bills) {
settledAmountByPatient += bill.getSettledAmountByPatient();
}

return settledAmountByPatient;
}

public Double calculateSponsorShareSubTotalByBills(List<Bill> bills) {
Double settledAmountBySponsor = 0.0;

for (Bill bill : bills) {
settledAmountBySponsor += bill.getSettledAmountBySponsor();
}

return settledAmountBySponsor;
}

public Double calculateDueAmountSubTotalByBills(List<Bill> bills) {
Double balance = 0.0;

for (Bill bill : bills) {
balance += bill.getBalance();
}

return balance;
}

public Double calculateGrossAmountNetTotal() {
double grossAmountNetTotal = 0.0;
Map<Institution, List<Bill>> billMap = bundle.getGroupedBillItemsByInstitution();

for (Map.Entry<Institution, List<Bill>> entry : billMap.entrySet()) {
List<Bill> bills = entry.getValue();

grossAmountNetTotal += calculateGrossAmountSubTotalByBills(bills);
}

return grossAmountNetTotal;
}

public Double calculateDiscountNetTotal() {
double discountNetTotal = 0.0;
Map<Institution, List<Bill>> billMap = bundle.getGroupedBillItemsByInstitution();

for (Map.Entry<Institution, List<Bill>> entry : billMap.entrySet()) {
List<Bill> bills = entry.getValue();

discountNetTotal += calculateDiscountSubTotalByBills(bills);
}

return discountNetTotal;
}

public Double calculatePatientShareNetTotal() {
double patientShareNetTotal = 0.0;
Map<Institution, List<Bill>> billMap = bundle.getGroupedBillItemsByInstitution();

for (Map.Entry<Institution, List<Bill>> entry : billMap.entrySet()) {
List<Bill> bills = entry.getValue();

patientShareNetTotal += calculatePatientShareSubTotalByBills(bills);
}

return patientShareNetTotal;
}

public Double calculateDueAmountNetTotal() {
double dueAmountNetTotal = 0.0;
Map<Institution, List<Bill>> billMap = bundle.getGroupedBillItemsByInstitution();

for (Map.Entry<Institution, List<Bill>> entry : billMap.entrySet()) {
List<Bill> bills = entry.getValue();

dueAmountNetTotal += calculateDueAmountSubTotalByBills(bills);
}

return dueAmountNetTotal;
}

public Double calculateSponsorShareNetTotal() {
double sponsorShareNetTotal = 0.0;
Map<Institution, List<Bill>> billMap = bundle.getGroupedBillItemsByInstitution();

for (Map.Entry<Institution, List<Bill>> entry : billMap.entrySet()) {
List<Bill> bills = entry.getValue();

sponsorShareNetTotal += calculateSponsorShareSubTotalByBills(bills);
}

return sponsorShareNetTotal;
}

public Double calculateNetAmountNetTotal() {
double netAmountNetTotal = 0.0;
Map<Institution, List<Bill>> billMap = bundle.getGroupedBillItemsByInstitution();

for (Map.Entry<Institution, List<Bill>> entry : billMap.entrySet()) {
List<Bill> bills = entry.getValue();

netAmountNetTotal += calculateNetAmountSubTotalByBills(bills);
}

return netAmountNetTotal;
}

public Double calculateNetAmountSubTotalByBills(List<Bill> bills) {
Double netTotal = 0.0;

for (Bill bill : bills) {
netTotal += bill.getNetTotal();
}

return netTotal;
}

public Double calculateGrossAmountSubTotalByBills(List<Bill> bills) {
Double billTotal = 0.0;

for (Bill bill : bills) {
billTotal += bill.getBillTotal();
}

return billTotal;
}

public Double calculatePatientShareSubTotalByBills(List<Bill> bills) {
Double settledAmountByPatient = 0.0;

for (Bill bill : bills) {
settledAmountByPatient += bill.getSettledAmountByPatient();
}

return settledAmountByPatient;
}

public Double calculateSponsorShareSubTotalByBills(List<Bill> bills) {
Double settledAmountBySponsor = 0.0;

for (Bill bill : bills) {
settledAmountBySponsor += bill.getSettledAmountBySponsor();
}

return settledAmountBySponsor;
}

public Double calculateDueAmountSubTotalByBills(List<Bill> bills) {
Double balance = 0.0;

for (Bill bill : bills) {
balance += bill.getBalance();
}

return balance;
}

public Double calculateGrossAmountNetTotal() {
double grossAmountNetTotal = 0.0;
Map<Institution, List<Bill>> billMap = bundle.getGroupedBillItemsByInstitution();

for (Map.Entry<Institution, List<Bill>> entry : billMap.entrySet()) {
List<Bill> bills = entry.getValue();

grossAmountNetTotal += calculateGrossAmountSubTotalByBills(bills);
}

return grossAmountNetTotal;
}

public Double calculateDiscountNetTotal() {
double discountNetTotal = 0.0;
Map<Institution, List<Bill>> billMap = bundle.getGroupedBillItemsByInstitution();

for (Map.Entry<Institution, List<Bill>> entry : billMap.entrySet()) {
List<Bill> bills = entry.getValue();

discountNetTotal += calculateDiscountSubTotalByBills(bills);
}

return discountNetTotal;
}

public Double calculateDiscountSubTotalByBills(List<Bill> bills) {
Double discount = 0.0;

for (Bill bill : bills) {
discount += bill.getDiscount();
}

return discount;
}

public Double calculatePatientShareNetTotal() {
double patientShareNetTotal = 0.0;
Map<Institution, List<Bill>> billMap = bundle.getGroupedBillItemsByInstitution();

for (Map.Entry<Institution, List<Bill>> entry : billMap.entrySet()) {
List<Bill> bills = entry.getValue();

patientShareNetTotal += calculatePatientShareSubTotalByBills(bills);
}

return patientShareNetTotal;
}

public Double calculateDueAmountNetTotal() {
double dueAmountNetTotal = 0.0;
Map<Institution, List<Bill>> billMap = bundle.getGroupedBillItemsByInstitution();

for (Map.Entry<Institution, List<Bill>> entry : billMap.entrySet()) {
List<Bill> bills = entry.getValue();

dueAmountNetTotal += calculateDueAmountSubTotalByBills(bills);
}

return dueAmountNetTotal;
}

public Double calculateSponsorShareNetTotal() {
double sponsorShareNetTotal = 0.0;
Map<Institution, List<Bill>> billMap = bundle.getGroupedBillItemsByInstitution();
Expand Down
53 changes: 53 additions & 0 deletions src/main/java/com/divudi/bean/emr/DataUploadController.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
import com.divudi.data.dataStructure.PharmacyImportCol;
import com.divudi.ejb.PharmacyBean;
import com.divudi.entity.Doctor;
import com.divudi.entity.Person;
import com.divudi.entity.inward.InwardService;
import com.divudi.entity.pharmacy.Ampp;
import com.divudi.entity.pharmacy.PharmaceuticalItemCategory;
Expand Down Expand Up @@ -292,6 +293,7 @@ public class DataUploadController implements Serializable {

private List<Doctor> doctorsTosave;
private List<Staff> staffToSave;
private List<Person> personsToSave;

private boolean pollActive;
private boolean uploadComplete;
Expand Down Expand Up @@ -344,6 +346,11 @@ public String navigateToDepartmentUpload() {
uploadComplete = false;
return "/admin/institutions/department_upload?faces-redirect=true";
}

public String navigateToUploadMembers() {
uploadComplete = false;
return "/membership/upload_members?faces-redirect=true";
}

public String navigateToSupplierUpload() {
uploadComplete = false;
Expand Down Expand Up @@ -1480,6 +1487,19 @@ public void uploadStaff() {
}
pollActive = false;
}

public void uploadMembers() {
pollActive = true;
items = new ArrayList<>();
if (file != null) {
try (InputStream inputStream = file.getInputStream()) {
personsToSave = readMembersFromExcel(inputStream);
} catch (IOException e) {
e.printStackTrace();
}
}
pollActive = false;
}

public void uploadFeeListItemFees() {
itemFees = new ArrayList<>();
Expand Down Expand Up @@ -2212,6 +2232,39 @@ public List<Staff> readStaffFromExcel(InputStream inputStream) throws IOExceptio

return stf;
}


public List<Person> readMembersFromExcel(InputStream inputStream) throws IOException {
List<Person> persons = new ArrayList<>();
Workbook workbook = new XSSFWorkbook(inputStream);
Sheet sheet = workbook.getSheetAt(0);
Iterator<Row> rowIterator = sheet.rowIterator();


String name="";
String phoneNumber1="";
Long phoneNumber; //convert string phone Number to Long

Person p = new Person();
p.setName(name);
p.setPhone(phoneNumber1);
p.setMobile(name);

// Assuming the first row contains headers, skip it
if (rowIterator.hasNext()) {
rowIterator.next();
}

while (rowIterator.hasNext()) {
Row row = rowIterator.next();

Person person = new Person();
person.setName(name);
persons.add(person);
}

return persons;
}

public void saveConsultants() {
for (Consultant con : consultantsToSave) {
Expand Down
Loading

0 comments on commit 0ac274c

Please sign in to comment.