Skip to content

Commit

Permalink
fix(patient): fix registry date bug
Browse files Browse the repository at this point in the history
This commit fixes some date errors in the patient registry filters,
identified by the work @lomamech did importing the large 1.x dataset.
All date filters were off by a single unit - weeks were a week early,
days were a day early.

It also updates translation keys with the new i18n syntax.
  • Loading branch information
Jonathan Niles committed Aug 10, 2016
1 parent 3778f2c commit 9c21e3b
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 18 deletions.
10 changes: 5 additions & 5 deletions client/src/js/services/LocationService.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ function LocationService($http, util, Modal) {

/** translation messages used in location <select> components */
service.messages = {
country: 'FORM.SELECTS.SELECT_COUNTRY',
province: 'FORM.SELECTS.SELECT_PROVINCE',
sector: 'FORM.SELECTS.SELECT_SECTOR',
village: 'FORM.SELECTS.SELECT_VILLAGE',
empty: 'FORM.SELECTS.EMPTY'
country: 'FORM.SELECT.COUNTRY',
province: 'FORM.SELECT.PROVINCE',
sector: 'FORM.SELECT.SECTOR',
village: 'FORM.SELECT.VILLAGE',
empty: 'FORM.SELECT.EMPTY'
};

/**
Expand Down
8 changes: 4 additions & 4 deletions client/src/partials/locations/locations.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<div class="panel panel-default" style="overflow: auto; max-height: 500px;">
<div class="panel-heading">
{{ "LOCATION.REGISTERED" | translate }}
</div>
</div>
<table class="table table-condensed">
<thead>
<tr>
Expand Down Expand Up @@ -68,9 +68,9 @@ <h4>{{ 'LOCATION.MANAGER_CONFIGURATION' | translate }}</h4>
{{ 'LOCATION.DESCRIPTION' | translate }}
<b>{{ 'LOCATION.DESCRIPTION_2' | translate }}</b>,
{{ 'LOCATION.LOCATION' | translate }}.
</p>
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
6 changes: 5 additions & 1 deletion client/src/partials/patients/registry/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ function PatientRegistryController(Patients, Notify, moment, AppCache, util) {
Notify.handleError(error);
}

function isEmpty(object) {
return Object.keys(object).length === 0;
}

// this function loads patients from the database with search parameters
// if passed in.
function load(parameters) {
Expand All @@ -71,7 +75,7 @@ function PatientRegistryController(Patients, Notify, moment, AppCache, util) {

// if we have search parameters, use search. Otherwise, just read all
// patients.
var request = angular.isDefined(parameters) ?
var request = angular.isDefined(parameters) && !isEmpty(parameters) ?
Patients.search(parameters) :
Patients.read();

Expand Down
12 changes: 6 additions & 6 deletions client/src/partials/patients/registry/search.modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,17 @@ function PatientRegistryModalController(ModalInstance, Patients, Dates, params)
vm.range = range;

switch (range) {
case 'today' :
case 'today':
vm.params[key] = new Date();
break;
case 'week' :
vm.params[key] = Dates.previous.week();
case 'week':
vm.params[key] = Dates.current.week();
break;
case 'month' :
vm.params[key] = Dates.previous.month();
case 'month':
vm.params[key] = Dates.current.month();
break;
default:
vm.params[key] = Dates.previous.year();
vm.params[key] = Dates.current.year();
}
}

Expand Down
2 changes: 1 addition & 1 deletion client/test/e2e/patient/registry.search.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function PatientRegistrySearch() {
element(by.id('male')).click();
FU.modal.submit();

expectNumberOfGridRows(2);
expectNumberOfGridRows(1);
expectNumberOfFilters(3);

// click the "clear filters" button
Expand Down
2 changes: 1 addition & 1 deletion server/models/test/data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ INSERT INTO `debtor` VALUES

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('1f162a10-9f67-4788-9eff-c1fea42fcc9b'),HUID('1f162a10-9f67-4788-9eff-c1fea42fcc9b'),'2015-11-14 07:04:49',NULL,NULL,'Patient','110', '', 1),
(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,'F',NULL,NULL,NULL,NULL,NULL,NULL,0,HUID('1f162a10-9f67-4788-9eff-c1fea42fcc9b'),HUID('1f162a10-9f67-4788-9eff-c1fea42fcc9b'),'2015-11-14 07:04:49',NULL,NULL,'Patient','100', '', 2);
(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,'F',NULL,NULL,NULL,NULL,NULL,NULL,0,HUID('1f162a10-9f67-4788-9eff-c1fea42fcc9b'),HUID('1f162a10-9f67-4788-9eff-c1fea42fcc9b'),'2016-03-14 07:04:49',NULL,NULL,'Patient','100', '', 2);

INSERT INTO `patient_visit` VALUES
(HUID('5d3f87d5c107-a4b9-4af6-984c-3be232f9'), HUID('274c51ae-efcc-4238-98c6-f402bfb39866'), '2016-04-25 00:00:00', NULL, 1),
Expand Down

0 comments on commit 9c21e3b

Please sign in to comment.