scopesList method

List<String> scopesList()

creates a list of strings from the Scopes object to use in the request, it checks if each item is null or false, and includes it appropriately

Implementation

List<String> scopesList() {
  List<String> returnValue = [];
  if (openid ?? false) {
    returnValue.add('openid');
  }
  if (fhirUser ?? false) {
    returnValue.add('fhirUser');
  }
  if (profile ?? false) {
    returnValue.add('profile');
  }
  if (patientLaunch ?? false) {
    returnValue.add('launch/patient');
  }
  if (encounterLaunch ?? false) {
    returnValue.add('launch/encounter');
  }
  if (onlineAccess ?? false) {
    returnValue.add('online_access');
  }
  if (offlineAccess ?? false) {
    returnValue.add('offline_access');
  }
  if (ehrLaunch ?? false) {
    returnValue.add('launch');
  }
  if (clinicalScopes != null) {
    for (final scope in clinicalScopes!) {
      var scopeArgument = scope.role == Role.patient
          ? 'patient/'
          : scope.role == Role.user
              ? 'user/'
              : 'system/';
      scopeArgument += scope.allTypes
          ? '*.'
          : resourceTypeToStringMap[scope.resourceType] ?? '';
      scopeArgument += scope.interaction == Interaction.any
          ? '.*'
          : '.${scope.interaction.toString().split(".").last}';
      returnValue.add(scopeArgument);
    }
  }
  if (needPatientBanner != null) {
    returnValue.add('need_patient_banner=$needPatientBanner');
  }
  if (intent != null) {
    returnValue.add('intent=$intent');
  }
  if (smartOrchestrateLaunch ?? false) {
    returnValue.add('smart/orchestrate_launch');
  }
  if (additional != null) {
    additional!.forEach(returnValue.add);
  }
  return returnValue;
}