| | 1 | = UseCase07 - Lab Technician Submits Lab Results = |
| | 2 | |
| | 3 | == Initiating Actor - `Lab Technician` == |
| | 4 | |
| | 5 | == Description == |
| | 6 | 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. |
| | 7 | |
| | 8 | == Scenario == |
| | 9 | |
| | 10 | 1. Lab technician logs in and navigates to "Pending Lab Tests". |
| | 11 | |
| | 12 | {{{ |
| | 13 | #!sql |
| | 14 | SELECT |
| | 15 | plt.performed_test_id, |
| | 16 | lt.test_name, |
| | 17 | u_p.first_name AS patient_first_name, |
| | 18 | u_p.last_name AS patient_last_name, |
| | 19 | u_d.first_name AS doctor_first_name, |
| | 20 | u_d.last_name AS doctor_last_name, |
| | 21 | plt.test_date, |
| | 22 | plt.notes |
| | 23 | FROM performed_lab_tests plt |
| | 24 | JOIN lab_tests lt ON plt.test_id = lt.test_id |
| | 25 | JOIN patients p ON plt.patient_id = p.patient_id |
| | 26 | JOIN users u_p ON p.patient_id = u_p.patient_id |
| | 27 | JOIN doctors d ON plt.doctor_id = d.doctor_id |
| | 28 | JOIN users u_d ON d.doctor_id = u_d.doctor_id; |
| | 29 | }}} |
| | 30 | |
| | 31 | 2. Technician selects a pending test and views its details. |
| | 32 | |
| | 33 | {{{ |
| | 34 | #!sql |
| | 35 | SELECT |
| | 36 | lt.test_id, |
| | 37 | lt.test_name, |
| | 38 | lt.description, |
| | 39 | lt.cost |
| | 40 | FROM lab_tests lt |
| | 41 | WHERE lt.test_id = ( |
| | 42 | SELECT test_id |
| | 43 | FROM performed_lab_tests |
| | 44 | WHERE performed_test_id = 1); |
| | 45 | }}} |
| | 46 | |
| | 47 | 3. Technician performs the test and submits the results. |
| | 48 | |
| | 49 | {{{ |
| | 50 | #!sql |
| | 51 | INSERT INTO lab_results (test_id, results, result_date) |
| | 52 | VALUES ( |
| | 53 | (SELECT test_id FROM performed_lab_tests WHERE performed_test_id = 1), |
| | 54 | 'Blood pressure: 145/90, Glucose: 105 mg/dL', |
| | 55 | '2026-06-05' |
| | 56 | ) |
| | 57 | RETURNING result_id; |
| | 58 | }}} |
| | 59 | |
| | 60 | 4. System links the lab result to the patient's medical record. |
| | 61 | |
| | 62 | {{{ |
| | 63 | #!sql |
| | 64 | INSERT INTO medical_record_lab_results (record_id, result_id) |
| | 65 | VALUES ( |
| | 66 | (SELECT record_id FROM medical_records WHERE patient_id = ( |
| | 67 | SELECT patient_id FROM performed_lab_tests WHERE performed_test_id = 1 |
| | 68 | )), |
| | 69 | (SELECT MAX(result_id) FROM lab_results) |
| | 70 | ); |
| | 71 | }}} |
| | 72 | |
| | 73 | 5. System confirms submission and displays the results now on record. |
| | 74 | |
| | 75 | {{{ |
| | 76 | #!sql |
| | 77 | SELECT |
| | 78 | lt.test_name, |
| | 79 | lr.results, |
| | 80 | lr.result_date |
| | 81 | FROM medical_record_lab_results mrlr |
| | 82 | JOIN lab_results lr ON mrlr.result_id = lr.result_id |
| | 83 | JOIN lab_tests lt ON lr.test_id = lt.test_id |
| | 84 | WHERE mrlr.record_id = ( |
| | 85 | SELECT record_id FROM medical_records |
| | 86 | WHERE patient_id = ( |
| | 87 | SELECT patient_id |
| | 88 | FROM performed_lab_tests |
| | 89 | WHERE performed_test_id = 1) |
| | 90 | ); |
| | 91 | }}} |