Statutory Reporting

National Statutory Reporting & Regulatory Compliance Architecture

1. Statutory Reporting Topology & Interceptor Pipelines

The HMIS handles statutory data collection implicitly at the point of clinical entry. Rather than running slow end-of-month batch operations, clinical events trigger real-time, event-driven tracking hooks. These hooks extract, sanitize, anonymize, and package key data points for regulatory endpoints.

Rendering Chart

1.1 Mandatory Regulatory Deliverables

The platform supports reporting for four primary regulatory systems, balancing statutory requirements with patient privacy protections:

Target SystemReport ReferenceData GranularityFrequencySecurity / Privacy Profile
Kenya Health Information System (KHIS)MoH 705A (Under 5) & MoH 705B (Over 5)Fully Anonymized Aggregates (Tallies by ICD-11 Class)Monthly (Before 5th Day)Zero Personal Identifiable Information (PII). Plain integer counts per morbidity category.
Ministry of Health (MoH)MoH 711 (Integrated Reproductive Health)Aggregated Operational IndicatorsMonthly (Before 5th Day)Anonymized summaries of deliveries, immunizations, and family planning metrics.
National Syndromic SurveillanceOutbreak Alert PipelinePseudo-Anonymized Case BundlesReal-time (Within 2 hours of clinical suspicion)Redacted PII. Includes broad geographical indicators (Sub-County/Ward level) and age groups for immediate epidemic response.
Kenya National Data Highway (KNDH)Standard Shared Care RecordsDe-identified Longitudinal FHIR JSON BlocksTransactional (Upon patient discharge)Cryptographically masked names and national IDs. Retains Unique Health Identifiers (UHI/NUPI) for patient matching across facilities.

2. Automated MoH 705A Morbidity Tally Compilation

The system aggregates daily outpatient morbidity data using asynchronous background tasks. This approach keeps slow analytical database queries out of the primary clinical loop.

2.1 Asynchronous Aggregator Task Implementation

The extraction worker runs every midnight to compile disease tallies directly from the day's finalized clinical consultations.

# apps/reporting/tasks.py
from huey.contrib.djhuey import periodic_task
from huey import crontab
from django.db.models import Count
from django.utils import timezone
from datetime import timedelta
from apps.clinical.models import ClinicalConsultation
from apps.reporting.models import StatutoryMorbidityLog

@periodic_task(crontab(minute='0', hour='1'))  # Runs daily at 1:00 AM
def generate_daily_moh705a_tallies() -> str:
    """
    Compiles daily outpatient diagnostic tallies for children under 
    5 years old based on standardized ICD-11 taxonomy classifications.
    """
    yesterday = timezone.now().date() - timedelta(days=1)
    
    # Query clinical entries filtered by age (under 5 years) and visit date
    morbidity_aggregates = (
        ClinicalConsultation.objects.filter(
            encounter__patient__date_of_birth__gte=yesterday - timedelta(days=5*365),
            encounter__visit_start_time__date=yesterday
        )
        .values('primary_icd11_code', 'encounter__patient__gender')
        .annotate(total_cases=Count('id'))
    )
    
    # Store aggregated records inside the statutory log cache table
    records_created = 0
    for record in morbidity_aggregates:
        StatutoryMorbidityLog.objects.update_or_create(
            report_type='MOH705A',
            log_date=yesterday,
            icd11_code=record['primary_icd11_code'],
            gender=record['encounter__patient__gender'],
            defaults={'case_count': record['total_cases']}
        )
        records_created += 1
        
    return f"Successfully compiled {records_created} MoH 705A tally links for {yesterday}."

3. Data Protection, Minimization, and De-identification Standards

Under the Kenya Data Protection Act (2019), sharing clinical information with national systems requires strict data minimization and de-identification pipelines.

Rendering Chart

3.1 De-identification Implementation Rules

  • Direct Identifier Suppression: Patient names, physical addresses, next of kin information, and full phone numbers are stripped from all statutory exports.
  • Date Truncation & Coarsening: Specific birth dates are removed and replaced with broad age ranges (e.g., 0-28 days, 1-11 months, 1-4 years, 5-14 years, 15+ years) unless explicitly required by public health law for tracking communicable outbreaks.
  • Cryptographic Pseudonymization: If an upstream longitudinal link is required (such as KNDH tracking), the cleartext identity card number or National Unique Patient Identifier (NUPI) is converted into an irreversible, salted cryptographic token:

$$\text{Pseudonym} = \text{HMAC-SHA256}(\text{NUPI String}, \text{Facility Salt Key})$$

3.2 Secure Transmission Protocol

All outbound payloads are signed using the facility’s private cryptographic certificate, encrypted using TLS 1.3, and tracked via an audit ledger table labeled statutory_transmission_audits. This tracking allows for compliance reviews and data verification checks.

Document Verification Block

Author: Ian Wataka - Backend DeveloperTarget Scope: KHIS (DHIS2), MoH Registries, and Data Protection Alignment