refactor(ccdaservice): test and refactor count entities function (#6805)
[openemr.git] / ccdaservice / utils / count-entities / count-entities.js
blobd9c7a12eb01d9fe81d9f12ac8593e60d40cf9641
1 'use strict';
3 function hasEntityKey(input) {
4     return ['npi', 'code', 'extension', 'id', 'date', 'use', 'type'].some(
5         (key) => Object.prototype.hasOwnProperty.call(input, key)
6     );
9 function countEntities(input) {
10     if (input === null || typeof input !== 'object') return 0;
11     return hasEntityKey(input) ? 1 : Object.keys(input).length;
14 exports.countEntities = countEntities;