Skip to content

Commit

Permalink
Merge pull request #205 from jembi/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
tresorluz authored Nov 4, 2024
2 parents e51d1df + 1a0be39 commit 98e457b
Show file tree
Hide file tree
Showing 27 changed files with 1,363 additions and 171 deletions.
8 changes: 8 additions & 0 deletions ui/app/clinical/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,14 @@ angular.module('consultation')
'print-lab-tests': {
templateUrl: 'dashboard/views/printLabTestsReport.html',
controller: 'PrintLabTestsReportController'
},
'print-hospitalization-certificate': {
templateUrl: 'dashboard/views/printHospitalizationCertificate.html',
controller: 'PrintHospitalizationCertificate'
},
'print-replacement-certificate': {
templateUrl: 'dashboard/views/printMedicalReplacementCertificate.html',
controller: 'replacementCertificateController'
}
}
})
Expand Down
63 changes: 57 additions & 6 deletions ui/app/clinical/consultation/controllers/consultationController.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ angular.module('bahmni.clinical').controller('ConsultationController',
['$scope', '$rootScope', '$state', '$location', '$translate', 'clinicalAppConfigService', 'diagnosisService', 'urlHelper', 'contextChangeHandler',
'spinner', 'encounterService', 'messagingService', 'sessionService', 'retrospectiveEntryService', 'patientContext', '$q',
'patientVisitHistoryService', '$stateParams', '$window', 'visitHistory', 'clinicalDashboardConfig', 'appService',
'ngDialog', '$filter', 'configurations', 'visitConfig', 'conditionsService', 'configurationService', 'auditLogService', 'printer', 'printPrescriptionReportService', 'printLabTestsReportService',
'ngDialog', '$filter', 'configurations', 'visitConfig', 'conditionsService', 'configurationService', 'auditLogService', 'printer', 'printPrescriptionReportService', 'printLabTestsReportService', 'printHospitalizationCertificateService', 'printReplacementCertificateService', 'printPregnancyCertificateService',
function ($scope, $rootScope, $state, $location, $translate, clinicalAppConfigService, diagnosisService, urlHelper, contextChangeHandler,
spinner, encounterService, messagingService, sessionService, retrospectiveEntryService, patientContext, $q,
patientVisitHistoryService, $stateParams, $window, visitHistory, clinicalDashboardConfig, appService,
ngDialog, $filter, configurations, visitConfig, conditionsService, configurationService, auditLogService, printer, printPrescriptionReportService, printLabTestsReportService) {
ngDialog, $filter, configurations, visitConfig, conditionsService, configurationService, auditLogService, printer, printPrescriptionReportService, printLabTestsReportService, printHospitalizationCertificateService, printReplacementCertificateService, printPregnancyCertificateService) {
var DateUtil = Bahmni.Common.Util.DateUtil;
var getPreviousActiveCondition = Bahmni.Common.Domain.Conditions.getPreviousActiveCondition;
$scope.togglePrintList = false;
Expand Down Expand Up @@ -74,12 +74,17 @@ angular.module('bahmni.clinical').controller('ConsultationController',
var prescriptionReportUuid = '2c6c27b0-3eef-4010-bfbb-9133d0016d25';
var tarvPrescriptionReportUuid = '31f15798-9983-4066-9b06-6868e1ba7210';
var labTestsReportUuid = 'ce9eb283-1852-47eb-8902-11c6dadf220e';

var hospitalizationCertificateUuid = '23c9b86c-893a-4941-86ca-d17fdbe4c10f';
var replacementCertificateUuid = '5576eef4-5922-4f7d-9b8c-b61f2648b7c2';
var pregnancyCertificateUuid = 'e6a80189-1a9c-4470-95c5-e8b214a64544';
$scope.printButtonDropdownOptions = [
{name: $translate.instant('PRINT_CLINICAL_DASHBOARD_LABEL'), uuid: clinicalDashboardUuid},
{name: $translate.instant('PRESCRIPTION_REPORT_PRINT_PRESCRIPTION_LABEL'), uuid: prescriptionReportUuid},
{name: $translate.instant('PRESCRIPTION_REPORT_PRINT_TARV_PRESCRIPTION_LABEL'), uuid: tarvPrescriptionReportUuid},
{name: $translate.instant('PRINT_LAB_TESTS_LABEL'), uuid: labTestsReportUuid} ];
{name: $translate.instant('PRINT_LAB_TESTS_LABEL'), uuid: labTestsReportUuid},
{name: $translate.instant('PRINT_HOSPITALIZATION_CERTIFICATE_LABEL'), uuid: hospitalizationCertificateUuid},
{name: $translate.instant('PRINT_MEDICAL_REPLACEMENT_CERTIFICATE_LABEL'), uuid: replacementCertificateUuid},
{name: $translate.instant('PREGNANCY_CERTIFICATE_TITLE'), uuid: pregnancyCertificateUuid}];

$scope.optionText = function (value) {
return value.name;
Expand All @@ -92,21 +97,67 @@ angular.module('bahmni.clinical').controller('ConsultationController',
if (option.uuid === prescriptionReportUuid) {
$rootScope.isTarvReport = false;
$rootScope.isLabTestsReport = false;
$rootScope.isHospitalizationCertificate = false;
$rootScope.isReplacementCertificate = false;
$rootScope.isPregnantCertificate = false;
} else if (option.uuid === tarvPrescriptionReportUuid) {
$rootScope.isTarvReport = true;
$rootScope.isLabTestsReport = false;
$rootScope.isReplacementCertificate = false;
$rootScope.isHospitalizationCertificate = false;
$rootScope.isReplacementCertificate = false;
$rootScope.isPregnantCertificate = false;
} else if (option.uuid === labTestsReportUuid) {
$rootScope.isTarvReport = false;
$rootScope.isHospitalizationCertificate = false;
$rootScope.isLabTestsReport = true;
$rootScope.isReplacementCertificate = false;
$rootScope.isPregnantCertificate = false;
} else if (option.uuid === hospitalizationCertificateUuid) {
$rootScope.isTarvReport = false;
$rootScope.isHospitalizationCertificate = true;
$rootScope.isLabTestsReport = false;
$rootScope.isReplacementCertificate = false;
$rootScope.isPregnantCertificate = false;
} else if (option.uuid === replacementCertificateUuid) {
$rootScope.isTarvReport = false;
$rootScope.isHospitalizationCertificate = false;
$rootScope.isLabTestsReport = false;
$rootScope.isReplacementCertificate = true;
$rootScope.isPregnantCertificate = false;
} else if (option.uuid === pregnancyCertificateUuid) {
$rootScope.isTarvReport = false;
$rootScope.isHospitalizationCertificate = false;
$rootScope.isLabTestsReport = false;
$rootScope.isReplacementCertificate = false;
$rootScope.isPregnantCertificate = true;
}
if ($rootScope.isLabTestsReport) {
printLabTestsReportService.getReportModel($stateParams.patientUuid)
.then(function (reportData) {
$rootScope.labTestsReportData = reportData;
printer.printFromScope("dashboard/views/printLabTestsReport.html", $scope, function () { });
});
}
else {
} else if ($rootScope.isHospitalizationCertificate) {
printHospitalizationCertificateService.getReportModel($stateParams.patientUuid)
.then(function (reportData) {
$rootScope.certificateData = reportData;
printer.printFromScope("dashboard/views/printHospitalizationCertificate.html", $scope, function () { });
});
} else if ($rootScope.isReplacementCertificate) {
printReplacementCertificateService.getReportModel($stateParams.patientUuid)
.then(function (reportData) {
$rootScope.data = reportData;
printer.printFromScope("dashboard/views/printMedicalReplacementCertificate.html", $scope, function () { });
});
} else if ($rootScope.isPregnantCertificate) {
printPregnancyCertificateService.getReportModel($stateParams.patientUuid)
.then(function (reportData) {
$rootScope.data = reportData;
console.log($rootScope.data);
printer.printFromScope("dashboard/views/printPregnancyCertificate.html", $scope, function () { });
});
} else {
printPrescriptionReportService.getReportModel($stateParams.patientUuid)
.then(function (reportData) {
$rootScope.prescriptionReportData = reportData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

angular.module('bahmni.clinical')
.controller('DrugOrderHistoryController', ['$scope', '$filter', '$stateParams', 'activeDrugOrders',
'treatmentConfig', 'treatmentService', 'spinner', 'drugOrderHistoryHelper', 'visitHistory', '$translate', '$rootScope',
'treatmentConfig', 'treatmentService', 'spinner', 'drugOrderHistoryHelper', 'visitHistory', '$translate', '$rootScope', '$http', 'messagingService',
function ($scope, $filter, $stateParams, activeDrugOrders, treatmentConfig, treatmentService, spinner,
drugOrderHistoryHelper, visitHistory, $translate, $rootScope) {
drugOrderHistoryHelper, visitHistory, $translate, $rootScope, $http, messagingService) {
var DrugOrderViewModel = Bahmni.Clinical.DrugOrderViewModel;
var DateUtil = Bahmni.Common.Util.DateUtil;
var currentVisit = visitHistory.activeVisit;
Expand All @@ -17,6 +17,17 @@ angular.module('bahmni.clinical')
$scope.consultation.drugOrderGroups = [];
createPrescribedDrugOrderGroups();
createRecentDrugOrderGroup(activeAndScheduledDrugOrders);

// Added exsiting Dispense date to orders
$scope.consultation.drugOrderGroups.forEach(function (item) {
if (item.hasOwnProperty('drugOrders')) {
item.drugOrders.forEach(function (order) {
if (order.hasOwnProperty('uuid')) {
setDispenseDate(order);
}
});
}
});
};

var getPreviousVisitDrugOrders = function () {
Expand Down Expand Up @@ -152,6 +163,13 @@ angular.module('bahmni.clinical')
drugOrder.orderReasonNotesEnabled = false;
};

$scope.start = function (drugOrder) {
if (drugOrder.isDiscontinuedAllowed) {
$rootScope.$broadcast("event:discontinueDrugOrder", drugOrder);
$scope.updateFormConditions(drugOrder);
}
};

$scope.discontinue = function (drugOrder) {
if (drugOrder.isDiscontinuedAllowed) {
$rootScope.$broadcast("event:discontinueDrugOrder", drugOrder);
Expand All @@ -176,6 +194,84 @@ angular.module('bahmni.clinical')
$scope.consultation.drugOrdersWithUpdatedOrderAttributes[drugOrder.uuid] = drugOrder;
}
};
$scope.discontinue = function (drugOrder) {
if (drugOrder.isDiscontinuedAllowed) {
$rootScope.$broadcast("event:discontinueDrugOrder", drugOrder);
$scope.updateFormConditions(drugOrder);
}
};
$scope.undoUpdateDispenseDateView = function (drugOrder) {
drugOrder.isMarkedForDispenseDate = false;
};
var getDispenseDate = function (order) {
return new Promise(function (resolve, reject) {
$http.get(Bahmni.Common.Constants.DispenseDate + '/' + order.uuid)
.then(function (response) {
var data = response.data;
var date = DateUtil.getDateWithoutTime(data.dispenseDate);
if (date != null) {
resolve(new Date(date));
} else {
resolve(null);
}
})
.catch(function (error) {
// Handle error
console.error('Error making GET request:', error);
reject(error);
});
});
};
var setDispenseDate = function (order) {
getDispenseDate(order)
.then(function (dispenseDate) {
order.dispenseDate = dispenseDate;
})
.catch(function (error) {
// Handle error
console.error("Error:", error);
});
};
$scope.showUpdateDispenseDateView = function (drugOrder) {
getDispenseDate(drugOrder)
.then(function (dispenseDate) {
console.log("Dispense Date:", dispenseDate);
if (dispenseDate != null) {
drugOrder.isDispenseDatePresent = true;
drugOrder.dispenseDate = new Date(dispenseDate);
} else {
console.log("The Dispense Date:", dispenseDate);
}
})
.catch(function (error) {
// Handle error
console.error("Error:", error);
});
drugOrder.isMarkedForDispenseDate = true;
};
$scope.updateDispenseDate = function (drugOrder) {
if (drugOrder.dispenseDate !== null) {
var data = {
dispenseDate: drugOrder.dispenseDate,
orderUuid: drugOrder.uuid
// Add more key-value pairs as needed
};
var url = Bahmni.Common.Constants.DispenseDate;
$http.post(url, data)
.then(function (response) {
// Handle success
console.log('POST request successful:', response.data);
messagingService.showMessage('info', 'MEDICATION_DISPENSE_DATE_SUCCESSFULLY_SAVED');
})
.catch(function (error) {
// Handle error
console.error('Error making POST request:', error);
messagingService.showMessage('error', 'MEDICATION_DISPENSE_DATE_ERROR_MESSAGE');
});
} else {
messagingService.showMessage('error', 'MEDICATION_DISPENSE_DATE_EMPTY');
}
};

$scope.toggleDrugOrderAttribute = function (orderAttribute, valueToSet) {
orderAttribute.value = valueToSet !== undefined ? valueToSet : !orderAttribute.value;
Expand Down Expand Up @@ -227,7 +323,7 @@ angular.module('bahmni.clinical')
};

var getAttribute = function (drugOrder, attributeName) {
return _.find(drugOrder.orderAttributes, {name: attributeName});
return _.find(drugOrder.orderAttributes, { name: attributeName });
};

init();
Expand Down
Loading

0 comments on commit 98e457b

Please sign in to comment.