EpicFhirClient.fromLaunchParameters constructor

EpicFhirClient.fromLaunchParameters({
  1. required Uri base,
  2. required Map<String, String> queryParameters,
  3. FhirUri? fhirUri,
  4. String? clientId,
  5. FhirUri? redirectUri,
  6. String? customUriScheme,
  7. List<String>? scopes,
  8. String? authorizeUrl,
  9. String? tokenUrl,
  10. String? launch,
  11. String? secret,
  12. String redirectPath = '/redirect.html',
})

Implementation

factory EpicFhirClient.fromLaunchParameters({
  required Uri base,
  required Map<String, String> queryParameters,
  FhirUri? fhirUri,
  String? clientId,
  FhirUri? redirectUri,
  String? customUriScheme,
  List<String>? scopes,
  String? authorizeUrl,
  String? tokenUrl,
  String? launch,
  String? secret,
  String redirectPath = '/redirect.html',
}) {
  launch ??= queryParameters['launch'];
  final launchParameters = launch == null ? null : JwtDecoder.decode(launch);
  fhirUri ??= queryParameters['iss'] == null
      ? throw Exception('no fhirUri was passed for SMART launch')
      : FhirUri(queryParameters['iss']);
  clientId ??= queryParameters['clientId'] ??
      (launchParameters == null ? null : launchParameters['client_id']);
  redirectUri ??= FhirUri(Uri(
    host: base.host,
    scheme: base.scheme,
    port: base.port,
    path: redirectPath,
  ));
  if (clientId == null) {
    throw Exception('no clientId was passed for SMART launch');
  }
  return EpicFhirClient(
    fhirUri: fhirUri,
    clientId: clientId,
    redirectUri: redirectUri,
    customUriScheme: customUriScheme,
    scopes: scopes,
    authorizeUrl: authorizeUrl == null ? null : FhirUri(authorizeUrl),
    tokenUrl: tokenUrl == null ? null : FhirUri(tokenUrl),
    launch: launch,
    secret: secret,
    contactSerialNumber: queryParameters['csn'],
    dob: queryParameters['dob'],
    encounterDate: queryParameters['encdate'],
    patientFirstName: queryParameters['fname'],
    patientLastName: queryParameters['lname'],
    patientMiddleName: queryParameters['mname'],
    sysLogin: queryParameters['syslogin'],
    userEpicId: queryParameters['epicuserid'],
    userProviderNumber: queryParameters['userprovfhirid'],
  );
}