Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature(Set Is Medical from Employee Jobtitle) #7227

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/src/i18n/en/form.json
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@
"FORM": "Form",
"FROM_ACCOUNT": "From Account",
"FROM": "From",
"FUNCTION": "Function",
"FUNCTION": "Job Function",
"FUNCTION_BONUS":"Function bonus",
"GAIN_ACCOUNT": "Gain on Exchange Rate Account",
"GENDER": "Gender",
Expand Down
4 changes: 2 additions & 2 deletions client/src/js/components/bhTitleSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ angular.module('bhima.components')
controller : TitleSelectController,
transclude : true,
bindings : {
fonctionId : '<',
titleId : '<',
onSelectCallback : '&',
label : '@?',
},
Expand Down Expand Up @@ -32,6 +32,6 @@ function TitleSelectController(titles, Notify) {

// fires the onSelectCallback bound to the component boundary
$ctrl.onSelect = ($item) => {
$ctrl.onSelectCallback({ fonction : $item });
$ctrl.onSelectCallback({ title : $item });
};
}
16 changes: 1 addition & 15 deletions client/src/modules/employees/registration/employees.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h4 translate>FORM.LABELS.CURRENT_LOCATION</h4>
<ui-select
name="fonction"
ng-model="EmployeeCtrl.employee.fonction_id">
<ui-select-match placeholder="{{ 'FORM.SELECT.PROFESSION' | translate }}">
<ui-select-match placeholder="{{ 'FORM.SELECT.FUNCTION' | translate }}">
<span>{{$select.selected.fonction_txt}}</span>
</ui-select-match>
<ui-select-choices ui-select-focus-patch repeat="f.id as f in EmployeeCtrl.functions | filter:{ fonction_txt : $select.search } | orderBy:'fonction_txt'">
Expand Down Expand Up @@ -401,20 +401,6 @@ <h4 translate>FORM.LABELS.CURRENT_LOCATION</h4>
</div>
</div>

<!-- Employee Medical Or Non-Medical -->
<div
class="form-group"
ng-class="{'has-error' : DetailForm.is_medical.$invalid && EmployeeRegistrationForm.$submitted}">

<label class="col-md-3 control-label" translate>FORM.LABELS.IS_MEDICAL_STAFF</label>
<div class="col-md-9">
<input type="checkbox" name="is_medical" ng-true-value="1" ng-false-value="0" ng-model="EmployeeCtrl.employee.is_medical">
<div class="help-block" ng-messages="DetailForm.email.$error" ng-show="EmployeeRegistrationForm.$submitted">
<div ng-messages-include="modules/templates/messages.tmpl.html"></div>
</div>
</div>
</div>

<!-- Employee phone -->
<div
class="form-group"
Expand Down
2 changes: 1 addition & 1 deletion client/src/modules/employees/registry/search.modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
</bh-fonction-select>

<bh-title-select
fonction-id="ModalCtrl.searchQueries.title_employee_id"
title-id="ModalCtrl.searchQueries.title_employee_id"
on-select-callback="ModalCtrl.onSelectTitle(title)">
<bh-clear on-clear="ModalCtrl.clear('title_employee_id')"></bh-clear>
</bh-title-select>
Expand Down
12 changes: 12 additions & 0 deletions client/src/modules/titles/modals/title.modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,20 @@
<div ng-messages-include="modules/templates/messages.tmpl.html"></div>
</div>
</div>

<!-- Employee Medical Or Non-Medical -->
<div class="form-group">
<div class="checkbox">
<label>
<input type="checkbox" name="is_medical" ng-true-value="1" ng-false-value="0"
ng-model="TitleModalCtrl.title.is_medical">
<span class="control-label" translate>FORM.LABELS.IS_MEDICAL_STAFF</span>
</label>
</div>
</div>
</div>


<div class="modal-footer">
<button data-method="cancel" type="button" class="btn btn-default" ng-click="TitleModalCtrl.closeModal()">
<span translate>FORM.BUTTONS.CANCEL</span>
Expand Down
2 changes: 1 addition & 1 deletion client/src/modules/titles/modals/title.modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function TitleModalController($state, Titles, Notify, AppCache, params) {
if (!vm.isCreateState) {
Titles.read(vm.stateParams.id)
.then(data => {
vm.function = data;
vm.title = data;
})
.catch(Notify.handleError);
}
Expand Down
8 changes: 4 additions & 4 deletions client/src/modules/titles/templates/action.tmpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
<span class="caret"></span>
</a>

<ul data-row-menu="{{row.entity.fonction_txt}}" class="dropdown-menu-right" bh-dropdown-menu-auto-dropup uib-dropdown-menu>
<li class="bh-dropdown-header">{{row.entity.fonction_txt}}</li>
<ul data-row-menu="{{row.entity.title_txt}}" class="dropdown-menu-right" bh-dropdown-menu-auto-dropup uib-dropdown-menu>
<li class="bh-dropdown-header">{{row.entity.title_txt}}</li>
<li>
<a data-method="edit-record" ui-sref="functions.edit({ id : row.entity.id })" href>
<a data-method="edit-record" ui-sref="titles.edit({ id : row.entity.id })" href>
<i class="fa fa-edit"></i> <span translate>FORM.BUTTONS.EDIT</span>
</a>
</li>
<li class="divider"></li>
<li>
<a data-method="delete-record" ng-click="grid.appScope.deleteFunction(row.entity)" href>
<a data-method="delete-record" ng-click="grid.appScope.deleteTitles(row.entity)" href>
<span class="text-danger">
<i class="fa fa-trash"></i> <span translate>PROFESSION.DELETE</span>
</span>
Expand Down
14 changes: 10 additions & 4 deletions client/src/modules/titles/titles.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function TitleManagementController(Titles, Modals, Notify, uiGridConstants) {
const vm = this;

// bind methods
vm.deleteFunction = deleteTitles;
vm.deleteTitles = deleteTitles;
vm.toggleFilter = toggleFilter;

// global variables
Expand All @@ -33,11 +33,17 @@ function TitleManagementController(Titles, Modals, Notify, uiGridConstants) {
field : 'title_txt',
displayName : 'FORM.LABELS.DESIGNATION',
headerCellFilter : 'translate',
}, {
field : 'is_medical',
width : 180,
displayName : 'FORM.LABELS.MEDICAL_STAFF',
headerCellFilter : 'translate',
cellTemplate : '/modules/titles/templates/medical.cell.html',
}, {
field : 'action',
width : 80,
displayName : '...',
cellTemplate : '/modules/functions/templates/action.tmpl.html',
cellTemplate : '/modules/titles/templates/action.tmpl.html',
enableSorting : false,
enableFiltering : false,
}],
Expand Down Expand Up @@ -66,12 +72,12 @@ function TitleManagementController(Titles, Modals, Notify, uiGridConstants) {
}

// switch to delete warning mode
function deleteTitles(profession) {
function deleteTitles(title) {
Modals.confirm('FORM.DIALOGS.CONFIRM_DELETE')
.then((bool) => {
if (!bool) { return; }

Titles.delete(profession.id)
Titles.delete(title.id)
.then(() => {
Notify.success('FORM.INFO.DELETE_SUCCESS');
loadTitles();
Expand Down
4 changes: 2 additions & 2 deletions server/controllers/admin/titles.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ const db = require('../../lib/db');

// GET /title
function lookupTitle(id) {
const sql = `SELECT id, title_txt FROM title_employee
const sql = `SELECT id, title_txt, is_medical FROM title_employee
WHERE title_employee.id = ?`;

return db.one(sql, [id]);
}

// Lists the titles of hospital employees
function list(req, res, next) {
const sql = `SELECT id, title_txt FROM title_employee;`;
const sql = `SELECT id, title_txt, is_medical FROM title_employee;`;

db.exec(sql)
.then((rows) => {
Expand Down
7 changes: 3 additions & 4 deletions server/controllers/payroll/employees/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function lookupEmployee(uid) {
BUID(employee.uuid) AS uuid, employee.code, patient.display_name, patient.sex,
patient.dob, employee.date_embauche, BUID(employee.service_uuid) as service_uuid,
employee.nb_spouse, employee.nb_enfant, BUID(employee.grade_uuid) as grade_uuid,
employee.locked, employee.is_medical, grade.text, grade.basic_salary,
employee.locked, title_employee.is_medical, grade.text, grade.basic_salary,
fonction.id AS fonction_id, fonction.fonction_txt, service.name AS service_txt, patient.hospital_no,
patient.phone, patient.email, patient.address_1 AS adresse, BUID(employee.patient_uuid) AS patient_uuid,
employee.bank, employee.bank_account, employee.title_employee_id, title_employee.title_txt,
Expand Down Expand Up @@ -251,7 +251,6 @@ function update(req, res, next) {
bank_account : employee.bank_account,
individual_salary : employee.individual_salary,
code : employee.code,
is_medical : employee.is_medical,
title_employee_id : employee.title_employee_id,
};

Expand Down Expand Up @@ -447,7 +446,7 @@ function find(options) {
grade.basic_salary, fonction.id AS fonction_id, fonction.fonction_txt, patient.hospital_no,
patient.phone, patient.email, patient.address_1 AS adresse, BUID(employee.patient_uuid) AS patient_uuid,
employee.bank, employee.bank_account, employee.title_employee_id, title_employee.title_txt,
employee.individual_salary, employee.is_medical, grade.code AS code_grade, BUID(debtor.uuid) as debtor_uuid,
employee.individual_salary, title_employee.is_medical, grade.code AS code_grade, BUID(debtor.uuid) as debtor_uuid,
debtor.text AS debtor_text, BUID(debtor.group_uuid) as debtor_group_uuid,
BUID(creditor.uuid) as creditor_uuid, creditor.text AS creditor_text,
BUID(creditor.group_uuid) as creditor_group_uuid, creditor_group.account_id,
Expand Down Expand Up @@ -481,7 +480,7 @@ function find(options) {
filters.equals('fonction_id', 'fonction_id', 'employee');
filters.equals('title_employee_id', 'title_employee_id', 'employee');
filters.equals('grade_uuid', 'grade_uuid', 'employee');
filters.equals('is_medical', 'is_medical', 'employee');
filters.equals('is_medical', 'is_medical', 'title_employee');
filters.equals('reference', 'text', 'entity_map');

if (options.cost_center_id) {
Expand Down
8 changes: 8 additions & 0 deletions server/models/migrations/next/migrate.sql
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,11 @@ CALL add_column_if_missing('employee', 'title_employee_id', 'TINYINT(1) NOT NULL
ALTER TABLE `employee` ADD CONSTRAINT `employee__title_employee` FOREIGN KEY (`title_employee_id`) REFERENCES `title_employee` (`id`);

CALL add_column_if_missing('enterprise_setting', 'percentage_fixed_bonus', 'TINYINT(3) UNSIGNED NOT NULL DEFAULT 100');

/**
* @author: lomamech
* @description: Move is_medical property from employee to title #7170
* @date: 2023-08-25
*/
ALTER TABLE `employee` DROP COLUMN `is_medical`;
CALL add_column_if_missing('title_employee', 'is_medical', 'TINYINT(1) DEFAULT 0');
2 changes: 1 addition & 1 deletion server/models/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,6 @@ CREATE TABLE `employee` (
`creditor_uuid` BINARY(16) DEFAULT NULL,
`locked` TINYINT(1) DEFAULT NULL,
`patient_uuid` BINARY(16) DEFAULT NULL,
`is_medical` TINYINT(1) DEFAULT 0,
`reference` SMALLINT(5) UNSIGNED DEFAULT NULL,
`title_employee_id` TINYINT(3) UNSIGNED DEFAULT NULL,
PRIMARY KEY (`uuid`),
Expand Down Expand Up @@ -664,6 +663,7 @@ DROP TABLE IF EXISTS `title_employee`;
CREATE TABLE `title_employee` (
`id` TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT,
`title_txt` VARCHAR(100) NOT NULL,
`is_medical` TINYINT(1) DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE KEY `title_1` (`title_txt`)
) ENGINE=InnoDB DEFAULT CHARACTER SET = utf8mb4 DEFAULT COLLATE = utf8mb4_unicode_ci;
Expand Down
10 changes: 5 additions & 5 deletions test/data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -498,9 +498,9 @@ INSERT INTO `reference` VALUES
(3, 0, 'AC', 'Reference resultat 1', 1, NULL, 1),
(4, 0, 'XX', 'Deletable reference 1', 1, NULL, NULL);

INSERT INTO `employee` (`uuid`, `code`, `date_embauche`, `grade_uuid`, `nb_spouse`, `nb_enfant`, `individual_salary`, `bank`, `bank_account`, `fonction_id`, `service_uuid`, `creditor_uuid`, `locked`, `patient_uuid`, `is_medical`) VALUES
(HUID('75e09694-65f2-45a1-a8a2-8b025003d793'),'E1','2016-02-02 00:00:00',HUID('71e9f21c-d9b1-11e5-8ab7-78eb2f2a46e0'),1,3,500,'TMB','1201-3456-5423-03', 1, @medicineInterneService, HUID('42d3756a-7770-4bb8-a899-7953cd859892'), NULL,HUID('274c51ae-efcc-4238-98c6-f402bfb39866'), 0),
(HUID('75e69409-562f-a2a8-45a1-3d7938b02500'), 'WWEFCB', '2016-01-01 01:00:00', HUID('9ee06e4a7b5948e6812cc0f8a00cf7d3'), 0, 0, 0, 'BCOL', '00-99-88-77', 1, @testService, HUID('18dcada5-f149-4eea-8267-19c346c2744f'), NULL, HUID('d1d7f856-d414-4400-8b94-8ba9445a2bc0'), 0);
INSERT INTO `employee` (`uuid`, `code`, `date_embauche`, `grade_uuid`, `nb_spouse`, `nb_enfant`, `individual_salary`, `bank`, `bank_account`, `fonction_id`, `service_uuid`, `creditor_uuid`, `locked`, `patient_uuid`) VALUES
(HUID('75e09694-65f2-45a1-a8a2-8b025003d793'),'E1','2016-02-02 00:00:00',HUID('71e9f21c-d9b1-11e5-8ab7-78eb2f2a46e0'),1,3,500,'TMB','1201-3456-5423-03', 1, @medicineInterneService, HUID('42d3756a-7770-4bb8-a899-7953cd859892'), NULL,HUID('274c51ae-efcc-4238-98c6-f402bfb39866')),
(HUID('75e69409-562f-a2a8-45a1-3d7938b02500'), 'WWEFCB', '2016-01-01 01:00:00', HUID('9ee06e4a7b5948e6812cc0f8a00cf7d3'), 0, 0, 0, 'BCOL', '00-99-88-77', 1, @testService, HUID('18dcada5-f149-4eea-8267-19c346c2744f'), NULL, HUID('d1d7f856-d414-4400-8b94-8ba9445a2bc0'));

-- invoicing fee configuration

Expand Down Expand Up @@ -1142,8 +1142,8 @@ INSERT INTO `patient` (`uuid`, `project_id`, `reference`, `debtor_uuid`, `displa
INSERT INTO `creditor` (`uuid`, `group_uuid`, `text`) VALUES (0x75ED6B1141764BF7821D34BA638B0647, 0xB0FA5ED204F94CB392F761D6404696E7, 'Crediteur [Employee indice 1]');
INSERT INTO `creditor` (`uuid`, `group_uuid`, `text`) VALUES (0x6150E9B14D214DC28E845BFAAB40DD5E, 0xB0FA5ED204F94CB392F761D6404696E7, 'Crediteur [Employee indice 2]');

INSERT INTO `employee` (`uuid`, `code`, `date_embauche`, `grade_uuid`, `nb_spouse`, `nb_enfant`, `individual_salary`, `bank`, `bank_account`, `fonction_id`, `service_uuid`, `creditor_uuid`, `locked`, `patient_uuid`, `is_medical`, `reference`) VALUES (0x10F64A41DA594962AA9A90CF0D42257C, 'IMA-ASSR-1', DATE_ADD(CURRENT_DATE, INTERVAL -2 YEAR), 0x71E9F21CD9B111E58AB778EB2F2A46E0, 0, 0, 0, NULL, NULL, 2, 0xB1816006555845F993A0C222B5EFA6CB, 0x75ED6B1141764BF7821D34BA638B0647, NULL, 0x4B23E6B9187F4CE69696542F798B5F32, 0, 3);
INSERT INTO `employee` (`uuid`, `code`, `date_embauche`, `grade_uuid`, `nb_spouse`, `nb_enfant`, `individual_salary`, `bank`, `bank_account`, `fonction_id`, `service_uuid`, `creditor_uuid`, `locked`, `patient_uuid`, `is_medical`, `reference`) VALUES (0xD321099D01CD41029686B87CB70B9311, 'IMA-ASSP-2', DATE_ADD(CURRENT_DATE, INTERVAL -2 YEAR), 0x61E9F21CD9B111E48AB678EB2F2A46E0, 0, 2, 0, NULL, NULL, 1, 0xE3988489EF6641DF88FA8B8ED6AA03AC, 0x6150E9B14D214DC28E845BFAAB40DD5E, NULL, 0xA6643C4F310145BA961B54FD83D71E7C, 0, 4);
INSERT INTO `employee` (`uuid`, `code`, `date_embauche`, `grade_uuid`, `nb_spouse`, `nb_enfant`, `individual_salary`, `bank`, `bank_account`, `fonction_id`, `service_uuid`, `creditor_uuid`, `locked`, `patient_uuid`, `reference`) VALUES (0x10F64A41DA594962AA9A90CF0D42257C, 'IMA-ASSR-1', DATE_ADD(CURRENT_DATE, INTERVAL -2 YEAR), 0x71E9F21CD9B111E58AB778EB2F2A46E0, 0, 0, 0, NULL, NULL, 2, 0xB1816006555845F993A0C222B5EFA6CB, 0x75ED6B1141764BF7821D34BA638B0647, NULL, 0x4B23E6B9187F4CE69696542F798B5F32, 3);
INSERT INTO `employee` (`uuid`, `code`, `date_embauche`, `grade_uuid`, `nb_spouse`, `nb_enfant`, `individual_salary`, `bank`, `bank_account`, `fonction_id`, `service_uuid`, `creditor_uuid`, `locked`, `patient_uuid`, `reference`) VALUES (0xD321099D01CD41029686B87CB70B9311, 'IMA-ASSP-2', DATE_ADD(CURRENT_DATE, INTERVAL -2 YEAR), 0x61E9F21CD9B111E48AB678EB2F2A46E0, 0, 2, 0, NULL, NULL, 1, 0xE3988489EF6641DF88FA8B8ED6AA03AC, 0x6150E9B14D214DC28E845BFAAB40DD5E, NULL, 0xA6643C4F310145BA961B54FD83D71E7C, 4);

INSERT INTO `config_employee_item` (`id`, `config_employee_id`, `employee_uuid`) VALUES
(3, 2, 0x10F64A41DA594962AA9A90CF0D42257C),
Expand Down
3 changes: 0 additions & 3 deletions test/integration/employee.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ describe('(/employees) the employees API endpoint', () => {
fonction_id : 1,
locked : 0,
service_uuid : testService,
is_medical : 0,
hospital_no : 'TP30',
creditor_group_uuid : 'B0FA5ED204F94CB392F761D6404696E7',
debtor_group_uuid : '4DE0FE47177F4D30B95FCFF8166400B4',
Expand All @@ -60,7 +59,6 @@ describe('(/employees) the employees API endpoint', () => {
email : 'me@info.com',
fonction_id : 1,
service_uuid : testService,
is_medical : 0,
creditor_group_uuid : 'B0FA5ED204F94CB392F761D6404696E7',
debtor_group_uuid : '4DE0FE47177F4D30B95FCFF8166400B4',
current_location_id : '1F162A109F6747889EFFC1FEA42FCC9B',
Expand All @@ -82,7 +80,6 @@ describe('(/employees) the employees API endpoint', () => {
fonction_id : 1,
locked : 0,
service_uuid : testService,
is_medical : 0,
hospital_no : 'TP30',
creditor_group_uuid : 'B0FA5ED204F94CB392F761D6404696E7',
debtor_group_uuid : '4DE0FE47177F4D30B95FCFF8166400B4',
Expand Down
1 change: 0 additions & 1 deletion test/integration/payroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ describe('(/multiplePayroll ) the Payroll API endpoint', () => {
nb_enfant : 0,
grade_uuid : '9ee06e4a-7b59-48e6-812c-c0f8a00cf7d3',
locked : null,
is_medical : 0,
text : '1.1',
basic_salary : 50,
fonction_id : 1,
Expand Down
3 changes: 2 additions & 1 deletion test/integration/titles.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ describe('(/titles) The job titles API endpoint', () => {
// Job titles we will add during this test suite.
const jobTitle = {
title_txt : 'Data scientist',
is_medical : 1,
};

const TITLE_KEY = ['id', 'title_txt'];
const TITLE_KEY = ['id', 'title_txt', 'is_medical'];
const NUM_TITLES = 3;

it('GET /TITLES returns a list of job title ', () => {
Expand Down