= UseCase07PrototypeImplementation - Lab Technician Submits Lab Results = == Initiating Actor - `Lab Technician` == == Description == A lab technician views pending lab tests, performs the test, and submits the results. The system records the results, links them to the patient's medical record, and makes them available to the doctor. == Scenario == 1. Lab technician logs in and navigates to "Pending Lab Tests" and selects for a certain patient for a certain date. [[Image(uc07-1.png, width=100%)]] {{{ #!sql SELECT lt.test_id, lt.test_name, lt.description, lt.cost FROM lab_tests lt WHERE lt.test_id IN ( SELECT test_id FROM performed_lab_tests WHERE patient_id = 4 AND test_date = '2026-06-16' ); }}} 2. Technician selects the pending Complete Blood Count test for the patient and views its details. {{{ #!sql SELECT lt.test_id, lt.test_name, lt.description, lt.cost FROM lab_tests lt WHERE lt.test_id = ( SELECT test_id FROM performed_lab_tests WHERE patient_id = 4 AND test_date = '2026-06-05' ); }}} 3. Technician performs the test and submits the results. [[Image(uc07-2.png, width=100%)]] {{{ #!sql INSERT INTO lab_results (test_id, results, result_date) VALUES ( (SELECT test_id FROM performed_lab_tests WHERE patient_id = 4 AND test_date = '2026-06-05'), 'Blood pressure: 145/90, Glucose: 105 mg/dL', '2026-06-05' ) RETURNING result_id; }}} 4. System links the lab result to the patient's medical record. [[Image(uc07-3.png, width=100%)]] {{{ #!sql INSERT INTO medical_record_lab_results (record_id, result_id) VALUES ( 4,(SELECT MAX(result_id) FROM lab_results) ); }}} 5. System confirms submission and displays the submitted results. [[Image(us07-4.png, width=100%)]] {{{ #!sql SELECT lt.test_name, lr.results, lr.result_date FROM medical_record_lab_results mrlr JOIN medical_records mr ON mrlr.record_id = mr.record_id JOIN lab_results lr ON mrlr.result_id = lr.result_id JOIN lab_tests lt ON lr.test_id = lt.test_id WHERE mr.patient_id = 4 AND lr.result_date = '2026-06-16'; }}}