fhirsmith 0.8.5 → 0.9.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/CHANGELOG.md +51 -0
- package/README.md +52 -22
- package/extension-tracker/extension-tracker-template.html +3 -1
- package/library/html-server.js +7 -0
- package/library/logger.js +234 -194
- package/library/regex-utilities.js +13 -0
- package/package.json +4 -2
- package/packages/packages-template.html +3 -1
- package/publisher/publisher-template.html +1 -0
- package/publisher/publisher.js +28 -7
- package/registry/registry-template.html +3 -1
- package/root-bare-template.html +9759 -37
- package/root-template.html +3 -2
- package/server.js +48 -12
- package/translations/Messages.properties +2 -1
- package/translations/rendering-phrases.properties +3 -1
- package/tx/cs/cs-api.js +4 -0
- package/tx/cs/cs-country.js +2 -1
- package/tx/cs/cs-cs.js +9 -4
- package/tx/cs/cs-loinc.js +2 -1
- package/tx/cs/cs-snomed.js +5 -1
- package/tx/data/OperationDefinition-ValueSet-related.json +133 -0
- package/tx/html/tx-template.html +3 -2
- package/tx/importers/atc-to-fhir.js +27 -27
- package/tx/library/codesystem.js +4 -0
- package/tx/library/renderer.js +20 -4
- package/tx/library/ucum-parsers.js +2 -1
- package/tx/ocl/cs-ocl.cjs +48 -15
- package/tx/ocl/vs-ocl.cjs +57 -34
- package/tx/operation-context.js +74 -19
- package/tx/tx-html.js +5 -5
- package/tx/tx.fhir.org.yml +4 -4
- package/tx/tx.js +1 -0
- package/tx/vs/vs-database.js +150 -100
- package/tx/vs/vs-vsac.js +90 -31
- package/tx/workers/expand.js +154 -113
- package/tx/workers/metadata.js +6 -3
- package/tx/workers/read.js +6 -3
- package/tx/workers/related.js +228 -87
- package/xig/xig-template.html +3 -1
- package/library/logger-telnet.js +0 -205
package/library/logger-telnet.js
DELETED
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Custom Winston transport for streaming logs over a TCP socket
|
|
3
|
-
* This allows viewing logs remotely via telnet or a custom client
|
|
4
|
-
*/
|
|
5
|
-
const winston = require('winston');
|
|
6
|
-
const net = require('net');
|
|
7
|
-
const Transport = winston.Transport;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Winston transport that streams logs to connected TCP clients
|
|
11
|
-
* @extends {winston.Transport}
|
|
12
|
-
*/
|
|
13
|
-
class SocketTransport extends Transport {
|
|
14
|
-
/**
|
|
15
|
-
* Create a new socket transport
|
|
16
|
-
* @param {Object} options - Transport options
|
|
17
|
-
* @param {string} [options.host='127.0.0.1'] - Host to bind to
|
|
18
|
-
* @param {number} [options.port=9300] - Port to listen on
|
|
19
|
-
* @param {string} [options.level='info'] - Minimum log level to stream
|
|
20
|
-
* @param {Function} [options.format] - Custom formatter function (msg, level, meta) => string
|
|
21
|
-
*/
|
|
22
|
-
constructor(options = {}) {
|
|
23
|
-
super(options);
|
|
24
|
-
this.name = 'socket';
|
|
25
|
-
this.level = options.level || 'info';
|
|
26
|
-
this.clients = new Set();
|
|
27
|
-
this.format = options.format || this._defaultFormat;
|
|
28
|
-
|
|
29
|
-
// Create TCP server
|
|
30
|
-
this.server = net.createServer((socket) => {
|
|
31
|
-
console.log(`Client connected to log stream from ${socket.remoteAddress}`);
|
|
32
|
-
|
|
33
|
-
// Send welcome message
|
|
34
|
-
socket.write(`=== Connected to log stream (${new Date().toISOString()}) ===\n`);
|
|
35
|
-
socket.write(`=== Log level: ${this.level} ===\n\n`);
|
|
36
|
-
|
|
37
|
-
// Add to clients set
|
|
38
|
-
this.clients.add(socket);
|
|
39
|
-
|
|
40
|
-
socket.on('close', () => {
|
|
41
|
-
console.log(`Client disconnected from log stream: ${socket.remoteAddress}`);
|
|
42
|
-
this.clients.delete(socket);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
socket.on('error', (err) => {
|
|
46
|
-
console.error(`Socket error: ${err.message}`);
|
|
47
|
-
this.clients.delete(socket);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
// Support for simple commands
|
|
51
|
-
socket.on('data', (data) => {
|
|
52
|
-
const command = data.toString().trim().toLowerCase();
|
|
53
|
-
|
|
54
|
-
if (command === 'help') {
|
|
55
|
-
socket.write(this._getHelpText());
|
|
56
|
-
} else if (command === 'stats') {
|
|
57
|
-
socket.write(this._getStatsText());
|
|
58
|
-
} else if (command === 'quit' || command === 'exit') {
|
|
59
|
-
socket.end('=== Disconnected ===\n');
|
|
60
|
-
} else if (command.startsWith('level ')) {
|
|
61
|
-
const newLevel = command.split(' ')[1];
|
|
62
|
-
if (['error', 'warn', 'info', 'debug', 'verbose', 'silly'].includes(newLevel)) {
|
|
63
|
-
this.level = newLevel;
|
|
64
|
-
socket.write(`=== Log level changed to ${newLevel} ===\n`);
|
|
65
|
-
} else {
|
|
66
|
-
socket.write(`=== Invalid log level: ${newLevel} ===\n`);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
// Start listening
|
|
73
|
-
const port = options.port || 9300;
|
|
74
|
-
const host = options.host || '127.0.0.1';
|
|
75
|
-
|
|
76
|
-
this.server.listen(port, host, () => {
|
|
77
|
-
console.log(`Log socket server running on ${host}:${port}`);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
this.server.on('error', (err) => {
|
|
81
|
-
console.error(`Socket transport error: ${err.message}`);
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Winston transport method called for each log
|
|
87
|
-
* @param {Object} info - Log information
|
|
88
|
-
* @param {Function} callback - Callback function
|
|
89
|
-
*/
|
|
90
|
-
log(info, callback) {
|
|
91
|
-
setImmediate(() => {
|
|
92
|
-
this.emit('logged', info);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
// Skip if no clients connected
|
|
96
|
-
if (this.clients.size === 0) {
|
|
97
|
-
callback();
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// Format the log entry
|
|
102
|
-
const logEntry = this.format(info);
|
|
103
|
-
|
|
104
|
-
// Send to all connected clients
|
|
105
|
-
const deadClients = [];
|
|
106
|
-
for (const client of this.clients) {
|
|
107
|
-
try {
|
|
108
|
-
client.write(logEntry);
|
|
109
|
-
} catch (err) {
|
|
110
|
-
deadClients.push(client);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// Remove dead connections
|
|
115
|
-
deadClients.forEach(client => this.clients.delete(client));
|
|
116
|
-
|
|
117
|
-
callback();
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Default log formatter
|
|
122
|
-
* @param {Object} info - Log information
|
|
123
|
-
* @returns {string} Formatted log entry
|
|
124
|
-
* @private
|
|
125
|
-
*/
|
|
126
|
-
_defaultFormat(info) {
|
|
127
|
-
const timestamp = info.timestamp || new Date().toISOString();
|
|
128
|
-
const level = info.level.toUpperCase().padEnd(7);
|
|
129
|
-
const message = info.message || '';
|
|
130
|
-
|
|
131
|
-
// Extract metadata excluding standard fields
|
|
132
|
-
const meta = { ...info };
|
|
133
|
-
delete meta.timestamp;
|
|
134
|
-
delete meta.level;
|
|
135
|
-
delete meta.message;
|
|
136
|
-
|
|
137
|
-
const metaStr = Object.keys(meta).length > 0
|
|
138
|
-
? ` ${JSON.stringify(meta)}`
|
|
139
|
-
: '';
|
|
140
|
-
|
|
141
|
-
return `${timestamp} [${level}] ${message}${metaStr}\n`;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Get help text for connected clients
|
|
146
|
-
* @returns {string} Help text
|
|
147
|
-
* @private
|
|
148
|
-
*/
|
|
149
|
-
_getHelpText() {
|
|
150
|
-
return `
|
|
151
|
-
=== Log Viewer Commands ===
|
|
152
|
-
help - Show this help
|
|
153
|
-
stats - Show connection statistics
|
|
154
|
-
level <level> - Change log level (error, warn, info, debug, verbose, silly)
|
|
155
|
-
quit/exit - Disconnect
|
|
156
|
-
|
|
157
|
-
=== Log Format ===
|
|
158
|
-
TIMESTAMP [LEVEL] MESSAGE {metadata}
|
|
159
|
-
|
|
160
|
-
=== Examples ===
|
|
161
|
-
level debug - Show debug and higher priority logs
|
|
162
|
-
level error - Show only error logs
|
|
163
|
-
|
|
164
|
-
`.trim() + '\n\n';
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Get statistics text for connected clients
|
|
169
|
-
* @returns {string} Statistics text
|
|
170
|
-
* @private
|
|
171
|
-
*/
|
|
172
|
-
_getStatsText() {
|
|
173
|
-
return `
|
|
174
|
-
=== Log Statistics ===
|
|
175
|
-
Connected clients: ${this.clients.size}
|
|
176
|
-
Current log level: ${this.level}
|
|
177
|
-
Server started: ${this.server.startTime || 'unknown'}
|
|
178
|
-
Current time: ${new Date().toISOString()}
|
|
179
|
-
|
|
180
|
-
`.trim() + '\n\n';
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Close the socket server
|
|
185
|
-
* @param {Function} [callback] - Callback function
|
|
186
|
-
*/
|
|
187
|
-
close(callback) {
|
|
188
|
-
// Notify all clients
|
|
189
|
-
for (const client of this.clients) {
|
|
190
|
-
try {
|
|
191
|
-
client.end('=== Log server shutting down ===\n');
|
|
192
|
-
} catch (err) {
|
|
193
|
-
// Ignore errors during shutdown
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// Close server
|
|
198
|
-
this.server.close(callback);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// Register the transport with Winston
|
|
203
|
-
winston.transports.Socket = SocketTransport;
|
|
204
|
-
|
|
205
|
-
module.exports = SocketTransport;
|