Project

General

Profile

Task #108

Updated by Varsha N 16 days ago

MODULE: Test Results (Based on Selected Tests in Registration) 

 Navigation: Login β†’ Sidebar β†’ Test Results 
 🎯 TASK OBJECTIVE: 
 Develop Test Results module where: 
	 β€’ 	 User searches a registration 
	 β€’ 	 System automatically loads the tests selected during registration 
	 β€’ 	 Parameters are fetched based on selected tests 
	 β€’ 	 Result entry is dynamic 
	 β€’ 	 Results saved per parameter 
	 β€’ 	 No manual test selection in this module 

 🧠 IMPORTANT LOGIC CHANGE 

 In registration table: 
 lab_test (JSON) 
 Example: 
 [1, 3] 
 Means: 
	 β€’ 	 Test ID 1 (CBC) 
	 β€’ 	 Test ID 3 (LFT) 

 So Test Results page must: 
	 1. 	 Read lab_test 
	 2. 	 Fetch parameters for each test 
	 3. 	 Render grouped result sections 

 PART 1 β€” FRONTEND IMPLEMENTATION 

 βœ… 1. Sidebar Menu 

 Add menu: Test Results 

 βœ… 2. Search Registration Section 

 Search by: 
	 β€’ 	 Patient ID 
	 β€’ 	 Date 
	 β€’ 	 Owner Name 
         β€’ 	 Mobile number  

 Display listing: 
 | Patient ID | Patient Name | Tests | Date | Action | 
 Action: 
 Enter Results 

 βœ… 3. After Clicking β€œEnter Results” 

 Show patient details (Read Only): 
	 β€’ 	 Patient ID 
	 β€’ 	 Patient Name 
	 β€’ 	 Owner Name 
	 β€’ 	 Species 
	 β€’ 	 Breed 
	 β€’ 	 Registration Date 

 βœ… 4. Load Selected Tests Automatically 
 From registration: 
 lab_test = [1, 3] 

 System must: 
	 β€’ 	 Loop through each test_id 
	 β€’ 	 Fetch test name 
	 β€’ 	 Fetch parameters for each test 

 βœ… 5. Dynamic Result Entry UI 
 Results must be grouped by Test. 

 Example UI: 
 πŸ”Ή CBC 

 Parameter 	 Input 
 HB 	         [ Decimal Input ] 
 WBC 	         [ Number Input ] 
 COLOR 	         [ Dropdown ] 

 πŸ”Ή LFT 

 Parameter 	 Input 
 SGPT 	         [ Decimal Input ] 
 Bilirubin 	 [ Decimal Input ] 


 🎨 Rendering Rules 

 Parameter Type 	 UI 
 INTEGER 	         Number input 
 DOUBLE 	         Decimal input 
 VARCHAR 	         Text input 
 SELECT 	         Dropdown 
 CHECKBOX 	 Multi select 
 OPTION 	         Radio button 

 βœ… 6. Save Button 

 On click: 
	 β€’ 	 Collect results for all tests 
	 β€’ 	 Send structured payload 

 βš™ PART 2 β€” BACKEND IMPLEMENTATION 

 βœ… 1. Table: test_result 

 id                   PK 
 patient_id           FK 
 enterprise_id        FK 
 registration_id      FK 
 test_id              FK 
 parameter_id         FK 
 parameter_name       FK 
 test_value           result_value         TEXT  
 added_date           DATE-TIME 

 βœ… 2. API β€” Get Registration 
 GET /api/registration/{id} 
 Return: 
	 β€’ 	 Registration details 
	 β€’ 	 lab_test JSON 


 βœ… 3. API β€” Get Parameters for Multiple Tests 
 GET /api/tests/{registration_id}/parameters/ 
 Backend Logic: 
	 β€’ 	 Read registration.lab_test 
	 β€’ 	 Fetch all parameters for those tests 
	 β€’ 	 Return grouped response 

 Example response: 

 { 
   "tests": [ 
     { 
       "test_id": 1, 
       "test_name": "CBC", 
       "parameters": [...] 
     }, 
     { 
       "test_id": 3, 
       "test_name": "LFT", 
       "parameters": [...] 
     } 
   ] 
 } 

 βΈ» 

 βœ… 4. Save Results API 

 POST /api/test-results/ 

 Payload Example: 

 { 
   "registration_id": 101, 
   "results": [ 
     { 
       "test_id": 1, 
       "parameter_id": "HB", 
       "value": 13.5 
     }, 
     { 
       "test_id": 3, 
       "parameter_id": "SGPT", 
       "value": 45 
     } 
   ] 
 } 


 Backend Processing 

 βœ” Validate registration exists 
 βœ” Validate test belongs to registration 
 βœ” Validate parameter belongs to test 
 βœ” Validate value type 
 βœ” Store enterprise_id 

 βΈ» 

 πŸ” VALIDATION RULES 

 Same as Parameter module: 
 Type 	        Rule 
 INTEGER 	        Whole number only 
 DOUBLE 	        Decimal allowed 
 VARCHAR 	        Text 
 SELECT 	        Must match one option 
 CHECKBOX         All values must match options 
 OPTION 	        Only one allowed 


 πŸ”„ SYSTEM FLOW 

 Registration created 
 β†’ Tests selected and stored in lab_test 
 β†’ User opens Test Results 
 β†’ Select registration 
 β†’ System loads tests automatically 
 β†’ Render dynamic parameter UI 
 β†’ Save results 

 βœ… COMPLETION CRITERIA 

 βœ” No manual test selection 
 βœ” Multiple tests handled 
 βœ” Dynamic UI grouped by test 
 βœ” Validation enforced 
 βœ” Results saved correctly 
 βœ” Enterprise filtering working 

Back