in src/smartScopeHelper.ts [8:32]
export const SEARCH_OPERATIONS: (TypeOperation | SystemOperation)[] = [
'search-type',
'search-system',
'history-type',
'history-instance',
'history-system',
];
export const FHIR_SCOPE_REGEX =
/^(?<scopeType>patient|user|system)\/(?<scopeResourceType>[A-Z][a-zA-Z]+|\*)\.(?<accessType>read|write|\*)$/;
export function convertScopeToSmartScope(scope: string): ClinicalSmartScope {
const matchClinicalScope = scope.match(FHIR_SCOPE_REGEX);
if (matchClinicalScope) {
const { scopeType, scopeResourceType, accessType } = matchClinicalScope.groups!;
return {
scopeType: <ScopeType>scopeType,
resourceType: scopeResourceType,
accessType: <AccessModifier>accessType,
};
}
throw new Error('Not a SmartScope');
}