@softspark/ai-toolkit 2.7.2 → 2.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/llms-full.txt CHANGED
@@ -43,6 +43,7 @@
43
43
  - [Manifest-Driven Install System](kb/reference/manifest-install.md)
44
44
  - [MCP Editor Compatibility](kb/reference/mcp-editor-compatibility.md)
45
45
  - [MCP Server Templates](kb/reference/mcp-templates.md)
46
+ - [Medplum Documentation Map](kb/reference/medplum-docs-map.md)
46
47
  - [Merge-Friendly Install Model](kb/reference/merge-friendly-install-model.md)
47
48
  - [AI Toolkit - opencode Compatibility](kb/reference/opencode-compatibility.md)
48
49
  - [Plugin Pack Conventions](kb/reference/plugin-pack-conventions.md)
@@ -7633,14 +7634,14 @@ tags: [rules, languages, coding-style, testing, patterns, security]
7633
7634
  version: "1.0.0"
7634
7635
  created: "2026-04-07"
7635
7636
  last_updated: "2026-04-07"
7636
- description: "Reference for the language-specific rules system: 13 languages, 5 categories per language, auto-detection."
7637
+ description: "Reference for the language-specific rules system: 14 languages, 5 categories per language, auto-detection."
7637
7638
  ---
7638
7639
 
7639
7640
  # Language Rules System
7640
7641
 
7641
7642
  ## Overview
7642
7643
 
7643
- ai-toolkit ships language-specific rule files covering 13 programming languages plus a common set (see README.md for current count). Rules are plain Markdown files injected into `CLAUDE.md` via `ai-toolkit install --local`. They provide coding-style, testing, patterns, frameworks, and security guidance specific to each language.
7644
+ ai-toolkit ships language-specific rule files covering 14 languages/platforms plus a common set (see README.md for current count). Rules are plain Markdown files injected into `CLAUDE.md` via `ai-toolkit install --local`. They provide coding-style, testing, patterns, frameworks, and security guidance specific to each language.
7644
7645
 
7645
7646
  Rules are distinct from skills: rules are injected as static text into `CLAUDE.md` and are always visible to Claude, whereas skills are loaded contextually by agents.
7646
7647
 
@@ -7675,10 +7676,11 @@ app/rules/
7675
7676
  ├── csharp/
7676
7677
  ├── php/
7677
7678
  ├── cpp/
7678
- └── ruby/
7679
+ ├── ruby/
7680
+ └── medplum/
7679
7681
  ```
7680
7682
 
7681
- **Total: 13 directories × 5 files each + 3 standalone = 68 rule files** (see README.md for canonical count)
7683
+ **Total: 14 directories × 5 files each + 3 standalone = 73 rule files** (see README.md for canonical count)
7682
7684
 
7683
7685
  ## Supported Languages
7684
7686
 
@@ -7697,6 +7699,7 @@ app/rules/
7697
7699
  | PHP | `rules/php/` | `composer.json` |
7698
7700
  | C++ | `rules/cpp/` | `CMakeLists.txt`, `Makefile`, `*.cpp` |
7699
7701
  | Ruby | `rules/ruby/` | `Gemfile`, `*.gemspec` |
7702
+ | Medplum | `rules/medplum/` | `medplum.config.mts`, `medplum.config.ts` |
7700
7703
 
7701
7704
  ## Rule Categories
7702
7705
 
@@ -7734,6 +7737,7 @@ Scans for configuration files defined in each module's `auto_detect` list in `ma
7734
7737
  10. `Package.swift` → Swift
7735
7738
  11. `*.csproj` or `*.sln` → C#
7736
7739
  12. `CMakeLists.txt` or `Makefile` → C++
7740
+ 13. `medplum.config.mts` or `medplum.config.ts` → Medplum
7737
7741
 
7738
7742
  ### Phase 2: Source file extensions (actual code presence)
7739
7743
 
@@ -7790,6 +7794,7 @@ Language rules are tracked as modules in `manifest.json`:
7790
7794
  | `rules-php` | PHP-specific rules |
7791
7795
  | `rules-cpp` | C++-specific rules |
7792
7796
  | `rules-ruby` | Ruby-specific rules |
7797
+ | `rules-medplum` | Medplum/FHIR healthcare platform rules |
7793
7798
 
7794
7799
  ## Rules vs Skills
7795
7800
 
@@ -8187,6 +8192,546 @@ export GITHUB_PERSONAL_ACCESS_TOKEN=ghp_...
8187
8192
 
8188
8193
  ---
8189
8194
 
8195
+ ## kb/reference/medplum-docs-map.md
8196
+
8197
+ ---
8198
+ title: "Medplum Documentation Map"
8199
+ category: reference
8200
+ service: ai-toolkit
8201
+ tags: [medplum, fhir, healthcare, ehr, sdk, api, clinical, interoperability]
8202
+ version: "1.0.0"
8203
+ created: "2026-04-17"
8204
+ last_updated: "2026-04-17"
8205
+ description: "Comprehensive navigable index of Medplum documentation covering SDK, FHIR resources, clinical workflows, security, integrations, and terminology."
8206
+ ---
8207
+
8208
+ # Medplum Documentation Map
8209
+
8210
+ ## Overview
8211
+
8212
+ Medplum is an open-source healthcare platform built on FHIR R4. It provides a FHIR-compliant datastore, TypeScript SDK, React component library, bot automation engine, and compliance infrastructure (HIPAA, SOC2, HITRUST).
8213
+
8214
+ | Item | Value |
8215
+ |------|-------|
8216
+ | Docs | `https://www.medplum.com/docs/` |
8217
+ | API Base | `https://api.medplum.com/fhir/R4/` |
8218
+ | App | `https://app.medplum.com/` |
8219
+ | Storybook | `https://storybook.medplum.com/` |
8220
+ | GraphiQL | `https://graphiql.medplum.com/` |
8221
+
8222
+ ### Key Packages
8223
+
8224
+ | Package | Purpose |
8225
+ |---------|---------|
8226
+ | `@medplum/core` | SDK client, FHIR helpers, FHIRPath, HL7 parsing |
8227
+ | `@medplum/fhirtypes` | TypeScript type definitions for all FHIR R4 resources |
8228
+ | `@medplum/react` | React UI components (Mantine 7+, React 18+) |
8229
+ | `@medplum/mock` | MockClient for unit testing |
8230
+ | `@medplum/cli` | Command-line interface for FHIR operations |
8231
+
8232
+ ---
8233
+
8234
+ ## Documentation Sections
8235
+
8236
+ | Section | Path | Description |
8237
+ |---------|------|-------------|
8238
+ | FHIR Basics | `/docs/fhir-basics` | Resources, references, search, CodeableConcepts, identifiers, ValueSets, Subscriptions |
8239
+ | FHIR Datastore | `/docs/fhir-datastore` | CRUD, binary data, batch requests, profiles, history, deduplication, USCDI |
8240
+ | Search | `/docs/search` | Basic search, advanced parameters, `_filter`, pagination, `_include`/`_revinclude`, chaining |
8241
+ | Terminology | `/docs/terminology` | CodeSystem, ValueSet, ConceptMap operations; LOINC, SNOMED, ICD-10 |
8242
+ | GraphQL | `/docs/graphql` | Queries, mutations, connections, nested resolution, reverse references, array filtering |
8243
+ | React Components | `/docs/react` | MedplumProvider, hooks, Mantine integration, tree-shaking, useSubscription |
8244
+ | Analytics | `/docs/analytics` | Analytics and reporting capabilities |
8245
+ | Auth | `/docs/auth` | OAuth2 flows, client credentials, external IDPs, Google, mTLS, MFA, token exchange, sessions |
8246
+ | User Management | `/docs/user-management` | Project vs server users, registration, invitations |
8247
+ | Access Control | `/docs/access` | Access policies, compartments, SMART scopes, IP rules, multi-tenant, field-level control |
8248
+ | AI | `/docs/ai` | AI operations, AWS integration, MCP server |
8249
+ | Bots | `/docs/bots` | Bot basics, cron jobs, questionnaire handlers, Lambda layers, secrets, webhooks, HL7, PDFs, unit testing |
8250
+ | Subscriptions | `/docs/subscriptions` | Event-driven notifications, WebSocket, webhook resending |
8251
+ | CLI | `/docs/cli` | Command-line FHIR operations, external servers |
8252
+ | Integrations | `/docs/integration` | DoseSpot, Health Gorilla, Stedi, Candid Health, eFax, HL7, FHIRcast, SMART, CDS Hooks, C-CDA |
8253
+ | Agent | `/docs/agent` | On-prem agent for HL7/DICOM bridging |
8254
+ | Self-Hosting | `/docs/self-hosting` | Self-hosted deployment |
8255
+ | Compliance | `/docs/compliance` | HIPAA, SOC2, HITRUST, ONC, CLIA/CAP, CFR11, GMP, ISO9001 |
8256
+ | API Reference | `/docs/api` | REST endpoints, FHIR resources (150+), operations (40+), datatypes (40+), Medplum custom resources |
8257
+ | SDK Reference | `/docs/sdk/core` | MedplumClient, utility functions, interfaces, types |
8258
+
8259
+ ---
8260
+
8261
+ ## Clinical Workflows
8262
+
8263
+ | Workflow | Path | Key Resources |
8264
+ |----------|------|---------------|
8265
+ | Intake & Registration | `/docs/intake` | Patient, QuestionnaireResponse, Encounter |
8266
+ | Charting | `/docs/charting` | Condition, AllergyIntolerance, Observation (vitals), DocumentReference |
8267
+ | Scheduling | `/docs/scheduling` | Schedule, Slot, Appointment, AppointmentResponse |
8268
+ | Labs & Imaging | `/docs/labs-imaging` | ServiceRequest, DiagnosticReport, Observation, ImagingStudy |
8269
+ | Medications | `/docs/medications` | MedicationRequest, Medication, MedicationAdministration |
8270
+ | Care Plans | `/docs/careplans` | CarePlan, CareTeam, Task, PlanDefinition, Goal |
8271
+ | Communications | `/docs/communications` | Communication, CommunicationRequest (threads, messaging, SMS) |
8272
+ | Billing | `/docs/billing` | Claim, Coverage, ExplanationOfBenefit, ChargeItem |
8273
+
8274
+ ### Clinical Configuration
8275
+
8276
+ | Feature | Path | Resources |
8277
+ |---------|------|-----------|
8278
+ | Provider Directory | `/docs/administration/provider-directory` | Practitioner, PractitionerRole, Organization, Location |
8279
+ | Questionnaires | `/docs/questionnaires` | Questionnaire, QuestionnaireResponse, SDC extensions |
8280
+ | Diagnostic Catalog | `/docs/careplans/diagnostic-catalog` | CodeSystem, ValueSet (LOINC panels) |
8281
+ | Clinical Protocols | `/docs/careplans/protocols` | PlanDefinition, ActivityDefinition |
8282
+
8283
+ ---
8284
+
8285
+ ## SDK Reference — MedplumClient
8286
+
8287
+ ### CRUD Operations
8288
+
8289
+ | Method | Description |
8290
+ |--------|-------------|
8291
+ | `createResource(resource)` | Create new FHIR resource (server assigns ID) |
8292
+ | `readResource(resourceType, id)` | Read resource by type and ID |
8293
+ | `updateResource(resource)` | Update existing resource (must include ID) |
8294
+ | `patchResource(resourceType, id, operations)` | Apply JSON Patch operations |
8295
+ | `deleteResource(resourceType, id)` | Delete resource by type and ID |
8296
+ | `upsertResource(resource, query)` | Atomic create-or-update via search query |
8297
+ | `createResourceIfNoneExist(resource, query)` | Conditional create if no match found |
8298
+
8299
+ ### Search
8300
+
8301
+ | Method | Description |
8302
+ |--------|-------------|
8303
+ | `search(resourceType, query)` | Execute FHIR search, returns Bundle |
8304
+ | `searchResources(resourceType, query)` | Returns resource array (unwrapped Bundle) |
8305
+ | `searchOne(resourceType, query)` | Returns first matching resource |
8306
+ | `searchResourcePages(resourceType, query)` | Async generator for paginated results |
8307
+ | `fhirSearchUrl(resourceType, query)` | Build search URL from parameters |
8308
+
8309
+ ### Authentication
8310
+
8311
+ | Method | Description |
8312
+ |--------|-------------|
8313
+ | `startLogin(loginRequest)` | Initiate user login flow |
8314
+ | `startClientLogin(clientId, clientSecret)` | OAuth2 client credentials flow |
8315
+ | `startGoogleLogin(loginRequest)` | Google Sign-In authentication |
8316
+ | `setAccessToken(accessToken, refreshToken)` | Manually set auth tokens |
8317
+ | `setBasicAuth(clientId, clientSecret)` | Configure basic auth |
8318
+ | `signOut()` | Revoke token and clear cache |
8319
+ | `isAuthenticated(gracePeriod)` | Check current auth status |
8320
+ | `getProfile()` | Get current user profile (sync) |
8321
+ | `getProfileAsync()` | Get current user profile (async fetch) |
8322
+
8323
+ ### Advanced Operations
8324
+
8325
+ | Method | Description |
8326
+ |--------|-------------|
8327
+ | `executeBatch(bundle)` | Process batch or transaction Bundle |
8328
+ | `executeBot(id, body, contentType)` | Run bot by ID or Identifier |
8329
+ | `graphql(query, operationName, variables)` | Execute GraphQL queries |
8330
+ | `readHistory(resourceType, id)` | Get all resource versions |
8331
+ | `readPatientEverything(id)` | Patient $everything operation |
8332
+ | `validateResource(resource)` | Validate resource against profiles |
8333
+ | `valueSetExpand(params)` | Expand ValueSet for code lookups |
8334
+ | `readResourceGraph(resourceType, id, graphName)` | Fetch linked resources via $graph |
8335
+
8336
+ ### Media & Files
8337
+
8338
+ | Method | Description |
8339
+ |--------|-------------|
8340
+ | `createBinary(data, filename, contentType)` | Create Binary resource from data |
8341
+ | `createAttachment(data, filename, contentType)` | Create Attachment element with Binary |
8342
+ | `createPdf(docDefinition, filename)` | Generate PDF as Binary (pdfmake) |
8343
+ | `uploadMedia(contents, contentType, filename)` | Upload and create Media resource |
8344
+ | `download(url)` | Download URL as blob |
8345
+
8346
+ ### Subscriptions & Real-time
8347
+
8348
+ | Method | Description |
8349
+ |--------|-------------|
8350
+ | `subscribeToCriteria(criteria, props)` | Subscribe to WebSocket notifications |
8351
+ | `unsubscribeFromCriteria(criteria, props)` | Unsubscribe from criteria |
8352
+ | `getSubscriptionManager()` | Access WebSocket subscription manager |
8353
+
8354
+ ---
8355
+
8356
+ ## SDK Utility Functions
8357
+
8358
+ | Function | Description |
8359
+ |----------|-------------|
8360
+ | `createReference(resource)` | Create a FHIR Reference from a resource |
8361
+ | `getReferenceString(resource)` | Get `ResourceType/id` string |
8362
+ | `getDisplayString(resource)` | Human-readable display for any resource |
8363
+ | `formatHumanName(name)` | Format FHIR HumanName as string |
8364
+ | `formatAddress(address)` | Format FHIR Address as string |
8365
+ | `formatCodeableConcept(cc)` | Format CodeableConcept as string |
8366
+ | `formatDate(date)` | Format FHIR date as human-readable |
8367
+ | `formatDateTime(dateTime)` | Format FHIR dateTime as human-readable |
8368
+ | `formatQuantity(quantity)` | Human-readable Quantity string |
8369
+ | `getCodeBySystem(cc, system)` | Find code for a given system in CodeableConcept |
8370
+ | `setCodeBySystem(cc, system, code)` | Set code for a given system |
8371
+ | `getIdentifier(resource, system)` | Get identifier value for a system |
8372
+ | `setIdentifier(resource, system, value)` | Set identifier for a system |
8373
+ | `getExtension(resource, urls)` | Get extension by URL |
8374
+ | `getExtensionValue(resource, urls)` | Get extension value by URL |
8375
+ | `parseReference(ref)` | Parse reference string to ResourceType/ID |
8376
+ | `resolveId(reference)` | Extract ID from reference |
8377
+ | `isResource(value)` | Type guard for FHIR resource |
8378
+ | `isReference(value)` | Type guard for FHIR Reference |
8379
+ | `deepClone(value)` | Deep clone a FHIR resource |
8380
+ | `deepEquals(a, b)` | Compare resources (ignoring versionId) |
8381
+ | `normalizeOperationOutcome(error)` | Normalize error to OperationOutcome |
8382
+ | `normalizeErrorString(error)` | Normalize error to displayable string |
8383
+ | `getQuestionnaireAnswers(response)` | Extract answers as map by linkId |
8384
+ | `evalFhirPath(expression, resource)` | Evaluate FHIRPath expression |
8385
+ | `validateResource(resource)` | Validate against StructureDefinition |
8386
+ | `generateId()` | Cross-platform UUID generator |
8387
+
8388
+ ---
8389
+
8390
+ ## FHIR Search Syntax
8391
+
8392
+ ### Parameter Types
8393
+
8394
+ | Type | Behavior | Example |
8395
+ |------|----------|---------|
8396
+ | `string` | Case-insensitive prefix match | `name=eve` matches Eve, Evelyn |
8397
+ | `token` | Exact match, supports system namespace | `identifier=http://sys\|val` |
8398
+ | `date` | Supports comparison prefixes | `birthdate=1940-03-29` |
8399
+ | `reference` | Links to other resources | `subject=Patient/123` |
8400
+ | `quantity` | Numeric with units | `value-quantity=gt40` |
8401
+ | `number` | Plain numeric | `probability=gt0.8` |
8402
+
8403
+ ### Operators
8404
+
8405
+ | Operator | Syntax | Example |
8406
+ |----------|--------|---------|
8407
+ | AND | Multiple parameters | `name=Simpson&birthdate=1940-03-29` |
8408
+ | OR | Comma-separated | `status=completed,cancelled` |
8409
+
8410
+ ### Modifiers
8411
+
8412
+ | Modifier | Purpose | Example |
8413
+ |----------|---------|---------|
8414
+ | `:not` | Exclude values | `status:not=completed` |
8415
+ | `:missing` | Include/exclude absent params | `birthdate:missing=true` |
8416
+ | `:contains` | Substring match (string only) | `name:contains=eve` |
8417
+ | `:exact` | Case-sensitive exact match | `name:exact=Eve` |
8418
+
8419
+ ### Comparison Prefixes (date, quantity, number)
8420
+
8421
+ | Prefix | Meaning |
8422
+ |--------|---------|
8423
+ | `eq` | Equal (default) |
8424
+ | `ne` | Not equal |
8425
+ | `gt` | Greater than |
8426
+ | `lt` | Less than |
8427
+ | `ge` | Greater than or equal |
8428
+ | `le` | Less than or equal |
8429
+ | `sa` | Starts after |
8430
+ | `eb` | Ends before |
8431
+
8432
+ ### Special Parameters
8433
+
8434
+ | Parameter | Purpose | Example |
8435
+ |-----------|---------|---------|
8436
+ | `_sort` | Sort results (prefix `-` for descending) | `_sort=-_lastUpdated` |
8437
+ | `_count` | Results per page | `_count=20` |
8438
+ | `_offset` | Pagination offset | `_offset=40` |
8439
+ | `_total` | Include total count | `_total=accurate` |
8440
+ | `_include` | Include forward-referenced resources | `_include=Observation:patient` |
8441
+ | `_revinclude` | Include backward-referencing resources | `_revinclude=Provenance:target` |
8442
+ | `_include:iterate` | Recursive inclusion (multi-hop) | `_include:iterate=Patient:general-practitioner` |
8443
+
8444
+ ---
8445
+
8446
+ ## Core FHIR Resources
8447
+
8448
+ ### Clinical
8449
+
8450
+ | Resource | Purpose |
8451
+ |----------|---------|
8452
+ | `Patient` | Demographics, identifiers, contacts |
8453
+ | `Practitioner` | Provider demographics, qualifications |
8454
+ | `PractitionerRole` | Provider role at organization/location |
8455
+ | `Organization` | Healthcare organization |
8456
+ | `Encounter` | Patient visit or interaction |
8457
+ | `Condition` | Diagnosis or health concern |
8458
+ | `Observation` | Measurements, vitals, lab results |
8459
+ | `DiagnosticReport` | Lab/imaging report aggregating observations |
8460
+ | `ServiceRequest` | Order for a procedure, lab, or referral |
8461
+ | `MedicationRequest` | Prescription or medication order |
8462
+ | `AllergyIntolerance` | Allergy or adverse reaction record |
8463
+ | `Procedure` | Performed clinical procedure |
8464
+ | `CarePlan` | Treatment plan with activities and goals |
8465
+ | `CareTeam` | Group of practitioners caring for a patient |
8466
+ | `Goal` | Patient health objective |
8467
+ | `Task` | Actionable work item |
8468
+
8469
+ ### Administrative
8470
+
8471
+ | Resource | Purpose |
8472
+ |----------|---------|
8473
+ | `Schedule` | Provider availability container |
8474
+ | `Slot` | Bookable time block within a Schedule |
8475
+ | `Appointment` | Scheduled visit with participants |
8476
+ | `Coverage` | Insurance/payer information |
8477
+ | `Claim` | Billing claim submission |
8478
+ | `Communication` | Message between participants |
8479
+ | `Questionnaire` | Form/survey definition |
8480
+ | `QuestionnaireResponse` | Completed form responses |
8481
+
8482
+ ### Infrastructure
8483
+
8484
+ | Resource | Purpose |
8485
+ |----------|---------|
8486
+ | `Bundle` | Collection of resources (transaction, batch, searchset) |
8487
+ | `Subscription` | Event-driven notification trigger |
8488
+ | `AuditEvent` | Security/privacy audit log entry |
8489
+ | `Binary` | Raw binary data (files, images) |
8490
+ | `DocumentReference` | Metadata about a document/attachment |
8491
+ | `OperationOutcome` | Processing result with issues/errors |
8492
+ | `ValueSet` | Set of codes for a specific use |
8493
+ | `CodeSystem` | Collection of codes in a domain |
8494
+ | `StructureDefinition` | Resource profile/schema definition |
8495
+ | `PlanDefinition` | Clinical protocol/workflow template |
8496
+
8497
+ ### Medplum Custom Resources
8498
+
8499
+ | Resource | Purpose |
8500
+ |----------|---------|
8501
+ | `Bot` | Serverless function definition |
8502
+ | `ClientApplication` | OAuth2 client registration |
8503
+ | `Project` | Top-level tenant/organization container |
8504
+ | `ProjectMembership` | User membership with role/access policy |
8505
+ | `AccessPolicy` | Resource-level access control rules |
8506
+ | `Agent` | On-prem integration agent |
8507
+ | `UserConfiguration` | User UI preferences |
8508
+
8509
+ ---
8510
+
8511
+ ## Security & Identity
8512
+
8513
+ ### Authentication Flows
8514
+
8515
+ | Flow | Use Case | SDK Method |
8516
+ |------|----------|------------|
8517
+ | Client Credentials | Service-to-service, backend | `startClientLogin(clientId, secret)` |
8518
+ | Authorization Code | User-facing web apps | `startLogin()` + `processCode()` |
8519
+ | Google Sign-In | Google SSO | `startGoogleLogin()` |
8520
+ | External IDP | Auth0, Cognito, Okta | `signInWithExternalAuth()` |
8521
+ | JWT Bearer | Server-issued JWT assertion | `startJwtBearerLogin()` |
8522
+ | Token Exchange | Convert external tokens | `exchangeExternalAccessToken()` |
8523
+ | mTLS | Certificate-based auth | Server config |
8524
+
8525
+ ### Access Policy Features
8526
+
8527
+ | Feature | Description |
8528
+ |---------|-------------|
8529
+ | Resource type rules | Allow/deny per resource type (read, write, create, delete) |
8530
+ | Read-only fields | `readonlyFields` array on resource type |
8531
+ | Hidden fields | `hiddenFields` array on resource type |
8532
+ | Criteria filtering | FHIR search query (e.g., `Patient?address-state=CA`) |
8533
+ | Compartments | Patient-based data isolation via `_compartment` |
8534
+ | Parameterized | Variables: `%profile`, `%profile.id`, `%patient`, custom |
8535
+ | Write constraints | FHIRPath expressions for state machine enforcement |
8536
+ | SMART scopes | `patient/*.read`, `user/*.write` style scopes |
8537
+ | IP rules | Restrict by IP address/CIDR |
8538
+
8539
+ ---
8540
+
8541
+ ## Automation
8542
+
8543
+ ### Bot Handler Pattern
8544
+
8545
+ ```typescript
8546
+ import { BotEvent, MedplumClient } from '@medplum/core';
8547
+ import { Patient } from '@medplum/fhirtypes';
8548
+
8549
+ export async function handler(medplum: MedplumClient, event: BotEvent): Promise<any> {
8550
+ const patient = event.input as Patient;
8551
+ // event.secrets — project secrets map
8552
+ // event.bot — reference to this Bot resource
8553
+ // event.traceId — request correlation ID
8554
+ return true;
8555
+ }
8556
+ ```
8557
+
8558
+ ### Bot Execution Triggers
8559
+
8560
+ | Trigger | Method |
8561
+ |---------|--------|
8562
+ | HTTP POST | `POST /fhir/R4/Bot/<ID>/$execute` |
8563
+ | FHIR Subscription | Subscription criteria → rest-hook to `Bot/<ID>` |
8564
+ | Cron schedule | Bot with cron expression in properties |
8565
+ | Manual | Execute button in Medplum App |
8566
+
8567
+ ### Subscription Pattern
8568
+
8569
+ ```typescript
8570
+ // Server-side: create Subscription resource
8571
+ const sub = await medplum.createResource({
8572
+ resourceType: 'Subscription',
8573
+ status: 'active',
8574
+ criteria: 'Patient?name=Simpson',
8575
+ channel: { type: 'rest-hook', endpoint: 'Bot/<BOT_ID>' }
8576
+ });
8577
+
8578
+ // Client-side: WebSocket subscription
8579
+ medplum.subscribeToCriteria('Patient?name=Simpson');
8580
+ ```
8581
+
8582
+ ---
8583
+
8584
+ ## Integrations
8585
+
8586
+ | Integration | Path | Purpose |
8587
+ |-------------|------|---------|
8588
+ | DoseSpot | `/docs/integration/dosespot` | E-prescribing (enrollment, favorites, Rx) |
8589
+ | Health Gorilla | `/docs/integration/health-gorilla` | Lab orders, receiving results |
8590
+ | Stedi | `/docs/integration/stedi` | EDI/X12 eligibility checks |
8591
+ | Candid Health | `/docs/integration/candid-health` | Revenue cycle management |
8592
+ | eFax | `/docs/integration/efax` | Fax send/receive |
8593
+ | HL7 v2 | `/docs/integration/hl7-interfacing` | ADT, ORM/OBR/OBX message interfacing |
8594
+ | FHIRcast | `/docs/fhircast` | Real-time clinical context synchronization |
8595
+ | SMART App Launch | `/docs/integration/smart-app-launch` | Embedded app launch framework |
8596
+ | CDS Hooks | `/docs/integration/cds-hooks` | Clinical decision support at workflow triggers |
8597
+ | C-CDA | `/docs/integration/c-cda` | Continuity of Care Document export |
8598
+ | On-Prem Agent | `/docs/agent` | Bridge to on-prem HL7/DICOM systems |
8599
+ | Log Streaming | `/docs/integration/log-streaming` | External log aggregation |
8600
+
8601
+ ---
8602
+
8603
+ ## Terminology Systems
8604
+
8605
+ | System | URI | Usage |
8606
+ |--------|-----|-------|
8607
+ | LOINC | `http://loinc.org` | Lab tests, vitals, clinical observations |
8608
+ | SNOMED CT | `http://snomed.info/sct` | Clinical findings, procedures, body structures |
8609
+ | ICD-10 | `http://hl7.org/fhir/sid/icd-10-cm` | Diagnoses, billing codes |
8610
+ | RxNorm | `http://www.nlm.nih.gov/research/umls/rxnorm` | Medications (ingredients, brands, dose forms) |
8611
+ | NDC | `http://hl7.org/fhir/sid/ndc` | Drug product codes (packaging level) |
8612
+ | CPT | `http://www.ama-assn.org/go/cpt` | Procedure billing codes |
8613
+ | UCUM | `http://unitsofmeasure.org` | Units of measure |
8614
+ | US NPI | `http://hl7.org/fhir/sid/us-npi` | National Provider Identifier |
8615
+ | US SSN | `http://hl7.org/fhir/sid/us-ssn` | Social Security Number |
8616
+
8617
+ ---
8618
+
8619
+ ## Compliance
8620
+
8621
+ | Standard | Path | Scope |
8622
+ |----------|------|-------|
8623
+ | HIPAA | `/docs/compliance/hipaa` | PHI protection, BAA, audit logging |
8624
+ | SOC 2 Type II | `/docs/compliance/soc2` | Security, availability, confidentiality |
8625
+ | HITRUST | `/docs/compliance/hitrust` | Healthcare security framework |
8626
+ | ONC | `/docs/compliance/onc` | Health IT certification |
8627
+ | CLIA/CAP | `/docs/compliance/clia-cap` | Laboratory certification |
8628
+ | 21 CFR Part 11 | `/docs/compliance/cfr11` | Electronic records/signatures |
8629
+ | ISO 9001 | `/docs/compliance/iso9001` | Quality management |
8630
+ | HTI-1/HTI-4 | `/docs/compliance/hti-4` | Health tech interoperability rules |
8631
+
8632
+ ---
8633
+
8634
+ ## React Components (@medplum/react)
8635
+
8636
+ ### Setup
8637
+
8638
+ Requires: React 18+, Mantine 7+, PostCSS with Mantine preset, `@medplum/core`, `@medplum/react`.
8639
+
8640
+ Provider nesting: `BrowserRouter` → `MedplumProvider` → `MantineProvider`.
8641
+
8642
+ ### Key Components
8643
+
8644
+ | Component | Purpose |
8645
+ |-----------|---------|
8646
+ | `<MedplumProvider>` | Provides MedplumClient context to app |
8647
+ | `<SignInForm>` | Authentication form |
8648
+ | `<ResourceTable>` | Display resource fields in table |
8649
+ | `<ResourceForm>` | Edit resource with auto-generated form |
8650
+ | `<SearchControl>` | Search interface with filters and results |
8651
+ | `<QuestionnaireForm>` | Render and submit FHIR Questionnaire |
8652
+ | `<QuestionnaireBuilder>` | Build/edit Questionnaire resources |
8653
+ | `<ChatControl>` | Communication thread interface |
8654
+
8655
+ ### Key Hooks
8656
+
8657
+ | Hook | Purpose |
8658
+ |------|---------|
8659
+ | `useMedplum()` | Access MedplumClient instance |
8660
+ | `useMedplumContext()` | Access client + profile + loading state |
8661
+ | `useResource(ref)` | Read resource by reference |
8662
+ | `useSearch(type, query)` | Execute search with React Suspense |
8663
+ | `useSubscription(criteria)` | WebSocket subscription with auto-cleanup |
8664
+
8665
+ ---
8666
+
8667
+ ## Bundle Transaction Pattern
8668
+
8669
+ ```typescript
8670
+ const bundle = await medplum.executeBatch({
8671
+ resourceType: 'Bundle',
8672
+ type: 'transaction',
8673
+ entry: [
8674
+ {
8675
+ fullUrl: 'urn:uuid:patient-1',
8676
+ resource: { resourceType: 'Patient', name: [{ family: 'Smith' }] },
8677
+ request: { method: 'POST', url: 'Patient' }
8678
+ },
8679
+ {
8680
+ resource: {
8681
+ resourceType: 'Observation',
8682
+ subject: { reference: 'urn:uuid:patient-1' }, // internal ref
8683
+ code: { coding: [{ system: 'http://loinc.org', code: '8867-4' }] }
8684
+ },
8685
+ request: { method: 'POST', url: 'Observation' }
8686
+ }
8687
+ ]
8688
+ });
8689
+ ```
8690
+
8691
+ Key patterns:
8692
+ - `urn:uuid:` for internal references resolved server-side
8693
+ - `ifNoneExist` on request for conditional creates
8694
+ - `ifMatch` with `W/"versionId"` for optimistic concurrency
8695
+ - Conditional references: `Practitioner?identifier=http://hl7.org/fhir/sid/us-npi|123`
8696
+ - Async processing via `Prefer: respond-async` header for large bundles
8697
+
8698
+ ---
8699
+
8700
+ ## GraphQL Patterns
8701
+
8702
+ ```graphql
8703
+ # Search with nested resolution
8704
+ {
8705
+ PatientList(name: "Eve", address_city: "Philadelphia") {
8706
+ id
8707
+ name { family given }
8708
+ }
8709
+ }
8710
+
8711
+ # Reverse references
8712
+ {
8713
+ Patient(id: "123") {
8714
+ encounters: EncounterList(_reference: patient) {
8715
+ id
8716
+ status
8717
+ }
8718
+ }
8719
+ }
8720
+
8721
+ # Inline fragments for reference resolution
8722
+ {
8723
+ DiagnosticReport(id: "456") {
8724
+ result {
8725
+ resource { ... on Observation { valueQuantity { value unit } } }
8726
+ }
8727
+ }
8728
+ }
8729
+ ```
8730
+
8731
+ Notes: Search uses snake_case params (not kebab-case). `:not`, `:missing`, `:contains` modifiers not supported in GraphQL. Schema introspection disabled by default.
8732
+
8733
+ ---
8734
+
8190
8735
  ## kb/reference/merge-friendly-install-model.md
8191
8736
 
8192
8737
  ---
package/llms.txt CHANGED
@@ -43,6 +43,7 @@
43
43
  - [Manifest-Driven Install System](kb/reference/manifest-install.md)
44
44
  - [MCP Editor Compatibility](kb/reference/mcp-editor-compatibility.md)
45
45
  - [MCP Server Templates](kb/reference/mcp-templates.md)
46
+ - [Medplum Documentation Map](kb/reference/medplum-docs-map.md)
46
47
  - [Merge-Friendly Install Model](kb/reference/merge-friendly-install-model.md)
47
48
  - [AI Toolkit - opencode Compatibility](kb/reference/opencode-compatibility.md)
48
49
  - [Plugin Pack Conventions](kb/reference/plugin-pack-conventions.md)
package/manifest.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.7.2",
2
+ "version": "2.7.3",
3
3
  "components": {
4
4
  "agents": {
5
5
  "description": "44 specialized agents (orchestrator, backend, frontend, security, devops, etc.)",
@@ -145,6 +145,10 @@
145
145
  "description": "Ruby-specific rules",
146
146
  "auto_detect": ["Gemfile", "*.gemspec"]
147
147
  },
148
+ "rules-medplum": {
149
+ "description": "Medplum/FHIR healthcare platform rules",
150
+ "auto_detect": ["medplum.config.mts", "medplum.config.ts"]
151
+ },
148
152
  "mcp-templates": {
149
153
  "description": "26 MCP server config templates",
150
154
  "default": false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softspark/ai-toolkit",
3
- "version": "2.7.2",
3
+ "version": "2.7.3",
4
4
  "description": "Professional-grade AI coding toolkit: 99 skills, 44 agents, multi-platform support (Claude, Cursor, Windsurf, Copilot, Gemini, Cline, Roo Code, Aider, Augment, Google Antigravity, Codex CLI, opencode), machine-enforced safety constitution, persona presets, skill security auditor, expanded lifecycle hooks, 11 plugin packs, and benchmark tooling.",
5
5
  "keywords": [
6
6
  "claude",