@outburn/fume-mapping-provider 0.1.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.
- package/LICENSE +21 -0
- package/README.md +397 -0
- package/dist/FumeMappingProvider.d.ts +112 -0
- package/dist/FumeMappingProvider.d.ts.map +1 -0
- package/dist/FumeMappingProvider.js +245 -0
- package/dist/FumeMappingProvider.js.map +1 -0
- package/dist/converters.d.ts +32 -0
- package/dist/converters.d.ts.map +1 -0
- package/dist/converters.js +201 -0
- package/dist/converters.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/providers.d.ts +61 -0
- package/dist/providers.d.ts.map +1 -0
- package/dist/providers.js +475 -0
- package/dist/providers.js.map +1 -0
- package/dist/types.d.ts +191 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +55 -0
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FumeMappingProvider = void 0;
|
|
4
|
+
const providers_1 = require("./providers");
|
|
5
|
+
const converters_1 = require("./converters");
|
|
6
|
+
/**
|
|
7
|
+
* Main orchestrator for FUME mappings from multiple sources
|
|
8
|
+
* Separates user mappings (file + server) from package mappings
|
|
9
|
+
*/
|
|
10
|
+
class FumeMappingProvider {
|
|
11
|
+
constructor(config) {
|
|
12
|
+
this.config = config;
|
|
13
|
+
this.userMappingsCache = new Map();
|
|
14
|
+
this.cachedAliases = {};
|
|
15
|
+
this.logger = config.logger;
|
|
16
|
+
this.initializeProviders();
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Initialize providers based on configuration
|
|
20
|
+
*/
|
|
21
|
+
initializeProviders() {
|
|
22
|
+
// User mapping provider (file + server)
|
|
23
|
+
if (this.config.mappingsFolder || this.config.fhirClient) {
|
|
24
|
+
this.logger?.info?.('Initializing user mapping provider');
|
|
25
|
+
this.userProvider = new providers_1.UserMappingProvider(this.config.mappingsFolder, this.config.fhirClient, this.logger, this.config.fileExtension);
|
|
26
|
+
}
|
|
27
|
+
// Package mapping provider
|
|
28
|
+
if (this.config.packageExplorer) {
|
|
29
|
+
this.logger?.info?.('Initializing package mapping provider');
|
|
30
|
+
this.packageProvider = new providers_1.PackageMappingProvider(this.config.packageExplorer, this.logger);
|
|
31
|
+
}
|
|
32
|
+
// Alias provider (server only)
|
|
33
|
+
if (this.config.fhirClient) {
|
|
34
|
+
this.logger?.info?.('Initializing alias provider');
|
|
35
|
+
this.aliasProvider = new providers_1.AliasProvider(this.config.fhirClient, this.logger);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Initialize all providers (load user mappings and aliases into cache)
|
|
40
|
+
*/
|
|
41
|
+
async initialize() {
|
|
42
|
+
this.logger?.info?.('Initializing FUME Mapping Provider');
|
|
43
|
+
if (this.userProvider) {
|
|
44
|
+
this.logger?.info?.('Loading user mappings');
|
|
45
|
+
this.userMappingsCache = await this.userProvider.loadMappings();
|
|
46
|
+
this.logger?.info?.(`Loaded ${this.userMappingsCache.size} user mapping(s)`);
|
|
47
|
+
}
|
|
48
|
+
if (this.aliasProvider) {
|
|
49
|
+
this.logger?.info?.('Loading aliases');
|
|
50
|
+
this.cachedAliases = await this.aliasProvider.loadAliases();
|
|
51
|
+
this.logger?.info?.(`Loaded ${Object.keys(this.cachedAliases).length} alias(es)`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Reload all user mappings
|
|
56
|
+
*/
|
|
57
|
+
async reloadUserMappings() {
|
|
58
|
+
/* istanbul ignore if */
|
|
59
|
+
if (!this.userProvider) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
this.logger?.info?.('Reloading user mappings');
|
|
63
|
+
this.userMappingsCache = await this.userProvider.loadMappings();
|
|
64
|
+
this.logger?.info?.(`Reloaded ${this.userMappingsCache.size} user mapping(s)`);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Refresh a specific user mapping by key
|
|
68
|
+
* @param key - The mapping key to refresh
|
|
69
|
+
* @param mapping - Optional mapping to use directly (avoids server roundtrip)
|
|
70
|
+
* @returns The refreshed mapping or null if not found
|
|
71
|
+
*/
|
|
72
|
+
async refreshUserMapping(key, mapping) {
|
|
73
|
+
/* istanbul ignore if */
|
|
74
|
+
if (!this.userProvider) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
// If mapping provided, use it directly (optimistic update)
|
|
78
|
+
if (mapping !== undefined) {
|
|
79
|
+
if (mapping) {
|
|
80
|
+
this.userMappingsCache.set(key, mapping);
|
|
81
|
+
this.logger?.debug?.(`Updated user mapping cache with provided value: ${key}`);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
this.userMappingsCache.delete(key);
|
|
85
|
+
this.logger?.debug?.(`Removed user mapping from cache: ${key}`);
|
|
86
|
+
}
|
|
87
|
+
return mapping;
|
|
88
|
+
}
|
|
89
|
+
// Otherwise fetch from source
|
|
90
|
+
const fetchedMapping = await this.userProvider.refreshMapping(key);
|
|
91
|
+
if (fetchedMapping) {
|
|
92
|
+
this.userMappingsCache.set(key, fetchedMapping);
|
|
93
|
+
this.logger?.debug?.(`Refreshed user mapping: ${key}`);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
this.userMappingsCache.delete(key);
|
|
97
|
+
this.logger?.debug?.(`User mapping no longer exists: ${key}`);
|
|
98
|
+
}
|
|
99
|
+
return fetchedMapping;
|
|
100
|
+
}
|
|
101
|
+
// ========== USER MAPPING API ==========
|
|
102
|
+
/**
|
|
103
|
+
* Get all user mappings (lightning-fast - from cache)
|
|
104
|
+
*/
|
|
105
|
+
getUserMappings() {
|
|
106
|
+
return Array.from(this.userMappingsCache.values());
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Get all user mapping keys (lightning-fast - from cache)
|
|
110
|
+
*/
|
|
111
|
+
getUserMappingKeys() {
|
|
112
|
+
return Array.from(this.userMappingsCache.keys());
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Get user mapping metadata (lightning-fast - from cache)
|
|
116
|
+
*/
|
|
117
|
+
getUserMappingsMetadata() {
|
|
118
|
+
return this.getUserMappings().map(m => ({
|
|
119
|
+
key: m.key,
|
|
120
|
+
source: m.source,
|
|
121
|
+
filename: m.filename,
|
|
122
|
+
sourceServer: m.sourceServer,
|
|
123
|
+
name: m.name,
|
|
124
|
+
url: m.url
|
|
125
|
+
}));
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Get a user mapping by key (lightning-fast - from cache)
|
|
129
|
+
*/
|
|
130
|
+
getUserMapping(key) {
|
|
131
|
+
return this.userMappingsCache.get(key);
|
|
132
|
+
}
|
|
133
|
+
// ========== PACKAGE MAPPING API ==========
|
|
134
|
+
/**
|
|
135
|
+
* Get all package mappings
|
|
136
|
+
* Always fresh from FPE (packages are immutable, FPE handles caching)
|
|
137
|
+
*/
|
|
138
|
+
async getPackageMappings(options) {
|
|
139
|
+
if (!this.packageProvider) {
|
|
140
|
+
return [];
|
|
141
|
+
}
|
|
142
|
+
return await this.packageProvider.loadMappings(options);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Get package mapping metadata
|
|
146
|
+
*/
|
|
147
|
+
async getPackageMappingsMetadata(options) {
|
|
148
|
+
const mappings = await this.getPackageMappings(options);
|
|
149
|
+
return mappings.map(m => ({
|
|
150
|
+
id: m.id,
|
|
151
|
+
packageId: m.packageId,
|
|
152
|
+
packageVersion: m.packageVersion,
|
|
153
|
+
filename: m.filename,
|
|
154
|
+
name: m.name,
|
|
155
|
+
url: m.url
|
|
156
|
+
}));
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Get a package mapping by identifier (tries url, id, name in order)
|
|
160
|
+
*/
|
|
161
|
+
async getPackageMapping(identifier, options) {
|
|
162
|
+
/* istanbul ignore if */
|
|
163
|
+
if (!this.packageProvider) {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
return await this.packageProvider.getMapping(identifier, options);
|
|
167
|
+
}
|
|
168
|
+
// ========== ALIAS API ==========
|
|
169
|
+
/**
|
|
170
|
+
* Reload all aliases from server
|
|
171
|
+
*/
|
|
172
|
+
async reloadAliases() {
|
|
173
|
+
/* istanbul ignore if */
|
|
174
|
+
if (!this.aliasProvider) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
this.logger?.info?.('Reloading aliases');
|
|
178
|
+
this.cachedAliases = await this.aliasProvider.loadAliases();
|
|
179
|
+
this.logger?.info?.(`Reloaded ${Object.keys(this.cachedAliases).length} alias(es)`);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Register or update a single alias (optimistic cache update without server roundtrip)
|
|
183
|
+
* @param name - The alias name/key
|
|
184
|
+
* @param value - The alias value
|
|
185
|
+
*/
|
|
186
|
+
registerAlias(name, value) {
|
|
187
|
+
this.cachedAliases[name] = value;
|
|
188
|
+
this.logger?.debug?.(`Registered alias: ${name}`);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Delete a specific alias from the cache
|
|
192
|
+
* @param name - The alias name/key to delete
|
|
193
|
+
*/
|
|
194
|
+
deleteAlias(name) {
|
|
195
|
+
delete this.cachedAliases[name];
|
|
196
|
+
this.logger?.debug?.(`Deleted alias: ${name}`);
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Get all cached aliases as a single object (lightning-fast - from cache)
|
|
200
|
+
* @returns The alias object with all key-value mappings
|
|
201
|
+
*/
|
|
202
|
+
getAliases() {
|
|
203
|
+
return { ...this.cachedAliases };
|
|
204
|
+
}
|
|
205
|
+
// ========== ALIAS CONVERTERS ==========
|
|
206
|
+
/**
|
|
207
|
+
* Transform a ConceptMap resource into an alias object
|
|
208
|
+
* @param conceptMap - The ConceptMap resource
|
|
209
|
+
* @returns An alias object with key-value mappings
|
|
210
|
+
*/
|
|
211
|
+
static conceptMapToAliasObject(conceptMap) {
|
|
212
|
+
return (0, converters_1.conceptMapToAliasObject)(conceptMap);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Transform an alias object into a ConceptMap resource
|
|
216
|
+
* @param aliases - The alias object
|
|
217
|
+
* @param canonicalBaseUrl - Base URL for canonical references (defaults to example.com)
|
|
218
|
+
* @param existingConceptMap - Optional existing ConceptMap to update
|
|
219
|
+
* @returns A ConceptMap resource
|
|
220
|
+
*/
|
|
221
|
+
static aliasObjectToConceptMap(aliases, canonicalBaseUrl, existingConceptMap) {
|
|
222
|
+
return (0, converters_1.aliasObjectToConceptMap)(aliases, canonicalBaseUrl || 'http://example.com', existingConceptMap);
|
|
223
|
+
}
|
|
224
|
+
// ========== MAPPING CONVERTERS ==========
|
|
225
|
+
/**
|
|
226
|
+
* Extract FUME expression from a StructureMap resource
|
|
227
|
+
* @param structureMap - The StructureMap resource
|
|
228
|
+
* @returns The FUME expression or null if not found
|
|
229
|
+
*/
|
|
230
|
+
static structureMapToExpression(structureMap) {
|
|
231
|
+
return (0, converters_1.structureMapToExpression)(structureMap);
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Create a StructureMap resource from a FUME expression
|
|
235
|
+
* @param mappingId - The mapping identifier
|
|
236
|
+
* @param expression - The FUME expression
|
|
237
|
+
* @param canonicalBaseUrl - Base URL for canonical references (defaults to example.com)
|
|
238
|
+
* @returns A StructureMap resource
|
|
239
|
+
*/
|
|
240
|
+
static expressionToStructureMap(mappingId, expression, canonicalBaseUrl) {
|
|
241
|
+
return (0, converters_1.expressionToStructureMap)(mappingId, expression, canonicalBaseUrl);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
exports.FumeMappingProvider = FumeMappingProvider;
|
|
245
|
+
//# sourceMappingURL=FumeMappingProvider.js.map
|
|
@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,EAAE,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;IACnC,CAAC;IAED,yCAAyC;IAEzC;;;;OAIG;IACH,MAAM,CAAC,uBAAuB,CAAC,UAAsB;QACnD,OAAO,IAAA,oCAAuB,EAAC,UAAU,CAAC,CAAC;IAC7C,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,uBAAuB,CAC5B,OAAoB,EACpB,gBAAyB,EACzB,kBAA+B;QAE/B,OAAO,IAAA,oCAAuB,EAAC,OAAO,EAAE,gBAAgB,IAAI,oBAAoB,EAAE,kBAAkB,CAAC,CAAC;IACxG,CAAC;IAED,2CAA2C;IAE3C;;;;OAIG;IACH,MAAM,CAAC,wBAAwB,CAAC,YAA0B;QACxD,OAAO,IAAA,qCAAwB,EAAC,YAAY,CAAC,CAAC;IAChD,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,wBAAwB,CAC7B,SAAiB,EACjB,UAAkB,EAClB,gBAAyB;QAEzB,OAAO,IAAA,qCAAwB,EAAC,SAAS,EAAE,UAAU,EAAE,gBAAgB,CAAC,CAAC;IAC3E,CAAC;CACF;AAjSD,kDAiSC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { StructureMap, ConceptMap, AliasObject } from './types';
|
|
2
|
+
import { Logger } from '@outburn/types';
|
|
3
|
+
/**
|
|
4
|
+
* Extracts the FUME expression from a StructureMap resource
|
|
5
|
+
* @param structureMap - The StructureMap resource
|
|
6
|
+
* @returns The FUME expression or null if not found
|
|
7
|
+
*/
|
|
8
|
+
export declare function structureMapToExpression(structureMap: StructureMap): string | null;
|
|
9
|
+
/**
|
|
10
|
+
* Creates a StructureMap resource from a FUME expression
|
|
11
|
+
* @param mappingId - The mapping identifier
|
|
12
|
+
* @param expression - The FUME expression
|
|
13
|
+
* @param canonicalBaseUrl - Base URL for canonical references (defaults to example.com)
|
|
14
|
+
* @returns A StructureMap resource
|
|
15
|
+
*/
|
|
16
|
+
export declare function expressionToStructureMap(mappingId: string, expression: string, canonicalBaseUrl?: string): StructureMap;
|
|
17
|
+
/**
|
|
18
|
+
* Transforms a ConceptMap resource into an alias object
|
|
19
|
+
* @param conceptMap - The ConceptMap resource
|
|
20
|
+
* @param logger - Optional logger for warnings
|
|
21
|
+
* @returns An alias object with key-value mappings
|
|
22
|
+
*/
|
|
23
|
+
export declare function conceptMapToAliasObject(conceptMap: ConceptMap, logger?: Logger): AliasObject;
|
|
24
|
+
/**
|
|
25
|
+
* Transforms an alias object into a ConceptMap resource
|
|
26
|
+
* @param aliases - The alias object
|
|
27
|
+
* @param canonicalBaseUrl - Base URL for canonical references
|
|
28
|
+
* @param existingConceptMap - Optional existing ConceptMap to update
|
|
29
|
+
* @returns A ConceptMap resource
|
|
30
|
+
*/
|
|
31
|
+
export declare function aliasObjectToConceptMap(aliases: AliasObject, canonicalBaseUrl?: string, existingConceptMap?: ConceptMap): ConceptMap;
|
|
32
|
+
//# sourceMappingURL=converters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"converters.d.ts","sourceRoot":"","sources":["../src/converters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAKxC;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM,GAAG,IAAI,CAwBlF;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,gBAAgB,GAAE,MAA+B,GAChD,YAAY,CAyEd;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,WAAW,CA0B5F;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,WAAW,EACpB,gBAAgB,GAAE,MAA+B,EACjD,kBAAkB,CAAC,EAAE,UAAU,GAC9B,UAAU,CAsDZ"}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.structureMapToExpression = structureMapToExpression;
|
|
4
|
+
exports.expressionToStructureMap = expressionToStructureMap;
|
|
5
|
+
exports.conceptMapToAliasObject = conceptMapToAliasObject;
|
|
6
|
+
exports.aliasObjectToConceptMap = aliasObjectToConceptMap;
|
|
7
|
+
const DEFAULT_CANONICAL_BASE = 'http://example.com';
|
|
8
|
+
const FUME_EXPRESSION_EXTENSION_URL = 'http://fhir.fume.health/StructureDefinition/mapping-expression';
|
|
9
|
+
/**
|
|
10
|
+
* Extracts the FUME expression from a StructureMap resource
|
|
11
|
+
* @param structureMap - The StructureMap resource
|
|
12
|
+
* @returns The FUME expression or null if not found
|
|
13
|
+
*/
|
|
14
|
+
function structureMapToExpression(structureMap) {
|
|
15
|
+
if (!structureMap.group || structureMap.group.length === 0) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
for (const group of structureMap.group) {
|
|
19
|
+
if (!group.rule || group.rule.length === 0) {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
for (const rule of group.rule) {
|
|
23
|
+
if (!rule.extension || rule.extension.length === 0) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
for (const ext of rule.extension) {
|
|
27
|
+
if (ext.url === FUME_EXPRESSION_EXTENSION_URL && ext.valueExpression?.expression) {
|
|
28
|
+
return ext.valueExpression.expression;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Creates a StructureMap resource from a FUME expression
|
|
37
|
+
* @param mappingId - The mapping identifier
|
|
38
|
+
* @param expression - The FUME expression
|
|
39
|
+
* @param canonicalBaseUrl - Base URL for canonical references (defaults to example.com)
|
|
40
|
+
* @returns A StructureMap resource
|
|
41
|
+
*/
|
|
42
|
+
function expressionToStructureMap(mappingId, expression, canonicalBaseUrl = DEFAULT_CANONICAL_BASE) {
|
|
43
|
+
const canonical = `${canonicalBaseUrl}/StructureMap/${mappingId}`;
|
|
44
|
+
const date = new Date().toISOString();
|
|
45
|
+
return {
|
|
46
|
+
resourceType: 'StructureMap',
|
|
47
|
+
id: mappingId,
|
|
48
|
+
url: canonical,
|
|
49
|
+
identifier: [
|
|
50
|
+
{
|
|
51
|
+
use: 'official',
|
|
52
|
+
type: {
|
|
53
|
+
text: 'Canonical URL'
|
|
54
|
+
},
|
|
55
|
+
system: 'urn:ietf:rfc:3986',
|
|
56
|
+
value: canonical
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
name: mappingId,
|
|
60
|
+
title: mappingId,
|
|
61
|
+
status: 'active',
|
|
62
|
+
date,
|
|
63
|
+
useContext: [
|
|
64
|
+
{
|
|
65
|
+
code: {
|
|
66
|
+
system: 'http://snomed.info/sct',
|
|
67
|
+
code: '706594005',
|
|
68
|
+
display: 'Information system software'
|
|
69
|
+
},
|
|
70
|
+
valueCodeableConcept: {
|
|
71
|
+
coding: [
|
|
72
|
+
{
|
|
73
|
+
system: 'http://codes.fume.health',
|
|
74
|
+
code: 'fume',
|
|
75
|
+
display: 'FUME'
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
text: 'FUME'
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
],
|
|
82
|
+
group: [
|
|
83
|
+
{
|
|
84
|
+
name: 'fumeMapping',
|
|
85
|
+
typeMode: 'none',
|
|
86
|
+
input: [
|
|
87
|
+
{
|
|
88
|
+
name: 'input',
|
|
89
|
+
mode: 'source'
|
|
90
|
+
}
|
|
91
|
+
],
|
|
92
|
+
rule: [
|
|
93
|
+
{
|
|
94
|
+
extension: [
|
|
95
|
+
{
|
|
96
|
+
url: FUME_EXPRESSION_EXTENSION_URL,
|
|
97
|
+
valueExpression: {
|
|
98
|
+
language: 'application/vnd.outburn.fume',
|
|
99
|
+
expression
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
],
|
|
103
|
+
name: 'evaluate',
|
|
104
|
+
source: [
|
|
105
|
+
{
|
|
106
|
+
context: 'input'
|
|
107
|
+
}
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Transforms a ConceptMap resource into an alias object
|
|
117
|
+
* @param conceptMap - The ConceptMap resource
|
|
118
|
+
* @param logger - Optional logger for warnings
|
|
119
|
+
* @returns An alias object with key-value mappings
|
|
120
|
+
*/
|
|
121
|
+
function conceptMapToAliasObject(conceptMap, logger) {
|
|
122
|
+
const aliases = {};
|
|
123
|
+
if (!conceptMap.group) {
|
|
124
|
+
return aliases;
|
|
125
|
+
}
|
|
126
|
+
for (const group of conceptMap.group) {
|
|
127
|
+
if (!group.element) {
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
for (const element of group.element) {
|
|
131
|
+
const key = element.code;
|
|
132
|
+
const value = element.target?.[0]?.code;
|
|
133
|
+
if (key && value) {
|
|
134
|
+
if (aliases[key]) {
|
|
135
|
+
logger?.warn?.(`Duplicate alias key found: ${key}`);
|
|
136
|
+
}
|
|
137
|
+
aliases[key] = value;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return aliases;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Transforms an alias object into a ConceptMap resource
|
|
145
|
+
* @param aliases - The alias object
|
|
146
|
+
* @param canonicalBaseUrl - Base URL for canonical references
|
|
147
|
+
* @param existingConceptMap - Optional existing ConceptMap to update
|
|
148
|
+
* @returns A ConceptMap resource
|
|
149
|
+
*/
|
|
150
|
+
function aliasObjectToConceptMap(aliases, canonicalBaseUrl = DEFAULT_CANONICAL_BASE, existingConceptMap) {
|
|
151
|
+
const elements = Object.entries(aliases).map(([key, value]) => ({
|
|
152
|
+
code: key,
|
|
153
|
+
target: [
|
|
154
|
+
{
|
|
155
|
+
code: value,
|
|
156
|
+
equivalence: 'equivalent'
|
|
157
|
+
}
|
|
158
|
+
]
|
|
159
|
+
}));
|
|
160
|
+
const date = new Date().toISOString();
|
|
161
|
+
const canonical = `${canonicalBaseUrl}/ConceptMap/fume-global-aliases`;
|
|
162
|
+
// Update existing ConceptMap or create new one
|
|
163
|
+
const conceptMap = existingConceptMap || {
|
|
164
|
+
resourceType: 'ConceptMap',
|
|
165
|
+
url: canonical,
|
|
166
|
+
name: 'FumeAliases',
|
|
167
|
+
status: 'active',
|
|
168
|
+
publisher: 'Outburn Ltd.',
|
|
169
|
+
description: 'The value associated with each FUME alias',
|
|
170
|
+
useContext: [
|
|
171
|
+
{
|
|
172
|
+
code: {
|
|
173
|
+
system: 'http://snomed.info/sct',
|
|
174
|
+
code: '706594005',
|
|
175
|
+
display: 'Information system software'
|
|
176
|
+
},
|
|
177
|
+
valueCodeableConcept: {
|
|
178
|
+
coding: [
|
|
179
|
+
{
|
|
180
|
+
system: 'http://codes.fume.health',
|
|
181
|
+
code: 'fume',
|
|
182
|
+
display: 'FUME Mapping Engine'
|
|
183
|
+
}
|
|
184
|
+
],
|
|
185
|
+
text: 'FUME - FHIR-Utilized Mapping Engine'
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
]
|
|
189
|
+
};
|
|
190
|
+
// Update mutable fields
|
|
191
|
+
conceptMap.date = date;
|
|
192
|
+
conceptMap.group = [
|
|
193
|
+
{
|
|
194
|
+
source: `${canonicalBaseUrl}/CodeSystem/fume-global-alias-name`,
|
|
195
|
+
target: `${canonicalBaseUrl}/CodeSystem/fume-global-alias-value`,
|
|
196
|
+
element: elements
|
|
197
|
+
}
|
|
198
|
+
];
|
|
199
|
+
return conceptMap;
|
|
200
|
+
}
|
|
201
|
+
//# sourceMappingURL=converters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"converters.js","sourceRoot":"","sources":["../src/converters.ts"],"names":[],"mappings":";;AAWA,4DAwBC;AASD,4DA6EC;AAQD,0DA0BC;AASD,0DA0DC;AA3ND,MAAM,sBAAsB,GAAG,oBAAoB,CAAC;AACpD,MAAM,6BAA6B,GAAG,gEAAgE,CAAC;AAEvG;;;;GAIG;AACH,SAAgB,wBAAwB,CAAC,YAA0B;IACjE,IAAI,CAAC,YAAY,CAAC,KAAK,IAAI,YAAY,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3D,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,MAAM,KAAK,IAAI,YAAY,CAAC,KAAK,EAAE,CAAC;QACvC,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3C,SAAS;QACX,CAAC;QAED,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;YAC9B,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACnD,SAAS;YACX,CAAC;YAED,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;gBACjC,IAAI,GAAG,CAAC,GAAG,KAAK,6BAA6B,IAAI,GAAG,CAAC,eAAe,EAAE,UAAU,EAAE,CAAC;oBACjF,OAAO,GAAG,CAAC,eAAe,CAAC,UAAU,CAAC;gBACxC,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,wBAAwB,CACtC,SAAiB,EACjB,UAAkB,EAClB,mBAA2B,sBAAsB;IAEjD,MAAM,SAAS,GAAG,GAAG,gBAAgB,iBAAiB,SAAS,EAAE,CAAC;IACl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IAAI;QACnD,YAAY,EAAE,YAAY;QAC1B,GAAG,EAAE,SAAS;QACd,IAAI,EAAE,aAAa;QACnB,MAAM,EAAE,QAAQ;QAChB,SAAS,EAAE,cAAc;QACzB,WAAW,EAAE,2CAA2C;QACxD,UAAU,EAAE;YACV;gBACE,IAAI,EAAE;oBACJ,MAAM,EAAE,wBAAwB;oBAChC,IAAI,EAAE,WAAW;oBACjB,OAAO,EAAE,6BAA6B;iBACvC;gBACD,oBAAoB,EAAE;oBACpB,MAAM,EAAE;wBACN;4BACE,MAAM,EAAE,0BAA0B;4BAClC,IAAI,EAAE,MAAM;4BACZ,OAAO,EAAE,qBAAqB;yBAC/B;qBACF;oBACD,IAAI,EAAE,qCAAqC;iBAC5C;aACF;SACF;KACF,CAAC;IAEF,wBAAwB;IACxB,UAAU,CAAC,IAAI,GAAG,IAAI,CAAC;IACvB,UAAU,CAAC,KAAK,GAAG;QACjB;YACE,MAAM,EAAE,GAAG,gBAAgB,oCAAoC;YAC/D,MAAM,EAAE,GAAG,gBAAgB,qCAAqC;YAChE,OAAO,EAAE,QAAQ;SAClB;KACF,CAAC;IAEF,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { FumeMappingProvider } from './FumeMappingProvider';
|
|
2
|
+
export { UserMapping, UserMappingMetadata, PackageMapping, PackageMappingMetadata, StructureMap, ConceptMap, AliasObject, FumeMappingProviderConfig, GetPackageMappingOptions } from './types';
|
|
3
|
+
export { structureMapToExpression, expressionToStructureMap, conceptMapToAliasObject, aliasObjectToConceptMap } from './converters';
|
|
4
|
+
export { UserMappingProvider, PackageMappingProvider, AliasProvider } from './providers';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAG5D,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,cAAc,EACd,sBAAsB,EACtB,YAAY,EACZ,UAAU,EACV,WAAW,EACX,yBAAyB,EACzB,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,aAAa,EACd,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AliasProvider = exports.PackageMappingProvider = exports.UserMappingProvider = exports.aliasObjectToConceptMap = exports.conceptMapToAliasObject = exports.expressionToStructureMap = exports.structureMapToExpression = exports.FumeMappingProvider = void 0;
|
|
4
|
+
// Export main class
|
|
5
|
+
var FumeMappingProvider_1 = require("./FumeMappingProvider");
|
|
6
|
+
Object.defineProperty(exports, "FumeMappingProvider", { enumerable: true, get: function () { return FumeMappingProvider_1.FumeMappingProvider; } });
|
|
7
|
+
// Export converters
|
|
8
|
+
var converters_1 = require("./converters");
|
|
9
|
+
Object.defineProperty(exports, "structureMapToExpression", { enumerable: true, get: function () { return converters_1.structureMapToExpression; } });
|
|
10
|
+
Object.defineProperty(exports, "expressionToStructureMap", { enumerable: true, get: function () { return converters_1.expressionToStructureMap; } });
|
|
11
|
+
Object.defineProperty(exports, "conceptMapToAliasObject", { enumerable: true, get: function () { return converters_1.conceptMapToAliasObject; } });
|
|
12
|
+
Object.defineProperty(exports, "aliasObjectToConceptMap", { enumerable: true, get: function () { return converters_1.aliasObjectToConceptMap; } });
|
|
13
|
+
// Export providers (for advanced usage)
|
|
14
|
+
var providers_1 = require("./providers");
|
|
15
|
+
Object.defineProperty(exports, "UserMappingProvider", { enumerable: true, get: function () { return providers_1.UserMappingProvider; } });
|
|
16
|
+
Object.defineProperty(exports, "PackageMappingProvider", { enumerable: true, get: function () { return providers_1.PackageMappingProvider; } });
|
|
17
|
+
Object.defineProperty(exports, "AliasProvider", { enumerable: true, get: function () { return providers_1.AliasProvider; } });
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,oBAAoB;AACpB,6DAA4D;AAAnD,0HAAA,mBAAmB,OAAA;AAe5B,oBAAoB;AACpB,2CAKsB;AAJpB,sHAAA,wBAAwB,OAAA;AACxB,sHAAA,wBAAwB,OAAA;AACxB,qHAAA,uBAAuB,OAAA;AACvB,qHAAA,uBAAuB,OAAA;AAGzB,wCAAwC;AACxC,yCAIqB;AAHnB,gHAAA,mBAAmB,OAAA;AACnB,mHAAA,sBAAsB,OAAA;AACtB,0GAAA,aAAa,OAAA"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { UserMapping, PackageMapping, GetPackageMappingOptions, AliasObject } from './types';
|
|
2
|
+
import { Logger } from '@outburn/types';
|
|
3
|
+
/**
|
|
4
|
+
* Provider for user mappings (file + server)
|
|
5
|
+
* Handles collision resolution: file overrides server
|
|
6
|
+
*/
|
|
7
|
+
export declare class UserMappingProvider {
|
|
8
|
+
private mappingsFolder;
|
|
9
|
+
private fhirClient;
|
|
10
|
+
private logger?;
|
|
11
|
+
private fileExtension;
|
|
12
|
+
constructor(mappingsFolder: string | undefined, fhirClient: any | undefined, logger?: Logger | undefined, fileExtension?: string);
|
|
13
|
+
/**
|
|
14
|
+
* Load all user mappings from file and server
|
|
15
|
+
* File mappings override server mappings on key collision (with warning)
|
|
16
|
+
*/
|
|
17
|
+
loadMappings(): Promise<Map<string, UserMapping>>;
|
|
18
|
+
/**
|
|
19
|
+
* Refresh a specific user mapping by key
|
|
20
|
+
* Checks both file and server (file takes precedence)
|
|
21
|
+
*/
|
|
22
|
+
refreshMapping(key: string): Promise<UserMapping | null>;
|
|
23
|
+
private loadFileMappings;
|
|
24
|
+
private loadFileMapping;
|
|
25
|
+
private loadServerMappings;
|
|
26
|
+
private loadServerMapping;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Provider for package mappings
|
|
30
|
+
* No collision handling needed - packages are immutable
|
|
31
|
+
*/
|
|
32
|
+
export declare class PackageMappingProvider {
|
|
33
|
+
private packageExplorer;
|
|
34
|
+
private logger?;
|
|
35
|
+
constructor(packageExplorer: any, logger?: Logger | undefined);
|
|
36
|
+
/**
|
|
37
|
+
* Load all package mappings
|
|
38
|
+
* Returns array since package mappings don't need key-based lookup
|
|
39
|
+
*/
|
|
40
|
+
loadMappings(options?: GetPackageMappingOptions): Promise<PackageMapping[]>;
|
|
41
|
+
/**
|
|
42
|
+
* Get a package mapping by identifier (tries url, id, name in order)
|
|
43
|
+
* Returns first successful resolution
|
|
44
|
+
*/
|
|
45
|
+
getMapping(identifier: string, options?: GetPackageMappingOptions): Promise<PackageMapping | null>;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Provider for aliases (server only)
|
|
49
|
+
* Handles loading and transforming FUME alias ConceptMap resources
|
|
50
|
+
*/
|
|
51
|
+
export declare class AliasProvider {
|
|
52
|
+
private fhirClient;
|
|
53
|
+
private logger?;
|
|
54
|
+
constructor(fhirClient: any | undefined, logger?: Logger | undefined);
|
|
55
|
+
/**
|
|
56
|
+
* Load aliases from FHIR server
|
|
57
|
+
* @returns AliasObject with all aliases, or empty object if none found
|
|
58
|
+
*/
|
|
59
|
+
loadAliases(): Promise<AliasObject>;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=providers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../src/providers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAgB,wBAAwB,EAAc,WAAW,E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