@@ -186,57 +186,53 @@ public function getTestingLabFacilityMap($labId)
186186 // $onlyActive = true/false
187187 public function getHealthFacilities ($ testType = null , $ byPassFacilityMap = false , $ allColumns = false , $ condition = [], $ onlyActive = true , $ userId = null )
188188 {
189-
190- return MemoUtility::remember (function () use ($ testType , $ byPassFacilityMap , $ allColumns , $ condition , $ onlyActive , $ userId ): string |array |null |int |float |false {
191- $ userId ??= null ;
192- if (isset ($ _SESSION ['userId ' ]) && $ userId === null ) {
193- $ userId ??= $ _SESSION ['userId ' ];
194- }
195- if (!$ byPassFacilityMap && !empty ($ userId )) {
196- $ facilityMap = $ this ->getUserFacilityMap ($ userId );
197- if (!empty ($ facilityMap )) {
198- $ this ->db ->where ("`facility_id` IN ( $ facilityMap) " );
199- }
189+ $ userId ??= null ;
190+ if (isset ($ _SESSION ['userId ' ]) && $ userId === null ) {
191+ $ userId ??= $ _SESSION ['userId ' ];
192+ }
193+ if (!$ byPassFacilityMap && !empty ($ userId )) {
194+ $ facilityMap = $ this ->getUserFacilityMap ($ userId );
195+ if (!empty ($ facilityMap )) {
196+ $ this ->db ->where ("`facility_id` IN ( $ facilityMap) " );
200197 }
198+ }
201199
202- if (!empty ($ testType )) {
203- // subquery
204- $ healthFacilities = $ this ->db ->subQuery ();
205- // we want to fetch facilities that have test type is not specified as well as this specific test type
206- $ healthFacilities ->where ("test_type is null or test_type like ' $ testType' " );
207- $ healthFacilities ->get ("health_facilities " , null , "facility_id " );
200+ if (!empty ($ testType )) {
201+ // subquery
202+ $ healthFacilities = $ this ->db ->subQuery ();
203+ // we want to fetch facilities that have test type is not specified as well as this specific test type
204+ $ healthFacilities ->where ("test_type is null or test_type like ' $ testType' " );
205+ $ healthFacilities ->get ("health_facilities " , null , "facility_id " );
208206
209- $ this ->db ->where ("facility_id " , $ healthFacilities , 'IN ' );
210- }
207+ $ this ->db ->where ("facility_id " , $ healthFacilities , 'IN ' );
208+ }
211209
212- if ($ onlyActive ) {
213- $ this ->db ->where ('status ' , 'active ' );
214- }
210+ if ($ onlyActive ) {
211+ $ this ->db ->where ('status ' , 'active ' );
212+ }
215213
216- if (!empty ($ condition )) {
217- $ condition = is_array ($ condition ) ? $ condition : [$ condition ];
218- foreach ($ condition as $ cond ) {
219- $ this ->db ->where ($ cond );
220- }
214+ if (!empty ($ condition )) {
215+ $ condition = is_array ($ condition ) ? $ condition : [$ condition ];
216+ foreach ($ condition as $ cond ) {
217+ $ this ->db ->where ($ cond );
221218 }
219+ }
222220
221+ $ this ->db ->orderBy ("facility_name " , "asc " );
223222
224- $ this ->db ->orderBy ("facility_name " , "asc " );
225-
226- if ($ allColumns ) {
227- return $ this ->db ->get ("facility_details " );
228- } else {
223+ if ($ allColumns ) {
224+ return $ this ->db ->get ("facility_details " );
225+ } else {
229226
230- $ response = [];
227+ $ response = [];
231228
232- $ results = $ this ->db ->get ("facility_details " , null , "facility_id,facility_name " );
229+ $ results = $ this ->db ->get ("facility_details " , null , "facility_id,facility_name " );
233230
234- foreach ($ results as $ row ) {
235- $ response [$ row ['facility_id ' ]] = $ row ['facility_name ' ];
236- }
237- return $ response ;
231+ foreach ($ results as $ row ) {
232+ $ response [$ row ['facility_id ' ]] = $ row ['facility_name ' ];
238233 }
239- }, 300 );
234+ return $ response ;
235+ }
240236 }
241237
242238
0 commit comments