UNPKG

@interoperability/atna-audit-messages

Version:

The ATNA Audit Messages Generator is a JavaScript library that provides a set of reusable static methods for generating Audit Trail and Node Authentication (ATNA) compliant audit messages. This library is particularly useful in healthcare systems and othe

91 lines (86 loc) 2.97 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ActiveParticipant = void 0; var _ATNAComplexType = require("./ATNAComplexType.js"); var _Code = require("./Code.js"); var _XMLElement = require("../helpers/xml/XMLElement.js"); /** * Represents an ActiveParticipant element for ATNA. */ class ActiveParticipant extends _ATNAComplexType.ATNAComplexType { /** * @param {string} userId - The user ID. * @param {string} altUserId - The alternative user ID. * @param {boolean} userIsRequestor - Indicates if the user is a requestor. */ constructor(userId, altUserId, userIsRequestor) { super(); this.userId = userId; this.altUserId = altUserId; this.userIsRequestor = userIsRequestor; } /** * Sets the RoleID codes for the ActiveParticipant. * @param {Code|Code[]} roleCodes - The RoleID code or an array of RoleID codes. * @returns {ActiveParticipant} - Returns the current instance for chaining. */ setRoleIDCodes(roleCodes) { if (!Array.isArray(roleCodes)) { roleCodes = [roleCodes]; } this.roleCodes = roleCodes.map(roleCode => { if (roleCode instanceof _Code.Code) { return roleCode; } else { throw new Error(`Not a valid RoleCode`, roleCode); } }); return this; } /** * Sets the NetworkAccessPointID for the ActiveParticipant. * @param {string} netAccessPointId - The NetworkAccessPointID. * @returns {ActiveParticipant} - Returns the current instance for chaining. */ setNetworkAccessPointID(netAccessPointId) { this.netAccessPointId = netAccessPointId; return this; } /** * Sets the NetworkAccessPointTypeCode for the ActiveParticipant. * @param {Code} netAccessPointTypeCode - The NetworkAccessPointTypeCode. * @returns {ActiveParticipant} - Returns the current instance for chaining. */ setNetworkAccessPointTypeCode(netAccessPointTypeCode) { this.netAccessPointTypeCode = netAccessPointTypeCode; return this; } /** * Prepares XML representation of the ActiveParticipant element. * @returns {XMLElement} - The XML representation of the ActiveParticipant element. */ prepareXML() { this.xml = new _XMLElement.XMLElement().setName('ActiveParticipant'); let attributes = { UserID: this.userId, AlternativeUserID: this.altUserId, UserIsRequestor: this.userIsRequestor }; if (this.netAccessPointId) { attributes.NetworkAccessPointID = this.netAccessPointId; } if (this.netAccessPointTypeCode) { attributes.NetworkAccessPointTypeCode = this.netAccessPointTypeCode; } if (this.roleCodes) { this.roleCodes.forEach(roleCode => { this.xml.addChild(new _XMLElement.XMLElement().setName('RoleIDCode').addChild(roleCode.prepareXML())); }); } this.xml.setAttributes(attributes); return this.xml; } } exports.ActiveParticipant = ActiveParticipant;