From 0a23871e39e813029ac46866a998304d6bbd061c Mon Sep 17 00:00:00 2001 From: larslemos Date: Sun, 18 Sep 2016 20:08:07 +0200 Subject: [PATCH] lastest pull, added patient dashboard status, missing followup and tests --- app/clinic/controllers/dashboardController.js | 128 ++++++++++++++++-- app/clinic/index.html | 1 - app/clinic/views/dashboard.html | 2 +- app/clinic/views/patient-state.html | 18 ++- app/clinic/views/patient-summary.html | 64 +++++---- app/common/domain/services/commonService.js | 22 +-- app/styles/main-styles.css | 6 +- .../openmrs/i18n/clinical/locale_en.json | 10 +- .../openmrs/i18n/clinical/locale_pt.json | 9 +- 9 files changed, 198 insertions(+), 62 deletions(-) diff --git a/app/clinic/controllers/dashboardController.js b/app/clinic/controllers/dashboardController.js index 85aec03a..ed2bc5d3 100755 --- a/app/clinic/controllers/dashboardController.js +++ b/app/clinic/controllers/dashboardController.js @@ -1,30 +1,134 @@ 'use strict'; angular.module('clinic') - .controller('DashboardController', ["$rootScope", "$scope", "$location", "$stateParams", "patientService", "openmrsPatientMapper", "alertService", function ($rootScope, $scope, $location, $stateParams, patientService, patientMapper, alertService) { + .controller('DashboardController', ["$rootScope", "$scope", "$location", "$stateParams", "$filter", "patientService", "openmrsPatientMapper", + "alertService", "encounterService", "observationsService", "commonService", + function ($rootScope, $scope, $location, $stateParams, $filter, patientService, patientMapper, alertService, encounterService, observationsService, commonService) { var patientUuid; - + + var patientPrescriptions = []; + init(); - function init() { patientUuid = $stateParams.patientUuid; - + patientService.get(patientUuid).success(function (data) { $rootScope.patient = patientMapper.map(data); }); } - - $scope.linkSearch = function() { + + $scope.linkSearch = function() { $location.url("/search"); // path not hash }; - - $scope.linkPatientDetail = function() { + + $scope.linkPatientDetail = function() { $location.url("/patient/detail/" + patientUuid + "/demographic"); // path not hash }; - - $scope.getAlerts = function () { + + $scope.getAlerts = function () { alertService.get(patientUuid).success(function (data) { $scope.flags = data.flags; }); - }; - }]); + }; + + //TODO: Add patientState Tests, fix followup refresh scope issue + $scope.initPatientState = function () { + var labEncounterUuid = "e2790f68-1d5f-11e0-b929-000c29ad1d07"; + var conceptsLabs = ["e1e68f26-1d5f-11e0-b929-000c29ad1d07", + "e1d6247e-1d5f-11e0-b929-000c29ad1d07"]; + + var seriesLabs = [$filter('translate')('CLINIC_PATIENT_CD4_COUNT'), + $filter('translate')('CLINIC_PATIENT_HIV_VIRAL_LOAD')]; + var name = "labResults"; + + encounterService.getEncountersForEncounterType(patientUuid, labEncounterUuid) + .success(function (data) { + var filteredLabs = filterObs(data, conceptsLabs, seriesLabs, name); + $scope.patientStates = createStateData(filteredLabs, conceptsLabs, seriesLabs, name); + }); + + //TODO: Fix concept translation reference and synonyms, answers + var conceptsTreatment = ["e1d9f7a2-1d5f-11e0-b929-000c29ad1d07", + "e1d9ee10-1d5f-11e0-b929-000c29ad1d07", + "e1d9ead2-1d5f-11e0-b929-000c29ad1d07", + "e1de8862-1d5f-11e0-b929-000c29ad1d07", + "e1d85906-1d5f-11e0-b929-000c29ad1d07", + "e2404d72-1d5f-11e0-b929-000c29ad1d07", + "e1d9ef28-1d5f-11e0-b929-000c29ad1d07", + "e1d83e4e-1d5f-11e0-b929-000c29ad1d07"]; + + var seriesFollowUp = [$filter('translate')('TUBERCULOSIS_PROPHYLAXIS_STARTED'), + $filter('translate')('ANTIRETROVIRAL PLAN'), + $filter('translate')('HISTORICAL_DRUG_START_DATE'), + $filter('translate')('TUBERCULOSIS_DRUG_TREATMENT_START_DATE'), + $filter('translate')('TUBERCULOSIS_DRUG_TREATMENT_START_DATE'), + $filter('translate')('ANTIRETROVIRAL_PLAN'), + $filter('translate')('REGIMEN')]; + + var adultFollowupEncounterUuid = "e278f956-1d5f-11e0-b929-000c29ad1d07";//TODO: create in configuration file + var childFollowupEncounterUuid = "e278fce4-1d5f-11e0-b929-000c29ad1d07";//TODO: create in configuration file + + var patient = commonService.deferPatient($rootScope.patient); + var patientPrescriptions = []; + + encounterService.getEncountersForEncounterType(patient.uuid, + (patient.age.years >= 15) ? adultFollowupEncounterUuid : childFollowupEncounterUuid) + .success(function (data) { + patientPrescriptions = commonService.filterGroupReverseFollowupObs("e1d9ef28-1d5f-11e0-b929-000c29ad1d07", data.results); + + var filteredFollowup = filterObs(data, conceptsTreatment, seriesFollowUp, "followUp"); + var encounterType = ((patient.age.years >= 15) ? adultFollowupEncounterUuid : childFollowupEncounterUuid); + $scope.patientFollowups = createStateData(filteredFollowup, conceptsTreatment, seriesFollowUp, "followUp"); + + + $scope.patientPrescriptions = patientPrescriptions[0]; + }); + }; + + var filterObs = function (data, concepts) { + + var nonRetired = encounterService.filterRetiredEncoounters(data.results); + + var sliced = _.slice(nonRetired, 0, 9); + + _.forEach(sliced, function (encounter) { + encounter.obs = observationsService.filterByList(encounter.obs, concepts); + }); + var filtered = _.filter(sliced, function (encounter) { + return !_.isEmpty(encounter.obs); + }); + + return filtered; + }; + + var createStateData = function (encounters, concepts, seriesLabs, state) { + var patientStates = []; + $scope[state + "dates"] = []; + $scope[state + "seriesLabs"] = seriesLabs; + var data = []; + + _.forEach(encounters, function (encounter) { + $scope[state + "dates"].push($filter('date')(encounter.encounterDatetime, "MMM d, y")); + _.forEach(concepts, function (concept, key) { + var found = _.find(encounter.obs, function (obs) { + return obs.concept.uuid === concept; + }); + if (typeof data[key] === 'undefined') data[key] = []; + data[key].push((found) ? found.value : null); + }); + }); + var lastDate = $scope[state + "dates"].length - 1; + $scope.labDate = $scope[state + "dates"][lastDate]; + $scope[state + "Data"] = data; + var lastObs = data.length - 1; + + angular.forEach(seriesLabs, function (value, key) { + var exam = value; + var result = data[key][lastObs]; + var state = {"exam": exam, "result": result}; + patientStates.push(state); + }); + + return patientStates; + } + }]); diff --git a/app/clinic/index.html b/app/clinic/index.html index 941141ed..f4869220 100755 --- a/app/clinic/index.html +++ b/app/clinic/index.html @@ -13,7 +13,6 @@ - diff --git a/app/clinic/views/dashboard.html b/app/clinic/views/dashboard.html index 7d131df2..d29dd681 100755 --- a/app/clinic/views/dashboard.html +++ b/app/clinic/views/dashboard.html @@ -21,7 +21,7 @@ -
+
diff --git a/app/clinic/views/patient-summary.html b/app/clinic/views/patient-summary.html index d3e0b99f..12346a55 100755 --- a/app/clinic/views/patient-summary.html +++ b/app/clinic/views/patient-summary.html @@ -1,25 +1,28 @@
-
+

{{'CLINIC_PATIENT_VISIT_HISTORY' | translate}}

-
+
{{'CLINIC_PATIENT_VISIT' | translate}} {{'COMMON_ON' | translate}} {{visit[0].encounterDatetime | date:"MMM d, y"}}
-
{{encounter.encounterType.display}} {{'COMMON_ON' | translate}} {{encounter.encounterDatetime | date:"MMM d, y"}}, +
{{encounter.encounterType.display}} {{'COMMON_ON' | translate}} {{encounter.encounterDatetime | + date:"MMM d, y"}}, {{'COMMON_BY' | translate}}: {{encounter.provider.display}}
- -
+ +

{{'CLINIC_PATIENT_DIAGNOSIS' | translate}}

- +
@@ -29,35 +32,37 @@

{{'CLINIC_PATIENT_DIAGNOSIS' | translate}}

{{diagn.concept.name.display}}
- -
+ +

{{'CLINIC_PATIENT_PRESCRIPTIONS' | translate}}/{{'CLINIC_PATIENT_REGIMENS' | translate}}

-
+
{{'CLINIC_PATIENT_PRESCRIBED' | translate}} {{'COMMON_ON' | translate}} {{encounter.encounterDatetime | date:"MMM d, y"}}
- {{obs.concept.name.display}}: + {{obs.concept.name.display}}: {{isObject(obs.value) ? obs.value.display : obs.value}}
- -
+ +

{{'CLINIC_PATIENT_VITALS' | translate}}

-
+
{{'CLINIC_PATIENT_CAPTURED' | translate}} {{'COMMON_ON' | translate}} {{encounter.encounterDatetime | date:"MMM d, y"}}
- {{obs.concept.name.display}}: + {{obs.concept.name.display}}: {{isObject(obs.value) ? obs.value.display : obs.value}}
@@ -65,11 +70,12 @@

{{'CLINIC_PATIENT_VITALS' | translate}}

-
+

{{'CLINIC_PATIENT_LAB' | translate}}

-
+
{{'CLINIC_PATIENT_COLLECTED' | translate}} {{'COMMON_ON' | translate}} {{visit[0].encounterDatetime | date:"MMM d, y"}}
@@ -85,7 +91,7 @@

{{'CLINIC_PATIENT_LAB' | translate}}

- {{obs.concept.name.display}}: + {{obs.concept.name.display}}: {{isObject(obs.value) ? obs.value.display : obs.value}}
@@ -93,29 +99,31 @@

{{'CLINIC_PATIENT_LAB' | translate}}

- -
+ +

{{'CLINIC_PATIENT_PHARMACY' | translate}}

-
+
{{'CLINIC_PATIENT_DISPENSED' | translate}} {{'COMMON_ON' | translate}} {{visit[0].encounterDatetime | date:"MMM d, y"}}
- {{obs.concept.name.display}}: + {{obs.concept.name.display}}: {{isObject(obs.value) ? obs.value.display : obs.value}}
- -
+ +

{{'CLINIC_PATIENT_ALLERGIES' | translate}}/{{'CLINIC_PATIENT_SIDE_EFFECTS' | translate}}

-
+
{{'CLINIC_PATIENT_DIAGNOSED' | translate}} {{'COMMON_ON' | translate}} {{encounter.encounterDatetime | date:"MMM d, y"}}
@@ -124,7 +132,7 @@

{{'CLINIC_PATIENT_ALLERGIES' | translate}}/{{'CLINIC_PAT

- +

{{'COMMON_PROGRAM_ENROLLMENT_SUMMARY_TITLE' | translate}}

@@ -137,8 +145,8 @@

{{'COMMON_PROGRAM_ENROLLMENT_SUMMARY_TITLE' | translate} {{'COMMON_PROGRAM_ENROLLMENT_ENROLLED_ON' | translate}}: ({{program.dateEnrolled | date:"MM/dd/yyyy"}}) {{'COMMON_PROGRAM_ENROLLMENT_COMPLETED_ON' | translate}}: ({{program.dateCompleted | date:"MM/dd/yyyy"}})

-
+
{{state.state.concept.display}} {{'COMMON_FROM' | translate}} ({{state.startDate | date:"MM/dd/yyyy"}}) @@ -148,4 +156,4 @@

{{'COMMON_PROGRAM_ENROLLMENT_SUMMARY_TITLE' | translate}

-
\ No newline at end of file +
diff --git a/app/common/domain/services/commonService.js b/app/common/domain/services/commonService.js index 45be0fcb..0122446c 100755 --- a/app/common/domain/services/commonService.js +++ b/app/common/domain/services/commonService.js @@ -3,7 +3,7 @@ angular.module('bahmni.common.domain') .service('commonService', ['encounterService', 'observationsService', function (encounterService, observationsService) { - + this.filterRetired = function (entities) { return _.filter(entities, function (entity) { return !entity.voided; @@ -15,8 +15,8 @@ angular.module('bahmni.common.domain') return !entity.voided; }); }; - - this.filterGroupReverse = function (data) { + + this.filterGroupReverse = function (data) { var nonRetired = encounterService.filterRetiredEncoounters(data.results); var grouped = _.groupBy(nonRetired, function (element) { return Bahmni.Common.Util.DateUtil.getDate(element.encounterDatetime); @@ -24,10 +24,12 @@ angular.module('bahmni.common.domain') var reversed = _.values(grouped).reverse(); return reversed; }; - - this.filterGroupReverseFollowupObs = function (concepts, results) { + + this.filterGroupReverseFollowupObs = function (concepts, results) { var nonRetired = encounterService.filterRetiredEncoounters(results); - _.forEach(nonRetired, function (encounter) { + + //TODO: Fix null referece + _.forEach(angular.copy(nonRetired), function (encounter) { encounter.obs = observationsService.filterByList(encounter.obs, concepts); }); var filtered = _.filter(nonRetired, function (encounter) { @@ -35,11 +37,11 @@ angular.module('bahmni.common.domain') }); return filtered.reverse(); }; - - this.deferPatient = function (patient) { + + this.deferPatient = function (patient) { var newPatient = patient; return newPatient; }; - -}]); + + }]); diff --git a/app/styles/main-styles.css b/app/styles/main-styles.css index 06cf3433..32429de3 100755 --- a/app/styles/main-styles.css +++ b/app/styles/main-styles.css @@ -21,7 +21,7 @@ and open the template in the editor. .panel-marginless-bottom { margin-bottom: -5px; } - + .go-to-right { text-align: right; } @@ -180,3 +180,7 @@ input[type=radio]:checked + label::before { color: #337ABA; font-weight: bold; } + +p.capitalize { + text-transform: capitalize; +} diff --git a/poc_config/openmrs/i18n/clinical/locale_en.json b/poc_config/openmrs/i18n/clinical/locale_en.json index b96ba52c..198f20a6 100755 --- a/poc_config/openmrs/i18n/clinical/locale_en.json +++ b/poc_config/openmrs/i18n/clinical/locale_en.json @@ -121,6 +121,14 @@ "CLINIC_LAB_RESULTS": "Lab Results", "CLINIC_PATIENT_HGB_COUNT": "HGB Count", "CLINIC_PATIENT_HIV_VIRAL_LOAD":"HIV VIRAL LOAD", - "CLINIC_PATIENT_SERUM_ALBUMIN":"Serum Albumin" + "CLINIC_PATIENT_SERUM_ALBUMIN":"Serum Albumin", + "TUBERCULOSIS_DRUG_TREATMENT_START_DATE":"Start Date of TB Treatment", + "TUBERCULOSIS PROPHYLAXIS STARTED":"Tuberculosis Treatment", + "START DRUGS":"Start of Treatment ", + "HISTORICAL_DRUG_START_DATE":"Start Date of TARV", + "PREVIOUS_ANTIRETROVIRAL_DRUGS_USED_FOR_TREATMENT": "Antiretroviral Drugs User for Treatment", + "ANTIRETROVIRAL_PLAN": "Gestao de TARV", + "START_DRUGS": "Start Drugs", + "REGIMEN":"Regimen" } diff --git a/poc_config/openmrs/i18n/clinical/locale_pt.json b/poc_config/openmrs/i18n/clinical/locale_pt.json index 273b4287..f1a58a51 100755 --- a/poc_config/openmrs/i18n/clinical/locale_pt.json +++ b/poc_config/openmrs/i18n/clinical/locale_pt.json @@ -127,5 +127,12 @@ "CLINIC_LAB_RESULTS": "Resultados do Laboratório", "CLINIC_PATIENT_HGB_COUNT": "HGB Absoluto", "CLINIC_PATIENT_HIV_VIRAL_LOAD":"HIV CARGA VIRAL", - "CLINIC_PATIENT_SERUM_ALBUMIN": "Albumina" + "CLINIC_PATIENT_SERUM_ALBUMIN": "Albumina", + "TUBERCULOSIS_DRUG_TREATMENT_START_DATE": "Data de Inicio de Tratamento TB", + "TUBERCULOSIS_PROPHYLAXIS_STARTED": "Em Tratemento TB", + "HISTORICAL_DRUG_START_DATE": "Data de Inicio de TARV", + "PREVIOUS_ANTIRETROVIRAL_DRUGS_USED_FOR_TREATMENT": "Medicamentos anti-retrovirais utilizados para o tratamento", + "ANTIRETROVIRAL_PLAN": "Gestao de TARV", + "START_DRUGS": "Inicio TARV", + "REGIMEN": "Regime" }