| | 1 | = UseCase12 - Create Medical Report = |
| | 2 | |
| | 3 | == Initiating Actor - `Doctor` == |
| | 4 | |
| | 5 | == Description == |
| | 6 | A doctor creates a medical report for a patient documenting consultation findings. The system records the report with the doctor, date, and description entered by the doctor. |
| | 7 | |
| | 8 | == Scenario == |
| | 9 | |
| | 10 | 1. Doctor opens a patient's medical record. |
| | 11 | |
| | 12 | {{{ |
| | 13 | #!sql |
| | 14 | SELECT |
| | 15 | mr.record_id, |
| | 16 | mr.patient_id |
| | 17 | FROM medical_records mr |
| | 18 | WHERE mr.patient_id = ( |
| | 19 | SELECT patient_id FROM users WHERE username = 'maja.veljanova' |
| | 20 | ); |
| | 21 | }}} |
| | 22 | |
| | 23 | 2. Doctor navigates to "Add new report" and enters the report description and date. |
| | 24 | |
| | 25 | {{{ |
| | 26 | #!sql |
| | 27 | INSERT INTO medical_report (record_id, doctor_id, description, report_date) |
| | 28 | VALUES ( |
| | 29 | (SELECT record_id FROM medical_records WHERE patient_id = (SELECT patient_id FROM users WHERE username = 'maja.veljanova')), |
| | 30 | (SELECT doctor_id FROM users WHERE username = 'elena.kirova'), |
| | 31 | 'Patient presents with hypertension. Recent ECG shows normal sinus rhythm.', |
| | 32 | '2026-05-30' |
| | 33 | ) |
| | 34 | RETURNING report_id; |
| | 35 | }}} |
| | 36 | |
| | 37 | 3. System displays the completed report with all entered information. |
| | 38 | |
| | 39 | {{{ |
| | 40 | #!sql |
| | 41 | SELECT |
| | 42 | mr.report_id, |
| | 43 | mr.description, |
| | 44 | mr.report_date, |
| | 45 | u_d.first_name AS doctor_first_name, |
| | 46 | u_d.last_name AS doctor_last_name |
| | 47 | FROM medical_report mr |
| | 48 | JOIN doctors d ON mr.doctor_id = d.doctor_id |
| | 49 | JOIN users u_d ON d.doctor_id = u_d.doctor_id |
| | 50 | WHERE mr.report_id = ( |
| | 51 | SELECT MAX(report_id) |
| | 52 | FROM medical_report); |
| | 53 | }}} |