LIS — Gap Analysis & Plan

3 New Investigation Result Types — File / Culture & Sensitivity / Histopathology
Project: Moon ERP — LIS module Author: Frontend + 3 research agents Date: 2026-05-24 Status: Draft for review

المحتويات

  1. الوضع الحالي — الأنواع الموجودة
  2. الـ Critical Paths في الكود
  3. النوع الجديد ① — file
  4. النوع الجديد ② — culture (Urine C&S)
  5. النوع الجديد ③ — histopathology
  6. البنية المشتركة (Shared Infra)
  7. خطة التذاكر — Backend + Frontend
  8. الترتيب الزمني والمخاطر

🎯 المبدأ — ما الذي يتغير وما الذي يبقى ثابتاً

قبل ما نطبخ — قاعدة المشروع الذهبية: الـ Flow ثابت تماماً. اللي بيختلف بس نقطتين.

✅ يبقى ثابت (مفيش أي تغيير)

  • الـ Request wizard — اختيار التحاليل بنفس الطريقة
  • الـ Sample collection + barcode + aliquoting
  • الـ Kanban board — received → in-progress → completed
  • الـ Status workflow — pending → entered → validated → approved → released
  • الـ Print pipeline — نفس الـ PDF / HTML templates، نفس الـ classic / editorial / bento ...
  • الـ Patient portal + الـ external lab portal
  • الـ Billing / invoicing / pricing
  • الـ Permissions structure — نفس الـ roles

🔧 يتغير فقط (نقطتين)

  • ① شكل تعريف التحليل — في /lab/investigations لما الـ admin يختار النوع الجديد، حقول إعدادات إضافية تظهر (max files / antibiotic panel / requires peer review)
  • ② شكل إدخال النتيجة — في الـ kanban دلوقتي بيظهر input عادي. للأنواع الجديدة، نفس المكان لكن بـ dialog مختلف:
    • file → dropzone
    • culture → AST dialog
    • histopath → نص طويل + صور (نفس الـ dialog، tabs داخله)
التحديث المهم على المخطط الأول: الـ Histopathology كان فيه "Pathology Worklist" منفصل وصفحة dedicated — اتشال. الـ histopath هيظهر في نفس الـ kanban + نفس الـ results page زي أي نوع تاني، بس بـ dialog مختلف الشكل لإدخال البيانات. الـ overhead بقى مماثل تماماً للـ culture.

① الوضع الحالي — الأنواع الموجودة

الـ ResultType enum يدعم 5 أنواع. كل نوع له تعامل خاص في 5 صفحات (investigation form, kanban, results entry, validation worklist, PDF report). أي نوع جديد لازم يـ "يتعلم" في كل المسارات دي.

النوعالاستخدامالتخزينالواجهة
numericقيمة رقمية واحدة (مثل HGB = 14)result_value (text)input number + range/flag
textنص قصير (مثل blood group A+)result_valueinput text
selectionاختيار من قائمة (positive/negative)result_value + selection_options JSON على الـ investigationdropdown
formulaمحسوب تلقائي من اختبارات أخرىresult_value (محسوب) + formula + formula_dependencies على الـ investigationread-only
memoنص طويل (تعليق)result_value أو result_texttextarea
الخلاصة المهمة: الـ 5 أنواع كلها بترجع لـ result_value string. مفيش نوع structured (مصفوفة، شجرة، multi-record)، ومفيش نوع binary (ملف). الأنواع الجديدة هتـ كسر النمط ده.

② الـ Critical Paths في الكود

كل نوع جديد لازم يـ تتبع في الأماكن الـ 7 دي. هنا الـ baseline اللي الـ agents فحصوها.

#الـ Layerالملفاللي بيتغير لكل نوع
1Backend Enum Modules/LIS/app/Enums/ResultType.php إضافة case File / Culture / Histopathology
2Backend Schema Modules/LIS/database/migrations/...lab_results.php
...lab_investigations.php
أعمدة جديدة (انظر تفاصيل كل نوع)
3Backend Service Modules/LIS/app/Services/LabResultService.php (enter, triggerFormulaCalculations) تخطي الـ abnormal flag للأنواع الجديدة، وقبول payload منظم
4Investigation form (FE) src/app/features/lis/investigations/lis-investigations.component.ts line 207 إضافة الخيار في resultTypeOptions + إعدادات خاصة بالنوع
5Result entry UI (FE) kanban/lis-kanban.component.ts line 790, results/lis-results.component.ts,
validation-worklist.component.html line 481, dept-worklist.component.html line 254
branch جديد على resultType === النوع الجديد
6Report (PDF + HTML) core/services/lis-print-report.service.ts,
lis-report-pdf.service.ts, lis-html-report.service.ts
renderer مخصص للنوع الجديد بدل الـ default row
7Patient portal features/lis/patient-portal-public/pp-request-detail.component.ts عرض النتيجة بشكل المناسب للعميل (file download، C&S table، histopath sub-report)

file النوع الجديد ① — File / Multi-file Upload

المختبر يرفع ملف أو أكتر كنتيجة (مثل تقارير أشعة، PDFs من جهاز خارجي، صور كاميرا ميكروسكوب). العميل يـ download من بوابته.

1. Schema — استخدام الـ attachments القائمة (polymorphic)

مفيش جدول جديد. الـ attachments القائمة في Core polymorphic أصلاً، نـ morph عليها LabResult.

// migration: add file_settings JSON to lab_investigations
$table->json('file_settings')->nullable();
// { max_files: 10, max_size_mb: 10, allowed_mime: ["application/pdf", "image/*"], required_min: 1 }

// LabResult model — new relation:
public function attachments() {
    return $this->morphMany(Attachment::class, 'attachable');
}

2. Investigation form

3. Result entry UI

component جديد ResultFileCellComponent يستخدم PrimeNG p-fileUpload (multiple, custom mode). يظهر:

4. API contract

إعادة استخدام endpoint الـ attachments العام (موجود أصلاً)، مع endpoint LIS صغير للـ transition:

POST /api/core/attachments        (multipart, موجود)
GET  /api/core/attachments?attachable_type=...
POST /api/lis/results/{id}/finalize-files   ← جديد
    → يفحص count >= required_min
    → يـ set result_value = "{n} files"
    → ينقل الـ status من pending → entered

5. Report / Portal

PDF report

"📎 N attachments" + قائمة الأسماء. الصور تـ embedded thumbnails (أول 3) عبر jsPDF.addImage().

Patient portal

grid من cards فيها أيقونة mime + اسم الملف + زر View/Download. الصور تـ inline thumbnails في PrimeNG Galleria.

6. الحالات الحرجة

7. Permissions

🎨 Mockup ① — Investigation form (الـ admin بيعرّف تحليل جديد نوعه File)

/lab/investigations → New investigation → Result type = File
New Investigation
📎 File Settings (تظهر تلقائياً للنوع ده)
PDF × JPG × PNG × DICOM × + add type
اتركه فاضي = أي نوع
ℹ️ الـ Normal Ranges tab مخفي تلقائياً للأنواع غير الرقمية.

🎨 Mockup ② — Result entry (الفني بيرفع الملفات)

/lab/results — السطر بعد ما يدوس عليه يتفتح dropzone
LR-2026-00112 · Ahmed Ali · Chest X-Ray Report 📎 file
📤 اسحب الملفات هنا أو اضغط للاختيار
PDF, JPG, PNG, DICOM · حتى 10 ملفات · 10 ميجا للملف
×
📄
xray_report.pdf
2.4 MB
×
🖼
frontal_view.jpg
1.8 MB
×
🖼
lateral_view.jpg
2.1 MB
✓ 3 ملفات تم رفعهم · إجمالي 6.3 MB Min required: 1 ✓

🎨 Mockup ③ — Patient portal (العميل بيشوف ويـ download)

/p/:token → request detail → File-type result
🔬 Moon Lab Report LR-2026-00112
Patient: Ahmed Ali · MRN-000142
📎 Chest X-Ray Report (3 attachments)
📄
xray_report.pdf
2.4 MB · ↓ Download
🖼
frontal_view.jpg
1.8 MB · 👁 View
🖼
lateral_view.jpg
2.1 MB · 👁 View

culture النوع الجديد ② — Urine Culture & Sensitivity

تقرير ميكروبيولوجي structured: عينة → نمو → كائن (أو أكتر) → matrix من المضادات الحيوية (S/I/R + MIC). الـ TAT أيام مش دقايق.

الـ Industry Context

تقرير C&S القياسي فيه:

1. Schema — result_payload JSON على lab_results

// migration:
$table->json('result_payload')->nullable();

// payload shape:
{
  "version": 1,
  "incubation_started_at": "2026-05-22T08:00:00Z",
  "incubation_hours": 48,
  "macroscopy": "Cloudy urine, RBCs +",
  "growth_type": "pure|mixed|no_growth|contaminated",
  "interpretation": "Significant bacteriuria...",
  "organisms": [
    {
      "name": "Escherichia coli",
      "colony_count": "1e5",
      "colony_count_unit": "CFU/mL",
      "ast": [
        { "antibiotic_id": 12, "code": "NIT", "result": "S", "mic": "16", "mic_unit": "µg/mL" },
        { "antibiotic_id": 13, "code": "AMP", "result": "R", "mic": null }
      ]
    }
  ]
}
لماذا JSON وليس جدول منفصل؟ الـ payload متغير الشكل (عدد كائنات، عدد مضادات) — Eloquent JSON cast كافي. لما الـ analytics تحتاج resistance trends لاحقاً نـ normalize.

2. Master data — جدول lab_antibiotics جديد

lab_antibiotics
  id, company_id, code, name, name_ar, abbreviation,
  drug_class (penicillin/quinolone/...), is_active, sort_order

seed بـ ~60 مضاد من CLSI starter. ميصحش نـ overload lab_investigations لأن المضادات مش tests يـ billable.

3. Investigation config

عمود JSON جديد culture_config على lab_investigations:

{
  "default_antibiotic_ids": [12, 13, 14, 15],
  "default_incubation_hours": 48,
  "growth_types_allowed": ["pure", "mixed", "no_growth", "contaminated"]
}

4. Result entry UI — Dialog منفصل

الـ resultType === 'culture' ميظهرش inline input. يظهر زر "Enter culture" يفتح CultureResultDialogComponent:

┌─ Specimen header (read-only) ────────────────────┐
│ Patient · MRN · Test code · Barcode · Day 2/3    │
├─ Growth ────────────────────────────────────────┤
│ ( ) No growth   ( ) Pure   (•) Mixed flora      │
│ Macroscopy: [textarea]                          │
│ Incubation started: [datetime]  Hours: [48]     │
├─ Organisms ──────────────────── [+ Add organism]┤
│ ┌ Organism 1 ────────────────────────── [X] ──┐ │
│ │ Name: [autocomplete: E.coli, ...]           │ │
│ │ Colony count: [1e5] [CFU/mL ▾]              │ │
│ │ AST grid:                                   │ │
│ │ ┌────────────┬───┬───┬───┬──────┬──────┐    │ │
│ │ │ Antibiotic │ S │ I │ R │ MIC  │ Unit │    │ │
│ │ │ Nitrofur.  │(•)│( )│( )│ 16   │µg/mL │    │ │
│ │ │ Ampicillin │( )│( )│(•)│      │      │    │ │
│ │ └────────────┴───┴───┴───┴──────┴──────┘    │ │
│ └─────────────────────────────────────────────┘ │
│ Interpretation: [textarea, optional]            │
├──────────── [Save draft] [Submit] ──────────────┤

5. API contract

تعديل POST /lis/results/{id}/enter ليقبل result_payload اختياري:

POST /lis/results/{id}/enter
{
  "result_value": "E. coli 1e5 CFU/mL — S to NIT, R to AMP",  // ملخص للقوائم
  "result_payload": { ...culture payload },                    // مطلوب لـ culture
  "comment": "..."
}

قاعدة validation جديدة: لو investigation.result_type === 'culture' فالـ result_payload required.

6. Report rendering

7. الحالات الحرجة

8. Permissions

إعادة استخدام lis.results.enter|validate|approve|release. صلاحية واحدة جديدة بس:

🎨 Mockup ① — Investigation form (admin بيعرّف Urine C&S)

/lab/investigations → New → Result type = Culture
New Investigation
🧫 Culture Config (يظهر للنوع ده)
Nitrofurantoin × Ampicillin × Ciprofloxacin × TMP-SMX × Cefuroxime × Gentamicin × + add antibiotic

🎨 Mockup ② — Result entry dialog (الفني يدخل نتيجة C&S كاملة)

من kanban أو results → دوس "Enter culture" → يفتح dialog منبثق
Enter Culture Result — LR-2026-00112 / UCS Day 2 / 2
Patient: Ahmed Ali · MRN-000142  ·  Barcode: 26052401AB-MIC

Growth

Organisms

×
1 Escherichia coli
AntibioticSIRMICUnit
Nitrofurantoin (NIT)SIRµg/mL
Ampicillin (AMP)SIRµg/mL
Ciprofloxacin (CIP)SIRµg/mL
TMP-SMXSIR
CefuroximeSIRµg/mL
GentamicinSIR
+ add antibiotic to this organism

🎨 Mockup ③ — Report rendering (الـ PDF/HTML اللي العميل بيشوفه)

Section: Microbiology → Urine C&S
Moon Lab
Laboratory Information System
LR-2026-00112
24 May 2026
Cairo, Egypt
Ahmed Ali
MRN-000142 · Male · 34y · Dr. Mohamed Hassan
Microbiology · Urine Culture & Sensitivity
Macroscopy: Cloudy urine, RBCs +
Growth: Pure growth · Incubation: 48 hours
Escherichia coli — 10⁵ CFU/mL
AntibioticResultMIC (µg/mL)
NitrofurantoinS16
AmpicillinR32
CiprofloxacinS0.25
TMP-SMXI
CefuroximeS8
GentamicinS
Interpretation: Significant bacteriuria with E. coli sensitive to nitrofurantoin and ciprofloxacin. Recommend nitrofurantoin 100mg PO BID for 5 days.
Legend: S Sensitive · I Intermediate · R Resistant

histopathology النوع الجديد ③ — Histopathology Report

تقرير باثولوجي طويل ومفصل (نص + صور slides + كود ICD). الـ TAT أيام، فيه مراجعة من باثولوجي ثاني (peer review). أشبه بـ Word document متعدد الأقسام مع صور مرفقة.

1. Schema — جدول جديد lab_histopath_results

هنا الـ structure ثابت ومعقد ومفيد للبحث/التدقيق، فجدول dedicated أفضل من JSON.

lab_histopath_results
  id, company_id, lab_result_id (FK unique),
  gross_description TEXT,
  microscopic_description TEXT,
  diagnosis TEXT,
  comment TEXT,
  recommendation TEXT,
  icd_code VARCHAR(20),
  icd_o_code VARCHAR(20),
  tnm_stage VARCHAR(50),
  margin_status VARCHAR(50),
  ihc_markers JSON,                     -- {ER:"+",PR:"-",HER2:"2+"}
  specimen_received_at TIMESTAMP,
  grossing_at TIMESTAMP,
  draft_saved_at TIMESTAMP,
  peer_reviewed_by BIGINT, peer_reviewed_at TIMESTAMP,
  signed_off_by BIGINT, signed_off_at TIMESTAMP,
  created_by, updated_by, timestamps, softDeletes

الصور تستخدم attachments القائمة (نفس النمط بتاع الـ file type).

2. Investigation form

3. Result entry UI — Dialog منبثق (نفس النمط بتاع culture)

الـ resultType === 'histopathology' ميظهرش inline input. من نفس مكان "Enter result" في الـ kanban / results page، يفتح HistopathResultDialogComponent — modal كبير فيه tabs. مفيش route جديد، مفيش page جديدة. UI tabs:

[Header: Patient | Request # | Specimen | Status]
[Tabs: Gross | Microscopic | Diagnosis | IHC/Staging | Images | Audit]
  - Gross: rich-text editor + specimen_received_at + grossing_at
  - Microscopic: rich-text editor
  - Diagnosis: rich-text editor + ICD code + ICD-O autocomplete
  - IHC/Staging: ihc_markers grid + TNM stage + margin status
  - Images: multi-upload drag-drop + captions
  - Audit: timestamps + signoff history
[Footer: [Save Draft] [Submit for Peer Review] [Sign-off & Release]]
Dependency جديدة: الـ rich-text editor مش متركب. لازم npm install quill@^2 + استخدام PrimeNG p-editor. لو الـ team عايز يتجنب الـ dep ده، البديل markdown textarea (أقل احترافية للباثولوجيين).

4. Workflow — نفس الـ 5 statuses + signoff fields

pending entered validated approved released

5. API contract — endpoints dedicated

PUT  /lis/results/{id}/histopath              ← حفظ draft / تحديث structured payload
POST /lis/results/{id}/histopath/submit       ← pending → entered
POST /lis/results/{id}/histopath/peer-review  ← entered → validated
POST /lis/results/{id}/histopath/images       ← multipart upload صور
DELETE /lis/results/{id}/histopath/images/{aid}

الـ approve و release standard endpoints بدون تغيير.

6. Report rendering — sub-report مستقل

التقرير العادي grid (سطر لكل نتيجة). تقرير الـ histopath narrative بصفحة كاملة. الحل:

7. TAT / Lifecycle — نفس الـ Kanban العادي

تحديث: الـ histopath يستخدم نفس الـ kanban الموجود (received → in-progress → completed). مفيش "Pathology Worklist" منفصل. الفرق بس إن لما الباثولوجي يـ "Enter result"، الـ dialog اللي بيفتح بـ tabs (Gross / Microscopic / Diagnosis / IHC / Images) بدلاً من input عادي. كده مفيش overhead إداري إضافي للـ workflow.

8. Permissions — 3 صلاحيات جديدة

🎨 Mockup ① — Investigation form (admin بيعرّف Breast Biopsy)

/lab/investigations → New → Result type = Histopathology
New Investigation
🔬 Histopathology Settings
قوالب جاهزة عناوين الأقسام للـ pathologist مع نص فاضي

🎨 Mockup ② — Result entry dialog (الباثولوجي بيكتب التقرير من kanban)

من kanban card → "Enter result" → نفس الـ dialog المنبثق زي culture، بس بـ tabs بدلاً من AST
LR-2026-00112 · Histopathology · Breast Biopsy DRAFT auto-saved 12s ago
Patient: Sara Mahmoud · MRN-000087 · Female · 52y  ·  Specimen: Breast tissue (left, upper outer)  ·  Received: 22 May 2026
📋 Gross 🔬 Microscopic ⚕️ Diagnosis 🧪 IHC / Staging 🖼 Images 3 📜 Audit
B I U | H1 H2 | | 🔗 🖼

Sections show fragments of breast tissue showing infiltrating tumor cells arranged in cords, nests and tubules within a desmoplastic stroma.

The tumor cells are moderately pleomorphic with vesicular nuclei, prominent nucleoli and eosinophilic cytoplasm. Mitotic figures are present (8/10 HPF).

No definite vascular or perineural invasion is identified in the available sections.

No DCIS component identified...

🎨 Mockup ③ — Images tab (نفس الصفحة)

Tab "Images" — multi-upload slides + captions
Histopath Images — Breast Biopsy
🖼 اسحب صور الـ slides هنا
JPG, PNG, TIFF · حتى 20 صورة · 20 ميجا للصورة
×
🔬 H&E ×40
slide_01_he_40x.jpg
×
🔬 H&E ×100
slide_02_he_100x.jpg
×
🧪 ER stain
ihc_er_positive.jpg

🎨 Mockup ④ — Report sub-section (الـ histopath في الـ printed report)

PDF — صفحة مخصصة كاملة للـ histopath narrative
Moon Lab
Pathology Report
LR-2026-00112
24 May 2026
Page 3 of 4
Sara Mahmoud
MRN-000087 · Female · 52y · Dr. Mohamed Hassan · Specimen received 22 May 2026
🔬 Histopathology Report — Breast Biopsy (left, upper outer)
Gross Description
Fragments of fibrofatty tissue measuring 1.2 × 0.8 × 0.4 cm in aggregate. Cut surface shows a firm, ill-defined area measuring 0.5 cm. Entire specimen submitted in cassette A1.
Microscopic Description
Sections show fragments of breast tissue showing infiltrating tumor cells arranged in cords, nests and tubules within a desmoplastic stroma. The tumor cells are moderately pleomorphic with vesicular nuclei, prominent nucleoli and eosinophilic cytoplasm. Mitotic figures (8/10 HPF). No definite vascular or perineural invasion. No DCIS component identified.
Diagnosis
Invasive Ductal Carcinoma, Nottingham Grade 2 (3+2+2 = 7)
IHC / Staging
ICD-10: C50.4ICD-O: 8500/3
TNM stage: pT1b N0 M0Margins: Free
IHC: ER +ve (~80%) · PR +ve (~60%) · HER2: 1+ (negative) · Ki-67: 15%
Slide Images
🔬 H&E ×40
🔬 H&E ×100
+ 1 IHC image (ER stain)
Pathologist: Dr. Adel Hossam
Signed: 24 May 2026 10:15
Peer reviewed by: Dr. Hany Mostafa
Reviewed: 24 May 2026 09:45

⑥ البنية المشتركة (Shared Infrastructure)

قبل ما نشتغل على أي نوع، فيه قرارات معمارية مشتركة لازم تتقفل أولاً.

القرارات المعمارية الأساسية

القرارالـ Recommendationالـ Affected
تخزين structured data JSON column result_payload على lab_results للـ culture، جدول dedicated للـ histopath. file يستخدم attachments القائمة. migrations جديدة
تخزين الملفات إعادة استخدام attachments القائمة (polymorphic morph على LabResult) file و histopath (الصور)
API style file: endpoint LIS صغير + Core attachments
culture: امتداد POST /enter بـ result_payload
histopath: endpoints dedicated منفصلة
كل نوع له لون
Result entry pattern file: cell component inline
culture: dialog منبثق
histopath: route مخصص
kanban + results + worklists
Workflow (5 statuses) إعادة استخدام نفس الـ 5 statuses لكل الأنواع. الـ histopath يضيف signoff fields على الجدول الخاص بيه بدون أي state جديد. LabResult
Skip في الـ auto-features triggerFormulaCalculations, calculateAbnormalFlag, Westgard QC — كلها تـ skip الأنواع الجديدة (مفيش معنى للـ numeric checks) LabResultService

الـ Master data الجديدة

⑦ خطة التذاكر — Backend (Ahmed) + Frontend (Hazem)

6 تذاكر إجمالاً (3 backend + 3 frontend). لازم الـ backend يتعمل أولاً، بعدها الـ frontend بـ parallel.

Backend Tickets — يـ assign لـ Ahmed (admin, id=3)

B1
LIS-B1 — Add file result type + investigation file_settings
file
  • Enum case File + lang strings
  • Migration: file_settings JSON على lab_investigations
  • LabResult::attachments() morph relation + Resource enrichment
  • POST /lis/results/{id}/finalize-files + LabResultService::finalizeFiles()
  • Extend StoreAttachmentRequest للـ LabResult-scoped mime/size validation
  • Status-gate uploads (block after approved/released)
  • Permissions lis.results.upload-file + delete-file
  • Hook في reset() لـ soft-delete attachments
  • Feature tests
B2
LIS-B2 — Add culture result type + antibiotics master data
culture
  • Enum case Culture + lang strings
  • Migration: lab_antibiotics table; result_payload JSON على lab_results; culture_config JSON على lab_investigations
  • LabAntibiotic model + CRUD + Resource + Seeder CLSI
  • Casts و fillable updates
  • Validation rules في EnterLabResultRequest (و sibling receive-results requests): result_payload required لو investigation type = culture
  • LabResultService::enter() يقبل ?array $payload
  • Skip للـ abnormal flag/formula triggers لـ culture
  • Routes: apiResource('antibiotics', ...)
  • Permissions lis.antibiotics.view|manage
  • Feature tests (enter, validation, no-growth)
B3
LIS-B3 — Add histopathology result type + signoff workflow
histopath
  • Enum case Histopathology
  • Migration: lab_histopath_results table; flags requires_peer_review + requires_grossing على lab_investigations
  • LabHistopathResult model + LabResult::histopath() hasOne relation
  • Morphed Attachments للصور
  • 5 endpoints: PUT /histopath, POST /submit, POST /peer-review, POST /images, DELETE /images/{aid}
  • FormRequests + validation
  • LabResultService::enter() يـ dispatch للـ LabHistopathResultService الجديدة
  • Skip الـ histopath من kanban queries
  • 3 Permissions: histopath.draft|peer_review|signoff
  • Resource enrichment لما result_type === 'histopathology'
  • Factories + feature tests كاملة للـ flow

Frontend Tickets — Hazem (يبدأوا بعد ما الـ Backend يـ ship)

F1
LIS-F1 — File result type UI
file
  • Investigation form: إضافة file option + file_settings panel
  • New ResultFileCellComponent (upload, list, delete, thumbnails)
  • Wire في lis-results.component.ts, kanban result dialog, dept-worklist, validation-worklist
  • Patient portal — gallery + download
  • PDF reports — embed image thumbnails, list file names
  • Translation keys LIS.INVESTIGATIONS.RESULT_FILE, LIS.RESULTS.FILE_*
  • تحديث models LisInvestigation, LisResult
F2
LIS-F2 — Culture result type UI + Antibiotics CRUD
culture
  • New LisAntibioticService + model + CRUD screen features/lis/antibiotics/
  • إضافة culture في resultTypeOptions
  • Investigation form: Culture config tab (default antibiotics multiselect + incubation hours)
  • New CultureResultDialogComponent (shared): organisms array + AST grid + interpretation
  • Wire في kanban, validation-worklist, results page
  • Report rendering: per-organism AST table + S/I/R colored cells
  • Patient portal — نفس الـ renderer
  • Translation keys LIS.CULTURE.*
  • تحديث models
F3
LIS-F3 — Histopathology UI (dialog)
histopath
  • npm install quill@^2 + استخدام EditorModule
  • إضافة histopathology في resultTypeOptions
  • New HistopathResultDialogComponent (modal) — tabbed editor (Gross / Microscopic / Diagnosis / IHC / Images / Audit)
  • الـ dialog يفتح من نفس الأماكن اللي بيفتح منها result entry الحالي (kanban card، results page، dept-worklist) — مفيش route جديد، مفيش worklist جديد
  • Auto-save (signal-based) من داخل الـ dialog
  • Extend الـ 4 HTML report templates + PDF service بـ renderHistopath() sub-report
  • Patient portal viewer للـ histopath sub-report
  • Translation keys LIS.HISTOPATH.*
  • RTL CSS للـ tabs + gallery داخل الـ dialog

⑧ الترتيب الزمني والمخاطر

الترتيب الموصى به

Phase 1 — File (الأسهل)

~3-5 أيام backend + ~3-5 أيام frontend

الأسهل لأنه يـ reuse الـ attachments القائمة. لو نجح هنا، الـ infra الـ polymorphic بقت مختبرة قبل ما نـ depend عليها في الـ histopath.

Phase 2 — Culture

~5-7 أيام backend + ~5-7 أيام frontend

الجدول الجديد lab_antibiotics + الـ result_payload JSON pattern. الـ UI dialog منفصل فمكنش هياثر على kanban الموجود.

Phase 3 — Histopathology

~7-10 أيام backend + ~10-14 أيام frontend

الأصعب: جدول جديد، 5 endpoints، rich-text editor جديد، صفحة worklist جديدة، تعديل الـ 4 HTML report templates، patient portal sub-report. لازم يكون آخر phase.

المخاطر والـ Dependencies

المخاطرةالتأثيرالمنع
كسر الـ existing 5 types عند تعديل EnterLabResultRequest عالي regression tests كاملة قبل أي backend deploy + result_value يـ stay required للـ 5 types القديمة
الـ Quill peer dep تكبر الـ bundle بـ ~200KB متوسط lazy-load الـ histopath route + Quill imports — يـ trigger الـ download بس لما الباثولوجي يدخل
الـ patient portal عنده core.attachments.view permission gap عالي (vital — العميل مش هيقدر يـ download) يـ wire portal auth guard ليـ grant attachment-read أوتوماتيك لـ released results بتاع المريض
الـ Westgard QC و formula triggers يحاولوا تشغيل numeric checks على الأنواع الجديدة متوسط — يـ throw exceptions guard في LabResultService يـ skip لو result_type مش numeric|formula
الـ HTML report templates الـ 4 لازم كلهم يدعموا الـ renderHistopath عالي — لو واحد بس يشتغل، الـ user اللي مختار غيره يـ see broken layout shared helper function يـ reusable + visual regression test لكل template

القرارات اللي محتاجة موافقة قبل ما نبدأ

  1. Quill OK؟ الـ rich-text editor للـ histopath. لو لا، البديل markdown.
  2. الـ Antibiotic master data من سيد لـ CLSI ولا نسيب الـ admin يـ enter؟ هنا قرار workflow.
  3. الـ Pathology Worklist صفحة منفصلة، ولا نـ extend الـ kanban بـ "Pathology" section؟ تم الحسم: ميفيش worklist منفصل — الـ histopath في نفس الـ kanban زي أي نوع تاني.
  4. الـ Peer Review optional ولا required بـ default؟ الـ requires_peer_review flag يـ default false، الـ admin يـ enable لكل investigation.
  5. الـ Culture يدعم Panels؟ الـ recommendation: لا في v1، نـ add لاحقاً لو محتاج.