feat(medical): add a medical module#3949
Conversation
Adds `faker.medical` with plausible, non-clinical healthcare data for tests, demos, and fixtures: specialty, department, condition, symptom, procedure, allergen, bloodType, and a fictitious drugName. Scoped to Faker's plausible-not-real policy per the discussion in faker-js#2309: real diagnosis codes (ICD-10), real medicine names, and correlated patient records are deliberately excluded. drugName() assembles invented brand-style names from morphemes and avoids real WHO INN stems, so it can never resemble a real drug. English locale data; tests, snapshots, and JSDoc included. Ref faker-js#2309
✅ Deploy Preview for fakerjs ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## next #3949 +/- ##
=======================================
Coverage 98.91% 98.92%
=======================================
Files 923 925 +2
Lines 3224 3242 +18
Branches 586 568 -18
=======================================
+ Hits 3189 3207 +18
Misses 31 31
Partials 4 4
🚀 New features to boost your workflow:
|
- add generated docs/.vitepress/api-pages.ts and regenerate the typed en/medical locale index (fixes the Check Code Generation job) - symptom: drop non-symptom trigger/modifier entries (Exercise, Laughing, Lifting, Relief with Movement, Worsening at Night, Tolerance), exact plural duplicates (Headaches, Red Patches, Sleep Disturbances), and entries duplicating the condition list (Anemia, Hyperlipidemia); clarify Frequency/Urgency as Urinary Frequency/Urinary Urgency - specialty: use Allergy and Immunology; add Anesthesiology, Emergency Medicine, Family Medicine, Neurosurgery, Pathology, Plastic Surgery, Radiology - procedure: replace the trademarked Botox Injection with Botulinum Toxin Injection - condition: use a literal ö in Sjögren's Syndrome - drug morphemes: swap pex/zia/se/ga for plex/vex/so/go so no generated name can contain an unfortunate substring; the full 31,500-name space is verified free of real brand names and WHO INN generics
|
Are you familiar with the medical sector? |
Looks like he is the maintainer of https://github.com/rodrigobnogueira/faker-healthcare-provider 👀 |
…tic list Per review feedback: drugName() now draws from a pre-generated drug_name locale array (250 names built once from the morphemes and screened against real brand names, WHO INN generic names, and INN class stems), instead of assembling names at runtime with a retry loop. The four morpheme definition keys are gone and the module reads like every other array-backed method. Also trims the class-level overview to not enumerate every method.
|
Software engineer, not a clinician 😄 — no clinical authority claimed. This module was deliberately scoped so nothing in it depends on clinical judgment — curated vocabulary only, no codes, no real medicines. I was starting a repo to port the python |
The fictitious brand generator could form names containing offensive substrings (256 of the 31,500 possible names): infix na + suffix zia and prefixes ending ra + suffix pex among others. Swap suffixes pex->plex and zia->vex, infixes se->so and ga->go, mirroring the fix already shipped in the TypeScript port (faker-js/faker#3949). Re-verified across the full 31,500-name space: zero offensive substrings (28-term list), zero collisions with shipped INN generics or well-known real brands, forbidden-ending retry trigger unchanged. zh_CN inherits the base generator, so all six locales are covered. Bump 2.3.0 -> 2.3.1.
ST-DDT
left a comment
There was a problem hiding this comment.
Looks good implementation wise.
I have no knowledge in the medical domain.
There was a problem hiding this comment.
Pull request overview
Adds a new faker.medical module to generate plausible, non-clinical healthcare terms (specialties, departments, conditions, symptoms, procedures, allergens, blood types, and fictitious drug names), with English locale data and API docs integration.
Changes:
- Introduces
MedicalModulewith eight methods wired intoFaker. - Adds English locale definitions for the new
medicalcategory plus type definitions and locale generation wiring. - Adds module tests/snapshots and updates API docs navigation/completeness snapshots.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| test/scripts/apidocs/snapshots/verify-jsdoc-tags.spec.ts.snap | Registers medical module/methods in JSDoc completeness snapshot. |
| test/modules/medical.spec.ts | Adds module-level tests for faker.medical.*. |
| test/modules/snapshots/medical.spec.ts.snap | Adds seeded snapshot outputs for medical. |
| src/modules/medical/module.ts | Implements MedicalModule methods + JSDoc. |
| src/modules/medical/index.ts | Barrel export for the module. |
| src/locales/en/medical/allergen.ts | Adds English allergen vocabulary. |
| src/locales/en/medical/blood_type.ts | Adds blood type vocabulary. |
| src/locales/en/medical/condition.ts | Adds condition vocabulary. |
| src/locales/en/medical/department.ts | Adds department vocabulary. |
| src/locales/en/medical/drug_name.ts | Adds fictitious drug name vocabulary. |
| src/locales/en/medical/procedure.ts | Adds procedure vocabulary. |
| src/locales/en/medical/specialty.ts | Adds specialty vocabulary. |
| src/locales/en/medical/symptom.ts | Adds symptom vocabulary. |
| src/locales/en/medical/index.ts | Aggregates medical locale definitions for en. |
| src/locales/en/index.ts | Wires medical into the en locale definition. |
| src/index.ts | Exports MedicalModule type from the public entrypoint. |
| src/faker.ts | Instantiates/exposes faker.medical. |
| src/definitions/medical.ts | Adds MedicalDefinition type. |
| src/definitions/index.ts | Re-exports MedicalDefinition. |
| src/definitions/definitions.ts | Adds optional medical to LocaleDefinition. |
| scripts/generate-locales.ts | Registers medical for locale generation typing. |
| docs/.vitepress/api-pages.ts | Adds Medical to the API docs sidebar. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Description
Adds a new
faker.medicalmodule — the request in #2309. It generates plausible, non-clinical healthcare data for tests, demos, and fixtures:specialty()'Cardiology'department()'Emergency Department'condition()'Type 2 Diabetes'(name only, no code)symptom()'Shortness of Breath'procedure()'Appendectomy'allergen()'Penicillin'bloodType()'O+'drugName()'Zolpraxen'(generated, fictitious)Scoped to Faker's "plausible, not real" policy
Following the discussion in #2309 (thanks @ST-DDT / @matthewmayer), I deliberately excluded:
drugName()assembles invented brand-style names from morphemes chosen to avoid real WHO INN stems (e.g.-statin,-pril), so a generated name reads as clearly invented (per @matthewmayer's point about fictitious medicines). The spec pins every value to the curated locale dataset, which is fictitious by construction.allergen()— the allergen vocabulary intentionally names real substances (foods, environmental triggers, and medicines such as penicillin), drawn from commonly available public lists of frequent allergens: an allergen field describes what a person reacts to, so real names make the data more meaningful there. The fictitious rule applies to generated medication names, not to this descriptive vocabulary.Notes
@example,@since 10.6.0) included;ts-check,lint,test, andbuildare green locally.Happy to adjust scope or naming (
medicalvshealth) — feedback welcome.