function getValidOperationsForScope()

in src/smartScopeHelper.ts [49:71]


function getValidOperationsForScope(
    smartScope: ClinicalSmartScope,
    scopeRule: ScopeRule,
    reqOperation: TypeOperation | SystemOperation,
    reqResourceType?: string,
): (TypeOperation | SystemOperation)[] {
    let validOperations: (TypeOperation | SystemOperation)[] = [];
    const { scopeType, resourceType, accessType } = smartScope;
    if (reqResourceType) {
        if (resourceType === '*' || resourceType === reqResourceType) {
            validOperations = getValidOperationsForScopeTypeAndAccessType(scopeType, accessType, scopeRule);
        }
    }
    // 'search-system' and 'history-system' request operation requires '*' for scopeResourceType
    else if (
        (['search-system', 'history-system'].includes(reqOperation) && resourceType === '*') ||
        ['transaction', 'batch'].includes(reqOperation)
    ) {
        validOperations = getValidOperationsForScopeTypeAndAccessType(scopeType, accessType, scopeRule);
    }

    return validOperations;
}