From 1fa059675a959fcf2756a3bad2f61452bcabb2b1 Mon Sep 17 00:00:00 2001 From: lomamech Date: Tue, 3 May 2016 08:57:21 +0100 Subject: [PATCH 1/6] Adding unit patient search and showing the data in a UI GRID --- client/src/i18n/en.json | 15 +++++ client/src/i18n/fr.json | 17 ++++- client/src/js/app.js | 5 +- client/src/js/services/DateService.js | 53 ++++++++++++++- client/src/js/services/PatientService.js | 2 +- .../src/partials/patients/search/search.html | 29 +++++++++ client/src/partials/patients/search/search.js | 65 +++++++++++++++++++ client/test/e2e/patient/search.spec.js | 25 +++++++ server/controllers/medical/patient.js | 11 +++- server/models/test/data.sql | 9 +++ 10 files changed, 223 insertions(+), 8 deletions(-) create mode 100644 client/src/partials/patients/search/search.html create mode 100644 client/src/partials/patients/search/search.js create mode 100644 client/test/e2e/patient/search.spec.js diff --git a/client/src/i18n/en.json b/client/src/i18n/en.json index 6e7f8de629..c95144dbb5 100644 --- a/client/src/i18n/en.json +++ b/client/src/i18n/en.json @@ -565,6 +565,15 @@ "TITLE" : "Title", "VIEW_PATIENT_RECORDS" : "View Patient Records" }, + "PATIENT_SEARCH" : { + "DAY" : "day", + "DAYS" : "days", + "MONTH" : "month", + "MONTHS" : "months", + "YEAR_OLD" : "year old", + "YEARS_OLD" : "years old", + "PAGE_TITLE" : "Patient Search" + }, "PERMISSIONS": { "ADDING_USER" : "Add a user", "ADD_USER" : "Add a New User", @@ -693,6 +702,7 @@ "ABBREVIATION" : "Abbreviation", "ACCOUNT" : "Account", "ACTION" : "Action", + "AGE" : "Age", "AMOUNT" : "Amount", "ASSET" : "Asser", "BALANCE_SECTION" : "Balance Sheet Section", @@ -702,6 +712,7 @@ "COUNTRY" : "Country", "CURRENCY" : "Currency", "DATE" : "Date", + "DATE_REGISTERED" : "Date Registered", "DESCRIPTION" : "Description", "EDIT" : "Edit", "EMAIL" : "Email", @@ -710,6 +721,7 @@ "EXCHANGE_RATE" : "Exchange Rate", "FIRST_NAME" : "First Name", "FUNCTION" : "Function", + "GENDER" : "Gender", "GRADE" : "Grade", "ID" : "ID", "INVENTORY" : "Inventory", @@ -719,6 +731,8 @@ "IS_WAREHOUSE" : "Is Warehouse ?", "LABEL" : "Label", "LAST_NAME" : "Last Name", + "LAST_TRANSACTION" : "Last Transactions", + "LAST_VISIT" : "Last Visit", "LISTS" : "Registered price list", "LOADING" : "Fetching data from the server.", "LOCKED" : "Locked", @@ -728,6 +742,7 @@ "NR" : "Nr", "NUM" : "Number", "PASSIVE" : "Passive", + "PATIENT_ID" : "ID Patient", "PERCENT" : "Percentage", "PHONE" : "Telephone", "POSITION" : "Position", diff --git a/client/src/i18n/fr.json b/client/src/i18n/fr.json index 0e68141b10..e96a1e0eb4 100644 --- a/client/src/i18n/fr.json +++ b/client/src/i18n/fr.json @@ -536,6 +536,15 @@ "TITLE" : "Titre", "VIEW_PATIENT_RECORDS" : "Voir Tous les enregistrements" }, + "PATIENT_SEARCH" : { + "DAY" : "jour", + "DAYS" : "jours", + "MONTH" : "mois", + "MONTHS" : "mois", + "YEAR_OLD" : "an", + "YEARS_OLD" : "ans", + "PAGE_TITLE" : "Recherche des patients" + }, "PERMISSIONS": { "ADDING_USER" : "Ajout utilisateur", "ADD_USER" : "Ajouter utilisateur", @@ -663,6 +672,7 @@ "ABBREVIATION" : "Abbreviation", "ACCOUNT" : "Compte", "ACTION" : "Action", + "AGE" : "Age", "AMOUNT" : "Montant", "ASSET" : "Actif", "BALANCE_SECTION" : "Section du Bilan", @@ -672,6 +682,7 @@ "COUNTRY" : "Pays", "CURRENCY" : "Monnaie", "DATE" : "Date", + "DATE_REGISTERED" : "Date d'enregistrement", "DESCRIPTION" : "Description", "EDIT" : "Editer", "EMAIL" : "Email", @@ -680,6 +691,7 @@ "EXCHANGE_RATE" : "Taux de change", "FIRST_NAME" : "Prenom", "FUNCTION" : "Fonction", + "GENDER" : "Genre", "GRADE" : "Grade", "ID" : "ID", "INVENTORY" : "Inventaire", @@ -689,6 +701,8 @@ "IS_WAREHOUSE" : "Entrepôt ?", "LABEL" : "Label", "LAST_NAME" : "Nom", + "LAST_TRANSACTION" : "Derniers Transactions", + "LAST_VISIT" : "Derniere visite", "LISTS" : "Liste des prix enregistrés", "LOADING" : "Récupération des données à partir du serveur.", "LOCKED" : "Bloquée", @@ -698,6 +712,7 @@ "NR" : "N°", "NUM" : "Numéro", "PASSIVE" : "Passive", + "PATIENT_ID" : "Patient Id", "PERCENT" : "Pourcentage", "PHONE" : "Telephone", "POSITION" : "Position", @@ -814,7 +829,7 @@ "PATIENT_RECORDS" : "Historique Patients", "PATIENT_REGISTRATION" : "Enregistrement Patient", "PATIENT_REGISTRATIONS" : "Enregistrement Patients", - "PATIENT_SEARCH" : "Recherche Patients", + "PATIENT_SEARCH" : "Recherche des Patients", "PATIENT_STANDING" : "Patients", "PATIENT_VISIT_STATUS" : "Patient Visitations", "PAYMENT_PERIOD" : "Gestion Périodes", diff --git a/client/src/js/app.js b/client/src/js/app.js index 6bd212e067..21cd559cbb 100644 --- a/client/src/js/app.js +++ b/client/src/js/app.js @@ -538,8 +538,9 @@ function bhimaConfig($stateProvider, $urlRouterProvider, $urlMatcherFactoryProvi templateUrl : 'partials/patient_invoice/patientInvoice.html' }) - .state('/patients/search/:patientID?', { - controller: 'patientRecords', + .state('/patients/search/', { + url : '/patients/search', + controller: 'PatientSearchController as PatientSearchCtrl', templateUrl: '/partials/patients/search/search.html' }) .state('patientGroups', { diff --git a/client/src/js/services/DateService.js b/client/src/js/services/DateService.js index 2b2d8d5272..fd44728b7d 100644 --- a/client/src/js/services/DateService.js +++ b/client/src/js/services/DateService.js @@ -45,6 +45,7 @@ function DateService() { service.current = {}; service.next = {}; service.util = {}; + service.getAge = getAge; /* * Very generic function to subtract days, months, years @@ -217,7 +218,7 @@ function DateService() { // yet another javascript date string function // expects a date object // return 'YYYY-MM-DD' format - service.util.str = function (date) { + service.util.str = function (date, simple) { // if we pass in a string, return it right away if (typeof date === 'string') { return date; } @@ -232,4 +233,54 @@ function DateService() { return [year, month, day].join('-'); }; + + // get an age object for the person with years, months, days + // inspired by http://stackoverflow.com/questions/7833709/calculating-age-in-months-and-days + + function getAge(date) { + var age = {}, + today = new Date(); + + // convert to date object + date = new Date(date); + + var y = [today.getFullYear(), date.getFullYear()], + ydiff = y[0] - y[1], + m = [today.getMonth(), date.getMonth()], + mdiff = m[0] - m[1], + d = [today.getDate(), date.getDate()], + ddiff = d[0] - d[1]; + + if (mdiff < 0 || (mdiff=== 0 && ddiff<0)) { --ydiff; } + + if (mdiff < 0) { mdiff+= 12; } + + if (ddiff < 0) { + date.setMonth(m[1]+1, 0); + ddiff = date.getDate()-d[1]+d[0]; + --mdiff; + } + + age.years = ydiff > 0 ? ydiff : 0; + age.months = mdiff > 0 ? mdiff : 0; + age.days = ddiff > 0 ? ddiff : 0; + + if(age.years > 0) { + age.duration = age.years; + age.period = (age.years === 1)? 'PATIENT_SEARCH.YEAR_OLD' : 'PATIENT_SEARCH.YEARS_OLD'; + } + + if((age.years === 0) && (age.months > 1)) { + age.duration = age.months; + age.period = (age.months === 1)? 'PATIENT_SEARCH.MONTH' : 'PATIENT_SEARCH.MONTHS'; + } + + if((age.years === 0) && (age.months === 0)) { + age.duration = age.days; + age.period = (age.days === 1)? 'PATIENT_SEARCH.DAY' : 'PATIENT_SEARCH.DAYS'; + } + + return age; + } + } diff --git a/client/src/js/services/PatientService.js b/client/src/js/services/PatientService.js index 81781e7058..d83d8d7308 100644 --- a/client/src/js/services/PatientService.js +++ b/client/src/js/services/PatientService.js @@ -47,7 +47,7 @@ function PatientService($http, util, Session) { * @return {Object} Promise object that will return patient details */ function detail(uuid) { - return $http.get(baseUrl.concat(uuid)) + return $http.get(baseUrl.concat(uuid || '')) .then(util.unwrapHttpResponse); } diff --git a/client/src/partials/patients/search/search.html b/client/src/partials/patients/search/search.html new file mode 100644 index 0000000000..649facc757 --- /dev/null +++ b/client/src/partials/patients/search/search.html @@ -0,0 +1,29 @@ +
+
+
    +
  1. {{ "TREE.HOSPITAL" | translate }}
  2. +
  3. {{ "PATIENT_SEARCH.PAGE_TITLE" | translate }}
  4. +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/client/src/partials/patients/search/search.js b/client/src/partials/patients/search/search.js new file mode 100644 index 0000000000..12597ff224 --- /dev/null +++ b/client/src/partials/patients/search/search.js @@ -0,0 +1,65 @@ +angular.module('bhima.controllers') +.controller('PatientSearchController', PatientSearchController); + +PatientSearchController.$inject = [ + '$translate', 'PatientService', 'DateService' +]; + +/** + * Users and Permission Controller + * + * This module is responsible for handling the creation + * of users and assigning permissions to existing modules. + * + * @todo Password insecure alert or not + */ +function PatientSearchController($translate, Patients, dateService) { + var vm = this; + + // options for the UI grid + + /** TODO MANAGE COLUMN : LAST_TRANSACTION */ + vm.uiGridOptions = { + appScopeProvider : vm, // ensure that the controller's `this` variable is bound to appScope + enableColumnMenus : false, + columnDefs : [ + { field : 'patientRef', name : $translate.instant('TABLE.COLUMNS.PATIENT_ID') }, + { field : 'patientName', name : $translate.instant('TABLE.COLUMNS.NAME') }, + { field : 'patientAge', name : $translate.instant('TABLE.COLUMNS.AGE') }, + { field : 'sex', name : $translate.instant('TABLE.COLUMNS.GENDER') }, + { field : 'registration_date', cellFilter:'date', name : $translate.instant('TABLE.COLUMNS.DATE_REGISTERED') }, + { field : 'last_visit', cellFilter:'date', name : $translate.instant('TABLE.COLUMNS.LAST_VISIT') }, + { field : '', name : $translate.instant('TABLE.COLUMNS.LAST_TRANSACTION') } + ], + enableSorting : true + }; + + /** @todo manage state without strings */ + vm.state = 'default'; // this is default || create || update + + + // TODO + function handler(error) { + throw error; + } + + // load user grid + function loadGrid() { + Patients.detail().then(function (patients) { + + patients.forEach(function (patient) { + var patientAge = dateService.getAge(patient.dob,'simple'); + patient.patientAge = patientAge.duration + ' ' + $translate.instant(patientAge.period); + }); + vm.uiGridOptions.data = patients; + }); + } + + // called on modules start + function startup() { + loadGrid(); + } + + // fire up the module + startup(); +} \ No newline at end of file diff --git a/client/test/e2e/patient/search.spec.js b/client/test/e2e/patient/search.spec.js new file mode 100644 index 0000000000..97c162506a --- /dev/null +++ b/client/test/e2e/patient/search.spec.js @@ -0,0 +1,25 @@ +/* global element, by, inject, browser */ +const chai = require('chai'); +const expect = chai.expect; + +const FU = require('../shared/FormUtils'); +const helpers = require('../shared/helpers'); +const components = require('../shared/components'); +const GridObjectTest = require('../shared/gridObjectTestUtils.spec.js'); + +helpers.configure(chai); + +describe('Research Patient UI Grid ', function () { + 'use strict'; + + const path = '#/patients/search'; + before(() => browser.get(path)); + + it('grid should have three visible rows', function () { + var defaultVisibleRowNumber = 3; + + GridObjectTest.expectRowCount(defaultVisibleRowNumber); + + }); + +}); diff --git a/server/controllers/medical/patient.js b/server/controllers/medical/patient.js index e0a1ccdc17..7d08608d79 100644 --- a/server/controllers/medical/patient.js +++ b/server/controllers/medical/patient.js @@ -327,9 +327,14 @@ function list(req, res, next) { var listPatientsQuery; listPatientsQuery = - `SELECT p.uuid, CONCAT(pr.abbr, p.reference) AS patientRef, p.first_name, - p.middle_name, p.last_name - FROM patient AS p JOIN project AS pr ON p.project_id = pr.id`; + `SELECT p.reference, CONCAT(p.first_name,' ', p.last_name,' ', p.middle_name) AS patientName, p.uuid, + p.first_name, p.last_name, p.middle_name, CONCAT(pr.abbr, p.reference) AS patientRef, p.dob, p.sex, + p.registration_date, MAX(pv.date) AS last_visit + FROM patient AS p + JOIN project AS pr ON p.project_id = pr.id + LEFT JOIN patient_visit AS pv ON pv.patient_uuid = p.uuid + GROUP BY p.uuid + ORDER BY p.registration_date DESC, p.last_name ASC`; db.exec(listPatientsQuery) .then(function (result) { diff --git a/server/models/test/data.sql b/server/models/test/data.sql index 3e073c8ea3..0cbd3aebe7 100644 --- a/server/models/test/data.sql +++ b/server/models/test/data.sql @@ -15,6 +15,7 @@ INSERT INTO unit VALUES (6, 'Account','TREE.ACCOUNT','Chart of Accounts management',30,'/partials/accounts/','/accounts'), (12, 'Hospital','TREE.HOSPITAL','The Hospital Super-Category',0,'/partials/hospital/index.html','/hospital'), (14, 'Patient Registration','TREE.PATIENT_REGISTRATION','Register patients',12,'/partials/patient/register/','/patients/register'), + (15, 'Patient Search','TREE.PATIENT_SEARCH','Search for patient',12,'/partials/patients/search/','/patients/search'), (16, 'Patient Invoice','TREE.PATIENT_INVOICE','Create an invoice for a patient',5,'/partials/patient_invoice/','/invoices/patient'), (18, 'Cash Window','TREE.CASH_WINDOW','Cash payments against past or future invoices',5,'/partials/cash/','/cash'), (19, 'Register Supplier','TREE.REGISTER_SUPPLIER','',1,'/partials/creditors/','/creditors'), @@ -126,6 +127,9 @@ INSERT INTO permission (unit_id, user_id) VALUES -- Patient Registration (14,1), +-- Patient Search +(15,1), + -- Patient Invoice (16,1), @@ -247,6 +251,11 @@ INSERT INTO `patient` VALUES (HUID('274c51ae-efcc-4238-98c6-f402bfb39866'),1,2,HUID('3be232f9-a4b9-4af6-984c-5d3f87d5c107'),'Test','2','1990-06-01 00:00:00',NULL,NULL,NULL,NULL,NULL,NULL,NULL,'M',NULL,NULL,NULL,NULL,NULL,NULL,0,HUID('bda70b4b-8143-47cf-a683-e4ea7ddd4cff'),HUID('bda70b4b-8143-47cf-a683-e4ea7ddd4cff'),'2015-11-14 07:04:49',NULL,NULL,'Patient','110'), (HUID('81af634f-321a-40de-bc6f-ceb1167a9f65'),1,1,HUID('a11e6b7f-fbbb-432e-ac2a-5312a66dccf4'),'Test','1','1990-06-01 00:00:00',NULL,NULL,NULL,NULL,NULL,NULL,NULL,'M',NULL,NULL,NULL,NULL,NULL,NULL,0,HUID('bda70b4b-8143-47cf-a683-e4ea7ddd4cff'),HUID('bda70b4b-8143-47cf-a683-e4ea7ddd4cff'),'2015-11-14 07:04:49',NULL,NULL,'Patient','100'); +INSERT INTO `patient_visit` VALUES + (HUID('5d3f87d5c107-a4b9-4af6-984c-3be232f9'), HUID('274c51ae-efcc-4238-98c6-f402bfb39866'), '2016-04-25 00:00:00', 1), + (HUID('710fa8b4da22-847d-4c6a-9b20-112a9fb5'), HUID('81af634f-321a-40de-bc6f-ceb1167a9f65'), '2016-04-28 00:00:00', 3), + (HUID('4c6aa8b4da22-847d-710f-9fb5-112a9b20'), HUID('81af634f-321a-40de-bc6f-ceb1167a9f65'), '2016-01-10 00:00:00', 2); + INSERT INTO `assignation_patient` VALUES (HUID('49b90fec-e69c-11e5-8606-843a4bc830ac'),HUID('112a9fb5-847d-4c6a-9b20-710fa8b4da24'),HUID('81af634f-321a-40de-bc6f-ceb1167a9f65')); From 3654fffec814fdb8a5e4a3bdfaa244efc616d679 Mon Sep 17 00:00:00 2001 From: lomamech Date: Tue, 3 May 2016 11:52:57 +0100 Subject: [PATCH 2/6] Adding test E2E for research patient --- client/test/e2e/patient/search.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/test/e2e/patient/search.spec.js b/client/test/e2e/patient/search.spec.js index 97c162506a..604ef5544a 100644 --- a/client/test/e2e/patient/search.spec.js +++ b/client/test/e2e/patient/search.spec.js @@ -5,7 +5,7 @@ const expect = chai.expect; const FU = require('../shared/FormUtils'); const helpers = require('../shared/helpers'); const components = require('../shared/components'); -const GridObjectTest = require('../shared/gridObjectTestUtils.spec.js'); +const gridTestUtils = require('../shared/gridTestUtils.spec.js'); helpers.configure(chai); From 90c4c8d8406e5aec8201ce68c1d010eb4ed149af Mon Sep 17 00:00:00 2001 From: lomamech Date: Tue, 3 May 2016 15:34:56 +0100 Subject: [PATCH 3/6] Improving the test E2E for Patient Registry and Adding an ID on the UI GRID for Patients Registries --- client/src/partials/patients/search/search.html | 2 +- client/test/e2e/patient/search.spec.js | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/client/src/partials/patients/search/search.html b/client/src/partials/patients/search/search.html index 649facc757..d4a24d816b 100644 --- a/client/src/partials/patients/search/search.html +++ b/client/src/partials/patients/search/search.html @@ -21,7 +21,7 @@
-
+
diff --git a/client/test/e2e/patient/search.spec.js b/client/test/e2e/patient/search.spec.js index 604ef5544a..89624e9b9a 100644 --- a/client/test/e2e/patient/search.spec.js +++ b/client/test/e2e/patient/search.spec.js @@ -1,11 +1,7 @@ /* global element, by, inject, browser */ const chai = require('chai'); const expect = chai.expect; - -const FU = require('../shared/FormUtils'); const helpers = require('../shared/helpers'); -const components = require('../shared/components'); -const gridTestUtils = require('../shared/gridTestUtils.spec.js'); helpers.configure(chai); @@ -15,11 +11,11 @@ describe('Research Patient UI Grid ', function () { const path = '#/patients/search'; before(() => browser.get(path)); - it('grid should have three visible rows', function () { + it('grid should have 3 visible rows', function () { var defaultVisibleRowNumber = 3; - - GridObjectTest.expectRowCount(defaultVisibleRowNumber); - + var grid = element(by.id('patient-registry')); + var rows = grid.element( by.css('.ui-grid-render-container-body')).all( by.repeater('(rowRenderIndex, row) in rowContainer.renderedRows track by $index') ); + expect(rows.count()).to.eventually.be.equal(defaultVisibleRowNumber); }); }); From 308fefcd099b014eaf47dcab5fdd5346c71e85ec Mon Sep 17 00:00:00 2001 From: lomamech Date: Tue, 3 May 2016 16:20:16 +0100 Subject: [PATCH 4/6] Update some test E2E Update the condition of comparaison for billing service and debtors groups update the rank for the deletion for the unit subsidy --- client/test/e2e/billingServices/billingServices.spec.js | 2 +- client/test/e2e/debtors/debtorgroups.spec.js | 2 +- client/test/e2e/subsidies/subsidies.spec.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/test/e2e/billingServices/billingServices.spec.js b/client/test/e2e/billingServices/billingServices.spec.js index 11624ed140..cea2e026ea 100644 --- a/client/test/e2e/billingServices/billingServices.spec.js +++ b/client/test/e2e/billingServices/billingServices.spec.js @@ -84,6 +84,6 @@ describe('Billing Services', function () { var rows = grid.element(by.css('.ui-grid-render-container-body')) .all(by.repeater('(rowRenderIndex, row) in rowContainer.renderedRows track by $index')); - expect(rows.count()).to.eventually.equal(2); + expect(rows.count()).to.eventually.equal(3); }); }); diff --git a/client/test/e2e/debtors/debtorgroups.spec.js b/client/test/e2e/debtors/debtorgroups.spec.js index 3186fea428..469fd49b55 100644 --- a/client/test/e2e/debtors/debtorgroups.spec.js +++ b/client/test/e2e/debtors/debtorgroups.spec.js @@ -10,7 +10,7 @@ var FU = require('../shared/FormUtils'); describe('Debtor Groups Management', function () { 'use strict'; - var initialGroups = 3; + var initialGroups = 7; /** @const */ diff --git a/client/test/e2e/subsidies/subsidies.spec.js b/client/test/e2e/subsidies/subsidies.spec.js index f668e5fe05..86265f7408 100644 --- a/client/test/e2e/subsidies/subsidies.spec.js +++ b/client/test/e2e/subsidies/subsidies.spec.js @@ -21,7 +21,7 @@ describe('Subsidies Module', function () { }; const defaultSubsidy = 0; - const subsidyRank = 1; + const subsidyRank = 2; it('successfully creates a new subsidy', function () { From f1fef1c24cd4bea0c393ec51284036ff3a5e41b5 Mon Sep 17 00:00:00 2001 From: lomamech Date: Wed, 4 May 2016 11:20:08 +0100 Subject: [PATCH 5/6] Improve patient registry Update translate files Using patient registry instead patient search Remove method getDate instead the using of angular-moment Fix some comment --- client/src/i18n/en.json | 6 +-- client/src/i18n/fr.json | 6 +-- client/src/js/app.js | 8 +-- client/src/js/services/DateService.js | 52 +------------------ client/src/js/services/PatientService.js | 6 +-- .../search.html => registry/registry.html} | 4 +- .../search.js => registry/registry.js} | 33 ++++-------- .../{search.spec.js => registry.spec.js} | 4 +- server/controllers/medical/patient.js | 2 +- server/models/test/data.sql | 2 +- 10 files changed, 31 insertions(+), 92 deletions(-) rename client/src/partials/patients/{search/search.html => registry/registry.html} (69%) rename client/src/partials/patients/{search/search.js => registry/registry.js} (60%) rename client/test/e2e/patient/{search.spec.js => registry.spec.js} (87%) diff --git a/client/src/i18n/en.json b/client/src/i18n/en.json index c95144dbb5..af6b018896 100644 --- a/client/src/i18n/en.json +++ b/client/src/i18n/en.json @@ -565,14 +565,14 @@ "TITLE" : "Title", "VIEW_PATIENT_RECORDS" : "View Patient Records" }, - "PATIENT_SEARCH" : { + "PATIENT_REGISTRY" : { "DAY" : "day", "DAYS" : "days", "MONTH" : "month", "MONTHS" : "months", "YEAR_OLD" : "year old", "YEARS_OLD" : "years old", - "PAGE_TITLE" : "Patient Search" + "TITLE" : "Patients Registry" }, "PERMISSIONS": { "ADDING_USER" : "Add a user", @@ -872,7 +872,7 @@ "PATIENT_RECORDS" : "Patient Records", "PATIENT_REGISTRATION" : "Patient Registration", "PATIENT_REGISTRATIONS" : "Patient Registrations", - "PATIENT_SEARCH" : "Patient Search", + "PATIENT_REGISTRY" : "Patients Registry", "PATIENT_STANDING" : "Patient Standing", "PATIENT_VISIT_STATUS" : "Patient Visits", "PAYMENT_PERIOD" : "Payment Period Management", diff --git a/client/src/i18n/fr.json b/client/src/i18n/fr.json index e96a1e0eb4..193ea25c82 100644 --- a/client/src/i18n/fr.json +++ b/client/src/i18n/fr.json @@ -536,14 +536,14 @@ "TITLE" : "Titre", "VIEW_PATIENT_RECORDS" : "Voir Tous les enregistrements" }, - "PATIENT_SEARCH" : { + "PATIENT_REGISTRY" : { "DAY" : "jour", "DAYS" : "jours", "MONTH" : "mois", "MONTHS" : "mois", "YEAR_OLD" : "an", "YEARS_OLD" : "ans", - "PAGE_TITLE" : "Recherche des patients" + "TITLE" : "Registre des patients" }, "PERMISSIONS": { "ADDING_USER" : "Ajout utilisateur", @@ -829,7 +829,7 @@ "PATIENT_RECORDS" : "Historique Patients", "PATIENT_REGISTRATION" : "Enregistrement Patient", "PATIENT_REGISTRATIONS" : "Enregistrement Patients", - "PATIENT_SEARCH" : "Recherche des Patients", + "PATIENT_REGISTRY" : "Registre des patients", "PATIENT_STANDING" : "Patients", "PATIENT_VISIT_STATUS" : "Patient Visitations", "PAYMENT_PERIOD" : "Gestion Périodes", diff --git a/client/src/js/app.js b/client/src/js/app.js index 21cd559cbb..3c761ae474 100644 --- a/client/src/js/app.js +++ b/client/src/js/app.js @@ -538,10 +538,10 @@ function bhimaConfig($stateProvider, $urlRouterProvider, $urlMatcherFactoryProvi templateUrl : 'partials/patient_invoice/patientInvoice.html' }) - .state('/patients/search/', { - url : '/patients/search', - controller: 'PatientSearchController as PatientSearchCtrl', - templateUrl: '/partials/patients/search/search.html' + .state('/patients/registry/', { + url : '/patients/registry', + controller: 'PatientRegistryController as PatientRegistryCtrl', + templateUrl: '/partials/patients/registry/registry.html' }) .state('patientGroups', { url : '/patients/groups', diff --git a/client/src/js/services/DateService.js b/client/src/js/services/DateService.js index fd44728b7d..4721d2adc7 100644 --- a/client/src/js/services/DateService.js +++ b/client/src/js/services/DateService.js @@ -45,7 +45,6 @@ function DateService() { service.current = {}; service.next = {}; service.util = {}; - service.getAge = getAge; /* * Very generic function to subtract days, months, years @@ -218,7 +217,7 @@ function DateService() { // yet another javascript date string function // expects a date object // return 'YYYY-MM-DD' format - service.util.str = function (date, simple) { + service.util.str = function (date) { // if we pass in a string, return it right away if (typeof date === 'string') { return date; } @@ -234,53 +233,4 @@ function DateService() { return [year, month, day].join('-'); }; - // get an age object for the person with years, months, days - // inspired by http://stackoverflow.com/questions/7833709/calculating-age-in-months-and-days - - function getAge(date) { - var age = {}, - today = new Date(); - - // convert to date object - date = new Date(date); - - var y = [today.getFullYear(), date.getFullYear()], - ydiff = y[0] - y[1], - m = [today.getMonth(), date.getMonth()], - mdiff = m[0] - m[1], - d = [today.getDate(), date.getDate()], - ddiff = d[0] - d[1]; - - if (mdiff < 0 || (mdiff=== 0 && ddiff<0)) { --ydiff; } - - if (mdiff < 0) { mdiff+= 12; } - - if (ddiff < 0) { - date.setMonth(m[1]+1, 0); - ddiff = date.getDate()-d[1]+d[0]; - --mdiff; - } - - age.years = ydiff > 0 ? ydiff : 0; - age.months = mdiff > 0 ? mdiff : 0; - age.days = ddiff > 0 ? ddiff : 0; - - if(age.years > 0) { - age.duration = age.years; - age.period = (age.years === 1)? 'PATIENT_SEARCH.YEAR_OLD' : 'PATIENT_SEARCH.YEARS_OLD'; - } - - if((age.years === 0) && (age.months > 1)) { - age.duration = age.months; - age.period = (age.months === 1)? 'PATIENT_SEARCH.MONTH' : 'PATIENT_SEARCH.MONTHS'; - } - - if((age.years === 0) && (age.months === 0)) { - age.duration = age.days; - age.period = (age.days === 1)? 'PATIENT_SEARCH.DAY' : 'PATIENT_SEARCH.DAYS'; - } - - return age; - } - } diff --git a/client/src/js/services/PatientService.js b/client/src/js/services/PatientService.js index d83d8d7308..198b96a76c 100644 --- a/client/src/js/services/PatientService.js +++ b/client/src/js/services/PatientService.js @@ -15,7 +15,7 @@ PatientService.$inject = [ '$http', 'util', 'SessionService' ]; * var Patients = PatientService; * * // returns patient details - * Patients.detail(uuid)... + * Patients.list(uuid)... * * // creates a patient * Patients.create(medicalDetails, financeDetails)... @@ -26,7 +26,7 @@ function PatientService($http, util, Session) { var service = this; var baseUrl = '/patients/'; - service.detail = detail; + service.list = list; service.create = create; service.update = update; service.groups = groups; @@ -46,7 +46,7 @@ function PatientService($http, util, Session) { * @param {String} uuid The patient's UUID * @return {Object} Promise object that will return patient details */ - function detail(uuid) { + function list(uuid) { return $http.get(baseUrl.concat(uuid || '')) .then(util.unwrapHttpResponse); } diff --git a/client/src/partials/patients/search/search.html b/client/src/partials/patients/registry/registry.html similarity index 69% rename from client/src/partials/patients/search/search.html rename to client/src/partials/patients/registry/registry.html index d4a24d816b..2d3382d9af 100644 --- a/client/src/partials/patients/search/search.html +++ b/client/src/partials/patients/registry/registry.html @@ -2,7 +2,7 @@
  1. {{ "TREE.HOSPITAL" | translate }}
  2. -
  3. {{ "PATIENT_SEARCH.PAGE_TITLE" | translate }}
  4. +
  5. {{ "PATIENT_REGISTRY.TITLE" | translate }}
@@ -21,7 +21,7 @@
-
+
diff --git a/client/src/partials/patients/search/search.js b/client/src/partials/patients/registry/registry.js similarity index 60% rename from client/src/partials/patients/search/search.js rename to client/src/partials/patients/registry/registry.js index 12597ff224..5c12b50250 100644 --- a/client/src/partials/patients/search/search.js +++ b/client/src/partials/patients/registry/registry.js @@ -1,21 +1,19 @@ angular.module('bhima.controllers') -.controller('PatientSearchController', PatientSearchController); +.controller('PatientRegistryController', PatientRegistryController); -PatientSearchController.$inject = [ - '$translate', 'PatientService', 'DateService' +PatientRegistryController.$inject = [ + '$translate', 'PatientService', ]; /** - * Users and Permission Controller + * Patient Registry Controller * - * This module is responsible for handling the creation - * of users and assigning permissions to existing modules. + * This module is responsible for the management + * of Patient Registry. * - * @todo Password insecure alert or not */ -function PatientSearchController($translate, Patients, dateService) { +function PatientRegistryController($translate, Patients) { var vm = this; - // options for the UI grid /** TODO MANAGE COLUMN : LAST_TRANSACTION */ @@ -34,22 +32,13 @@ function PatientSearchController($translate, Patients, dateService) { enableSorting : true }; - /** @todo manage state without strings */ - vm.state = 'default'; // this is default || create || update - - - // TODO - function handler(error) { - throw error; - } - - // load user grid + // load Patient Registry Grid function loadGrid() { - Patients.detail().then(function (patients) { + Patients.list().then(function (patients) { patients.forEach(function (patient) { - var patientAge = dateService.getAge(patient.dob,'simple'); - patient.patientAge = patientAge.duration + ' ' + $translate.instant(patientAge.period); + var patientAge = moment(patient.dob).fromNow(); + patient.patientAge = patientAge; }); vm.uiGridOptions.data = patients; }); diff --git a/client/test/e2e/patient/search.spec.js b/client/test/e2e/patient/registry.spec.js similarity index 87% rename from client/test/e2e/patient/search.spec.js rename to client/test/e2e/patient/registry.spec.js index 89624e9b9a..8f53f00bc7 100644 --- a/client/test/e2e/patient/search.spec.js +++ b/client/test/e2e/patient/registry.spec.js @@ -5,10 +5,10 @@ const helpers = require('../shared/helpers'); helpers.configure(chai); -describe('Research Patient UI Grid ', function () { +describe('Patient Registry UI Grid ', function () { 'use strict'; - const path = '#/patients/search'; + const path = '#/patients/registry'; before(() => browser.get(path)); it('grid should have 3 visible rows', function () { diff --git a/server/controllers/medical/patient.js b/server/controllers/medical/patient.js index 7d08608d79..a9d874f62c 100644 --- a/server/controllers/medical/patient.js +++ b/server/controllers/medical/patient.js @@ -327,7 +327,7 @@ function list(req, res, next) { var listPatientsQuery; listPatientsQuery = - `SELECT p.reference, CONCAT(p.first_name,' ', p.last_name,' ', p.middle_name) AS patientName, p.uuid, + `SELECT BUID(p.uuid) AS uuid, p.reference, CONCAT(p.first_name,' ', p.last_name,' ', p.middle_name) AS patientName, p.first_name, p.last_name, p.middle_name, CONCAT(pr.abbr, p.reference) AS patientRef, p.dob, p.sex, p.registration_date, MAX(pv.date) AS last_visit FROM patient AS p diff --git a/server/models/test/data.sql b/server/models/test/data.sql index 0cbd3aebe7..00df935fb1 100644 --- a/server/models/test/data.sql +++ b/server/models/test/data.sql @@ -15,7 +15,7 @@ INSERT INTO unit VALUES (6, 'Account','TREE.ACCOUNT','Chart of Accounts management',30,'/partials/accounts/','/accounts'), (12, 'Hospital','TREE.HOSPITAL','The Hospital Super-Category',0,'/partials/hospital/index.html','/hospital'), (14, 'Patient Registration','TREE.PATIENT_REGISTRATION','Register patients',12,'/partials/patient/register/','/patients/register'), - (15, 'Patient Search','TREE.PATIENT_SEARCH','Search for patient',12,'/partials/patients/search/','/patients/search'), + (15, 'Patient Registry','TREE.PATIENT_REGISTRY','Patient Registry',12,'/partials/patients/registry/','/patients/registry'), (16, 'Patient Invoice','TREE.PATIENT_INVOICE','Create an invoice for a patient',5,'/partials/patient_invoice/','/invoices/patient'), (18, 'Cash Window','TREE.CASH_WINDOW','Cash payments against past or future invoices',5,'/partials/cash/','/cash'), (19, 'Register Supplier','TREE.REGISTER_SUPPLIER','',1,'/partials/creditors/','/creditors'), From 82dae7d22c7b765049fd3dd41c452121aa468ea3 Mon Sep 17 00:00:00 2001 From: lomamech Date: Wed, 4 May 2016 12:15:12 +0100 Subject: [PATCH 6/6] Complete translate liste --- client/src/i18n/en.json | 46 ++++++++++++++++++++--------------------- client/src/i18n/fr.json | 42 ++++++++++++++++++++++++++++++++++++- 2 files changed, 63 insertions(+), 25 deletions(-) diff --git a/client/src/i18n/en.json b/client/src/i18n/en.json index af6b018896..f04b5ce31b 100644 --- a/client/src/i18n/en.json +++ b/client/src/i18n/en.json @@ -104,6 +104,10 @@ "ER_ROW_IS_REFERENCED_2" : "Cannot delete entry since it has been used in a transaction." }, "DEBTOR_GRP": { + "BACK" : "Back to Debtor Groups", + "CREATE" : "Create Debtor Group", + "CREATE_ANOTHER" : "Create another Debtor Group", + "CREATED" : "Debtor group recorded successfully", "EDIT" : "Edit Debtor Group", "GROUPS" : "Debtor Groups", "HELP_TXT_1" : "This interface allows you to review, find, and configure debtor groups", @@ -113,13 +117,6 @@ "INFO" : "Group Information", "NEW" : "Add a Debtor Group", "NEW_DEBTOR_GRP" : "New Debtor Group", - "TITLE" : "Debtor Group Management", - "SUBSCRIBED" : "Debtors subscribed", - "BACK" : "Back to Debtor Groups", - "CREATE" : "Create Debtor Group", - "CREATE_ANOTHER" : "Create another Debtor Group", - "CREATED" : "Debtor group recorded successfully", - "UPDATED" : "Debtor group record updated", "POLICIES" : { "TITLE" : "Group Policies", "SUBSIDIES" : { @@ -137,7 +134,10 @@ "INFO" : "With this configuration option checked all members of this debtor group will be exempt from paying automatically applied billing services", "LABEL" : "This group is exempt from paying billing services" } - } + }, + "TITLE" : "Debtor Group Management", + "SUBSCRIBED" : "Debtors subscribed", + "UPDATED" : "Debtor group record updated" }, "DEPOT": { "ADD_DEPOT" : "Add a Depot", @@ -179,9 +179,9 @@ "TITLE" : "Enterprise Management" }, "ERRORS": { + "ERR_INTERNET_DISCONNECTED" : "You are not connected to the network.", "NO_EXCHANGE_RATE" : "No Exchange rate defined", - "UNAUTHORIZED" : "Unauthorized", - "ERR_INTERNET_DISCONNECTED" : "You are not connected to the network." + "UNAUTHORIZED" : "Unauthorized" }, "EXCHANGE": { "ADDING_RATE" : "Adding an exchange Rate", @@ -446,9 +446,9 @@ "ENTER_SECTOR" : "Enter sector", "ENTER_USERNAME" : "Enter username", "ENTER_VILLAGE" : "Enter village", + "FILTER_NAME" : "Filter by name...", "SEARCH_NAME" : "Search by Name", - "SEARCH_PATIENT_ID" : "Search by Patient ID", - "FILTER_NAME" : "Filter by name..." + "SEARCH_PATIENT_ID" : "Search by Patient ID" }, "SELECTS": { "EMPTY" : "Empty", @@ -593,11 +593,11 @@ "ITEMS" : "Items", "NEW_PRICE_LIST" : "New Price List", "NO_RECORDS" : "No Records", + "NONE" : "Apply no price list", "PRICE_LIST_ITEMS" : "Price list items", "TITLE" : "Price List Management", "UNABLE_TO_DELETE" : "Price list cannot be deleted - it may currently be assigned to patient/ debtor groups", - "UPDATE" : "Update a Price List", - "NONE" : "Apply no price list" + "UPDATE" : "Update a Price List" }, "PROJECT": { "ADDING_PROJECT" : "Adding a new project", @@ -719,6 +719,9 @@ "EMPTY" : "There are no records to display.", "ENTERPRISE_ID" : "ID Enterprise", "EXCHANGE_RATE" : "Exchange Rate", + "FILTERING": { + "LABEL" : "Filter" + }, "FIRST_NAME" : "First Name", "FUNCTION" : "Function", "GENDER" : "Gender", @@ -760,12 +763,6 @@ "RESULT_ACCOUNT_SCT" : "Result Account section", "SECTOR" : "Sector", "SERVICE" : "Service", - "TEXT" : "Text", - "TOTAL" : "Total", - "TYPE" : "Type", - "VALUE" : "Value", - "VILLAGE" : "Village", - "SORTING": { "LABEL" : "Sort", "NAME_ASC" : "Name [A-Z]", @@ -774,10 +771,11 @@ "CREATED_DSC" : "Newest", "TOTAL_ASC" : "Largest" }, - - "FILTERING": { - "LABEL" : "Filter" - } + "TEXT" : "Text", + "TOTAL" : "Total", + "TYPE" : "Type", + "VALUE" : "Value", + "VILLAGE" : "Village" } }, "TREE": { diff --git a/client/src/i18n/fr.json b/client/src/i18n/fr.json index 193ea25c82..7c73aecaae 100644 --- a/client/src/i18n/fr.json +++ b/client/src/i18n/fr.json @@ -103,6 +103,10 @@ "ER_ROW_IS_REFERENCED_2" : "Vous ne pouvez pas supprimer cette donnée car il a été utilisé dans une transaction." }, "DEBTOR_GRP": { + "BACK" : "Retour vers les groupes débiteurs", + "CREATE" : "Créer un Groupe débiteur", + "CREATE_ANOTHER" : "Créer un autre Groupe débiteur", + "CREATED" : "Groupes débiteurs enregistrés avec succès", "EDIT" : "Editer le groupe debiteur", "GROUPS" : "Groupes Débiteurs", "HELP_TXT_1" : "Cette interface vous permet de visualiser, trouver, et configurer un groupe de debiteur", @@ -112,7 +116,27 @@ "INFO" : "Information du Groupe", "NEW" : "Ajouter un Groupe Débiteur", "NEW_DEBTOR_GRP" : "Nouveau Groupe de Débiteur", - "TITLE" : "Gestion des Groupes des Débiteurs" + "POLICIES" : { + "TITLE" : "Les stratégies de groupe", + "SUBSIDIES" : { + "TITLE" : "Subventions", + "INFO" : "Avec cette configuration, aucun membre de ce groupe débiteur ne sera subventionné", + "LABEL" : "Ce groupe est qualifié pour les subventions" + }, + "DISCOUNTS" : { + "TITLE" : "Réductions", + "INFO" : "Avec cette configuration, aucun membre de ce groupe débiteur n'aura des réductions", + "LABEL" : "Ce groupe est qualifié pour les réductions" + }, + "BILLING_SERVICES" : { + "TITLE" : "Services des facturations", + "INFO" : "Avec cette configuration, tous les membres de ce groupe débiteur sera exonéré de paiement des services de facturation appliqués automatiquement", + "LABEL" : "Ce groupe est exempté du paiement des services de facturation" + } + }, + "TITLE" : "Gestion des Groupes des Débiteurs", + "SUBSCRIBED" : "Débiteurs abonnés", + "UPDATED" : "Enregistrement du groupe débiteur mis à jour" }, "DEPOT": { "ADD_DEPOT" : "Ajouter un dépôt", @@ -154,6 +178,7 @@ "TITLE" : "Gestion des entreprises" }, "ERRORS": { + "ERR_INTERNET_DISCONNECTED" : "Vous n'êtes pas connecté à un réseau.", "NO_EXCHANGE_RATE" : "Aucun taux de change defini", "UNAUTHORIZED" : "Non autorisé" }, @@ -271,6 +296,7 @@ "CONTACT" : "Contact", "COST_CENTER" : "Centre de cout", "COUNTRY" : "Pays", + "CREATED" : "Crée", "CREDITOR_GROUP" : "Groupe Créditeur", "CURRENCIES" : "Monnaies", "CURRENCY" : "Monnaie", @@ -329,6 +355,7 @@ "MALE" : "Homme", "MARITAL_STATUS" : "Etat Civil", "MAX_CREDIT" : "Crédit Max", + "MAX_CREDIT_INFO" : "La valeur de crédit maximum de ce groupe débiteur peut recueillir avant d'être mis en garde. Une valeur de 0 signifie aucune limite maximale.", "MIDDLE_NAME" : "Post-nom", "MOTHER_NAME" : "Nom de la Mère", "NAME" : "Nom", @@ -418,6 +445,7 @@ "ENTER_SECTOR" : "Entrer secteur", "ENTER_USERNAME" : "Entrer le nom utilisateur", "ENTER_VILLAGE" : "Entrer village", + "FILTER_NAME" : "Filtrer par Nom...", "SEARCH_NAME" : "Chercher Par Nom", "SEARCH_PATIENT_ID" : "Chercher ID Patient" }, @@ -564,6 +592,7 @@ "ITEMS" : "Items", "NEW_PRICE_LIST" : "Nouvelle Liste des Prix", "NO_RECORDS" : "Pas d'enregistrement", + "NONE" : "Appliquer aucune liste de prix", "PRICE_LIST_ITEMS" : "Eléments de la liste des prix", "TITLE" : "Liste des Prix", "UNABLE_TO_DELETE" : "La liste de prix ne peut être supprimer - car elle peut être courament assignée à un groupe de patient / groupes débiteurs", @@ -689,6 +718,9 @@ "EMPTY" : "Il n'y a pas d'enregistrements à afficher.", "ENTERPRISE_ID" : "ID enterprise", "EXCHANGE_RATE" : "Taux de change", + "FILTERING": { + "LABEL" : "Filtre" + }, "FIRST_NAME" : "Prenom", "FUNCTION" : "Fonction", "GENDER" : "Genre", @@ -730,6 +762,14 @@ "RESULT_ACCOUNT_SCT" : "Section Compte Résultat", "SECTOR" : "Secteur", "SERVICE" : "Service", + "SORTING": { + "LABEL" : "Tri", + "NAME_ASC" : "Nom [A-Z]", + "NAME_DSC" : "Nom [Z-A]", + "CREATED_ASC" : "Le plus ancien", + "CREATED_DSC" : "Le plus récent", + "TOTAL_ASC" : "Le plus grand" + }, "TEXT" : "Text", "TOTAL" : "Total", "TYPE" : "Type",