nbrain-egypt-uhis-fhir
# `nbrain-egypt-uhis-fhir` — Egypt Universal Health Insurance (UHIA / GAHAR) HL7 FHIR R4 & 14-Digit National ID SDK
Zero-dependency Python 3.10+ library, native Rust x64 binary, and **Model Context Protocol (MCP)** server engineered by **NBrain ([nbra.in](https://nbra.in))** & **Eng. Nadeem Mohamed Badr El-Din ([nadeembadr.com](https://nadeembadr.com))** — creators of **Nabd Masr** (94.99% Clinical Chest X-Ray AI spotlighted by the Egyptian Cabinet).
- **Live Zero-Signup Interactive Web Lab:** <https://nbra.in/tools/egypt-uhis-fhir>
- **Live Remote Streamable-HTTP MCP Endpoint:** `https://nbra.in/mcp`
## Core Capabilities
1. **14-Digit Egyptian National ID (`الرقم القومي المصري`) Decoder & Verifier:**
- Normalizes Arabic-Indic (`٠-٩`) and ASCII digits automatically.
- Extracts & validates **Century (`2`=1900s, `3`=2000s)**, **Exact Gregorian Birthdate (including leap years)**, **27 Official Ministry of Interior Governorate Codes + `88` Born Abroad** (bilingual Arabic/English), **Gender (`digit 13` parity)**, and **Weighted Modulo-11 Checksum (`[2,7,6,5,4,3,2,7,6,5,4,3,2]`)** with configurable `strict_checksum` mode.
2. **Egypt UHIA / EHA / GAHAR HL7 FHIR R4 Bundle Validator:**
- Validates `Patient` (`http://uhia.gov.eg/identifier/national-id` & UHIA family enrollment),
- Validates `DiagnosticReport` (LOINC `36643-5` Chest X-Ray & GAHAR National Safety Goal critical-finding notification timestamps),
- Validates `Claim` with exact `Decimal` EGP piastres (`ROUND_HALF_UP`) line totals, UHIA copayment rules, and **Egyptian Drug Authority (EDA) GS1 GTIN-14** modulo-10 checksums (`float` inputs raise `TypeError`).
## Supply-Chain Safe Installation (Direct Verified Git Tag or GHCR)
To prevent package-registry name-squatting attacks, install directly from the canonical signed GitHub tag or container:
```bash
pip install "git+https://github.com/NBrain-Studio/nbrain-egypt-uhis-fhir.git@v1.0.0"
# Or run via Docker GHCR:
docker run -i --rm ghcr.io/nbrain-studio/nbrain-egypt-uhis-fhir:1.0.0
```
## License
MIT © 2026 Eng. Nadeem Mohamed Badr El-Din & NBrain (`https://nbra.in`).
TDQS
Scored across 4 tools
Each tool targets a clearly distinct artifact: a national ID, a FHIR bundle, a GTIN-14 barcode, or sample generation. The only mild overlap is that validate_egypt_uhis_gahar_fhir_bundle internally re-checks National ID and GTIN-14 data, so an agent might occasionally ponder whether to validate a barcode standalone or via the bundle validator. Verbs (decode/validate/generate) plus distinct object nouns keep them separable.
All four tools use snake_case with a consistent verb_noun structure (decode_..., validate_..., validate_..., generate_...). Domain prefixes (egypt_uhis, egypt_eda_gtin14, egypt_14digit_national_id) are applied consistently, making names predictable and scannable.
Four tools is a tight, focused surface appropriate for a narrow validation/utility domain, well within the 3-15 sweet spot. It sits at the low end, so a little more coverage (e.g., encoding or standalone resource validation) would round it out.
The core validation lifecycle is present: decode IDs, validate barcodes, validate bundles, and generate a sample bundle. However, there are notable gaps: no National ID or GTIN-14 generator/encoder, only one sample bundle type (Chest X-Ray), and no validation of individual FHIR resources outside a full bundle, which could cause dead ends for some agent workflows.