Skip to content

Commit

Permalink
Merge pull request #6862 from hmislk/issue#6861
Browse files Browse the repository at this point in the history
Issue#6861 Closes #6861
  • Loading branch information
Irani96 authored Aug 21, 2024
2 parents aed5977 + 9ffd4ec commit b5d9f54
Show file tree
Hide file tree
Showing 11 changed files with 332 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/main/java/com/divudi/bean/common/ItemFeeManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ public String navigateToUploadItemFees() {
return "/admin/pricing/item_fee_upload?faces-redirect=true";
}

public String navigateToUploadFeeListType(){
return "/admin/pricing/feelist_type_upload?faces-redirect=true";
}

public String navigateToUploadCollectingCentreFeeList() {
return "/admin/pricing/collecting_centre_price_list_upload?faces-redirect=true";
}
Expand Down
145 changes: 144 additions & 1 deletion src/main/java/com/divudi/bean/emr/DataUploadController.java
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ public class DataUploadController implements Serializable {
List<Department> departmentsSaved;
private List<Consultant> consultantsToSave;
private List<Institution> creditCompanies;
private List<Route> routes;
private List<Category>feeListTypes;

private List<Doctor> doctorsTosave;
private List<Staff> staffToSave;
Expand All @@ -243,6 +245,10 @@ public class DataUploadController implements Serializable {
private List<ClinicalEntity> surgeries;
private List<ClinicalEntity> surgeriesToSave;
private List<ClinicalEntity> surgeriesToSkiped;

public String navigateToRouteUpload(){
return "/admin/institutions/route_upload?faces-redirect=true";
}

public String navigateToCollectingCenterUpload() {
uploadComplete = false;
Expand All @@ -256,7 +262,7 @@ public String navigateToDepartmentUpload() {

public String navigateToSupplierUpload() {
uploadComplete = false;
return "/admin/institutions/supplier_upload?faces-redirect=true";
return "/admin/institutions/route_upload?faces-redirect=true";
}

public void uploadPatientAreas() {
Expand All @@ -269,6 +275,17 @@ public void uploadPatientAreas() {
}
}
}

public void uploadFeeListTypes() {
feeListTypes = new ArrayList<>();
if (file != null) {
try ( InputStream inputStream = file.getInputStream()) {
feeListTypes = readFeeListTypesFromExcel(inputStream);
} catch (IOException e) {
e.printStackTrace();
}
}
}

public List<Area> readAreasFromExcel(InputStream inputStream) throws IOException {
Workbook workbook = new XSSFWorkbook(inputStream);
Expand Down Expand Up @@ -393,6 +410,8 @@ public String toUploadAmpsMin() {
public String toUploadVmps() {
return "/pharmacy/admin/upload_vmps?faces-redirect=true";
}



public void uploadPatients() {
List<Patient> patients;
Expand Down Expand Up @@ -589,6 +608,47 @@ public void uploadStaff() {
}
pollActive = false;
}

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

if (rowIterator.hasNext()) {
rowIterator.next();
}

Category category;

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);
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<Consultant> readConsultantsFromExcel(InputStream inputStream) throws IOException {
List<Consultant> cons = new ArrayList<>();
Expand Down Expand Up @@ -2799,6 +2859,23 @@ 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<>();
Expand All @@ -2825,6 +2902,54 @@ public void uploadCreditCOmpanies() {
}
}
}

private List<Route> readRoutesFromExcel(InputStream inputStream) throws IOException{
Workbook workbook = new XSSFWorkbook(inputStream);
Sheet sheet = workbook.getSheetAt(0);
Iterator<Row> rowIterator = sheet.rowIterator();

List<Route> 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<Institution> readCollectingCentresFromExcel(InputStream inputStream) throws IOException {
Workbook workbook = new XSSFWorkbook(inputStream);
Expand Down Expand Up @@ -3566,6 +3691,8 @@ public void uploadCollectingCentrePriceList() {
}
}
}



public void uploadInvestigations() {
List<Investigation> investigations;
Expand Down Expand Up @@ -5523,4 +5650,20 @@ public void setTemplateForsupplierCentreUpload(StreamedContent templateForsuppli
this.templateForsupplierUpload = templateForsupplierCentreUpload;
}

public List<Route> getRoutes() {
return routes;
}

public void setRoutes(List<Route> routes) {
this.routes = routes;
}

public List<Category> getFeeListTypes() {
return feeListTypes;
}

public void setFeeListTypes(List<Category> feeListTypes) {
this.feeListTypes = feeListTypes;
}

}
1 change: 1 addition & 0 deletions src/main/java/com/divudi/bean/hr/StaffController.java
Original file line number Diff line number Diff line change
Expand Up @@ -1201,6 +1201,7 @@ public void saveSelected() {

recreateModel();
getItems();
fillSelectedItemsWithAllStaff();
}

public void updateFormItem(FormItemValue fi) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/META-INF/persistence.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<persistence version="2.2" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd">
<persistence-unit name="hmisPU" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/sethma</jta-data-source>
<jta-data-source>jdbc/arogya</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.logging.level.sql" value="INFO"/>
Expand All @@ -13,7 +13,7 @@
</properties>
</persistence-unit>
<persistence-unit name="hmisAuditPU" transaction-type="JTA">
<jta-data-source>jdbc/sethmaAudit</jta-data-source>
<jta-data-source>jdbc/arogyaAudit</jta-data-source>
<class>com.divudi.entity.AuditEvent</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
<p:commandButton styleClass="linkButton" ajax="false" value="Upload Collecting Centres" icon="fas fa-upload" action="#{dataUploadController.navigateToCollectingCenterUpload()}" />
<p:commandButton styleClass="linkButton" ajax="false" value="Upload Departments" icon="fas fa-upload" action="#{dataUploadController.navigateToDepartmentUpload()}" />
<p:commandButton styleClass="linkButton" ajax="false" value="Upload Supplier" icon="fas fa-upload" action="#{dataUploadController.navigateToSupplierUpload()}" />
<p:commandButton styleClass="linkButton" ajax="false" value="Upload Routes" icon="fas fa-upload" action="#{dataUploadController.navigateToRouteUpload()}" />

</div>
</p:tab>
Expand Down
1 change: 1 addition & 0 deletions src/main/webapp/admin/institutions/collecting_centre.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
id="acColl"
filter="true"
class="w-100"
style="max-width: 100%"
filterMatchMode="contains">
<f:selectItem itemLabel="Select" ></f:selectItem>
<f:selectItems
Expand Down
115 changes: 115 additions & 0 deletions src/main/webapp/admin/institutions/route_upload.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!-- Configuration done by Dr M H B Ariyaratne with assistance from ChatGPT from OpenAI. -->
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
template="/admin/institutions/admin_institutions_index.xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:p="http://primefaces.org/ui">
<ui:define name="admin">

<h:panelGroup rendered="#{!adjustmentCategoryControllerdataUploadController.uploadComplete}" >
<div class="container-fluid" >
<div class="card" >
<div class="card-header" >
<h2>Upload Routes</h2>
</div>
<div class="card-body" >
<h:form enctype="multipart/form-data">
<p:fileUpload value="#{dataUploadController.file}"
mode="simple"
label="Choose File"/>
<p:commandButton value="Upload"
icon="fas fa-upload"
class="ui-button-success"
action="#{dataUploadController.uploadRoutes()}"
ajax="false"/>
<p:commandButton value="Download Template"
ajax="false"
icon="fas fa-download"
class="ui-button-warning mx-2"
onclick="PrimeFaces.monitorDownload(start, stop);" >
<p:fileDownload value="#{dataUploadController.templateForSupplierUpload}" />
</p:commandButton>

<p:dialog modal="true" widgetVar="statusDialog" header="Status" draggable="false" closable="false" resizable="false">
</p:dialog>
<script type="text/javascript">
function start() {
PF('statusDialog').show();
}

function stop() {
PF('statusDialog').hide();
}
</script>

</h:form>

<table class="table">
<thead>
<tr>
<th>Column</th>
<th>Title</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>A</td>
<td>Name</td>
<td>Name. Required</td>
</tr>
<tr>
<td>B</td>
<td>Institution Name</td>
<td>Institution Name. Required</td>
</tr>
<tr>
<td>C</td>
<td>Description</td>
<td>Description. Optional</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>

<p:poll update="tbl"></p:poll>
</h:panelGroup>

<h:panelGroup rendered="#{adjustmentCategoryControllerdataUploadController.uploadComplete}" >

<p:dataTable id="tbl"
value="#{dataUploadController.routes}"
var="routes"
paginator="true"
rows="10"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="5,10,15">
<f:facet name="header" class="p-1" >
<p:outputLabel value="Uploded More Collecting Centres" ></p:outputLabel>
<p:commandButton
style="float: right;"
class="m-1"
ajax="false"
value="To Upload Routes"
icon="fas fa-upload" action="#{dataUploadController.navigateToRouteUpload()}" />
</f:facet>

<p:column headerText="Name">
<h:outputText value="#{collectincentre.code}" />
</p:column>
<p:column headerText="Institution">
<h:outputText value="#{collectincentre.name}" />
</p:column>
</p:dataTable>


</h:panelGroup>


</ui:define>
</ui:composition>
2 changes: 1 addition & 1 deletion src/main/webapp/admin/pricing/fee_list_types.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<table class="alignTop">
<tr class="alignTop">
<td colspan="2" class="alignTop">
<p:selectOneListbox id="lstItems" value="#{categoryController.current}" class="w-100">
<p:selectOneListbox id="lstItems" filter="true" value="#{categoryController.current}" class="w-100">
<f:selectItems value="#{categoryController.feeListTypes}"
var="r" itemLabel="#{r.name} " itemValue="#{r}" />
<f:ajax event="change" execute="lstItems" render="panelDetails" />
Expand Down
Loading

0 comments on commit b5d9f54

Please sign in to comment.