Skip to content

feat(medical): add a medical module#3949

Open
rodrigobnogueira wants to merge 4 commits into
faker-js:nextfrom
rodrigobnogueira:feat/medical-module
Open

feat(medical): add a medical module#3949
rodrigobnogueira wants to merge 4 commits into
faker-js:nextfrom
rodrigobnogueira:feat/medical-module

Conversation

@rodrigobnogueira

@rodrigobnogueira rodrigobnogueira commented Jul 11, 2026

Copy link
Copy Markdown

Description

Adds a new faker.medical module — the request in #2309. It generates plausible, non-clinical healthcare data for tests, demos, and fixtures:

Method Example
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:

  • Real diagnosis codes (e.g. ICD-10) — WHO-copyrighted and not "plausible" data.
  • Real medicine names in generated drugsdrugName() 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.
  • Note on 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.
  • Correlated composites (full patient records) — methods stay atomic; correlation is left to the user.

Notes

  • English locale data only for now — curated, deduped, and sorted.
  • Tests, snapshots, and JSDoc (@example, @since 10.6.0) included; ts-check, lint, test, and build are green locally.
  • The vocabulary was reshaped from an existing Python Faker healthcare provider to fit the constraints above.

Happy to adjust scope or naming (medical vs health) — feedback welcome.

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
@rodrigobnogueira
rodrigobnogueira requested a review from a team as a code owner July 11, 2026 23:13
@netlify

netlify Bot commented Jul 11, 2026

Copy link
Copy Markdown

Deploy Preview for fakerjs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 741c09a
🔍 Latest deploy log https://app.netlify.com/projects/fakerjs/deploys/6a5416d83d59c50008ef6be1
😎 Deploy Preview https://deploy-preview-3949.fakerjs.dev
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Jul 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.92%. Comparing base (bd561fb) to head (741c09a).

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           
Files with missing lines Coverage Δ
src/faker.ts 100.00% <100.00%> (ø)
src/locales/en/index.ts 100.00% <ø> (ø)
src/locales/en/medical/index.ts 100.00% <100.00%> (ø)
src/modules/medical/module.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

- 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
Comment thread src/modules/medical/module.ts Outdated
Comment thread src/modules/medical/module.ts Outdated
@ST-DDT ST-DDT added c: feature Request for new feature p: 1-normal Nothing urgent s: pending triage Pending Triage labels Jul 12, 2026
@ST-DDT

ST-DDT commented Jul 12, 2026

Copy link
Copy Markdown
Member

Are you familiar with the medical sector?

@Shinigami92

Copy link
Copy Markdown
Member

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.
@rodrigobnogueira

rodrigobnogueira commented Jul 12, 2026

Copy link
Copy Markdown
Author

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 faker-healthcare-provider to a typescript package. Then I found this issue #2309 , so I gave up the idea of a new package and opened this PR. Hope it helps 🙏

rodrigobnogueira added a commit to rodrigobnogueira/faker-healthcare-provider that referenced this pull request Jul 12, 2026
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 ST-DDT left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good implementation wise.
I have no knowledge in the medical domain.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 MedicalModule with eight methods wired into Faker.
  • Adds English locale definitions for the new medical category 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.

Comment thread src/locales/en/medical/allergen.ts
Comment thread src/locales/en/medical/allergen.ts
Comment thread src/locales/en/medical/allergen.ts
Comment thread src/locales/en/medical/allergen.ts
Comment thread test/modules/medical.spec.ts
@ST-DDT ST-DDT linked an issue Jul 13, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: feature Request for new feature p: 1-normal Nothing urgent s: pending triage Pending Triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add medical module

5 participants