Registry / database / sof-mssql

sof-mssql

JSON →
library2.2.0jsnpmunverified

A TypeScript library and CLI tool (v2.2.0) for loading FHIR R4 resources into Microsoft SQL Server and transpiling SQL on FHIR v2 ViewDefinitions into T-SQL queries. It uses JSON_VALUE, JSON_QUERY, and OPENJSON for efficient query generation, supports FHIRPath expressions, array flattening via CROSS APPLY, and unionAll for polymorphic fields. Includes a bulk NDJSON loader with options for batching, parallel processing, and connection configuration via environment variables. Compatible with Node.js >=18.0.0 and ships TypeScript declarations.

npm install sof-mssql
INSTALL
IMPORT
SIG · SOF-MSSQL
S
sof-mssql
databasejavascriptv2.2.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import sofMssql from 'sof-mssql'
const sofMssql = require('sof-mssql')
ESM-only package; named exports also available in v2.1+
transpile
import { transpile } from 'sof-mssql'
import { transpileView } from 'sof-mssql'
Function takes ViewDefinition object, returns T-SQL string
loadNdjson
import { loadNdjson } from 'sof-mssql'
import loadNdjson from 'sof-mssql'
Named export for programmatic loading; requires tedious connection config

Transpile a ViewDefinition object to a T-SQL query string using the transpile function.

import { transpile } from 'sof-mssql'; import { readFileSync } from 'fs'; import { fileURLToPath } from 'url'; import { dirname, join } from 'path'; // Load a ViewDefinition JSON file const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); const viewDefPath = join(__dirname, 'Patient.view.json'); const viewDef = JSON.parse(readFileSync(viewDefPath, 'utf8')); // Transpile to T-SQL try { const sql = transpile(viewDef); console.log('Generated T-SQL query:'); console.log(sql); } catch (error) { console.error('Transpilation failed:', error.message); }
Debug
Known issues
breakingNode.js <18 not supported; engine restricts >=18.0.0
fix
Upgrade Node.js to version 18+ or use version 1.x
affects: >=2.0.0
breakingPackage is ESM-only; require() will throw ERR_REQUIRE_ESM
fix
Use import syntax or dynamic import() instead of require()
affects: >=2.0.0
deprecatedCLI options changed: --user and --password replaced by --username and --password? Check docs
fix
Use --user and --password (current) or update to latest syntax
affects: >=2.0.0
gotchaNDJSON files must be named exactly `ResourceType.ndjson`; otherwise data may not load
fix
Rename files to follow the pattern (e.g., Patient.ndjson)
affects: >=2.0.0
gotchaDefault batch size 1000 may be too low for large datasets, causing slow performance
fix
Increase batch size using --batch-size (e.g., 5000) for better throughput
affects: >=2.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/node_modules/sof-mssql/... not supported.
Using require() on an ESM-only package
fix
Change to import statement or use dynamic import()
Error: Cannot find module 'tedious'
Missing optional peer dependency tedious for load functionality
fix
Install tedious: npm install tedious
TypeError: transpile is not a function
Incorrect import; default import used when expecting named export
fix
Use import { transpile } from 'sof-mssql'
Error: Invalid ViewDefinition: missing required field 'resource'
ViewDefinition JSON does not contain the 'resource' field
fix
Ensure the JSON includes a 'resource' property with "Patient" etc.
Upgrade
Version history
2.2.0latest on npm
Audit
Dependencies
tediousrequiredMSSQL driver for Node.js used for database connections and queries
commanderrequiredCLI command parsing for the bin script
Agent activity
40 hits · last 30 days
node
32
OpenAI (training)
1
Resources
sof-mssql — npm install sof-mssql · libregistry