Skip to content

Commit

Permalink
update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
hitgeek committed Jun 6, 2024
1 parent d4c08f2 commit cb465e5
Show file tree
Hide file tree
Showing 4 changed files with 1,101 additions and 1,690 deletions.
20 changes: 12 additions & 8 deletions lib/hl7/encoder.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
var get = require('lodash.get');
var set = require('lodash.set');
var moment = require('moment');
var _ = require('lodash');
var get = _.get;
var set = _.set;
var dayjs = require('dayjs');
var customParseFormat = require('dayjs/plugin/customParseFormat');
var Message = require('./message');
var Field = require('./field');
var utils = require('./utils');

dayjs.extend(customParseFormat);

function encoder(config) {
this.config = config;
}
Expand Down Expand Up @@ -149,7 +153,7 @@ function decodeValue(stringValue, type) {
return Number(stringValue);
}
if (type == "Date") {
return moment(stringValue, "YYYYMMDD").toDate();
return dayjs(stringValue, "YYYYMMDD").toDate();
}
return stringValue;
}
Expand All @@ -158,16 +162,16 @@ encoder.prototype.encode = function (obj) {
var config = this.config;
var header = config.header || {};
var timestampFormat = config.timestampFormat || "YYYYMMDDhhmmss";
var now = moment();
var now = new Date();
var msh = new Message(
header.sendingApplication || "SENDAPP",
header.sendingFacility || "SENDFAC",
header.recievingApplication || "RECAPP",
header.recievingFacility || "RECFAC",
now.format(timestampFormat),
dayjs(now).format(timestampFormat),
header.security || '',
obj.messageType || '',
now.format("YYYYMMDDhhmmssSS"),
dayjs(now).format("YYYYMMDDhhmmssSSS"),
header.processingId || "P",
header.version || "2.5"
);
Expand Down Expand Up @@ -312,7 +316,7 @@ function pushValueToFields(msh, obj, config, segment, fields, value) {

function encodeValue(value, type, config) {
if (type == "Date") {
return moment(value).format("YYYYMMDD")
return dayjs(value).format("YYYYMMDD")
}
return value;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/server/tcp-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var Message = require('../hl7/message');
var net = require('net');
var Parser = require('../hl7/parser');
var util = require('util');
var moment = require('moment');
var dayjs = require('dayjs');

var VT = String.fromCharCode(0x0b);
var FS = String.fromCharCode(0x1c);
Expand Down Expand Up @@ -102,11 +102,11 @@ TcpServer.prototype.createAckMessage = function(msg) {
}

TcpServer.prototype.getDate = function(date) {
return moment(date).format("YYYYMMDDhhmmss")
return dayjs(date).format("YYYYMMDDhhmmss")
}

TcpServer.prototype.getControlId = function(date) {
return moment(date).format("YYYYMMDDhhmmssSS")
return dayjs(date).format("YYYYMMDDhhmmssSSS")
}

module.exports = TcpServer;
Loading

0 comments on commit cb465e5

Please sign in to comment.