Skip to content

Commit

Permalink
Merge pull request #3 from udsm-dhis2-lab/excemption-updated-report
Browse files Browse the repository at this point in the history
Excemption updated report
  • Loading branch information
KAL99-byte authored Jan 22, 2025
2 parents a6d11f4 + 20b3ab4 commit bca64e5
Show file tree
Hide file tree
Showing 4 changed files with 1,370 additions and 1 deletion.
2 changes: 1 addition & 1 deletion EMR/Bin-card.html
Original file line number Diff line number Diff line change
Expand Up @@ -563,4 +563,4 @@ <h2 class="text-center report-header">Bin Card</h2>
</div>
</div>
</body>
</html>
</html>
236 changes: 236 additions & 0 deletions EMR/excemption.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
<!DOCTYPE html>
<html lang="en">
<head>
<style>
#report-app .loader-section {
padding: 5rem;
text-align: center;
background-color: #f2f2f2;
margin-top: 10px;
margin-bottom: 20px;
}

#report-app .spaced {
margin-top: 5rem;
}
#report-app table {
border-collapse: collapse;
}
#report-app table,
#report-app th,
#report-app td {
border: 1px solid #c0c0c0;
}
#report-app th {
text-align: center;
}
#report-app td,
#report-app th {
height: 25px;
padding: 6px;
margin: 10px;
}

#report-app .loader {
border: 16px solid #f3f3f3;
border-radius: 50%;
border-top: 16px solid #3498db;
width: 120px;
height: 120px;
-webkit-animation: spin 2s linear infinite; /* Safari */
animation: spin 2s linear infinite;
}

/* Safari */
@-webkit-keyframes spin {
0% {
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
}
}

@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
</style>

<link
rel="stylesheet"
type="text/css"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"
/>
<link
rel="stylesheet"
type="text/css"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css"
/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js"
integrity="sha512-WFN04846sdKMIP5LKNphMaWzU7YpMyCU245etK3g/2ARYbPK9Ub18eG+ljU96qKRCWh+quCY7yefSmlkQw1ANQ=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
></script>
<script type="text/javascript">
angular
.module("reportModule", [])
.factory("FactoryDefns", function ($window, $http) {
var uri = "data:application/vnd.ms-excel;base64,",
template =
'<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table border="1">{table}</table><br /><table border="1">{table}</table></body></html>',
base64 = function (s) {
return $window.btoa(unescape(encodeURIComponent(s)));
},
format = function (s, c) {
return s.replace(/{(\w+)}/g, function (m, p) {
return c[p];
});
};
return {
tableToExcel: function () {
var tables = $(
".pop-table, .maternal-table, .cchp-table, .opd-table, .ipd-table, .death-table, .notifiable-table, .tracer-table"
);
var ctx = { worksheet: "Sheet 1" };
var str =
'<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body>';

tables.each(function (index) {
$(this)
.find("td.hidden")
.each(function (index2) {
this.remove();
});
ctx["table" + index] = this.innerHTML;
if (this.title == "no-border") {
str += "<table>{" + "table" + index + "}</table><br />";
} else {
str +=
'<table border="1">{' + "table" + index + "}</table><br />";
}
});
str += "</body></html>";
var href = uri + base64(format(str, ctx));
return href;
},
getData: async function (reportDimensions) {
if (!reportDimensions) {
return null;
}
return await $http
.get(
`../../../openmrs/ws/rest/v1/reportingrest/dataSet/${reportDimensions?.dataSetUuid}?startDate=${reportDimensions?.startDate}&endDate=${reportDimensions?.endDate}`
)
.then((response) => {
return response.data;
});
},
};
})
.controller("reportController", [
"$scope",
"$http",
"$timeout",
"$q",
"$sce",
"FactoryDefns",
function ($scope, $http, $timeout, $q, $sce, FactoryDefns) {
$scope.currentUser = null;
$scope.loading = false;
$scope.reasonsHeaders = [];
$scope.reportDimensions = {
startDate: window["iReportsDimensions"]
? window["iReportsDimensions"]?.startDate
: "2022-11-22",
endDate: window["iReportsDimensions"]
? window["iReportsDimensions"]?.endDate
: new Date().getFullYear().toString() +
"-" +
new Date().getMonth() +
1 +
"-" +
new Date().getDate(),
dataSetUuid: "8bf496d9-a915-4802-af13-5a312e7860a3",

};
$scope.dataRows = [];
$scope.maxRejectionReasons = 1;
$scope.loading = true;
FactoryDefns.getData($scope.reportDimensions).then((response) => {
const responseRows = response?.rows;
$scope.dataRows = responseRows?.map((row, index) => {
return {
...row,
concept_amounts: $sce.trustAsHtml(
row.concept_amounts.replace(/, /g, "<br>") // Replace commas with <br> for new lines
),
}
})


$scope.loading = false;
$scope.$apply();
});
},
]);
</script>
</head>
<body>
<div id="report-app" ng-app="reportModule" ng-controller="reportController">
<h3 class="text-center">PATIENTS' EXCEMPTION REPORT</h3>
<div style="width: 100%; overflow: auto; margin-top: 16px">
<table class="table table-bordered" ng-if="!loading">
<thead style="background-color: #2e8180; color: #fff">
<tr>
<th>SN</th>
<th>DATE </th>
<th>FIRST NAME</th>
<th>LAST NAME</th>
<th>GENDER</th>
<th>EXEMPTION TYPE</th>
<th>CRITERIA</th>
<th>TOTAL AMOUNT</th>
<th>DESCRIPTION</th>
<th>REMARKS</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="dataRow in dataRows;">
<td>{{$index+1}}</td>
<td>{{dataRow.date_created | date:'yyyy-MM-dd'}}</td>
<td>{{dataRow.first_name}}</td>
<td>{{dataRow.last_name}}</td>
<td>{{dataRow.gender}}</td>
<td>{{dataRow.exemption_type}}</td>
<td>{{dataRow.criteria_name}}</td>
<td>{{dataRow.total_amount_exempted}}</td>
<td ng-bind-html="dataRow.concept_amounts"></td>
<td>{{dataRow.remarks}}</td>
</tr>
</tbody>
</table>
<div
ng-if="loading"
style="
width: 100%;
display: flex;
align-items: center;
justify-content: center;
"
>
<div class="loader"></div>
</div>
</div>
</div>
</body>
</html>
Loading

0 comments on commit bca64e5

Please sign in to comment.