Skip to content

Quality Control (مراقبة الجودة)

Quality Control (QC) ensures analytical accuracy by running control materials with known values alongside patient samples. The LIS module supports QC lot management, result recording with Westgard rule evaluation, and Levey-Jennings chart data generation.

QC Lot Attributes

FieldTypeRequiredDescription
idintegerautoPrimary key
lot_numberstringyesManufacturer lot number
namestringyesLot name (English)
name_arstringnoLot name (Arabic)
investigation_idFKyesInvestigation this lot is for
manufacturerstringnoControl material manufacturer
expiry_datedatenoLot expiration date
target_meandecimal(12,4)yesExpected mean value
target_sddecimal(12,4)yesExpected standard deviation
unitstringnoMeasurement unit
levelintegernoQC level (1, 2, 3)
is_activebooleannoActive status (default: true)

QC Result Attributes

FieldTypeRequiredDescription
idintegerautoPrimary key
qc_lot_idFKyesParent QC lot
valuedecimal(12,4)yesMeasured QC value
sd_from_meandecimal(12,4)autoStandard deviations from mean
statusenumautopass, warning, fail
shiftenumnomorning, evening, night
violated_rulesJSONautoArray of violated Westgard rules
commenttextnoTechnician comment
performed_atdatetimeyesWhen the QC was run
performed_byFKyesUser who ran the QC
reviewed_byFKnoSupervisor who reviewed

ER Diagram

API Endpoints

MethodEndpointDescriptionPermission
GET/api/lis/qc-lotsList QC lotslis.qc-lots.view
POST/api/lis/qc-lotsCreate QC lotlis.qc-lots.create
GET/api/lis/qc-lots/{id}Get QC lot detailslis.qc-lots.view
PUT/api/lis/qc-lots/{id}Update QC lotlis.qc-lots.update
DELETE/api/lis/qc-lots/{id}Delete QC lotlis.qc-lots.delete
GET/api/lis/qc-lots/{id}/resultsList QC resultslis.qc-lots.view
POST/api/lis/qc-lots/{id}/resultsRecord QC resultlis.qc-lots.create
DELETE/api/lis/qc-lots/{id}/results/{rid}Delete QC resultlis.qc-lots.delete
GET/api/lis/qc-lots/{id}/levey-jenningsLevey-Jennings chart datalis.qc-lots.view

Request / Response Examples

Create QC Lot

bash
curl -X POST /api/lis/qc-lots \
  -H "Authorization: Bearer {token}" \
  -H "Content-Type: application/json" \
  -d '{
    "lot_number": "LOT-2026-001",
    "name": "Normal Control - Glucose",
    "name_ar": "مادة ضبط عادية - جلوكوز",
    "investigation_id": 5,
    "manufacturer": "Bio-Rad",
    "expiry_date": "2027-06-30",
    "target_mean": 95.0,
    "target_sd": 3.5,
    "unit": "mg/dL",
    "level": 1
  }'
dart
final response = await dio.post('/api/lis/qc-lots', data: {
  'lot_number': 'LOT-2026-001',
  'name': 'Normal Control - Glucose',
  'name_ar': 'مادة ضبط عادية - جلوكوز',
  'investigation_id': 5,
  'manufacturer': 'Bio-Rad',
  'expiry_date': '2027-06-30',
  'target_mean': 95.0,
  'target_sd': 3.5,
  'unit': 'mg/dL',
  'level': 1,
});

Record QC Result

bash
curl -X POST /api/lis/qc-lots/1/results \
  -H "Authorization: Bearer {token}" \
  -H "Content-Type: application/json" \
  -d '{
    "value": 97.2,
    "shift": "morning",
    "performed_at": "2026-03-01T08:30:00Z",
    "performed_by": 1
  }'
dart
final response = await dio.post('/api/lis/qc-lots/1/results', data: {
  'value': 97.2,
  'shift': 'morning',
  'performed_at': '2026-03-01T08:30:00Z',
  'performed_by': 1,
});

Get Levey-Jennings Data

bash
curl -G /api/lis/qc-lots/1/levey-jennings \
  -H "Authorization: Bearer {token}"
dart
final response = await dio.get('/api/lis/qc-lots/1/levey-jennings');

Westgard Rules

The system evaluates QC results against the following Westgard multi-rules:

RuleDescriptionStatus
1-2sSingle result exceeds mean +/- 2SDWarning
1-3sSingle result exceeds mean +/- 3SDFail
2-2sTwo consecutive results exceed mean +/- 2SD (same side)Fail
R-4sRange between two consecutive results exceeds 4SDFail
4-1sFour consecutive results on the same side of the mean beyond 1SDWarning
10xTen consecutive results on the same side of the meanFail

Business Rules

  1. SD calculation -- sd_from_mean is calculated as (value - target_mean) / target_sd.
  2. Automatic status -- QC status (pass, warning, fail) is set automatically based on Westgard rule evaluation.
  3. Violated rules -- The violated_rules JSON array lists which Westgard rules were triggered.
  4. Levey-Jennings -- The chart endpoint returns all data points with SD lines for visualization.
  5. Shift tracking -- QC results are tracked by shift (morning, evening, night) for trend analysis.

Moon ERP API Documentation