wiki:UseCase06PrototypeImplementation

UseCase06PrototypeImplementation - Doctor Requests Lab Test

Initiating Actor - Doctor

Description

A doctor requests a laboratory test for a patient. The system creates a performed lab test record linking the doctor, patient, and the specific test.

Scenario

  1. Doctor opens a patient's medical record.
SELECT
    mr.record_id,
    mr.patient_id
FROM medical_records mr
WHERE mr.patient_id = 4;
  1. Doctor navigates to "Request Lab Test" and system displays all available lab tests.

SELECT
    lt.test_id,
    lt.test_name,
    lt.description,
    lt.cost
FROM lab_tests lt
ORDER BY lt.test_name;
  1. Doctor selects a lab test, specifies the test date and notes, and submits the request.

INSERT INTO performed_lab_tests (patient_id, doctor_id, test_id, test_date, notes)
VALUES (
    4,
    (SELECT doctor_id FROM doctors WHERE user_id = (SELECT user_id FROM users WHERE username = 'elena.kirova')),
    (SELECT test_id FROM lab_tests WHERE test_name = 'Complete Blood Count'),
    '2026-06-16',
    'Blood work for hypertension monitoring'
)
RETURNING performed_test_id;
  1. System calculates the total cost of lab tests performed on that date for this patient.
SELECT SUM(lt.cost) AS total_cost
FROM performed_lab_tests plt
JOIN lab_tests lt ON plt.test_id = lt.test_id
WHERE plt.patient_id = 4
  AND plt.test_date = '2026-06-16';
Last modified 8 hours ago Last modified on 06/17/26 15:14:44

Attachments (2)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.