From 9225725990ee07a37e4f1ff66b9ce86153b34396 Mon Sep 17 00:00:00 2001 From: larslemos Date: Tue, 30 Aug 2016 06:49:07 -0700 Subject: [PATCH 01/12] latest pull from master, added icd10 mock fields to diagnosis form --- app/clinic/controllers/patientChartController.js | 4 ++-- app/clinic/views/patient-chart.html | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/clinic/controllers/patientChartController.js b/app/clinic/controllers/patientChartController.js index f616aa98..746abcd7 100755 --- a/app/clinic/controllers/patientChartController.js +++ b/app/clinic/controllers/patientChartController.js @@ -95,14 +95,14 @@ angular.module('clinic') type: 'linear', display: true, position: 'left', - ticks: {max: 100, min: 0, stepSize: 10} + ticks: {max: 80, min: 0, stepSize: 10} }, { id: 'serieA', type: 'linear', display: true, position: 'right', - ticks: {stepSize: 10, min: 40, max: 100} + ticks: {stepSize: 10, min: 40, max: 110} }] }, pointDotRadius: 10 diff --git a/app/clinic/views/patient-chart.html b/app/clinic/views/patient-chart.html index 3632a077..9fe0abc1 100755 --- a/app/clinic/views/patient-chart.html +++ b/app/clinic/views/patient-chart.html @@ -4,9 +4,11 @@

{{'CLINIC_LAB_RESULTS' | translate}}

+
+
From 00bbc6338d52e9b7384c2d491aeda4738e6f37da Mon Sep 17 00:00:00 2001 From: larslemos Date: Thu, 1 Sep 2016 10:36:16 -0700 Subject: [PATCH 02/12] latest pull from master, added observation test --- .../services/observationService.spec.js | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 test/spec/common/domain/services/observationService.spec.js diff --git a/test/spec/common/domain/services/observationService.spec.js b/test/spec/common/domain/services/observationService.spec.js new file mode 100644 index 00000000..f7bc6e66 --- /dev/null +++ b/test/spec/common/domain/services/observationService.spec.js @@ -0,0 +1,30 @@ +'use strict'; + +describe("observationsService", function () { + var mockBackend, observationsService; + + beforeEach(function () { + module('bahmni.common.domain'); + inject(function (_observationsService_, $httpBackend) { + observationsService = _observationsService_; + mockBackend = $httpBackend + }); + }); + + describe("fetchForPatient", function () { + it("should fetch observations for encounter", function () { + mockBackend + .expectGET('/openmrs/ws/rest/v1/bahmnicore/observations?concept=concept+name&patientUuid=encounterUuid') + .respond({results: ["Some data"]}); + + observationsService.fetch("encounterUuid", ["concept name"]).then(function (response) { + expect(response.data.results.length).toBe(1); + expect(response.data.results[0]).toBe("Some data"); + + }); + + mockBackend.flush(); + }) + }); + +}); From 067209066003c97b26a665be2b15a0e643750c67 Mon Sep 17 00:00:00 2001 From: larslemos Date: Thu, 1 Sep 2016 11:22:46 -0700 Subject: [PATCH 03/12] latest pull from master, added observation test --- .../common/domain/observationFilter.spec.js | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 test/spec/common/domain/observationFilter.spec.js diff --git a/test/spec/common/domain/observationFilter.spec.js b/test/spec/common/domain/observationFilter.spec.js new file mode 100644 index 00000000..73c8096e --- /dev/null +++ b/test/spec/common/domain/observationFilter.spec.js @@ -0,0 +1,50 @@ +describe("Observation Filter", function () { + describe("filter", function() { + var buildObservation = Bahmni.Tests.observationMother.build; + var observationFilter; + + beforeEach(function() { + observationFilter = new Bahmni.Common.Domain.ObservationFilter(); + }); + + + it("should not void existing observations groups which has mamber with value", function() { + var observations = [buildObservation({ uuid: '1111', value: null, + groupMembers: [buildObservation({value: '10', uuid: '2222'})] + })]; + + var filteredObservations = observationFilter.filter(observations); + + expect(filteredObservations.length).toBe(1); + expect(filteredObservations[0].voided).toBe(false); + expect(filteredObservations[0].groupMembers[0].voided).toBe(false); + }); + + it("should remove new member observations without value", function() { + var observation = buildObservation({ uuid: null, + groupMembers: [buildObservation({value: null, uuid: null}), buildObservation({value: 10, uuid: null})] + }); + var observations = [observation]; + + var filteredObservations = observationFilter.filter(observations); + + expect(filteredObservations.length).toBe(1); + expect(filteredObservations[0].groupMembers.length).toBe(1); + expect(filteredObservations[0].groupMembers[0].value).toBe(10); + }); + + it("should remove new member observations which are voided", function() { + var observation = buildObservation({ uuid: null, + groupMembers: [buildObservation({value: "something", uuid: null, voided: true}), buildObservation({value: 10, uuid: null})] + }); + + var observations = [observation]; + + var filteredObservations = observationFilter.filter(observations); + + expect(filteredObservations.length).toBe(1); + expect(filteredObservations[0].groupMembers.length).toBe(2); + expect(filteredObservations[0].groupMembers[0].value).toBe('something'); + }); + }); +}); From 33e672221717e7e0b35729a3cecc329f80b7a525 Mon Sep 17 00:00:00 2001 From: larslemos Date: Thu, 1 Sep 2016 11:24:00 -0700 Subject: [PATCH 04/12] latest pull from master, added observation test --- test/spec/common/domain/services/visitService.spec.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/spec/common/domain/services/visitService.spec.js b/test/spec/common/domain/services/visitService.spec.js index d86bba39..20d3c535 100755 --- a/test/spec/common/domain/services/visitService.spec.js +++ b/test/spec/common/domain/services/visitService.spec.js @@ -53,4 +53,15 @@ describe('Registration Visit Service', function () { expect(mockHttp.post.calls.mostRecent().args[1].withCredentials).toBeTruthy(); }); + it("Should post visit details to create visit url", function () { + var visitDetails = {patientUuid: "uuid"}; + + visitService.create(visitDetails); + + expect(mockHttp.post).toHaveBeenCalled(); + expect(mockHttp.post.calls.mostRecent().args[0]).toBe(openmrsUrl); + expect(mockHttp.post.calls.mostRecent().args[1]).toBe(visitDetails); + expect(mockHttp.post.calls.mostRecent().args[2].withCredentials).toBeTruthy(); + }); + }); From 0c802a175f92ebae865ebb7faf05b1a24251ce9a Mon Sep 17 00:00:00 2001 From: larslemos Date: Thu, 1 Sep 2016 11:25:47 -0700 Subject: [PATCH 05/12] latest pull from master, added observation test --- .../domain/services/locationService.spec.js | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 test/spec/common/domain/services/locationService.spec.js diff --git a/test/spec/common/domain/services/locationService.spec.js b/test/spec/common/domain/services/locationService.spec.js new file mode 100644 index 00000000..4f9bce49 --- /dev/null +++ b/test/spec/common/domain/services/locationService.spec.js @@ -0,0 +1,58 @@ +'use strict'; + +describe('LocationService', function () { + var locationUuids = ["location1", "location2"]; + + var getReturnValue = function(params, args){ + if(_.includes(params,"bahmnicore/visitLocation")){ + return {uuid: "visitLocationUuid"} + } + else{ + return locationUuids; + } + }; + + var $http, mockBahmniCookieStore, + mockHttp = { + defaults: { + headers: { + common: { + 'X-Requested-With': 'present' + } + } + }, + get: jasmine.createSpy('Http get').and.callFake(getReturnValue) + }; + + beforeEach(module('bahmni.common.domain')); + beforeEach(module(function ($provide) { + $provide.value('$http', mockHttp); + $provide.value('$bahmniCookieStore', mockBahmniCookieStore); + })); + + it('should get locations by tag', inject(['locationService', function(locationService){ + var tag = "tag1"; + var params = { params : { s : 'byTags', q: 'tag1' }, cache : true }; + + var results = locationService.getAllByTag(tag); + + expect(mockHttp.get).toHaveBeenCalled(); + expect(mockHttp.get.calls.mostRecent().args[0]).toBe(Bahmni.Common.Constants.locationUrl); + expect(mockHttp.get.calls.mostRecent().args[1]).toEqual(params); + expect(results).toBe(locationUuids); + }])); + + it('should get locations by name', inject(['locationService', function(locationService){ + var name = "name"; + var params = { params : { q: 'name' }, cache : true, withCredentials: false }; + + var results = locationService.get(name); + + expect(mockHttp.get).toHaveBeenCalled(); + expect(mockHttp.get.calls.mostRecent().args[0]).toBe(Bahmni.Common.Constants.locationUrl); + expect(mockHttp.get.calls.mostRecent().args[1]).toEqual(params); + expect(results).toBe(locationUuids); + }])); + + +}); From d62237b7a0306825a480c5d57729606aea8df586 Mon Sep 17 00:00:00 2001 From: larslemos Date: Thu, 1 Sep 2016 11:26:43 -0700 Subject: [PATCH 06/12] latest pull from master, added observation test --- test/spec/common/domain/services/programService.spec.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/spec/common/domain/services/programService.spec.js b/test/spec/common/domain/services/programService.spec.js index c17969ea..7df1aa76 100755 --- a/test/spec/common/domain/services/programService.spec.js +++ b/test/spec/common/domain/services/programService.spec.js @@ -248,7 +248,7 @@ describe('programService', function () { ] } }; - + mockBackend.whenGET('/openmrs/ws/rest/v1/programenrollment?patient=somePatientUuid&v=full').respond(data.data); programService.getPatientPrograms(patientUuid).then(function (response) { @@ -277,7 +277,7 @@ describe('programService', function () { required: false }]; - mockBackend.whenPOST('/openmrs/ws/rest/v1/programenrollment').respond(function (method, url, data, headers) { + mockBackend.whenPOST('/openmrs/ws/rest/v1/programenrollment').respond(function (method, url, data) { expect(method).toEqual('POST'); data = JSON.parse(data); expect(url).toEqual(Bahmni.Common.Constants.programEnrollPatientUrl); @@ -317,7 +317,7 @@ describe('programService', function () { var patientProgramUuid = "somePatientProgramUuid"; var content = "SampleContent"; - mockBackend.whenPOST('/openmrs/ws/rest/v1/programenrollment/somePatientProgramUuid').respond(function (method, url, data, headers) { + mockBackend.whenPOST('/openmrs/ws/rest/v1/programenrollment/somePatientProgramUuid').respond(function (method, url, data) { expect(url).toEqual(Bahmni.Common.Constants.programEnrollPatientUrl + "/" + patientProgramUuid); expect(JSON.parse(data).states[0].state.uuid).toEqual(content); return [200, {}, {}]; @@ -326,4 +326,6 @@ describe('programService', function () { mockBackend.flush(); }); + + }); From 0f9ca4e1d3b48a4d2a29e5774497034704b7fa72 Mon Sep 17 00:00:00 2001 From: larslemos Date: Thu, 1 Sep 2016 11:27:35 -0700 Subject: [PATCH 07/12] latest pull from master, added observation test --- .../manageProgramController.spec.js | 119 ++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 test/spec/controllers/manageProgramController.spec.js diff --git a/test/spec/controllers/manageProgramController.spec.js b/test/spec/controllers/manageProgramController.spec.js new file mode 100644 index 00000000..da24d625 --- /dev/null +++ b/test/spec/controllers/manageProgramController.spec.js @@ -0,0 +1,119 @@ +'use strict'; + +//TODO: Test under development 20% +xdescribe("ManageProgramController", function () { + + var scope, rootScope, q, controller, deferred, messageService, i = 0, + programService, _spinner, _provide, + programSelected, allPrograms; + + var setUp = function () { + return controller('ManageProgramController',{ + $scope: scope, + $rootScope: rootScope, + q: q + }); + }; + + beforeEach(module('bahmni.common.uicontrols.programmanagment')); + + beforeEach(module(function ($provide) { + _provide = $provide; + programService = jasmine.createSpyObj('programService', + ['getPatientPrograms','getAllPrograms']); + + programService.getPatientPrograms.and.callFake(function () { + deferred = q.defer(); + deferred.resolve(listOfPrograms); + return deferred.promise; + }); + + programService.getAllPrograms.and.callFake(function () { + deferred = q.defer; + deferred.resolve(allPrograms); + return deferred.promise; + }); + + $provide.value('programService',programService); + $provide.value('spinner', _spinner); + $provide('$stateParams', {configName: "default"}); + + })); + + beforeEach(inject(function ($controller, $rootScope, $q) { + controller = $controller; + rootScope = $rootScope; + scope = $rootScope.$new(); + q = $q; + })); + + beforeEach(function () { + allPrograms = [ + { + "uuid": "1209df07-b3a5-4295-875f-2f7bae20f86e", + "name": "program", + "outcomesConcept": { + "uuid": "6475249b-b681-4aae-ad6c-a2d580b4be3d", + "display": "HIV outcomes", + "setMembers": [ + { + "uuid": "8a1ab485-e599-4682-8c82-c60ce03c916e", + "display": "Cured" + }, + { + "uuid": "041daad2-198b-4223-aa46-6b23e85776a9", + "display": "Death" + } + ], + "resourceVersion": "1.9" + }, + + "allWorkflows": [ + { + "uuid": "6a6c990f-01e2-464b-9452-2a97f0c05c7c", + "concept": { + "uuid": "8227f47f-3f10-11e4-adec-0800271c1b75", + "display": "All_Tests_and_Panels", + "links": [ + { + "uri": "NEED-TO-CONFIGURE/ws/rest/v1/concept/8227f47f-3f10-11e4-adec-0800271c1b75", + "rel": "self" + } + ] + }, + "retired": false, + "states": [{ + "uuid": "8227f47f-3f10-11e4-adec-0800271c1b75", + "display": "All_Tests_and_Panels", + "retired":false + },{ + "uuid": "8227f47f-3f10-11e4-adec-0800271c1590", + "display": "VAT_Tests_and_Panels", + "retired":false + + }], + "links": [ + { + "uri": "NEED-TO-CONFIGURE/ws/rest/v1/workflow/6a6c990f-01e2-464b-9452-2a97f0c05c7c", + "rel": "self" + } + ] + } + ], + "links": [ + { + "uri": "NEED-TO-CONFIGURE/ws/rest/v1/program/1209df07-b3a5-4295-875f-2f7bae20f86e", + "rel": "self" + } + ] + } + ]; + }); + + it("should update active programs list", function () { + //scope.$apply(setUp); + expect(scope).toBeDefined(); + //expect(scope.allPrograms).toBe(1); + //expect(scope.programSelected).toEqual(null); + }); +}); From bd00644123acdf0f9a5c975e53b0dbf33e58b2e0 Mon Sep 17 00:00:00 2001 From: larslemos Date: Thu, 1 Sep 2016 11:28:19 -0700 Subject: [PATCH 08/12] latest pull from master, added observation test --- test/spec/support/specUtil.js | 135 +++++++++++++++++++++------------- 1 file changed, 82 insertions(+), 53 deletions(-) diff --git a/test/spec/support/specUtil.js b/test/spec/support/specUtil.js index 89c8b32d..1f9a5d1a 100755 --- a/test/spec/support/specUtil.js +++ b/test/spec/support/specUtil.js @@ -1,58 +1,87 @@ var specUtil = { - createServicePromise: function (name) { - var servicePromise = {}; - servicePromise.then = jasmine.createSpy(name + ' then').and.returnValue(servicePromise); - servicePromise.success = jasmine.createSpy(name + ' success').and.returnValue(servicePromise); - servicePromise.error = jasmine.createSpy(name + ' error').and.returnValue(servicePromise); - servicePromise['finally'] = jasmine.createSpy(name + ' finally').and.returnValue(servicePromise); - servicePromise.callSuccessCallBack = function () { - servicePromise.success.calls.mostRecent().args[0].apply(servicePromise, arguments); - }; - servicePromise.callErrorCallBack = function () { - servicePromise.error.calls.mostRecent().args[0].apply(servicePromise, arguments); - }; - servicePromise.callThenCallBack = function () { - servicePromise.then.calls.mostRecent().args[0].apply(servicePromise, arguments); - }; - return servicePromise; - }, - - controller: function () { - - }, - - respondWith: function (data) { - var deferred = Q.defer(); - deferred.resolve(data); - return deferred.promise; - }, - - respondWithPromise: function($q, data) { - var deferred = $q.defer(); - deferred.resolve(data); - return deferred.promise; - } - -}; - -specUtil.createFakePromise = function (data) { - var FakePromise = function(data){ - this.data=data; - }; - FakePromise.prototype.then=function(callback){ - return new FakePromise(callback({data:this.data})); + createServicePromise: function (name) { + var servicePromise = {}; + servicePromise.then = jasmine.createSpy(name + ' then').and.returnValue(servicePromise); + servicePromise.success = jasmine.createSpy(name + ' success').and.returnValue(servicePromise); + servicePromise.error = jasmine.createSpy(name + ' error').and.returnValue(servicePromise); + servicePromise['finally'] = jasmine.createSpy(name + ' finally').and.returnValue(servicePromise); + servicePromise.callSuccessCallBack = function () { + servicePromise.success.calls.mostRecent().args[0].apply(servicePromise, arguments); }; - FakePromise.prototype.success=function(resolve){ - resolve(this.data); + servicePromise.callErrorCallBack = function () { + servicePromise.error.calls.mostRecent().args[0].apply(servicePromise, arguments); }; - FakePromise.prototype.error=function(reject){ - reject(this.data); + servicePromise.callThenCallBack = function () { + servicePromise.then.calls.mostRecent().args[0].apply(servicePromise, arguments); }; - FakePromise.prototype.finally=function(callback){ - callback(); - }; - FakePromise.prototype.catch=function(errorCallBack){ - errorCallBack(this.data); + return servicePromise; + }, + + controller: function () { + + }, + + respondWith: function (data) { + var deferred = Q.defer(); + deferred.resolve(data); + return deferred.promise; + }, + + respondWithPromise: function($q, data) { + var deferred = $q.defer(); + deferred.resolve(data); + return deferred.promise; + } + +}; + +specUtil.simplePromise = function(data) { + var SimplePromise = function(data) { + this.then = function(callback) { + return new SimplePromise(callback(data)); }; - return new FakePromise(data); -}; \ No newline at end of file + this.success = function(callback){ + return new SimplePromise(callback(data)); + } + }; + return new SimplePromise(data); +} + +specUtil.createFakePromise = function (data) { + var FakePromise = function(data){ + this.data=data; + }; + FakePromise.prototype.then=function(callback){ + return new FakePromise(callback({data:this.data})); + }; + FakePromise.prototype.success=function(resolve){ + resolve(this.data); + }; + FakePromise.prototype.error=function(reject){ + reject(this.data); + }; + FakePromise.prototype.finally=function(callback){ + callback(); + }; + FakePromise.prototype.catch=function(errorCallBack){ + errorCallBack(this.data); + }; + return new FakePromise(data); +}; + +// catch the error thrown by a promise in async specs +var notifyError = function (error) { + expect(error).toBeTruthy(); + expect("Error : '" + error.message + "' not to be thrown").toBeNull(); // It is a hack. But, instead of wasting time on making it perfect it's better to go with it +}; +// log a message to see whether a then callback is called or not. +// ex: 101 - promise.then(...) +// 102 - .then(...) +// 103 - .then(specUtil.debug(103)) +// 104 - .then(...); +specUtil.debug = function (lineNumber) { + return function(data){ + console.log(lineNumber+" : here"); + return data; + }; +}; From 63e85a4404367b36dde1ac0e1e47375595e38df9 Mon Sep 17 00:00:00 2001 From: larslemos Date: Thu, 1 Sep 2016 11:28:48 -0700 Subject: [PATCH 09/12] latest pull from master, added observation test --- app/common/domain/init.js | 2 +- .../views/patient-demo-info.html | 36 +++++++++--------- .../form-display/views/error-messages.html | 3 +- test/karma.conf.js | 1 + .../mappers/observationValueMapper.spec.js | 8 ++++ .../domain/services/encounterService.spec.js | 37 +++++++++++++++++++ 6 files changed, 68 insertions(+), 19 deletions(-) create mode 100644 test/spec/common/domain/mappers/observationValueMapper.spec.js create mode 100644 test/spec/common/domain/services/encounterService.spec.js diff --git a/app/common/domain/init.js b/app/common/domain/init.js index 95f67e40..fa0125ee 100755 --- a/app/common/domain/init.js +++ b/app/common/domain/init.js @@ -3,4 +3,4 @@ var Bahmni = Bahmni || {}; Bahmni.Common = Bahmni.Common || {}; Bahmni.Common.Domain = Bahmni.Common.Domain || {}; -angular.module('bahmni.common.domain', []); \ No newline at end of file +angular.module('bahmni.common.domain', []); diff --git a/app/patient-details/views/patient-demo-info.html b/app/patient-details/views/patient-demo-info.html index 10d58693..d2ac6dca 100755 --- a/app/patient-details/views/patient-demo-info.html +++ b/app/patient-details/views/patient-demo-info.html @@ -27,27 +27,29 @@

{{'PATIENT_DAILY_HOSPITAL_PROCESS' | translate}}

- + --> diff --git a/app/poc-common/form-display/views/error-messages.html b/app/poc-common/form-display/views/error-messages.html index 819832cd..fa62f045 100755 --- a/app/poc-common/form-display/views/error-messages.html +++ b/app/poc-common/form-display/views/error-messages.html @@ -1,3 +1,4 @@ + This field is required This field is too short This field is too long @@ -5,4 +6,4 @@ This field format is incorrect This field value is already in use The value is too big for this field -The value is too small for this field \ No newline at end of file +The value is too small for this field diff --git a/test/karma.conf.js b/test/karma.conf.js index 6e4332f7..efeea14b 100755 --- a/test/karma.conf.js +++ b/test/karma.conf.js @@ -69,6 +69,7 @@ module.exports = function(config) { 'lib/modernizr.custom.80690.js', // application files 'app/**/*.js', + 'app/common/**/*.js', // fixtures 'test/fixtures/**/*.json', //test utils diff --git a/test/spec/common/domain/mappers/observationValueMapper.spec.js b/test/spec/common/domain/mappers/observationValueMapper.spec.js new file mode 100644 index 00000000..b4d8dfbf --- /dev/null +++ b/test/spec/common/domain/mappers/observationValueMapper.spec.js @@ -0,0 +1,8 @@ +xdescribe("Obcservation Value Mapper", function () { + var mapper = Bahmni.Common.Domain.ObservationValueMapper; + + it("should return date value", function () { + var obs = {type: "Date", value:"2015-12-19", concept: {}}; + expect(mapper.map(obs)).toBe("19-Dec-2015"); + }); +}); diff --git a/test/spec/common/domain/services/encounterService.spec.js b/test/spec/common/domain/services/encounterService.spec.js new file mode 100644 index 00000000..f76744dc --- /dev/null +++ b/test/spec/common/domain/services/encounterService.spec.js @@ -0,0 +1,37 @@ +xdescribe('EncounterService', function () { + //TODO: Discuss with valerios API design + var $cookieStore; + var encounterService; + var $q= Q; + var rootScope = {currentProvider: {uuid: 'provider-uuid'}}; + + beforeEach(module('bahmni.common.domain')); + + beforeEach(module(function ($provide) { + $cookieStore = jasmine.createSpyObj('$cookieStore', ['get']); + $provide.value('$q', $q); + $provide.value('$cookieStore', $cookieStore); + $provide.value('$rootScope', rootScope); + })); + + beforeEach(inject(['encounterService',function (encounterServiceInjected) { + encounterService = encounterServiceInjected; + }])); + + it('should get encounter type based on login location when login location uuid is present',function (done) { + var programUuid = null; + //var locationUuid = "locationUuid"; + var loginLocationToEncounterTypeMapping = { + "data" :{ + "results": [ + { "entityUuid": {"uuid": "locationUuid"}, + "mappings": [{"uuid": "encounterUuid"}]} + ]}}; + + encounterService.getDefaultEncounterType().then(function (response) { + expect(response[0].uuid).toBe("encounterUuid"); + done(); + }); + }); + +}); From 153da7abf9c2b8669fcac78062bc3e4ce4f2e799 Mon Sep 17 00:00:00 2001 From: larslemos Date: Mon, 5 Sep 2016 20:05:04 +0200 Subject: [PATCH 10/12] fixed lodash alias, added tests --- app/common/util/validationUtil.js | 4 +- test/spec/common/util/validationUtil.spec.js | 61 ++++++++ .../createPatientRequestMapper.spec.js | 141 ++++++++++++++++++ 3 files changed, 204 insertions(+), 2 deletions(-) create mode 100644 test/spec/common/util/validationUtil.spec.js create mode 100644 test/spec/controllers/createPatientRequestMapper.spec.js diff --git a/app/common/util/validationUtil.js b/app/common/util/validationUtil.js index c8910c87..3afd37e8 100755 --- a/app/common/util/validationUtil.js +++ b/app/common/util/validationUtil.js @@ -3,7 +3,7 @@ Bahmni.Common.Util.ValidationUtil = (function () { var isAcceptableType = function (propertyToCheck) { - return _.contains(["string", "boolean", "number", "object"], typeof propertyToCheck); + return _.includes(["string", "boolean", "number", "object"], typeof propertyToCheck); }; var flattenObject = function (ob) { @@ -54,4 +54,4 @@ Bahmni.Common.Util.ValidationUtil = (function () { return { validate: validate }; -})(); \ No newline at end of file +})(); diff --git a/test/spec/common/util/validationUtil.spec.js b/test/spec/common/util/validationUtil.spec.js new file mode 100644 index 00000000..412b36d8 --- /dev/null +++ b/test/spec/common/util/validationUtil.spec.js @@ -0,0 +1,61 @@ +Bahmni.Registration.customValidator = { + "age.days": {}, + "name": {}, + "Telephone Number": {}, + "date": {} +}; + +describe('ValidationUtil', function () { + var date = new Date(); + + var ValidationUtil = Bahmni.Common.Util.ValidationUtil; + var customValidator = Bahmni.Registration.customValidator; + var complexObject, objectConfiguration; + beforeEach(function () { + complexObject = { + "name": "valerio", + "age": {days: 7}, + "address": { + "addr1": "addr1", + "addr2": "addr2", + "street": "road", + "pin": 1110 + }, + "date": date + }; + objectConfiguration = { + "one": { "name": "name" }, + "two": { "name": "age" } + }; + }); + + //TODO: Check issue with Dates units + it("should call the custom validators", function () { + customValidator["age.days"] = jasmine.createSpyObj('age.days', ['method']); + customValidator["age.days"].method.and.returnValue(true); + customValidator["name"] = jasmine.createSpyObj('name', ['method']); + customValidator["name"].method.and.returnValue(true); + customValidator["date"] = jasmine.createSpyObj('date', ['method']); + customValidator["date"].method.and.returnValue(true); + ValidationUtil.validate(complexObject, objectConfiguration); + expect(customValidator["name"].method).toHaveBeenCalledWith("name", "valerio", objectConfiguration.one); + expect(customValidator["age.days"].method).toHaveBeenCalledWith("age.days", 7, undefined); + //expect(customValidator["date"].method).toHaveBeenCalledWith("date", date, undefined); + }); + + it("should return the error message when the predicate fails", function () { + customValidator["Telephone Number"] = jasmine.createSpyObj('Telephone Number', ['method']); + customValidator["Telephone Number"].method.and.returnValue(false); + customValidator["Telephone Number"].errorMessage = "Invalid Telephone Number"; + complexObject["Telephone Number"] = 983; + var msg = ValidationUtil.validate(complexObject, objectConfiguration); + expect(msg).toEqual("Invalid Telephone Number"); + }); + + it("should return nothing when the custom validator is not present", function () { + customValidator = undefined; + var msg = ValidationUtil.validate(complexObject, objectConfiguration); + expect(msg).toEqual(''); + }); + +}); diff --git a/test/spec/controllers/createPatientRequestMapper.spec.js b/test/spec/controllers/createPatientRequestMapper.spec.js new file mode 100644 index 00000000..419eca16 --- /dev/null +++ b/test/spec/controllers/createPatientRequestMapper.spec.js @@ -0,0 +1,141 @@ +'use strict'; + +describe('CreatePatientRequestMapper', function () { + + var patient; + var patientAttributeTypes; + var identifiersMock, identifierDetails; + var date = new Date(); + + beforeEach(function () { + module('registration'); + module('common.patient'); + module(function($provide){ + identifiersMock = jasmine.createSpyObj('identifiers', ['create']); + identifierDetails = { + primaryIdentifier: { + identifierType: { + primary: true, + uuid: "identifier-type-uuid", + identifierSources: [{ + prefix: "GAN", + uuid: 'dead-cafe' + }, { + prefix: "SEM", + uuid: 'new-cafe' + }] + } + } + }; + identifiersMock.create.and.returnValue(identifierDetails); + + $provide.value('identifiers', identifiersMock); + }); + inject(['patient', function (patientFactory) { + patient = patientFactory.create(); + }]); + + patientAttributeTypes = [ + { + "uuid": "class-uuid", + "sortWeight": 2.0, + "name": "class", + "description": "Caste", + "format": "java.lang.String", + "answers": [] + }, + { + "uuid": "education-uuid", + "sortWeight": 2.0, + "name": "education", + "description": "Caste", + "format": "java.lang.String", + "answers": [] + }, + { + "uuid": "testDate-uuid", + "sortWeight": 2.0, + "name": "testDate", + "description": "Test Date", + "format": "org.openmrs.util.AttributableDate", + "answers": [] + } + ]; + + }); + + it('should map angular patient model to openmrs patient', function () { + + angular.extend(patient, { + "givenName": "gname", + "familyName": "fname", + "address": { + "address1": "house street", + "address2": "grampan", + "address3": "tehsil", + "cityVillage": "vill", + "countyDistrict": "dist" + }, + "birthdate": moment(date).format("DD-MM-YYYY"), + "age": { + "years": 0, + "months": 4, + "days": 17 + }, + "gender": "M", + "registrationDate": moment(date).format(), + "education": "16", + "occupation": "23", + "primaryContact": "primary cont", + "secondaryContact": "second cont", + "healthCenter": "2", + "primaryRelative": "fathus name", + "class": "10", + "givenNameLocal": "fmoz", + "familyNameLocal": "lmoz", + "secondaryIdentifier": "sec id", + "isNew": "true", + "dead": true, + "causeOfDeath": 'uuid', + "deathDate": null, + + "testDate": "Fri Jan 01 1999 00:00:00" + }); + + var openmrsPatient = new Bahmni.Registration.CreatePatientRequestMapper(new Date()).mapFromPatient(patientAttributeTypes, patient); + + expect(openmrsPatient.patient.person.names).toEqual([ + { + givenName: "gname", + familyName: "fname", + middleName: undefined, + "preferred": false + } + ]); + + expect(openmrsPatient.patient.person.addresses).toEqual([ + { + address1: "house street", + address2: "grampan", + address3: "tehsil", + cityVillage: "vill", + countyDistrict: "dist" + + } + ]); + + expect(openmrsPatient.patient.person.gender).toBe("M"); + + expect(openmrsPatient.patient.person.dead).toBe(true); + + expect(openmrsPatient.patient.person.deathDate).toBe(null); + + expect(openmrsPatient.patient.person.causeOfDeath).toBeUndefined(); + + expect(openmrsPatient.patient.identifiers.length).toBe(0); + + + + expect(openmrsPatient.patient.person.personDateCreated).toBe(moment(date).format()); + }); + }); From c9b2a410884fa6500b106b8299d5d8d9b11fb999 Mon Sep 17 00:00:00 2001 From: larslemos Date: Tue, 13 Sep 2016 12:51:46 +0200 Subject: [PATCH 11/12] lastest pull, reverted address form autocomplete --- .../directives/addressFields.js | 14 +++++++++----- .../views/patient-identifier-input.html | 18 ++++++++++-------- test/spec/common/util/validationUtil.spec.js | 4 ++-- .../mapper}/createPatientRequestMapper.spec.js | 0 4 files changed, 21 insertions(+), 15 deletions(-) rename test/spec/{controllers => registration/mapper}/createPatientRequestMapper.spec.js (100%) diff --git a/app/patient-details/directives/addressFields.js b/app/patient-details/directives/addressFields.js index 2597ff70..4cef1121 100755 --- a/app/patient-details/directives/addressFields.js +++ b/app/patient-details/directives/addressFields.js @@ -14,15 +14,19 @@ angular.module('patient.details') }; }) .controller('AddressFieldsDirectiveController', function ($scope, addressAttributeService) { - var addressLevelsCloneInDescendingOrder = $scope.addressLevels.slice(0).reverse(); - $scope.addressLevelsChunks = Bahmni.Common.Util.ArrayUtil.chunk(addressLevelsCloneInDescendingOrder, 2); - var addressLevelsNamesInDescendingOrder = addressLevelsCloneInDescendingOrder.map(function (addressLevel) { + var addressLevelsCloneInAscendingOrder = $scope.addressLevels; + $scope.addressLevelsChunks = Bahmni.Common.Util.ArrayUtil.chunk(addressLevelsCloneInAscendingOrder, 2); + + var addressLevelsInAscendingOrder = addressLevelsCloneInAscendingOrder.map(function (addressLevel) { return addressLevel.addressField; }); var autocompletedFields = []; $scope.addressFieldSelected = function (fieldName) { return function (addressFieldItem) { - var parentFields = addressLevelsNamesInDescendingOrder.slice(addressLevelsNamesInDescendingOrder.indexOf(fieldName) + 1); + var startAddress = 0; + var endAddress = addressLevelsInAscendingOrder.indexOf(fieldName) ; + + var parentFields = addressLevelsInAscendingOrder.slice(startAddress, endAddress).reverse(); var parent = addressFieldItem.addressField.parent; parentFields.forEach(function (parentField) { if (!parent) return; @@ -67,7 +71,7 @@ angular.module('patient.details') }); } }; - + $scope.$watch('$parent.showMessages', function (value) { $scope.showMessages = value; }); diff --git a/app/registration/views/patient-identifier-input.html b/app/registration/views/patient-identifier-input.html index bc719371..36a5eb25 100755 --- a/app/registration/views/patient-identifier-input.html +++ b/app/registration/views/patient-identifier-input.html @@ -6,7 +6,7 @@

{{'PATIENT_INFO_IDENTIFIERS' | translate}}

@@ -24,13 +24,14 @@

{{'PATIENT_INFO_IDENTIFIERS' | translate}}

{{'PATIENT_INFO_IDENTIFIER_TYPE' | translate}} {{'PATIENT_INFO_IDENTIFIER_IDENTIFIER' | translate}} {{'PATIENT_INFO_IDENTIFIER_PREFERRED' | translate}} - + + Mascara/Formato de Indentificador - + -
@@ -38,14 +39,15 @@

{{'PATIENT_INFO_IDENTIFIERS' | translate}}

- +
- @@ -54,6 +56,8 @@

{{'PATIENT_INFO_IDENTIFIERS' | translate}}

+ + @@ -65,5 +69,3 @@

{{'PATIENT_INFO_IDENTIFIERS' | translate}}

- - \ No newline at end of file diff --git a/test/spec/common/util/validationUtil.spec.js b/test/spec/common/util/validationUtil.spec.js index 412b36d8..b663f48a 100644 --- a/test/spec/common/util/validationUtil.spec.js +++ b/test/spec/common/util/validationUtil.spec.js @@ -13,7 +13,7 @@ describe('ValidationUtil', function () { var complexObject, objectConfiguration; beforeEach(function () { complexObject = { - "name": "valerio", + "name": "don joe", "age": {days: 7}, "address": { "addr1": "addr1", @@ -38,7 +38,7 @@ describe('ValidationUtil', function () { customValidator["date"] = jasmine.createSpyObj('date', ['method']); customValidator["date"].method.and.returnValue(true); ValidationUtil.validate(complexObject, objectConfiguration); - expect(customValidator["name"].method).toHaveBeenCalledWith("name", "valerio", objectConfiguration.one); + expect(customValidator["name"].method).toHaveBeenCalledWith("name", "don joe", objectConfiguration.one); expect(customValidator["age.days"].method).toHaveBeenCalledWith("age.days", 7, undefined); //expect(customValidator["date"].method).toHaveBeenCalledWith("date", date, undefined); }); diff --git a/test/spec/controllers/createPatientRequestMapper.spec.js b/test/spec/registration/mapper/createPatientRequestMapper.spec.js similarity index 100% rename from test/spec/controllers/createPatientRequestMapper.spec.js rename to test/spec/registration/mapper/createPatientRequestMapper.spec.js From 0a23871e39e813029ac46866a998304d6bbd061c Mon Sep 17 00:00:00 2001 From: larslemos Date: Sun, 18 Sep 2016 20:08:07 +0200 Subject: [PATCH 12/12] 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" }