Skip to content
Permalink
Browse files

BAH-832: Minimal display control that compute billing status of ERP i…

…tems
  • Loading branch information...
rbuisson committed Jun 13, 2019
1 parent 928a8be commit 31a43b72480439451442abc761330bc9f60c2345
@@ -15,6 +15,19 @@
"groupByVisits":true
}
},
"customControl": {
"type": "custom",
"displayOrder": 1,
"showDetailsButton": true,
"config": {
"retireLinesConditions": [["ORDER", "FULLY_INVOICED"]],
"nonApprovedConditions": [["ORDER", "NON_INVOICED"],["INVOICE", "OVERDUE", "NOT_PAID"]],
"approvedConditions": [["INVOICE", "PAID"],["INVOICE", "NOT_OVERDUE"]],
"showDetailsButton": true,
"translationKey": "IMPL_BILLING_STATUS",
"template": "<billing-status></billing-status>"
}
},
"diagnosis":{
"translationKey":"DASHBOARD_TITLE_DIAGNOSIS_KEY",
"type":"diagnosis",
@@ -151,4 +164,4 @@
}}
}
}
}
}
@@ -1,3 +1,181 @@
'use strict';
angular.module('bahmni.common.displaycontrol.custom')
.service('erpService', ['$http', '$httpParamSerializer', 'sessionService', function($http, $httpParamSerializer, sessionService) {

angular.module('bahmni.common.displaycontrol.custom');
this.getOrder = function(id, representation) {
var order = $http.get(Bahmni.Common.Constants.openmrsUrl + "/ws/rest/v1/erp/order/" + id + "?" + $httpParamSerializer({
rep: representation
}), {});
return order;
};

this.getAllOrders = function(filters, representation) {
var patientFilter = {
"field": "uuid",
"comparison": "=",
"value": ""
}
// filters.push(patientFilter)
var orders = $http.post(Bahmni.Common.Constants.openmrsUrl + "/ws/rest/v1/erp/order?" + $httpParamSerializer({
rep: representation
}), {
filters: filters
});
return orders;
};

this.getInvoice = function(id, representation) {
var invoice = $http.get(Bahmni.Common.Constants.openmrsUrl + "/ws/rest/v1/erp/invoice/" + id + "?" + $httpParamSerializer({
rep: representation
}), {});
return invoice;
};

this.getAllInvoices = function(filters, representation) {
var patientFilter = {
"field": "uuid",
"comparison": "=",
"value": ""
}
// filters.push(patientFilter)
var salesInvoiceFilter = {
"field": "type",
"comparison": "=",
"value": "out_invoice"
}
filters.push(salesInvoiceFilter)
var invoices = $http.post(Bahmni.Common.Constants.openmrsUrl + "/ws/rest/v1/erp/invoice?" + $httpParamSerializer({
rep: representation
}), {
params: {
rep: "full"
},
filters: filters
});
return invoices;
};

}]);

angular.module('bahmni.common.displaycontrol.custom')
.directive('billingStatus', ['erpService', 'appService', 'spinner', '$q', function(erpService, appService, spinner, $q) {
var link = function($scope) {

$scope.contentUrl = appService.configBaseUrl() + "/customDisplayControl/views/billingStatus.html";

var lines = [];
$scope.lines = [];
$scope.debug = [];

const ORDER = "ORDER"
const INVOICE = "INVOICE"

const NON_INVOICED = "NON INVOICED"
const FULLY_INVOICED = "FULLY_INVOICED"
const PARTIALLY_INVOICED = "PARTIALLY_INVOICED"

const PAID = "PAID"
const NOT_PAID = "NOT_PAID"

const OVERDUE = "OVERDUE"
const NOT_OVERDUE = "NOT_OVERDUE"

var retireLinesConditions = $scope.config.retireLinesConditions
var nonApprovedConditions = $scope.config.nonApprovedConditions
var approvedConditions = $scope.config.approvedConditions

var ordersFilters = [];
var invoicesFilters = [];

erpService.getAllOrders(ordersFilters, "full").success(function(orders) {
erpService.getAllInvoices(invoicesFilters, "full").success(function(invoices) {
setTagsToOrderLines(orders);
setTagsToInvoiceLines(invoices);
setApprovalStatusToLines();
$scope.lines = lines;
});
});

var setApprovalStatusToLines = function() {
lines.forEach(function(line) {
line.approved = false;
line.retire = false;
approvedConditions.forEach(function(condition) {
if (_.difference(condition, line.tags).length == 0) {
line.approved = line.approved || true;
}
})
nonApprovedConditions.forEach(function(condition) {
if (_.difference(condition, line.tags).length == 0) {
line.approved = line.approved || false;
}
})
// set lines to retire
retireLinesConditions.forEach(function(condition) {
if (_.difference(condition, line.tags).length == 0) {
line.retire = line.retire || true;
}
})
})
};

var setTagsToOrderLines = function(orders) {
orders.forEach(function(order) {
order.order_lines.forEach(function(line) {
// NON INVOICED
var tags = []
tags.push(ORDER);
if (line.qty_invoiced == 0) {
tags.push(NON_INVOICED);
} else if (line.qty_invoiced != 0 && line.qty_to_invoice != 0) {
// PARTIALLY_INVOICED
tags.push(PARTIALLY_INVOICED);
} else if (line.qty_to_invoice == 0) {
// FULLY_INVOICED
tags.push(FULLY_INVOICED);
}
lines.push({
"id": line.id,
"date": order.date_order,
"document": order.name,
"tags": tags,
"displayName": line.display_name
})
})
})
return orders;
};

var setTagsToInvoiceLines = function(invoices) {
invoices.forEach(function(invoice) {
invoice.invoice_lines.forEach(function(line) {
var tags = [];
tags.push(INVOICE)
if (invoice.state == "paid") {
tags.push(PAID);
} else {
tags.push(NOT_PAID);
}
if (new Date(invoice.date_due).getDate() >= new Date().getDate()) {
tags.push(OVERDUE);
} else {
tags.push(NOT_OVERDUE);
}
lines.push({
"id": line.id,
"date": invoice.date,
"document": invoice.number,
"tags": tags,
"displayName": line.display_name
})
})
return invoices;
});
};
}
return {
restrict: 'E',
link: link,
template: '<ng-include src="contentUrl"/>'
}
}])
@@ -0,0 +1,40 @@
<section class="dashboard-section">
<h2 ng-dialog-class="ngdialog ngdialog-theme-default ng-dialog-all-details-page" ng-dialog-data='{"section": {{section}}, "patient": {{patient}} }' class="section-title">
<span class="title-link">{{config.translationKey | translate}} </span>
<i class="fa"></i>
</h2>

<div ng-hide="lines.length">
<div class="placeholder-text">
<p translate="DISPLAY_CONTROL_ERROR_MESSAGE_KEY" translate-values="{displayControl : '{{config.translationKey | translate}}'}"></p>
</div>
</div>

<table ng-show="lines.length" class="dashboard-table">
<tbody>
<tr ng-repeat="line in lines | filter:{retire: false } | orderBy: '-date'">
<td>
<span>
{{ line.document }}
</span>
</td>
<td>
<span>
{{ line.displayName }}
</span>
</td>
<td>
<span>
<i class="fa fa-ok" ng-show="line.approved"></i>
<i class="fa fa-times-circle" ng-hide="line.approved"></i>
</span>
</td>
<td>
<span>
{{ line.date | bahmniDate }}
</span>
</td>
</tr>
</tbody>
</table>
</section>
@@ -7,4 +7,3 @@
}
]
}

@@ -10,6 +10,7 @@
"MODULE_LABEL_QUEUE_KEY":"Queue",
"IMPL_BP_PULSE":"BP / Pulse",
"IMPL_GROWTH_CHART":"Growth Chart",
"IMPL_BILLING_STATUS":"Billing Status",
"DASHBOARD_TITLE_LAB_RESULTS_KEY": "Lab Results",
"DASHBOARD_TITLE_LAB_ORDERS_DISPLAY_CONTROL_KEY": "Lab Orders Fulfillment",
"DASHBOARD_TITLE_PACS_KEY": "Pacs",
@@ -36,37 +37,37 @@
"DASHBOARD_TITLE_WEIGHT_BMI": "Weight/BMI",
"DASHBOARD_TITLE_DIABETES_BLOOD_SUGAR": "Diabetes/Blood Sugar",
"DASHBOARD_TITLE_PULSE": "Pulse",

"DASHBOARD_TAB_GENERAL_KEY": "General",
"DASHBOARD_TAB_TRENDS_KEY": "Trends",
"DASHBOARD_TAB_PATIENT_SUMMARY_KEY": "Patient Summary",
"DASHBOARD_TAB_DISCHARGE_SUMMARY_KEY": "Discharge Summary",
"DASHBOARD_TAB_ORDERS_KEY": "Orders",

"LAB_INVESTIGATIONS_KEY":"Lab Investigations",
"PACS_ORDERS_VISIT_PAGE_KEY": "Pacs Orders Visit Page",

"DISCHARGE_SUMMARY_DIAGNOSIS_KEY" :"Diagnosis",

"DISCHARGE_SUMMARY_ADVICE_ON_DISCHARGE_KEY": "Advice on Discharge",
"DISCHARGE_SUMMARY_AT_ADMISSION_KEY": "At Admission",
"DISCHARGE_SUMMARY_ADMISSION_DETAILS_KEY": "Admission Details",
"DISCHARGE_SUMMARY_CLINICAL_NOTES_KEY": "Clinical Notes",
"DISCHARGE_SUMMARY_AT_DISCHARGE_KEY": "At Discharge",
"DISCHARGE_SUMMARY_TREATMENTS_KEY": "Treatments",


"OBSERVATIONS_BOARD_LABEL_KEY":"Observations",
"MEDICATIONS_BOARD_LABEL_KEY":"Medications",
"ORDERS_BOARD_LABEL_KEY":"Orders",
"BACTERIOLOGY_BOARD_LABEL_KEY":"Bacteriology",
"CONSULTATION_BOARD_LABEL_KEY":"Consultation",
"DISPOSITION_BOARD_LABEL_KEY":"Disposition",
"DIAGNOSIS_BOARD_LABEL_KEY":"Diagnosis",

"CLINICAL_ORDER_RADIOLOGY_NEED_PRINT": "Need Print for this order.",
"CLINICAL_ORDER_RADIOLOGY_NEED_PRINT_BUTTON": "Needs Print",

"CONSULTATION_PAGE_KEY" :"Consultation",
"PROGRAM_MANAGEMENT_PAGE_KEY":"Program Management Page",
"DISCHARGE_SUMMARY_PAGE_KEY":"Discharge Summary Page",
@@ -76,7 +77,7 @@
"HOME_DASHBOARD_KEY":"Home Dashboard",
"MEDICATION_CHANGE_DURATION_BUTTON": "Change Duration",
"DASHBOARD_TITLE_Consultation_KEY": "Consultation Notes",

"DASHBOARD_TITLE_APPOINTMENTS_KEY": "Appointments",
"DASHBOARD_APPOINTMENTS_SLOT_KEY": "Slot",
"DASHBOARD_APPOINTMENTS_SERVICE_KEY": "Service",
@@ -90,4 +91,3 @@
"DASHBOARD_NO_PAST_APPOINTMENTS_KEY": "No past appointments",
"DASHBOARD_NO_UPCOMING_APPOINTMENTS_KEY": "No upcoming appointments"
}

0 comments on commit 31a43b7

Please sign in to comment.
You can’t perform that action at this time.