saferx-pharma-sdk 1.1.0 → 1.3.0

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.
@@ -43,8 +43,8 @@ function normalizeClientOptions(options) {
43
43
  const headers = (0, headers_js_1.mergeHeaders)({
44
44
  "X-Fern-Language": "JavaScript",
45
45
  "X-Fern-SDK-Name": "saferx-pharma-sdk",
46
- "X-Fern-SDK-Version": "1.1.0",
47
- "User-Agent": "saferx-pharma-sdk/1.1.0",
46
+ "X-Fern-SDK-Version": "1.3.0",
47
+ "User-Agent": "saferx-pharma-sdk/1.3.0",
48
48
  "X-Fern-Runtime": core.RUNTIME.type,
49
49
  "X-Fern-Runtime-Version": core.RUNTIME.version,
50
50
  }, options === null || options === void 0 ? void 0 : options.headers);
@@ -2,7 +2,7 @@
2
2
  * Clinical safety alert from cross-drug analysis
3
3
  */
4
4
  export interface ClinicalAlert {
5
- /** SFX_ID of the drug involved */
5
+ /** sfrx_id of the drug involved */
6
6
  drug_id?: string | undefined;
7
7
  /** Drug name (English) */
8
8
  drug?: string | undefined;
@@ -5,7 +5,7 @@ import type * as SafeRx from "../index.js";
5
5
  * is provided in the request.
6
6
  */
7
7
  export interface ClinicalData {
8
- /** Per-drug clinical data keyed by SFX_ID */
8
+ /** Per-drug clinical data keyed by sfrx_id */
9
9
  drug_specific?: Record<string, SafeRx.DrugClinicalData> | undefined;
10
10
  /** Cross-drug condition-related alerts (requires `patient_profile.conditions`) */
11
11
  condition_alerts?: SafeRx.ClinicalAlert[] | undefined;
@@ -1,22 +1,47 @@
1
1
  export interface Interaction {
2
- /** SFX_ID of the first drug in the interaction pair */
3
- drug_1_id?: string | undefined;
4
- /** SFX_ID of the second drug in the interaction pair */
5
- drug_2_id?: string | undefined;
2
+ /** sfrx_id of the first drug in the interaction pair */
3
+ sfrx_id_1?: string | undefined;
4
+ /** sfrx_id of the second drug in the interaction pair */
5
+ sfrx_id_2?: string | undefined;
6
6
  /**
7
- * Interaction severity level.
8
- * - `2` — Minor: minimal clinical significance
9
- * - `3` — Moderate: may require monitoring or dose adjustment
10
- * - `4` — Major: avoid combination if possible, close monitoring required
11
- * - `5` — Contraindicated: do not use together
7
+ * Interaction severity level (clinical interactions only).
8
+ * - `1` — Minor: minimal clinical significance
9
+ * - `2` — Moderate: may require monitoring or dose adjustment
10
+ * - `3` — Major: avoid combination if possible, close monitoring required
11
+ * - `4` — Contraindicated: do not use together
12
+ *
13
+ * The API filters out noise interactions (severity ≤ 0) by default.
14
+ * The internal V8 scale extends to -3 (noise) and 0 (unknown),
15
+ * but these are never returned in the public response.
12
16
  */
13
17
  severity?: number | undefined;
18
+ /**
19
+ * Original severity before route-based or noise adjustments.
20
+ * Uses the full V8 scale: -3 (decreased efficacy), -2 (pharmacokinetic),
21
+ * -1 (metabolic), 0 (unknown), 1-4 (clinical). May differ from
22
+ * `severity` when route adjustments apply.
23
+ */
24
+ base_severity?: number | undefined;
14
25
  /** Human-readable severity label */
15
26
  severity_name?: Interaction.SeverityName | undefined;
27
+ /**
28
+ * Noise classification for this interaction, if applicable.
29
+ * Null for clinically significant interactions. Possible values:
30
+ * `"DECREASED_EFFICACY"`, `"PHARMACOKINETIC"`, `"METABOLIC"`.
31
+ */
32
+ noise_type?: (string | null) | undefined;
16
33
  /** Interaction mechanism or clinical description (English) */
17
34
  description?: string | undefined;
18
35
  /** Interaction description in Arabic */
19
36
  description_ar?: string | undefined;
37
+ /** Expected clinical effect of the interaction (English) */
38
+ clinical_effect?: (string | null) | undefined;
39
+ /** Expected clinical effect in Arabic */
40
+ clinical_effect_ar?: (string | null) | undefined;
41
+ /** Clinical management strategy (English) */
42
+ management?: (string | null) | undefined;
43
+ /** Clinical management strategy in Arabic */
44
+ management_ar?: (string | null) | undefined;
20
45
  /** Clinical recommendation for managing this interaction (English) */
21
46
  recommendation?: string | undefined;
22
47
  /** Clinical recommendation in Arabic */
@@ -27,4 +27,28 @@ export interface ReproductiveSafetyData {
27
27
  lactation_rationale?: string | undefined;
28
28
  pregnancy_warning?: SafeRx.ReproductiveWarning | undefined;
29
29
  lactation_warning?: SafeRx.ReproductiveWarning | undefined;
30
+ /** First trimester pregnancy risk classification */
31
+ preg_t1_risk?: (string | null) | undefined;
32
+ /** First trimester clinical note */
33
+ preg_t1_note?: (string | null) | undefined;
34
+ /** First trimester note in Arabic */
35
+ preg_t1_ar?: (string | null) | undefined;
36
+ /** Second trimester pregnancy risk classification */
37
+ preg_t2_risk?: (string | null) | undefined;
38
+ /** Second trimester clinical note */
39
+ preg_t2_note?: (string | null) | undefined;
40
+ /** Second trimester note in Arabic */
41
+ preg_t2_ar?: (string | null) | undefined;
42
+ /** Third trimester pregnancy risk classification */
43
+ preg_t3_risk?: (string | null) | undefined;
44
+ /** Third trimester clinical note */
45
+ preg_t3_note?: (string | null) | undefined;
46
+ /** Third trimester note in Arabic */
47
+ preg_t3_ar?: (string | null) | undefined;
48
+ /** Measured drug concentration in breast milk (mg/L) */
49
+ lact_milk_level_mgl?: (number | null) | undefined;
50
+ /** Milk-to-plasma concentration ratio */
51
+ lact_mp_ratio?: (number | null) | undefined;
52
+ /** Relative Infant Dose (%) — percentage of maternal dose received by infant */
53
+ lact_rid?: (number | null) | undefined;
30
54
  }
@@ -7,7 +7,12 @@ export interface ResolvedDrug {
7
7
  * SafeRx product identifier. Primary key used across all safety
8
8
  * domains. Format: `SRX-{category}-{sequence}`.
9
9
  */
10
- SFX_ID: string;
10
+ sfrx_id: string;
11
+ /**
12
+ * Parent product identifier for strength/pack variants of the same drug.
13
+ * Null if this product has no parent.
14
+ */
15
+ parent_sfrx_id?: (string | null) | undefined;
11
16
  /** Registered trade name with strength and pack size */
12
17
  brand_name: string;
13
18
  /** Active pharmaceutical ingredient(s), pipe-separated for combinations */
@@ -15,13 +20,13 @@ export interface ResolvedDrug {
15
20
  /** Pharmaceutical dosage form */
16
21
  form: string;
17
22
  /** Marketing authorization holder */
18
- manufacturer?: string | undefined;
23
+ manufacturer_en?: string | undefined;
19
24
  /** ATC-based therapeutic classification, pipe-separated hierarchy */
20
25
  therapeutic_class?: string | undefined;
21
26
  /** Primary prescribing specialty */
22
27
  medical_specialty?: string | undefined;
23
- /** Distribution company (may be empty) */
24
- distributor?: string | undefined;
28
+ /** Distribution/supply company (may be empty) */
29
+ supplier_en?: string | undefined;
25
30
  /** Product barcode (may be empty) */
26
31
  barcode?: string | undefined;
27
32
  /** Current price in Egyptian Pounds (EGP) */
@@ -6,17 +6,17 @@ import type * as SafeRx from "../index.js";
6
6
  */
7
7
  export interface SafetyData {
8
8
  /**
9
- * Adverse effects data keyed by SFX_ID. Includes risk level,
9
+ * Adverse effects data keyed by sfrx_id. Includes risk level,
10
10
  * Black Box Warnings, severe/common effects, monitoring, and
11
11
  * dose classification.
12
12
  */
13
13
  side_effects?: Record<string, SafeRx.SideEffectsData> | undefined;
14
14
  interactions?: SafeRx.InteractionsData | undefined;
15
- /** Pregnancy & lactation risk data keyed by SFX_ID */
15
+ /** Pregnancy & lactation risk data keyed by sfrx_id */
16
16
  reproductive_safety?: Record<string, SafeRx.ReproductiveSafetyData> | undefined;
17
- /** Food-drug interaction data keyed by SFX_ID */
17
+ /** Food-drug interaction data keyed by sfrx_id */
18
18
  food?: Record<string, SafeRx.FoodData> | undefined;
19
19
  clinical?: SafeRx.ClinicalData | undefined;
20
- /** Maximum daily dose data keyed by SFX_ID */
20
+ /** Maximum daily dose data keyed by sfrx_id */
21
21
  dosing?: Record<string, SafeRx.DosingData> | undefined;
22
22
  }
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "1.1.0";
1
+ export declare const SDK_VERSION = "1.3.0";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = "1.1.0";
4
+ exports.SDK_VERSION = "1.3.0";
@@ -6,8 +6,8 @@ export function normalizeClientOptions(options) {
6
6
  const headers = mergeHeaders({
7
7
  "X-Fern-Language": "JavaScript",
8
8
  "X-Fern-SDK-Name": "saferx-pharma-sdk",
9
- "X-Fern-SDK-Version": "1.1.0",
10
- "User-Agent": "saferx-pharma-sdk/1.1.0",
9
+ "X-Fern-SDK-Version": "1.3.0",
10
+ "User-Agent": "saferx-pharma-sdk/1.3.0",
11
11
  "X-Fern-Runtime": core.RUNTIME.type,
12
12
  "X-Fern-Runtime-Version": core.RUNTIME.version,
13
13
  }, options === null || options === void 0 ? void 0 : options.headers);
@@ -2,7 +2,7 @@
2
2
  * Clinical safety alert from cross-drug analysis
3
3
  */
4
4
  export interface ClinicalAlert {
5
- /** SFX_ID of the drug involved */
5
+ /** sfrx_id of the drug involved */
6
6
  drug_id?: string | undefined;
7
7
  /** Drug name (English) */
8
8
  drug?: string | undefined;
@@ -5,7 +5,7 @@ import type * as SafeRx from "../index.mjs";
5
5
  * is provided in the request.
6
6
  */
7
7
  export interface ClinicalData {
8
- /** Per-drug clinical data keyed by SFX_ID */
8
+ /** Per-drug clinical data keyed by sfrx_id */
9
9
  drug_specific?: Record<string, SafeRx.DrugClinicalData> | undefined;
10
10
  /** Cross-drug condition-related alerts (requires `patient_profile.conditions`) */
11
11
  condition_alerts?: SafeRx.ClinicalAlert[] | undefined;
@@ -1,22 +1,47 @@
1
1
  export interface Interaction {
2
- /** SFX_ID of the first drug in the interaction pair */
3
- drug_1_id?: string | undefined;
4
- /** SFX_ID of the second drug in the interaction pair */
5
- drug_2_id?: string | undefined;
2
+ /** sfrx_id of the first drug in the interaction pair */
3
+ sfrx_id_1?: string | undefined;
4
+ /** sfrx_id of the second drug in the interaction pair */
5
+ sfrx_id_2?: string | undefined;
6
6
  /**
7
- * Interaction severity level.
8
- * - `2` — Minor: minimal clinical significance
9
- * - `3` — Moderate: may require monitoring or dose adjustment
10
- * - `4` — Major: avoid combination if possible, close monitoring required
11
- * - `5` — Contraindicated: do not use together
7
+ * Interaction severity level (clinical interactions only).
8
+ * - `1` — Minor: minimal clinical significance
9
+ * - `2` — Moderate: may require monitoring or dose adjustment
10
+ * - `3` — Major: avoid combination if possible, close monitoring required
11
+ * - `4` — Contraindicated: do not use together
12
+ *
13
+ * The API filters out noise interactions (severity ≤ 0) by default.
14
+ * The internal V8 scale extends to -3 (noise) and 0 (unknown),
15
+ * but these are never returned in the public response.
12
16
  */
13
17
  severity?: number | undefined;
18
+ /**
19
+ * Original severity before route-based or noise adjustments.
20
+ * Uses the full V8 scale: -3 (decreased efficacy), -2 (pharmacokinetic),
21
+ * -1 (metabolic), 0 (unknown), 1-4 (clinical). May differ from
22
+ * `severity` when route adjustments apply.
23
+ */
24
+ base_severity?: number | undefined;
14
25
  /** Human-readable severity label */
15
26
  severity_name?: Interaction.SeverityName | undefined;
27
+ /**
28
+ * Noise classification for this interaction, if applicable.
29
+ * Null for clinically significant interactions. Possible values:
30
+ * `"DECREASED_EFFICACY"`, `"PHARMACOKINETIC"`, `"METABOLIC"`.
31
+ */
32
+ noise_type?: (string | null) | undefined;
16
33
  /** Interaction mechanism or clinical description (English) */
17
34
  description?: string | undefined;
18
35
  /** Interaction description in Arabic */
19
36
  description_ar?: string | undefined;
37
+ /** Expected clinical effect of the interaction (English) */
38
+ clinical_effect?: (string | null) | undefined;
39
+ /** Expected clinical effect in Arabic */
40
+ clinical_effect_ar?: (string | null) | undefined;
41
+ /** Clinical management strategy (English) */
42
+ management?: (string | null) | undefined;
43
+ /** Clinical management strategy in Arabic */
44
+ management_ar?: (string | null) | undefined;
20
45
  /** Clinical recommendation for managing this interaction (English) */
21
46
  recommendation?: string | undefined;
22
47
  /** Clinical recommendation in Arabic */
@@ -27,4 +27,28 @@ export interface ReproductiveSafetyData {
27
27
  lactation_rationale?: string | undefined;
28
28
  pregnancy_warning?: SafeRx.ReproductiveWarning | undefined;
29
29
  lactation_warning?: SafeRx.ReproductiveWarning | undefined;
30
+ /** First trimester pregnancy risk classification */
31
+ preg_t1_risk?: (string | null) | undefined;
32
+ /** First trimester clinical note */
33
+ preg_t1_note?: (string | null) | undefined;
34
+ /** First trimester note in Arabic */
35
+ preg_t1_ar?: (string | null) | undefined;
36
+ /** Second trimester pregnancy risk classification */
37
+ preg_t2_risk?: (string | null) | undefined;
38
+ /** Second trimester clinical note */
39
+ preg_t2_note?: (string | null) | undefined;
40
+ /** Second trimester note in Arabic */
41
+ preg_t2_ar?: (string | null) | undefined;
42
+ /** Third trimester pregnancy risk classification */
43
+ preg_t3_risk?: (string | null) | undefined;
44
+ /** Third trimester clinical note */
45
+ preg_t3_note?: (string | null) | undefined;
46
+ /** Third trimester note in Arabic */
47
+ preg_t3_ar?: (string | null) | undefined;
48
+ /** Measured drug concentration in breast milk (mg/L) */
49
+ lact_milk_level_mgl?: (number | null) | undefined;
50
+ /** Milk-to-plasma concentration ratio */
51
+ lact_mp_ratio?: (number | null) | undefined;
52
+ /** Relative Infant Dose (%) — percentage of maternal dose received by infant */
53
+ lact_rid?: (number | null) | undefined;
30
54
  }
@@ -7,7 +7,12 @@ export interface ResolvedDrug {
7
7
  * SafeRx product identifier. Primary key used across all safety
8
8
  * domains. Format: `SRX-{category}-{sequence}`.
9
9
  */
10
- SFX_ID: string;
10
+ sfrx_id: string;
11
+ /**
12
+ * Parent product identifier for strength/pack variants of the same drug.
13
+ * Null if this product has no parent.
14
+ */
15
+ parent_sfrx_id?: (string | null) | undefined;
11
16
  /** Registered trade name with strength and pack size */
12
17
  brand_name: string;
13
18
  /** Active pharmaceutical ingredient(s), pipe-separated for combinations */
@@ -15,13 +20,13 @@ export interface ResolvedDrug {
15
20
  /** Pharmaceutical dosage form */
16
21
  form: string;
17
22
  /** Marketing authorization holder */
18
- manufacturer?: string | undefined;
23
+ manufacturer_en?: string | undefined;
19
24
  /** ATC-based therapeutic classification, pipe-separated hierarchy */
20
25
  therapeutic_class?: string | undefined;
21
26
  /** Primary prescribing specialty */
22
27
  medical_specialty?: string | undefined;
23
- /** Distribution company (may be empty) */
24
- distributor?: string | undefined;
28
+ /** Distribution/supply company (may be empty) */
29
+ supplier_en?: string | undefined;
25
30
  /** Product barcode (may be empty) */
26
31
  barcode?: string | undefined;
27
32
  /** Current price in Egyptian Pounds (EGP) */
@@ -6,17 +6,17 @@ import type * as SafeRx from "../index.mjs";
6
6
  */
7
7
  export interface SafetyData {
8
8
  /**
9
- * Adverse effects data keyed by SFX_ID. Includes risk level,
9
+ * Adverse effects data keyed by sfrx_id. Includes risk level,
10
10
  * Black Box Warnings, severe/common effects, monitoring, and
11
11
  * dose classification.
12
12
  */
13
13
  side_effects?: Record<string, SafeRx.SideEffectsData> | undefined;
14
14
  interactions?: SafeRx.InteractionsData | undefined;
15
- /** Pregnancy & lactation risk data keyed by SFX_ID */
15
+ /** Pregnancy & lactation risk data keyed by sfrx_id */
16
16
  reproductive_safety?: Record<string, SafeRx.ReproductiveSafetyData> | undefined;
17
- /** Food-drug interaction data keyed by SFX_ID */
17
+ /** Food-drug interaction data keyed by sfrx_id */
18
18
  food?: Record<string, SafeRx.FoodData> | undefined;
19
19
  clinical?: SafeRx.ClinicalData | undefined;
20
- /** Maximum daily dose data keyed by SFX_ID */
20
+ /** Maximum daily dose data keyed by sfrx_id */
21
21
  dosing?: Record<string, SafeRx.DosingData> | undefined;
22
22
  }
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "1.1.0";
1
+ export declare const SDK_VERSION = "1.3.0";
@@ -1 +1 @@
1
- export const SDK_VERSION = "1.1.0";
1
+ export const SDK_VERSION = "1.3.0";
package/package.json CHANGED
@@ -1,11 +1,7 @@
1
1
  {
2
2
  "name": "saferx-pharma-sdk",
3
- "version": "1.1.0",
3
+ "version": "1.3.0",
4
4
  "private": false,
5
- "repository": {
6
- "type": "git",
7
- "url": "git+https://github.com/KaRamHelal/SafeRx_Pharma.git"
8
- },
9
5
  "type": "commonjs",
10
6
  "main": "./dist/cjs/index.js",
11
7
  "module": "./dist/esm/index.mjs",
package/README.md DELETED
@@ -1,398 +0,0 @@
1
- # Saferx TypeScript Library
2
-
3
- [![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2FKaRamHelal%2FSafeRx_Pharma)
4
- [![npm shield](https://img.shields.io/npm/v/saferx-pharma-sdk)](https://www.npmjs.com/package/saferx-pharma-sdk)
5
-
6
- The Saferx TypeScript library provides convenient access to the Saferx APIs from TypeScript.
7
-
8
- ## Table of Contents
9
-
10
- - [What S Here](#what-s-here)
11
- - [Quick Start](#quick-start)
12
- - [Sd Ks](#sd-ks)
13
- - [Mcp Server](#mcp-server)
14
- - [Safety Domains](#safety-domains)
15
- - [Api Tiers](#api-tiers)
16
- - [Documentation](#documentation)
17
- - [Links](#links)
18
- - [License](#license)
19
- - [Installation](#installation)
20
- - [Reference](#reference)
21
- - [Usage](#usage)
22
- - [Request and Response Types](#request-and-response-types)
23
- - [Exception Handling](#exception-handling)
24
- - [Advanced](#advanced)
25
- - [Additional Headers](#additional-headers)
26
- - [Additional Query String Parameters](#additional-query-string-parameters)
27
- - [Retries](#retries)
28
- - [Timeouts](#timeouts)
29
- - [Aborting Requests](#aborting-requests)
30
- - [Access Raw Response Data](#access-raw-response-data)
31
- - [Logging](#logging)
32
- - [Runtime Compatibility](#runtime-compatibility)
33
- - [Contributing](#contributing)
34
-
35
- ## What's Here
36
-
37
- ```
38
- SafeRx_Pharma/
39
- ├── openapi/ # OpenAPI 3.1.1 spec (source of truth)
40
- │ └── drug-safety-v1.yaml # ~2000 lines, fully typed
41
- ├── mcp-server/ # MCP server for AI assistants
42
- │ └── src/index.ts # Published: @saferx_pharma/mcp-server
43
- ├── fern/ # Fern docs + SDK generation config
44
- │ ├── docs.yml # docs.saferx.online (26 pages)
45
- │ ├── docs/ # Documentation content (MDX)
46
- │ ├── generators.yml # SDK generators (Python, TS, C#, Java, Go, Swift)
47
- │ └── apis/ # API definitions per SDK
48
- ├── postman/ # Postman collection (8 requests)
49
- └── LICENSE # MIT
50
- ```
51
-
52
- ## Quick Start
53
-
54
- ### Get a Free API Key
55
-
56
- ```bash
57
- # Step 1: Request verification code
58
- curl -X POST https://saferx.online/api/developers/keys/free \
59
- -H "Content-Type: application/json" \
60
- -d '{"email": "you@example.com"}'
61
-
62
- # Step 2: Verify with the 6-digit code from your email
63
- curl -X POST https://saferx.online/api/developers/keys/free/verify \
64
- -H "Content-Type: application/json" \
65
- -d '{"email": "you@example.com", "code": "123456"}'
66
- ```
67
-
68
- ### Check Drug Safety
69
-
70
- ```bash
71
- curl -X POST https://saferx.online/api/drug_safety/check \
72
- -H "X-SafeRx-API-Key: YOUR_KEY" \
73
- -H "Content-Type: application/json" \
74
- -H "User-Agent: MyApp/1.0" \
75
- -d '{"drugs": ["Augmentin 1g", "Marivan", "Glucophage 500"]}'
76
- ```
77
-
78
- Returns safety data across all 6 domains in ~40ms.
79
-
80
- ## SDKs
81
-
82
- | Language | Package | Install |
83
- |----------|---------|---------|
84
- | Python | [`saferx-pharma`](https://pypi.org/project/saferx-pharma/) | `pip install saferx-pharma` |
85
- | TypeScript | [`saferx-pharma-sdk`](https://www.npmjs.com/package/saferx-pharma-sdk) | `npm install saferx-pharma-sdk` |
86
- | C# | [`SafeRx`](https://www.nuget.org/packages/SafeRx) | `dotnet add package SafeRx` |
87
-
88
- ```python
89
- from saferx import SafeRxClient
90
-
91
- client = SafeRxClient(api_key="sfx_free_...")
92
- result = client.drug_safety.check(drugs=["Augmentin 1g", "Marivan"])
93
- ```
94
-
95
- ```typescript
96
- import { SafeRxClient } from "saferx-pharma-sdk";
97
-
98
- const client = new SafeRxClient({ apiKey: "sfx_free_..." });
99
- const result = await client.drugSafety.check({ drugs: ["Augmentin 1g", "Marivan"] });
100
- ```
101
-
102
- ## MCP Server
103
-
104
- For AI assistants (Claude Desktop, Claude Code, Cursor):
105
-
106
- ```bash
107
- npx @saferx_pharma/mcp-server
108
- ```
109
-
110
- Requires `SAFERX_API_KEY` environment variable. See [`mcp-server/README.md`](mcp-server/README.md) for configuration details.
111
-
112
- ## Safety Domains
113
-
114
- | Domain | Code | Coverage |
115
- |--------|------|----------|
116
- | Adverse Effects | `ae` | 920K+ effects, Black Box Warnings |
117
- | Drug Interactions | `ddi` | 337K+ interaction pairs |
118
- | Pregnancy & Lactation | `pllr` | 24K+ products, 0-7 risk scale |
119
- | Food Interactions | `food` | 38K+ interactions |
120
- | Clinical Considerations | `clinical` | 5 populations, 14 conditions |
121
- | Dosing | `dose` | 19K+ products, dual-source |
122
-
123
- ## API Tiers
124
-
125
- | | Free | Pro | Enterprise |
126
- |---|------|-----|------------|
127
- | Requests/min | 20 | 60 | Custom |
128
- | Requests/day | 60 | 500 | Custom |
129
- | Max drugs/request | 20 | 20 | 50 |
130
- | Auth | API Key | API Key | API Key |
131
- | Database | Full (28,557 products) | Full | Full |
132
- | Support | Email | Priority | Dedicated |
133
-
134
- ## Documentation
135
-
136
- - [API Reference](https://saferx.docs.buildwithfern.com) — Interactive endpoint docs
137
- - [Integration Guides](https://saferx.docs.buildwithfern.com/guides/integration-guides/pharmacy-dispensing) — Pharmacy, Hospital EHR, POS, Mobile, AI Agent
138
- - [OpenAPI Spec](openapi/drug-safety-v1.yaml) — Machine-readable API definition
139
- - [Postman Collection](postman/SafeRx-Drug-Safety-API.postman_collection.json) — Import and test in seconds
140
-
141
- ## Links
142
-
143
- - **Website:** [saferx.online](https://saferx.online)
144
- - **Developer Portal:** [saferx.online/developer.html](https://saferx.online/developer.html)
145
- - **npm:** [@saferx_pharma/mcp-server](https://www.npmjs.com/package/@saferx_pharma/mcp-server)
146
- - **Status:** [saferx.instatus.com](https://saferx.instatus.com)
147
- - **Support:** support@saferx.online
148
-
149
- ## License
150
-
151
- MIT
152
-
153
- ## Installation
154
-
155
- ```sh
156
- npm i -s saferx-pharma-sdk
157
- ```
158
-
159
- ## Reference
160
-
161
- A full reference for this library is available [here](https://github.com/KaRamHelal/SafeRx_Pharma/blob/HEAD/./reference.md).
162
-
163
- ## Usage
164
-
165
- Instantiate and use the client with the following:
166
-
167
- ```typescript
168
- import { SafeRxClient } from "saferx-pharma-sdk";
169
-
170
- const client = new SafeRxClient({ apiKey: "YOUR_API_KEY" });
171
- await client.drugSafety.check({
172
- drugs: ["Augmentin 1g", "Glucophage 500mg"],
173
- lang: "ar"
174
- });
175
- ```
176
-
177
- ## Request and Response Types
178
-
179
- The SDK exports all request and response types as TypeScript interfaces. Simply import them with the
180
- following namespace:
181
-
182
- ```typescript
183
- import { SafeRx } from "saferx-pharma-sdk";
184
-
185
- const request: SafeRx.DrugSafetyCheckRequest = {
186
- ...
187
- };
188
- ```
189
-
190
- ## Exception Handling
191
-
192
- When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error
193
- will be thrown.
194
-
195
- ```typescript
196
- import { SafeRxError } from "saferx-pharma-sdk";
197
-
198
- try {
199
- await client.drugSafety.check(...);
200
- } catch (err) {
201
- if (err instanceof SafeRxError) {
202
- console.log(err.statusCode);
203
- console.log(err.message);
204
- console.log(err.body);
205
- console.log(err.rawResponse);
206
- }
207
- }
208
- ```
209
-
210
- ## Advanced
211
-
212
- ### Additional Headers
213
-
214
- If you would like to send additional headers as part of the request, use the `headers` request option.
215
-
216
- ```typescript
217
- import { SafeRxClient } from "saferx-pharma-sdk";
218
-
219
- const client = new SafeRxClient({
220
- ...
221
- headers: {
222
- 'X-Custom-Header': 'custom value'
223
- }
224
- });
225
-
226
- const response = await client.drugSafety.check(..., {
227
- headers: {
228
- 'X-Custom-Header': 'custom value'
229
- }
230
- });
231
- ```
232
-
233
- ### Additional Query String Parameters
234
-
235
- If you would like to send additional query string parameters as part of the request, use the `queryParams` request option.
236
-
237
- ```typescript
238
- const response = await client.drugSafety.check(..., {
239
- queryParams: {
240
- 'customQueryParamKey': 'custom query param value'
241
- }
242
- });
243
- ```
244
-
245
- ### Retries
246
-
247
- The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
248
- as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
249
- retry limit (default: 2).
250
-
251
- A request is deemed retryable when any of the following HTTP status codes is returned:
252
-
253
- - [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
254
- - [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
255
- - [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
256
-
257
- Use the `maxRetries` request option to configure this behavior.
258
-
259
- ```typescript
260
- const response = await client.drugSafety.check(..., {
261
- maxRetries: 0 // override maxRetries at the request level
262
- });
263
- ```
264
-
265
- ### Timeouts
266
-
267
- The SDK defaults to a 60 second timeout. Use the `timeoutInSeconds` option to configure this behavior.
268
-
269
- ```typescript
270
- const response = await client.drugSafety.check(..., {
271
- timeoutInSeconds: 30 // override timeout to 30s
272
- });
273
- ```
274
-
275
- ### Aborting Requests
276
-
277
- The SDK allows users to abort requests at any point by passing in an abort signal.
278
-
279
- ```typescript
280
- const controller = new AbortController();
281
- const response = await client.drugSafety.check(..., {
282
- abortSignal: controller.signal
283
- });
284
- controller.abort(); // aborts the request
285
- ```
286
-
287
- ### Access Raw Response Data
288
-
289
- The SDK provides access to raw response data, including headers, through the `.withRawResponse()` method.
290
- The `.withRawResponse()` method returns a promise that results to an object with a `data` and a `rawResponse` property.
291
-
292
- ```typescript
293
- const { data, rawResponse } = await client.drugSafety.check(...).withRawResponse();
294
-
295
- console.log(data);
296
- console.log(rawResponse.headers['X-My-Header']);
297
- ```
298
-
299
- ### Logging
300
-
301
- The SDK supports logging. You can configure the logger by passing in a `logging` object to the client options.
302
-
303
- ```typescript
304
- import { SafeRxClient, logging } from "saferx-pharma-sdk";
305
-
306
- const client = new SafeRxClient({
307
- ...
308
- logging: {
309
- level: logging.LogLevel.Debug, // defaults to logging.LogLevel.Info
310
- logger: new logging.ConsoleLogger(), // defaults to ConsoleLogger
311
- silent: false, // defaults to true, set to false to enable logging
312
- }
313
- });
314
- ```
315
- The `logging` object can have the following properties:
316
- - `level`: The log level to use. Defaults to `logging.LogLevel.Info`.
317
- - `logger`: The logger to use. Defaults to a `logging.ConsoleLogger`.
318
- - `silent`: Whether to silence the logger. Defaults to `true`.
319
-
320
- The `level` property can be one of the following values:
321
- - `logging.LogLevel.Debug`
322
- - `logging.LogLevel.Info`
323
- - `logging.LogLevel.Warn`
324
- - `logging.LogLevel.Error`
325
-
326
- To provide a custom logger, you can pass in an object that implements the `logging.ILogger` interface.
327
-
328
- <details>
329
- <summary>Custom logger examples</summary>
330
-
331
- Here's an example using the popular `winston` logging library.
332
- ```ts
333
- import winston from 'winston';
334
-
335
- const winstonLogger = winston.createLogger({...});
336
-
337
- const logger: logging.ILogger = {
338
- debug: (msg, ...args) => winstonLogger.debug(msg, ...args),
339
- info: (msg, ...args) => winstonLogger.info(msg, ...args),
340
- warn: (msg, ...args) => winstonLogger.warn(msg, ...args),
341
- error: (msg, ...args) => winstonLogger.error(msg, ...args),
342
- };
343
- ```
344
-
345
- Here's an example using the popular `pino` logging library.
346
-
347
- ```ts
348
- import pino from 'pino';
349
-
350
- const pinoLogger = pino({...});
351
-
352
- const logger: logging.ILogger = {
353
- debug: (msg, ...args) => pinoLogger.debug(args, msg),
354
- info: (msg, ...args) => pinoLogger.info(args, msg),
355
- warn: (msg, ...args) => pinoLogger.warn(args, msg),
356
- error: (msg, ...args) => pinoLogger.error(args, msg),
357
- };
358
- ```
359
- </details>
360
-
361
-
362
- ### Runtime Compatibility
363
-
364
-
365
- The SDK works in the following runtimes:
366
-
367
-
368
-
369
- - Node.js 18+
370
- - Vercel
371
- - Cloudflare Workers
372
- - Deno v1.25+
373
- - Bun 1.0+
374
- - React Native
375
-
376
- ### Customizing Fetch Client
377
-
378
- The SDK provides a way for you to customize the underlying HTTP client / Fetch function. If you're running in an
379
- unsupported environment, this provides a way for you to break glass and ensure the SDK works.
380
-
381
- ```typescript
382
- import { SafeRxClient } from "saferx-pharma-sdk";
383
-
384
- const client = new SafeRxClient({
385
- ...
386
- fetcher: // provide your implementation here
387
- });
388
- ```
389
-
390
- ## Contributing
391
-
392
- While we value open-source contributions to this SDK, this library is generated programmatically.
393
- Additions made directly to this library would have to be moved over to our generation code,
394
- otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
395
- a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
396
- an issue first to discuss with us!
397
-
398
- On the other hand, contributions to the README are always very welcome!
package/reference.md DELETED
@@ -1,335 +0,0 @@
1
- # Reference
2
- ## Drug Safety
3
- <details><summary><code>client.drugSafety.<a href="/src/api/resources/drugSafety/client/Client.ts">check</a>({ ...params }) -> SafeRx.DrugSafetyCheckResponse</code></summary>
4
- <dl>
5
- <dd>
6
-
7
- #### 📝 Description
8
-
9
- <dl>
10
- <dd>
11
-
12
- <dl>
13
- <dd>
14
-
15
- Screen one or more drugs across six safety domains in a single request.
16
-
17
- The API resolves drug names via fuzzy matching, runs all requested safety
18
- checks in parallel, and returns a unified response with alerts bubbled to
19
- the top for easy triage.
20
-
21
- **Typical response time:** ~40ms (warm cache, 3 drugs, all domains).
22
- </dd>
23
- </dl>
24
- </dd>
25
- </dl>
26
-
27
- #### 🔌 Usage
28
-
29
- <dl>
30
- <dd>
31
-
32
- <dl>
33
- <dd>
34
-
35
- ```typescript
36
- await client.drugSafety.check({
37
- drugs: ["Augmentin 1g", "Glucophage 500mg", "Marivan"],
38
- lang: "en"
39
- });
40
-
41
- ```
42
- </dd>
43
- </dl>
44
- </dd>
45
- </dl>
46
-
47
- #### ⚙️ Parameters
48
-
49
- <dl>
50
- <dd>
51
-
52
- <dl>
53
- <dd>
54
-
55
- **request:** `SafeRx.DrugSafetyCheckRequest`
56
-
57
- </dd>
58
- </dl>
59
-
60
- <dl>
61
- <dd>
62
-
63
- **requestOptions:** `DrugSafetyClient.RequestOptions`
64
-
65
- </dd>
66
- </dl>
67
- </dd>
68
- </dl>
69
-
70
-
71
- </dd>
72
- </dl>
73
- </details>
74
-
75
- <details><summary><code>client.drugSafety.<a href="/src/api/resources/drugSafety/client/Client.ts">getMetadata</a>() -> SafeRx.MetadataResponse</code></summary>
76
- <dl>
77
- <dd>
78
-
79
- #### 📝 Description
80
-
81
- <dl>
82
- <dd>
83
-
84
- <dl>
85
- <dd>
86
-
87
- Returns available populations, conditions, database versions, risk level
88
- scales, and current tier limits.
89
-
90
- Use this endpoint to:
91
- - Populate dropdown menus with valid population and condition values
92
- - Check database versions and coverage statistics
93
- - Verify your tier and rate limits
94
- - Cache metadata locally (changes infrequently — safe to cache for 24 hours)
95
- </dd>
96
- </dl>
97
- </dd>
98
- </dl>
99
-
100
- #### 🔌 Usage
101
-
102
- <dl>
103
- <dd>
104
-
105
- <dl>
106
- <dd>
107
-
108
- ```typescript
109
- await client.drugSafety.getMetadata();
110
-
111
- ```
112
- </dd>
113
- </dl>
114
- </dd>
115
- </dl>
116
-
117
- #### ⚙️ Parameters
118
-
119
- <dl>
120
- <dd>
121
-
122
- <dl>
123
- <dd>
124
-
125
- **requestOptions:** `DrugSafetyClient.RequestOptions`
126
-
127
- </dd>
128
- </dl>
129
- </dd>
130
- </dl>
131
-
132
-
133
- </dd>
134
- </dl>
135
- </details>
136
-
137
- <details><summary><code>client.drugSafety.<a href="/src/api/resources/drugSafety/client/Client.ts">getDrugSafetyHealth</a>() -> SafeRx.GetDrugSafetyHealthResponse</code></summary>
138
- <dl>
139
- <dd>
140
-
141
- #### 📝 Description
142
-
143
- <dl>
144
- <dd>
145
-
146
- <dl>
147
- <dd>
148
-
149
- Returns health status of the Drug Safety API subsystem including
150
- overall system health and availability.
151
-
152
- No authentication required. Designed for monitoring services.
153
- </dd>
154
- </dl>
155
- </dd>
156
- </dl>
157
-
158
- #### 🔌 Usage
159
-
160
- <dl>
161
- <dd>
162
-
163
- <dl>
164
- <dd>
165
-
166
- ```typescript
167
- await client.drugSafety.getDrugSafetyHealth();
168
-
169
- ```
170
- </dd>
171
- </dl>
172
- </dd>
173
- </dl>
174
-
175
- #### ⚙️ Parameters
176
-
177
- <dl>
178
- <dd>
179
-
180
- <dl>
181
- <dd>
182
-
183
- **requestOptions:** `DrugSafetyClient.RequestOptions`
184
-
185
- </dd>
186
- </dl>
187
- </dd>
188
- </dl>
189
-
190
-
191
- </dd>
192
- </dl>
193
- </details>
194
-
195
- ## Developers
196
- <details><summary><code>client.developers.<a href="/src/api/resources/developers/client/Client.ts">createFreeKey</a>({ ...params }) -> SafeRx.CreateFreeKeyDevelopersResponse</code></summary>
197
- <dl>
198
- <dd>
199
-
200
- #### 📝 Description
201
-
202
- <dl>
203
- <dd>
204
-
205
- <dl>
206
- <dd>
207
-
208
- Step 1 of 2: Request a verification code to get a free API key.
209
-
210
- - Sends a 6-digit code to your email (expires in 30 minutes)
211
- - Max 5 codes per email per hour (anti-spam)
212
- - If email already has a verified key, returns it immediately
213
- - Use POST /api/developers/keys/free/verify with the code to receive your key
214
- </dd>
215
- </dl>
216
- </dd>
217
- </dl>
218
-
219
- #### 🔌 Usage
220
-
221
- <dl>
222
- <dd>
223
-
224
- <dl>
225
- <dd>
226
-
227
- ```typescript
228
- await client.developers.createFreeKey({
229
- email: "developer@example.com"
230
- });
231
-
232
- ```
233
- </dd>
234
- </dl>
235
- </dd>
236
- </dl>
237
-
238
- #### ⚙️ Parameters
239
-
240
- <dl>
241
- <dd>
242
-
243
- <dl>
244
- <dd>
245
-
246
- **request:** `SafeRx.CreateFreeKeyDevelopersRequest`
247
-
248
- </dd>
249
- </dl>
250
-
251
- <dl>
252
- <dd>
253
-
254
- **requestOptions:** `DevelopersClient.RequestOptions`
255
-
256
- </dd>
257
- </dl>
258
- </dd>
259
- </dl>
260
-
261
-
262
- </dd>
263
- </dl>
264
- </details>
265
-
266
- <details><summary><code>client.developers.<a href="/src/api/resources/developers/client/Client.ts">verifyFreeKey</a>({ ...params }) -> SafeRx.VerifyFreeKeyDevelopersResponse</code></summary>
267
- <dl>
268
- <dd>
269
-
270
- #### 📝 Description
271
-
272
- <dl>
273
- <dd>
274
-
275
- <dl>
276
- <dd>
277
-
278
- Step 2 of 2: Verify your email with the 6-digit code and receive your API key.
279
-
280
- - Code expires after 30 minutes
281
- - Max 5 wrong attempts per code (then must request new code)
282
- - On success: issues sfx_free_ key (persistent, 1 per email)
283
- - Free tier: 20 requests/minute, 60 requests/day
284
- </dd>
285
- </dl>
286
- </dd>
287
- </dl>
288
-
289
- #### 🔌 Usage
290
-
291
- <dl>
292
- <dd>
293
-
294
- <dl>
295
- <dd>
296
-
297
- ```typescript
298
- await client.developers.verifyFreeKey({
299
- email: "developer@example.com",
300
- code: "123456"
301
- });
302
-
303
- ```
304
- </dd>
305
- </dl>
306
- </dd>
307
- </dl>
308
-
309
- #### ⚙️ Parameters
310
-
311
- <dl>
312
- <dd>
313
-
314
- <dl>
315
- <dd>
316
-
317
- **request:** `SafeRx.VerifyFreeKeyDevelopersRequest`
318
-
319
- </dd>
320
- </dl>
321
-
322
- <dl>
323
- <dd>
324
-
325
- **requestOptions:** `DevelopersClient.RequestOptions`
326
-
327
- </dd>
328
- </dl>
329
- </dd>
330
- </dl>
331
-
332
-
333
- </dd>
334
- </dl>
335
- </details>