Skip to content

Commit

Permalink
Merge pull request #9657 from hmislk/#9642_Report_Upload_(Out_Source)
Browse files Browse the repository at this point in the history
#9642 report upload (out source)  Closes #9642
  • Loading branch information
Irani96 authored Dec 17, 2024
2 parents 9ab5c0d + b40a4cc commit 3de8a03
Show file tree
Hide file tree
Showing 12 changed files with 685 additions and 136 deletions.
117 changes: 117 additions & 0 deletions .github/workflows/dev_ci_cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: DEV Deployment Pipeline

on:
push:
branches:
- dev-ci-cd-setup

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'

- name: Cache Maven Packages
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build with Maven
run: mvn clean package -DskipTests

- name: Archive Build Artifacts
uses: actions/upload-artifact@v3
with:
name: build-artifacts
path: target/*.war

# - name: Run Tests
# run: mvn test

deploy:
needs: build
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Download Build Artifact
uses: actions/download-artifact@v3
with:
name: build-artifacts
path: ./

- name: Deploy to Payara
env:
SERVER_IP: ${{ secrets.SERVER_IP }}
SERVER_USER: ${{ secrets.SERVER_USER }}
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
PAYARA_ADMIN_PASS: ${{ secrets.PAYARA_ADMIN_PASS }}
run: |
# Add SSH private key to the SSH agent
echo "$SSH_PRIVATE_KEY" > private_key.pem
chmod 600 private_key.pem
# Variables
WAR_NAME="hmis.war"
WAR_DIR="~/app/latest"
# Ensure deployment directory exists
ssh -i private_key.pem -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "
mkdir -p $WAR_DIR
cd $WAR_DIR
# Remove old backup if it exists
if [ -f $WAR_NAME.old ]; then
rm $WAR_NAME.old
fi
# If the current WAR file exists, back it up
if [ -f $WAR_NAME ]; then
mv $WAR_NAME $WAR_NAME.old
fi
"
# Copy new WAR file to the server
rsync -aL --progress -e "ssh -i private_key.pem" ./*.war $SERVER_USER@$SERVER_IP:$WAR_DIR/$WAR_NAME
# Deploy the WAR using asadmin
ssh -i private_key.pem -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "
echo 'AS_ADMIN_PASSWORD=${{ secrets.PAYARA_ADMIN_PASS }}' > /tmp/payara-admin-pass.txt
/opt/payara5/bin/asadmin --user admin --passwordfile /tmp/payara-admin-pass.txt undeploy sethmademo || true
/opt/payara5/bin/asadmin --user admin --passwordfile /tmp/payara-admin-pass.txt deploy --force $WAR_DIR/$WAR_NAME
rm /tmp/payara-admin-pass.txt
"
# Validate if the application is running
ssh -i private_key.pem -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "
STATUS=\$(/opt/payara5/bin/asadmin list-applications | grep 'sethmademo')
if echo \"$STATUS\" | grep -q 'running'; then
echo 'Application is running.'
else
echo 'Application failed to start.' >&2
exit 1
fi
"
# Verify that the application is reachable via HTTP
RESPONSE_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://$SERVER_IP/sethmademo)
if [ "$RESPONSE_CODE" != "200" ]; then
echo "Application is not reachable at http://$SERVER_IP/sethmademo (HTTP $RESPONSE_CODE)" >&2
exit 1
fi
# Cleanup
rm -f private_key.pem
Original file line number Diff line number Diff line change
Expand Up @@ -1882,11 +1882,6 @@ public void searchBillsWithoutSampleId() {
jpql += " AND pi.billItem.bill.toDepartment = :department";
params.put("department", getDepartment());
}

if (bills != null) {
jpql += " AND pi.billItem.bill IN :bills";
params.put("bills", getBills());
}

if (patientInvestigationStatus != null) {
jpql += " AND pi.billItem.bill.status = :status";
Expand Down Expand Up @@ -2466,7 +2461,7 @@ public void searchPatientInvestigations() {
}

public void searchPatientReportsInBillingDepartment() {

StringBuilder jpql = new StringBuilder();
Map<String, Object> params = new HashMap<>();

Expand Down Expand Up @@ -3116,15 +3111,15 @@ public void listBillItemsForLabs() {
btas.add(BillTypeAtomic.OPD_BILL_CANCELLATION);
btas.add(BillTypeAtomic.OPD_BILL_REFUND);
btas.add(BillTypeAtomic.OPD_BILL_CANCELLATION_DURING_BATCH_BILL_CANCELLATION);


btas.add(BillTypeAtomic.PACKAGE_OPD_BILL_WITH_PAYMENT);
btas.add(BillTypeAtomic.PACKAGE_OPD_BILL_PAYMENT_COLLECTION_AT_CASHIER);
btas.add(BillTypeAtomic.PACKAGE_OPD_BILL_CANCELLATION);
btas.add(BillTypeAtomic.PACKAGE_OPD_BILL_CANCELLATION_DURING_BATCH_BILL_CANCELLATION);
btas.add(BillTypeAtomic.PACKAGE_OPD_BILL_REFUND);


// Starting from BillItem and joining to PatientInvestigation if needed
jpql = "SELECT DISTINCT b "
+ " FROM BillItem b "
Expand Down
138 changes: 133 additions & 5 deletions src/main/java/com/divudi/bean/lab/PatientReportController.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import com.divudi.bean.common.util.JsfUtil;
import static com.divudi.data.InvestigationItemValueType.Memo;
import static com.divudi.data.InvestigationItemValueType.Varchar;
import com.divudi.data.ReportType;
import com.divudi.data.lab.PatientInvestigationStatus;
import com.divudi.entity.clinical.ClinicalFindingValue;
import com.divudi.entity.lab.PatientSample;
Expand Down Expand Up @@ -182,6 +183,29 @@ public StreamedContent getReportAsPdf() {
return pdfSc;
}

public String navigateToViewPatientReport(PatientReport patientReport) {
System.out.println("Navigate To View Patient Report");
System.out.println("Report Type = " + patientReport.getReportType());
if (null == patientReport.getReportType()) {
System.out.println("Null");
setCurrentPatientReport(patientReport);
return "/lab/patient_report?faces-redirect=true";
} else {
switch (patientReport.getReportType()) {
case GENARATE:
System.out.println("GENARATE");
setCurrentPatientReport(patientReport);
return "/lab/patient_report?faces-redirect=true";
case UPLOAD:
System.out.println("UPLOAD");
patientReportUploadController.setPatientInvestigation(patientReport.getPatientInvestigation());
return "/lab/upload_patient_report?faces-redirect=true";
default:
return "";
}
}
}

public String searchRecentReportsOrderedByMyself() {
Doctor doctor;
String j = "Select r from PatientReport r "
Expand Down Expand Up @@ -326,7 +350,7 @@ public List<PatientReport> patientReports(PatientInvestigation pi) {
m.put("pi", pi);
return getFacade().findByJpql(j, m);
}

public List<PatientReport> approvedPatientReports(PatientInvestigation pi) {
String j = "select r from PatientReport r "
+ " where r.patientInvestigation=:pi"
Expand All @@ -336,8 +360,8 @@ public List<PatientReport> approvedPatientReports(PatientInvestigation pi) {
m.put("ret", false);
return getFacade().findByJpql(j, m);
}
public int approvedPatientReportCount(PatientInvestigation pi){

public int approvedPatientReportCount(PatientInvestigation pi) {
int reportCount = 0;
reportCount = approvedPatientReports(pi).size();
return reportCount;
Expand Down Expand Up @@ -2294,6 +2318,17 @@ public PatientReport createNewPatientReport(PatientInvestigation pi, Investigati
return createNewPatientReport(pi, ix, sampleIDs);
}

public PatientReport createNewPatientReportForUpload(PatientInvestigation pi, Investigation ix) {
String sampleIDs = "";
List<PatientSampleComponant> pscs = patientInvestigationController.getPatientSampleComponentsByInvestigation(pi);
if (pscs != null) {
for (PatientSampleComponant psc : pscs) {
sampleIDs += psc.getPatientSample().getIdStr() + " ";
}
}
return createNewPatientReportForUpload(pi, ix, sampleIDs);
}

public PatientReport createNewPatientReport(PatientInvestigation pi, Investigation ix, String sampleIds) {
System.out.println("createNewPatientReport");
System.out.println("pi = " + pi);
Expand All @@ -2302,6 +2337,7 @@ public PatientReport createNewPatientReport(PatientInvestigation pi, Investigati
PatientReport r = null;
if (pi != null && pi.getId() != null && ix != null) {
r = new PatientReport();
r.setReportType(ReportType.GENARATE);
r.setSampleIDs(sampleIds);
r.setCreatedAt(Calendar.getInstance(TimeZone.getTimeZone("IST")).getTime());
r.setCreater(getSessionController().getLoggedUser());
Expand All @@ -2319,7 +2355,57 @@ public PatientReport createNewPatientReport(PatientInvestigation pi, Investigati
getFacade().create(r);
r.setPatientInvestigation(pi);
getPrBean().addPatientReportItemValuesForReport(r);
// getEjbFacade().edit(r);
getFacade().edit(r);
setCurrentPatientReport(r);
pi.getPatientReports().add(r);
pi.setStatus(PatientInvestigationStatus.SAMPLE_INTERFACED);
pi.setPerformed(true);
pi.setPerformDepartment(sessionController.getDepartment());
pi.setPerformInstitution(sessionController.getInstitution());
pi.setPerformedAt(new Date());
pi.setPerformedUser(sessionController.getLoggedUser());

pi.setPrinted(false);
pi.setPrintingAt(null);
pi.setPrintingDepartment(null);
pi.setPrintingInstitution(null);
pi.setPrintingUser(null);

piFacade.edit(pi);
getCommonReportItemController().setCategory(ix.getReportFormat());
} else {
JsfUtil.addErrorMessage("No ptIx or Ix selected to add");
}
return r;
}

public PatientReport createNewPatientReportForUpload(PatientInvestigation pi, Investigation ix, String sampleIds) {
System.out.println("createNewPatientReport");
System.out.println("pi = " + pi);
System.out.println("ix = " + ix);
//System.err.println("creating a new patient report");
PatientReport r = null;
if (pi != null && pi.getId() != null && ix != null) {
r = new PatientReport();
r.setSampleIDs(sampleIds);
r.setReportType(ReportType.UPLOAD);
r.setCreatedAt(Calendar.getInstance(TimeZone.getTimeZone("IST")).getTime());
r.setCreater(getSessionController().getLoggedUser());
r.setItem(ix);
r.setDataEntryDepartment(sessionController.getLoggedUser().getDepartment());
r.setDataEntryInstitution(sessionController.getLoggedUser().getInstitution());
if (r.getTransInvestigation() != null) {
if (r.getTransInvestigation().getReportFormat() != null) {
r.setReportFormat(r.getTransInvestigation().getReportFormat());
} else {
ReportFormat nrf = reportFormatController.getValidReportFormat();
r.setReportFormat(nrf);
}
}
getFacade().create(r);
System.out.println("r = " + r);
r.setPatientInvestigation(pi);
getFacade().edit(r);
setCurrentPatientReport(r);
pi.getPatientReports().add(r);
pi.setStatus(PatientInvestigationStatus.SAMPLE_INTERFACED);
Expand Down Expand Up @@ -2463,13 +2549,55 @@ public String navigateToCreatedPatientReport(PatientInvestigation pi) {
}

if (pi.getInvestigation().isAlternativeReportAllowed()) {
link = patientInvestigationController.navigateToAlternativeReportSelector(pi);
link = patientInvestigationController.navigateToAlternativeReportSelector(pi);
} else {
link = navigateToNewlyCreatedPatientReport(pi);
}
return link;
}

public String navigateToUploadPatientReport(PatientInvestigation pi) {
String link;
if (pi == null) {
JsfUtil.addErrorMessage("No Patient Investigation");
return null;
}
Investigation ix = null;
if (pi.getInvestigation() == null) {
JsfUtil.addErrorMessage("No Investigation for Patient Report");
return null;
} else {
ix = (Investigation) pi.getInvestigation();
}
if (ix.getReportedAs() != null) {
ix = (Investigation) pi.getInvestigation().getReportedAs();
}
currentReportInvestigation = ix;
currentPtIx = pi;
PatientReport newlyCreatedReport = null;

newlyCreatedReport = createNewPatientReportForUpload(pi, ix);

if (newlyCreatedReport == null) {
JsfUtil.addErrorMessage("Error");
return null;
}
currentPatientReport = newlyCreatedReport;

System.out.println("New Report = " + currentPatientReport);

getCommonReportItemController().setCategory(ix.getReportFormat());

System.out.println("currentPtIx = " + currentPtIx);

patientReportUploadController.setPatientInvestigation(currentPtIx);

return "/lab/upload_patient_report?faces-redirect=true";
}

@Inject
PatientReportUploadController patientReportUploadController;

public String navigateToNewlyCreatedPatientReport(PatientInvestigation pi) {
if (pi == null) {
JsfUtil.addErrorMessage("No Patient Report");
Expand Down
Loading

0 comments on commit 3de8a03

Please sign in to comment.