Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
aade0ef
Fix broken tests
Zangetsu101 Mar 15, 2022
7bb65b4
Bump up tap from 10.1 to 12.6
Zangetsu101 Mar 15, 2022
50b66da
Bump up talisman from 0.21.0 to 1.1.4
Zangetsu101 Mar 15, 2022
36179be
Bump up standard from 8.6.0 to 11.0.0
Zangetsu101 Mar 15, 2022
67317f2
Bump up standard from 11.0.0 to 12.0.1
Zangetsu101 Mar 16, 2022
d156dd3
Bump up mongodb from 2.2.22 to 3.5.4
Zangetsu101 Mar 16, 2022
895bf29
Remove engine limitations
Zangetsu101 Mar 16, 2022
fbf9c32
Bump up tap from 12.6 to 14.10
Zangetsu101 Mar 16, 2022
8cd1fb0
Make tests run serially
Zangetsu101 Mar 16, 2022
8c36e14
Bump up nconf from 0.10.0 to 0.11.3
Zangetsu101 Mar 18, 2022
8430344
Bump up codecov from 3.6.1 to 3.8.3
Zangetsu101 Mar 18, 2022
31ba9b4
Add resolution for tar 4.4.19
Zangetsu101 Mar 18, 2022
7872e59
Upgrade ini to 1.3.8
Zangetsu101 Mar 18, 2022
cbd9583
Bump up standard from 12.0.1 to 13.1.0
Zangetsu101 Mar 18, 2022
3363ced
Bump up standard from 13.1.0 to 14.3.4
Zangetsu101 Mar 18, 2022
c7bf7f0
Dedup 'mkdirp' in lock file
Zangetsu101 Mar 21, 2022
781ffe1
Upgrade hosted-git-info
Zangetsu101 Mar 21, 2022
cbe4005
Dedup minmist
Zangetsu101 Mar 21, 2022
e43c59e
Bump up snazzy from 8.0.0 to 9.0.0
Zangetsu101 Mar 21, 2022
a37cae4
Bump up standard from 14.3.4 to 15.0.1
Zangetsu101 Mar 21, 2022
dccd7d9
Bump up standard from 15.0.1 to 16.0.4
Zangetsu101 Mar 21, 2022
d3f9e6c
Bump up tap from 14.10 to 15.2.3
Zangetsu101 Mar 21, 2022
5ebe118
Bump up urijs from 1.19.2 to 1.19.10
Zangetsu101 Mar 21, 2022
1fe71bf
Bump up jsprim from 1.4.1 to 1.4.2
Zangetsu101 Mar 21, 2022
aa7ac63
Dedup string-width
Zangetsu101 Mar 21, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions lib/atna-audit.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/**
* Copyright (c) 2017-present, Jembi Health Systems NPC.
* All rights reserved.
*
Expand All @@ -12,7 +12,7 @@ const fs = require('fs')
const ATNA = require('atna-audit')
const ATNAAuditConfig = require('./config').getConf('atnaAudit')

let connDetail = {
const connDetail = {
interface: ATNAAuditConfig.interface,
host: ATNAAuditConfig.host,
port: ATNAAuditConfig.port
Expand All @@ -32,25 +32,25 @@ if (ATNAAuditConfig.certOptions.ca) {

exports.buildPIXmAuditMsg = (ctx) => {
// event
var eventID = new ATNA.construct.Code(110112, 'Query', 'DCM')
var typeCode = new ATNA.construct.Code('ITI-83', 'Mobile Patient Identifier Cross-reference Query', 'IHE Transactions')
var eIdent = new ATNA.construct.EventIdentification(ATNA.constants.EVENT_ACTION_EXECUTE, new Date(), ATNA.constants.OUTCOME_SUCCESS, eventID, typeCode)
const eventID = new ATNA.construct.Code(110112, 'Query', 'DCM')
const typeCode = new ATNA.construct.Code('ITI-83', 'Mobile Patient Identifier Cross-reference Query', 'IHE Transactions')
const eIdent = new ATNA.construct.EventIdentification(ATNA.constants.EVENT_ACTION_EXECUTE, new Date(), ATNA.constants.OUTCOME_SUCCESS, eventID, typeCode)

// Active Participant - System
var sysRoleCode = new ATNA.construct.Code(110153, 'Source', 'DCM')
var sysParticipant = new ATNA.construct.ActiveParticipant(ctx.authenticatedUser, '', false, ctx.requestorIp, ATNA.constants.NET_AP_TYPE_IP, [sysRoleCode])
const sysRoleCode = new ATNA.construct.Code(110153, 'Source', 'DCM')
const sysParticipant = new ATNA.construct.ActiveParticipant(ctx.authenticatedUser, '', false, ctx.requestorIp, ATNA.constants.NET_AP_TYPE_IP, [sysRoleCode])

// Active Participant - User
var userRoleCodeDef = new ATNA.construct.Code(110152, 'DCM', 'Destination')
var userParticipant = new ATNA.construct.ActiveParticipant(ctx.authenticatedUser, '', true, null, null, [userRoleCodeDef])
const userRoleCodeDef = new ATNA.construct.Code(110152, 'DCM', 'Destination')
const userParticipant = new ATNA.construct.ActiveParticipant(ctx.authenticatedUser, '', true, null, null, [userRoleCodeDef])

// Audit Source
var sourceTypeCode = new ATNA.construct.Code(ATNA.constants.AUDIT_SRC_TYPE_WEB_SERVER, '', '')
var sourceIdent = new ATNA.construct.AuditSourceIdentification(null, ctx.authenticatedUser, sourceTypeCode)
const sourceTypeCode = new ATNA.construct.Code(ATNA.constants.AUDIT_SRC_TYPE_WEB_SERVER, '', '')
const sourceIdent = new ATNA.construct.AuditSourceIdentification(null, ctx.authenticatedUser, sourceTypeCode)

// Participant Object
var objIdTypeCode = new ATNA.construct.Code('ITI-83', 'Mobile Patient Identifier Cross-reference Query', 'IHE Transactions')
var participantObj = new ATNA.construct.ParticipantObjectIdentification(
const objIdTypeCode = new ATNA.construct.Code('ITI-83', 'Mobile Patient Identifier Cross-reference Query', 'IHE Transactions')
const participantObj = new ATNA.construct.ParticipantObjectIdentification(
ctx.fullUrl,
ATNA.constants.OBJ_TYPE_SYS_OBJ,
ATNA.constants.OBJ_TYPE_CODE_ROLE_QUERY,
Expand All @@ -62,8 +62,8 @@ exports.buildPIXmAuditMsg = (ctx) => {
ctx.headers
)

var audit = new ATNA.construct.AuditMessage(eIdent, [sysParticipant, userParticipant], [participantObj], [sourceIdent])
var xml = audit.toXML()
const audit = new ATNA.construct.AuditMessage(eIdent, [sysParticipant, userParticipant], [participantObj], [sourceIdent])
const xml = audit.toXML()

const syslog = ATNA.construct.wrapInSyslog(xml)

Expand All @@ -72,25 +72,25 @@ exports.buildPIXmAuditMsg = (ctx) => {

exports.buildPDQmAuditMsg = (ctx) => {
// event
var eventID = new ATNA.construct.Code(110112, 'Query', 'DCM')
var typeCode = new ATNA.construct.Code('ITI-78', 'Mobile Patient Demographics Query', 'IHE Transactions')
var eIdent = new ATNA.construct.EventIdentification(ATNA.constants.EVENT_ACTION_EXECUTE, new Date(), ATNA.constants.OUTCOME_SUCCESS, eventID, typeCode)
const eventID = new ATNA.construct.Code(110112, 'Query', 'DCM')
const typeCode = new ATNA.construct.Code('ITI-78', 'Mobile Patient Demographics Query', 'IHE Transactions')
const eIdent = new ATNA.construct.EventIdentification(ATNA.constants.EVENT_ACTION_EXECUTE, new Date(), ATNA.constants.OUTCOME_SUCCESS, eventID, typeCode)

// Active Participant - System
var sysRoleCode = new ATNA.construct.Code(110153, 'Source', 'DCM')
var sysParticipant = new ATNA.construct.ActiveParticipant(ctx.authenticatedUser, '', false, ctx.requestorIp, ATNA.constants.NET_AP_TYPE_IP, [sysRoleCode])
const sysRoleCode = new ATNA.construct.Code(110153, 'Source', 'DCM')
const sysParticipant = new ATNA.construct.ActiveParticipant(ctx.authenticatedUser, '', false, ctx.requestorIp, ATNA.constants.NET_AP_TYPE_IP, [sysRoleCode])

// Active Participant - User
var userRoleCodeDef = new ATNA.construct.Code(110152, 'DCM', 'Destination')
var userParticipant = new ATNA.construct.ActiveParticipant(ctx.authenticatedUser, '', true, null, null, [userRoleCodeDef])
const userRoleCodeDef = new ATNA.construct.Code(110152, 'DCM', 'Destination')
const userParticipant = new ATNA.construct.ActiveParticipant(ctx.authenticatedUser, '', true, null, null, [userRoleCodeDef])

// Audit Source
var sourceTypeCode = new ATNA.construct.Code(ATNA.constants.AUDIT_SRC_TYPE_WEB_SERVER, '', '')
var sourceIdent = new ATNA.construct.AuditSourceIdentification(null, ctx.authenticatedUser, sourceTypeCode)
const sourceTypeCode = new ATNA.construct.Code(ATNA.constants.AUDIT_SRC_TYPE_WEB_SERVER, '', '')
const sourceIdent = new ATNA.construct.AuditSourceIdentification(null, ctx.authenticatedUser, sourceTypeCode)

// Participant Object
var objIdTypeCode = new ATNA.construct.Code('ITI-78', 'Mobile Patient Demographics Query', 'IHE Transactions')
var participantObj = new ATNA.construct.ParticipantObjectIdentification(
const objIdTypeCode = new ATNA.construct.Code('ITI-78', 'Mobile Patient Demographics Query', 'IHE Transactions')
const participantObj = new ATNA.construct.ParticipantObjectIdentification(
ctx.fullUrl,
ATNA.constants.OBJ_TYPE_SYS_OBJ,
ATNA.constants.OBJ_TYPE_CODE_ROLE_QUERY,
Expand All @@ -102,8 +102,8 @@ exports.buildPDQmAuditMsg = (ctx) => {
ctx.headers
)

var audit = new ATNA.construct.AuditMessage(eIdent, [sysParticipant, userParticipant], [participantObj], [sourceIdent])
var xml = audit.toXML()
const audit = new ATNA.construct.AuditMessage(eIdent, [sysParticipant, userParticipant], [participantObj], [sourceIdent])
const xml = audit.toXML()

const syslog = ATNA.construct.wrapInSyslog(xml)

Expand Down
2 changes: 1 addition & 1 deletion lib/config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/**
* Copyright (c) 2017-present, Jembi Health Systems NPC.
* All rights reserved.
*
Expand Down
2 changes: 1 addition & 1 deletion lib/constants.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/**
* Copyright (c) 2017-present, Jembi Health Systems NPC.
* All rights reserved.
*
Expand Down
2 changes: 1 addition & 1 deletion lib/custom-api/password-helper.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/**
* Copyright (c) 2017-present, Jembi Health Systems NPC. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
Expand Down
4 changes: 2 additions & 2 deletions lib/custom-api/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ module.exports = exports = mongo => {
if (err) {
return callback(err)
}
db.collection('user').findOne({email}, callback)
db.collection('user').findOne({ email }, callback)
})
}

Expand Down Expand Up @@ -143,7 +143,7 @@ module.exports = exports = mongo => {
return next(err)
}
logger.info(`Created session for user ${req.body.email}`)
res.status(201).send({token})
res.status(201).send({ token })
})
})
}
Expand Down
36 changes: 18 additions & 18 deletions lib/custom-api/user.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/**
* Copyright (c) 2017-present, Jembi Health Systems NPC.
* All rights reserved.
*
Expand Down Expand Up @@ -34,13 +34,13 @@ const handleErrorAndBadRequest = (err, badRequest, res) => {
}

module.exports = (mongo) => {
let authorization = Authorization(mongo)
let fhirCommon = FhirCommon(mongo)
const authorization = Authorization(mongo)
const fhirCommon = FhirCommon(mongo)
const hooks = Hooks()

let setPasswordHashForUser = (user) => {
const setPasswordHashForUser = (user) => {
if (user.password) {
let saltHash = passwordHelper.generateSaltedHash(user.password)
const saltHash = passwordHelper.generateSaltedHash(user.password)
user.hash = saltHash.hash
user.salt = saltHash.salt
delete user.password
Expand All @@ -56,8 +56,8 @@ module.exports = (mongo) => {
return callback(err)
}

let c = db.collection('user')
c.findOne({email: defaultUser.email}, (err, user) => {
const c = db.collection('user')
c.findOne({ email: defaultUser.email }, (err, user) => {
if (err) {
return callback(err)
}
Expand Down Expand Up @@ -103,8 +103,8 @@ module.exports = (mongo) => {
return res.status(500).send(fhirCommon.internalServerErrorOutcome())
}

let c = db.collection('user')
c.findOne({email: req.params.email}, {fields: {salt: 1, locked: 1}}, (err, user) => {
const c = db.collection('user')
c.findOne({ email: req.params.email }, { fields: { salt: 1, locked: 1 } }, (err, user) => {
if (err) {
logger.error(err)
return res.status(500).send(fhirCommon.internalServerErrorOutcome())
Expand Down Expand Up @@ -170,8 +170,8 @@ module.exports = (mongo) => {
return res.status(500).send(fhirCommon.internalServerErrorOutcome())
}

let c = db.collection('user')
c.findOne({email: req.params.email}, {fields: {email: 1, type: 1, resource: 1}}, (err, user) => {
const c = db.collection('user')
c.findOne({ email: req.params.email }, { fields: { email: 1, type: 1, resource: 1 } }, (err, user) => {
if (err) {
logger.error(err)
return res.status(500).send(fhirCommon.internalServerErrorOutcome())
Expand Down Expand Up @@ -204,7 +204,7 @@ module.exports = (mongo) => {
return res.status(badRequest.httpStatus).send(badRequest.resource)
}

let query = { $and: [] }
const query = { $and: [] }

if (req.query.resource) {
query.$and.push({ resource: req.query.resource })
Expand All @@ -225,7 +225,7 @@ module.exports = (mongo) => {
return res.status(500).send(fhirCommon.internalServerErrorOutcome())
}

let c = db.collection('user')
const c = db.collection('user')
c.findOne(query, { password: 0, hash: 0, salt: 0 }, (err, user) => {
if (err) {
logger.error(err)
Expand Down Expand Up @@ -262,8 +262,8 @@ module.exports = (mongo) => {
return res.status(500).send(fhirCommon.internalServerErrorOutcome())
}

let c = db.collection('user')
c.findOne({email: req.body.email}, {fields: {email: 1}}, (err, user) => {
const c = db.collection('user')
c.findOne({ email: req.body.email }, { fields: { email: 1 } }, (err, user) => {
if (err) {
logger.error(err)
return res.status(500).send(fhirCommon.internalServerErrorOutcome())
Expand Down Expand Up @@ -341,8 +341,8 @@ module.exports = (mongo) => {
return res.status(500).send(fhirCommon.internalServerErrorOutcome())
}

let c = db.collection('user')
c.findOne({email: req.params.email}, {fields: {email: 1}}, (err, user) => {
const c = db.collection('user')
c.findOne({ email: req.params.email }, { fields: { email: 1 } }, (err, user) => {
if (err) {
logger.error(err)
return res.status(500).send(fhirCommon.internalServerErrorOutcome())
Expand All @@ -353,7 +353,7 @@ module.exports = (mongo) => {
}

setPasswordHashForUser(req.body)
c.updateOne({_id: user._id}, {$set: req.body}, (err) => {
c.updateOne({ _id: user._id }, { $set: req.body }, (err) => {
if (err) {
logger.error(err)
return res.status(500).send(fhirCommon.internalServerErrorOutcome())
Expand Down
18 changes: 10 additions & 8 deletions lib/fhir/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,14 @@ module.exports = exports = (mongo) => {
return
}

// eslint-disable-next-line array-callback-return
_.castArray(property).map((prop) => {
if (nextProperty[0]) {
evaluateProperties(prop[nextProperty[0]], nextProperty.slice(1))
} else {
if (!prop.reference) {
// No reference
// eslint-disable-next-line array-callback-return
return
}
promises.push(new Promise((resolve, reject) => {
Expand Down Expand Up @@ -191,7 +193,7 @@ module.exports = exports = (mongo) => {
const itemReference = itemList.slice(1)

const promises = results
.filter(item => item['resourceType'] === itemResource)
.filter(item => item.resourceType === itemResource)
.map(item => new Promise((resolve, reject) => {
resolveNestedProperties(item, itemReference, (err, data) => {
if (err) {
Expand Down Expand Up @@ -224,7 +226,7 @@ module.exports = exports = (mongo) => {

let mappings = searchParamsMap[itemResource][itemReference]
if (!Array.isArray(mappings)) {
mappings = [ mappings ]
mappings = [mappings]
}

resolve(mappings.map((mapping) => `${itemResource}.${mapping.path}`))
Expand Down Expand Up @@ -254,9 +256,9 @@ module.exports = exports = (mongo) => {
})

return Promise.all(promises).then((res) => {
let flattenedRes = [].concat.apply([], res)
const flattenedRes = [].concat.apply([], res)

for (var i = flattenedRes.length - 1; i >= 0; i--) {
for (let i = flattenedRes.length - 1; i >= 0; i--) {
if (flattenedRes[i] == null) {
flattenedRes.splice(i, 1) // remove null values from the result set
}
Expand Down Expand Up @@ -296,7 +298,7 @@ module.exports = exports = (mongo) => {
}

// Get a reference to the module for searching by the resource type
let module = moduleLoader.getMatchingModule(resourceType)
const module = moduleLoader.getMatchingModule(resourceType)

// Build a query for each result
const queryPromises = results.map((result) => {
Expand Down Expand Up @@ -330,7 +332,7 @@ module.exports = exports = (mongo) => {
}
resolve(db)
})
}).then(db => db.collection(resourceType).find({$or: queries}).toArray())
}).then(db => db.collection(resourceType).find({ $or: queries }).toArray())
})
}

Expand Down Expand Up @@ -520,7 +522,7 @@ module.exports = exports = (mongo) => {
* @param {Object} list The array of json objects as the search context
*/
containsObject: (obj, list) => {
var i
let i
for (i = 0; i < list.length; i++) {
if (_.isEqual(list[i], obj)) {
return true
Expand Down Expand Up @@ -602,7 +604,7 @@ module.exports = exports = (mongo) => {
* @return {Object} a reference to the original resource.
*/
resolveReferences: function resolveReferences (resource, oldRef, newRef) {
for (let prop in resource) {
for (const prop in resource) {
if (prop === 'reference' && resource[prop] === oldRef) {
resource[prop] = newRef
} else if (typeof resource[prop] === 'object') {
Expand Down
16 changes: 8 additions & 8 deletions lib/fhir/core.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/**
* Copyright (c) 2017-present, Jembi Health Systems NPC.
* All rights reserved.
*
Expand Down Expand Up @@ -195,7 +195,7 @@ module.exports = (mongo, modules) => {

let fhirModule = modules[resourceType]
if (!fhirModule) {
fhirModule = modules['Default']
fhirModule = modules.Default
}
hooks.executeBeforeHooks('search', fhirModule, ctx, resourceType, (err, badRequest) => {
if (err || badRequest) {
Expand Down Expand Up @@ -351,11 +351,11 @@ module.exports = (mongo, modules) => {
return callback(err)
}

let query = [
const query = [
{ $limit: 1 },
{ $lookup: { from: resourceType, pipeline: [], as: 'top' } },
{ $lookup: { from: `${resourceType}_history`, pipeline: [], as: 'history' } },
{ $project: { all: { $setUnion: [ '$top', '$history' ] } } },
{ $project: { all: { $setUnion: ['$top', '$history'] } } },
{ $unwind: '$all' },
{ $replaceRoot: { newRoot: '$all' } }
]
Expand All @@ -371,7 +371,7 @@ module.exports = (mongo, modules) => {
query[2].$lookup.pipeline.push(matchClause)
}

let cntQuery = query.slice(0, query.length)
const cntQuery = query.slice(0, query.length)
cntQuery.push({ $count: 'total' })

query.push({ $sort: { '_transforms.meta.lastUpdated': -1 } })
Expand All @@ -383,7 +383,7 @@ module.exports = (mongo, modules) => {
}

const c = db.collection(resourceType)
c.aggregate(cntQuery, (err, total) => {
c.aggregate(cntQuery).toArray((err, total) => {
if (err) {
return callback(err)
}
Expand Down Expand Up @@ -563,7 +563,7 @@ module.exports = (mongo, modules) => {

const op = config.getConf('operations:updateCreate')
if (typeof op !== 'boolean') {
logger.debug(`'operations:updateCreate' is not a boolean value`)
logger.debug('\'operations:updateCreate\' is not a boolean value')
}

if ((typeof op === 'string') && (op === 'true')) {
Expand Down Expand Up @@ -759,7 +759,7 @@ module.exports = (mongo, modules) => {
return callback(null, fhirCommon.buildHTTPOutcome(400, 'error', 'invalid', 'Match operation not supported on resource type'))
}

const matchModule = modules['Matching']
const matchModule = modules.Matching

matchModule.match(resourceType, resource, count, (err, badRequest, results, certainMatchFlag) => {
if (err || badRequest) {
Expand Down
Loading