From 360533cb9b239467a87a8ac1c141d9bb1346d2a0 Mon Sep 17 00:00:00 2001 From: SreelekhaDarsi Date: Thu, 7 Nov 2024 16:22:54 +0530 Subject: [PATCH] "Sreelekha,Sri Laxmi | BAH-4105 | Form name/number to not be displayed on patient dashboard display control" --- .../services/formRecordTreeBuildService.js | 15 ++++++++------- .../formRecordTreeBuildService.spec.js | 18 +++++++++--------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/ui/app/common/displaycontrols/observation/services/formRecordTreeBuildService.js b/ui/app/common/displaycontrols/observation/services/formRecordTreeBuildService.js index f7e8aa7b4c..7fda4f5f41 100644 --- a/ui/app/common/displaycontrols/observation/services/formRecordTreeBuildService.js +++ b/ui/app/common/displaycontrols/observation/services/formRecordTreeBuildService.js @@ -9,13 +9,14 @@ angular.module('bahmni.common.displaycontrol.observation') obs.value = self.preProcessMultiSelectObs(obs.value); }); - formService.getAllForms().then(function (response) { - var formBuildForms = response.data; - var obs = self.createObsGroupForForm(bahmniObservations, formBuildForms); - if (!hasNoHierarchy) { - updateObservationsWithFormDefinition(obs, formBuildForms); - } - }); + if (!hasNoHierarchy) { + formService.getAllForms().then(function (response) { + var formBuildFroms = response.data; + // This block builds hierarchy for the passed bahmniObservations + var obs = self.createObsGroupForForm(bahmniObservations, formBuildFroms); + updateObservationsWithFormDefinition(obs, formBuildFroms); + }); + } }; self.createMultiSelectObservation = function (observations) { diff --git a/ui/test/unit/common/displaycontrols/observation/services/formRecordTreeBuildService.spec.js b/ui/test/unit/common/displaycontrols/observation/services/formRecordTreeBuildService.spec.js index 70b87ebceb..983467bab6 100644 --- a/ui/test/unit/common/displaycontrols/observation/services/formRecordTreeBuildService.spec.js +++ b/ui/test/unit/common/displaycontrols/observation/services/formRecordTreeBuildService.spec.js @@ -3238,12 +3238,11 @@ describe("FormRecordTreeBuildService", function () { let multiSelectObservation = observations[0].value[0]; - expect(multiSelectObservation.concept.shortName).toBe("CodedForm"); - expect(multiSelectObservation.groupMembers.length).toBe(1); - expect(multiSelectObservation.groupMembers[0].groupMembers.length).toBe(2); - expect(multiSelectObservation.groupMembers[0].type).toBe("multiSelect"); - expect(multiSelectObservation.groupMembers[0].groupMembers[0].valueAsString).toBe("Susceptible"); - expect(multiSelectObservation.groupMembers[0].groupMembers[1].valueAsString).toBe("Resistant"); + expect(multiSelectObservation.concept.shortName).toBe("MD, Medical History"); + expect(multiSelectObservation.groupMembers.length).toBe(2); + expect(multiSelectObservation.type).toBe("multiSelect"); + expect(multiSelectObservation.groupMembers[0].valueAsString).toBe("Susceptible"); + expect(multiSelectObservation.groupMembers[1].valueAsString).toBe("Resistant"); }); it('should return observations with out hierarchy when hasNoHierarchy is true', function () { @@ -3357,9 +3356,10 @@ describe("FormRecordTreeBuildService", function () { formDetailDeferred.resolve(formDetails); $scope.$apply(); - expect(observations[0].value[0].groupMembers.length, 2); - const observationOne = observations[0].value[0].groupMembers[0]; - const observationTwo = observations[0].value[0].groupMembers[1]; + expect(observations[0].value.length).toBe(2); + + const observationOne = observations[0].value[0]; + const observationTwo = observations[0].value[1]; expect(observationOne.concept.shortName).toBe("MD, Medical History"); expect(observationOne.formFieldPath).toBe("CodedForm.1/5-0");