Skip to content

Commit

Permalink
Merge #1969
Browse files Browse the repository at this point in the history
1969: Remove the deprecated filter into patient registry r=jniles

In this PR : 

- The deprecated filter is removed from the patient registry file,

- The search modal was also updated to follow the new standard

- A new component was implemented ```bhPatientGroupSelect``` and its test

This PR references #1942
  • Loading branch information
bors[bot] committed Aug 14, 2017
2 parents 5c2f712 + ad90506 commit 3d1eefb
Show file tree
Hide file tree
Showing 10 changed files with 172 additions and 101 deletions.
41 changes: 41 additions & 0 deletions client/src/js/components/bhPatientGroupSelect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
angular.module('bhima.components')
.component('bhPatientGroupSelect', {
templateUrl : 'modules/templates/bhPatientGroupSelect.tmpl.html',
controller : PatientGroupSelectController,
transclude : true,
bindings : {
patientGroupUuid : '<',
onSelectCallback : '&',
label : '@?',
required : '<?',
validateTrigger : '<?',
},
});

PatientGroupSelectController.$inject = [
'PatientGroupService', 'NotifyService'
];

/**
* Patient Group selection component
*
*/
function PatientGroupSelectController(PatientGroups, Notify) {
var $ctrl = this;

$ctrl.$onInit = function onInit() {
// default for label
$ctrl.label = $ctrl.label || 'PATIENT_GROUP.PATIENT_GROUP';

// load all patient groups
PatientGroups.read()
.then(function (pgs) {
$ctrl.patientGroups = pgs;
})
.catch(Notify.handleError);
};

$ctrl.onSelect = function ($item, $model) {
$ctrl.onSelectCallback({ patientGroup : $item });
};
}
14 changes: 7 additions & 7 deletions client/src/modules/patients/patients.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,14 @@ function PatientService($http, util, Session, $uibModal,
{ key : 'sex', label : 'FORM.LABELS.GENDER' },
{ key : 'hospital_no', label : 'FORM.LABELS.HOSPITAL_NO' },
{ key : 'reference', label : 'FORM.LABELS.REFERENCE' },
{ key : 'dateBirthFrom', label : 'FORM.LABELS.DOB', comparitor: '>', ngFilter:'date' },
{ key : 'dateBirthTo', label : 'FORM.LABELS.DOB', comparitor: '<', ngFilter:'date' },
{ key : 'dateRegistrationFrom', label: 'FORM.LABELS.DATE_REGISTRATION', comparitor: '>', ngFilter:'date' },
{ key : 'dateRegistrationTo', label: 'FORM.LABELS.DATE_REGISTRATION', comparitor: '<', ngFilter:'date' },
{ key : 'dateBirthFrom', label : 'FORM.LABELS.DOB', comparitor: '>', valueFilter:'date' },
{ key : 'dateBirthTo', label : 'FORM.LABELS.DOB', comparitor: '<', valueFilter:'date' },
{ key : 'dateRegistrationFrom', label: 'FORM.LABELS.DATE_REGISTRATION', comparitor: '>', valueFilter:'date' },
{ key : 'dateRegistrationTo', label: 'FORM.LABELS.DATE_REGISTRATION', comparitor: '<', valueFilter:'date' },
{ key : 'debtor_group_uuid', label: 'FORM.LABELS.DEBTOR_GROUP' },
{ key : 'patient_group_uuid', label: 'PATIENT_GROUP.PATIENT_GROUP' },
{ key : 'user_id', label: 'FORM.LABELS.USER' },
{ key : 'defaultPeriod', label : 'TABLE.COLUMNS.PERIOD', ngFilter : 'translate' },
{ key : 'defaultPeriod', label : 'TABLE.COLUMNS.PERIOD'},
]);

if (filterCache.filters) {
Expand Down Expand Up @@ -294,9 +294,9 @@ function PatientService($http, util, Session, $uibModal,
keyboard: false,
animation: false,
backdrop: 'static',
controller: 'PatientRegistryModalController as ModalCtrl',
controller: 'PatientRegistryModalController as $ctrl',
resolve : {
params : function paramsProvider() { return params; }
filters : function paramsProvider() { return params; }
}
}).result;
}
Expand Down
4 changes: 2 additions & 2 deletions client/src/modules/patients/registry/registry.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="flex-header static">
<div class="flex-header">
<div class="bhima-title">
<ol class="headercrumb">
<li class="static" translate>TREE.HOSPITAL</li>
Expand Down Expand Up @@ -64,6 +64,7 @@

<div class="flex-util bh-filter-bar">
<bh-filters
style="max-width:90%"
filters="PatientRegistryCtrl.latestViewFilters"
on-remove-filter="PatientRegistryCtrl.onRemoveFilter(filter)">
</bh-filters>
Expand All @@ -74,7 +75,6 @@
<div
id="patient-registry"
class="grid-full-height-with-filters"
ng-style="PatientRegistryCtrl.filterBarHeight"
ui-grid="PatientRegistryCtrl.uiGridOptions"
ui-grid-auto-resize
ui-grid-resize-columns
Expand Down
26 changes: 8 additions & 18 deletions client/src/modules/patients/registry/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ PatientRegistryController.$inject = [
'$state', 'PatientService', 'NotifyService', 'AppCache',
'util', 'ReceiptModal', 'uiGridConstants', '$translate',
'GridColumnService', 'GridSortingService', 'bhConstants',
'DepricatedFilterService', 'GridStateService', 'LanguageService', 'ExportService'];
'GridStateService', 'LanguageService', 'ExportService'];

/**
* Patient Registry Controller
Expand All @@ -14,20 +14,15 @@ PatientRegistryController.$inject = [
*/
function PatientRegistryController($state, Patients, Notify, AppCache,
util, Receipts, uiGridConstants, $translate,
Columns, Sorting, bhConstants, Filters, GridState, Languages, Export) {
Columns, Sorting, bhConstants, GridState, Languages, Export) {
var vm = this;

var filter = new Filters();
vm.filter = filter;

var cacheKey = 'PatientRegistry';
var cache = AppCache(cacheKey);
var FILTER_BAR_HEIGHT = bhConstants.grid.FILTER_BAR_HEIGHT;
var state;

vm.search = search;
vm.patientCard = patientCard;
vm.filterBarHeight = {};
vm.openColumnConfiguration = openColumnConfiguration;
vm.gridApi = {};
vm.onRemoveFilter = onRemoveFilter;
Expand Down Expand Up @@ -129,17 +124,14 @@ function PatientRegistryController($state, Patients, Notify, AppCache,
return Object.keys(object).length === 0;
}

// this function loads patients from the database with search parameters
// if passed in.
function load(parameters) {
// this function loads patients from the database with search filters, if passed in.
function load(filters) {

// flush error and loading states
vm.hasError = false;
toggleLoadingIndicator();

// if we have search parameters, use search. Otherwise, just read all
// patients.
var request = Patients.read(null, parameters);
var request = Patients.read(null, filters);

// hook the returned patients up to the grid.
request.then(function (patients) {
Expand Down Expand Up @@ -194,11 +186,9 @@ function PatientRegistryController($state, Patients, Notify, AppCache,
// startup function. Checks for cached filters and loads them. This behavior could be changed.
function startup() {

if ($state.params.filters) {
// Fix me, generate change dynamically
var change = [{ key : $state.params.filters.key, value : $state.params.filters.value }];

Patients.filters.replaceFilters(change);
if($state.params.filters) {
var changes = [{ key : $state.params.filters.key, value : $state.params.filters.value }]
Patients.filters.replaceFilters(changes);
Patients.cacheFilters();
}

Expand Down
78 changes: 36 additions & 42 deletions client/src/modules/patients/registry/search.modal.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<form
name="ModalForm"
ng-submit="ModalCtrl.submit(ModalForm)"
ng-submit="$ctrl.submit(ModalForm)"
data-modal="patient-search"
novalidate>

Expand All @@ -15,94 +15,90 @@
<uib-tabset>
<uib-tab index="0" heading="{{ 'FORM.LABELS.SEARCH_QUERRIES' | translate }}" data-custom-filter-tab>
<div class="tab-body">
<div class="form-group" ng-class="{ 'has-error' : ModalForm.$submitted && ModalForm.name.$invalid }">
<!--patient name-->
<div class="form-group" ng-class="{ 'has-error' : ModalForm.$submitted && ModalForm.display_name.$invalid }">
<label class="control-label" translate> FORM.LABELS.NAME </label>
<bh-clear on-clear="ModalCtrl.clear('display_name')"></bh-clear>
<input type="text" class="form-control" name="display_name" ng-model="ModalCtrl.params.display_name">
<bh-clear on-clear="$ctrl.clear('display_name')"></bh-clear>
<input type="text" class="form-control" name="display_name" ng-model="$ctrl.searchQueries.display_name">
<div class="help-block" ng-messages="ModalForm.display_name.$error" ng-show="ModalForm.$submitted">
<div ng-messages-include="modules/templates/messages.tmpl.html"></div>
</div>
</div>

<!-- patient reference -->
<div class="form-group" ng-class="{ 'has-error' : ModalForm.$submitted && ModalForm.reference.$invalid }">
<label class="control-label" translate> FORM.LABELS.REFERENCE </label>
<bh-clear on-clear="ModalCtrl.clear('reference')"></bh-clear>
<bh-clear on-clear="$ctrl.clear('reference')"></bh-clear>

<input type="text" class="form-control" name="reference" ng-model="ModalCtrl.params.reference">
<input type="text" class="form-control" name="reference" ng-model="$ctrl.searchQueries.reference">
<div class="help-block" ng-messages="ModalForm.reference.$error" ng-show="ModalForm.$submitted">
<div ng-messages-include="modules/templates/messages.tmpl.html"></div>
</div>
</div>

<!-- patient hospital number-->
<div class="form-group" ng-class="{ 'has-error' : ModalForm.$submitted && ModalForm.hospital_no.$invalid }">
<label class="control-label" translate>
FORM.LABELS.HOSPITAL_FILE_NR
</label>
<bh-clear on-clear="ModalCtrl.clear('hospital_no')"></bh-clear>
<bh-clear on-clear="$ctrl.clear('hospital_no')"></bh-clear>

<input type="text" class="form-control" name="hospital_no" ng-model="ModalCtrl.params.hospital_no">
<input type="text" class="form-control" name="hospital_no" ng-model="$ctrl.searchQueries.hospital_no">
<div class="help-block" ng-messages="ModalForm.reference.$error" ng-show="ModalForm.$submitted">
<div ng-messages-include="modules/templates/messages.tmpl.html"></div>
</div>
</div>

<!-- patient gender-->
<div class="radio">
<p class="control-label">
<strong translate>FORM.LABELS.GENDER</strong>
<bh-clear on-clear="ModalCtrl.clear('sex')"></bh-clear>
<bh-clear on-clear="$ctrl.clear('sex')"></bh-clear>
</p>

<label>
<input type="radio" name="sex" id="male" value="M" ng-model="ModalCtrl.params.sex">
<input type="radio" name="sex" id="male" value="M" ng-model="$ctrl.searchQueries.sex">
<span translate>FORM.LABELS.MALE</span>
</label>
</div>

<div class="radio">
<label>
<input type="radio" name="sex" id="female" value="F" ng-model="ModalCtrl.params.sex">
<input type="radio" name="sex" id="female" value="F" ng-model="$ctrl.searchQueries.sex">
<span translate>FORM.LABELS.FEMALE</span>
</label>
</div>

<!-- patient debtor group -->
<bh-debtor-group-select
debtor-group-uuid = "ModalCtrl.params.debtor_group_uuid"
on-select-callback = "ModalCtrl.onSelectDebtor(debtorGroup)">
<bh-clear on-clear="ModalCtrl.clear('debtor_group_uuid')"></bh-clear>
debtor-group-uuid = "$ctrl.searchQueries.debtor_group_uuid"
on-select-callback = "$ctrl.onSelectDebtor(debtorGroup)">
<bh-clear on-clear="$ctrl.clear('debtor_group_uuid')"></bh-clear>
</bh-debtor-group-select>

<div class="form-group">
<label class="control-label" translate>
PATIENT_GROUP.PATIENT_GROUP
</label>

<bh-clear on-clear="ModalCtrl.clear('patient_group_uuid')"></bh-clear>

<!-- @todo make data driven selects components to handle loading and error states -->
<ui-select
name="patientGroup"
ng-model="ModalCtrl.params.patient_group_uuid">
<ui-select-match placeholder="{{ 'FORM.PLACEHOLDERS.PATIENT_GROUP' | translate }}"><span>{{$select.selected.name}}</span></ui-select-match>
<ui-select-choices ui-select-focus-patch repeat="group.uuid as group in (ModalCtrl.patientGroups | filter:$select.search | orderBy:'name') track by group.uuid">
<span ng-bind-html="group.name | highlight:$select.search"></span>
</ui-select-choices>
</ui-select>
</div>
<!-- patient patient group -->
<bh-patient-group-select
patient-group-uuid = "$ctrl.searchQueries.patient_group_uuid"
on-select-callback = "$ctrl.onSelectPatientGroup(patientGroup)">
<bh-clear on-clear="$ctrl.clear('patient_group_uuid')"></bh-clear>
</bh-patient-group-select>

<!-- patient user selection -->
<bh-user-select
user-id="ModalCtrl.params.user_id"
user-id="$ctrl.searchQueries.user_id"
name="user_id"
on-select-callback="ModalCtrl.onSelectUser(user)">
<bh-clear on-clear="ModalCtrl.clear('user_id')"></bh-clear>
on-select-callback="$ctrl.onSelectUser(user)">
<bh-clear on-clear="$ctrl.clear('user_id')"></bh-clear>
</bh-user-select>

<!-- patient date interval components -->
<fieldset>
<legend translate>FORM.LABELS.DOB</legend>
<bh-date-interval
date-id="dob-date"
validation-trigger="ModalForm.$submitted"
date-from="ModalCtrl.params.dateBirthFrom"
date-to="ModalCtrl.params.dateBirthTo"
date-from="$ctrl.searchQueries.dateBirthFrom"
date-to="$ctrl.searchQueries.dateBirthTo"
mode="clean">
</bh-date-interval>
</fieldset>
Expand All @@ -112,16 +108,14 @@
<uib-tab index="1" heading="{{ 'FORM.LABELS.DEFAULTS' | translate }}" data-default-filter-tab>
<div class="tab-body">
<!-- period selection -->
<!-- start period selection component -->
<bh-period-select
default-period="{{ModalCtrl.filters.period}}"
on-select-callback="ModalCtrl.onSelectPeriod(period)">
default-period="{{$ctrl.filters.period}}"
on-select-callback="$ctrl.onSelectPeriod(period)">
</bh-period-select>
<!-- end period selection component -->

<div class="form-group" ng-class="{ 'has-error' : ModalForm.limit.$invalid }">
<label class="control-label" translate>FORM.LABELS.LIMIT</label>
<input name="limit" type="number" bh-integer class="form-control" ng-model="ModalCtrl.defaultQueries.limit" ng-change="ModalCtrl.onSelectLimit(ModalCtrl.defaultQueries.limit)">
<input name="limit" type="number" bh-integer class="form-control" ng-model="$ctrl.defaultQueries.limit" ng-change="$ctrl.onSelectLimit($ctrl.defaultQueries.limit)">

<div class="help-block" ng-messages="ModalForm.limit.$error">
<div ng-messages-include="modules/templates/messages.tmpl.html"></div>
Expand All @@ -133,7 +127,7 @@
</div>

<div class="modal-footer">
<button type="button" class="btn btn-default" ng-click="ModalCtrl.cancel()" data-method="cancel" translate>
<button type="button" class="btn btn-default" ng-click="$ctrl.cancel()" data-method="cancel" translate>
FORM.BUTTONS.CLOSE
</button>
<button type="submit" class="btn btn-primary" data-method="submit" translate>
Expand Down
Loading

0 comments on commit 3d1eefb

Please sign in to comment.