Skip to content

Commit

Permalink
updated patient image url because link was broken. updated roster rem…
Browse files Browse the repository at this point in the history
…ote repository and added authentication remote repository.
  • Loading branch information
TreyThomas93 committed Sep 10, 2024
1 parent fd65984 commit ff958b2
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 20 deletions.
30 changes: 15 additions & 15 deletions assets/data/patients.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"allergies": ["Vecuronium", "Amoxicillin"],
"clinician_id": 600,
"date_of_birth": "12/02/1949",
"image_url": "https://www.digital-photo-secrets.com/images/elderly-man-outside.jpg",
"image_url": "https://i.pinimg.com/236x/29/e3/45/29e345e38ba9d96f77e88c135a9be9a0.jpg",
"medical_history": ["Atrial Fibrillation"],
"medications": ["Coumadin"],
"mrn": "870968671",
Expand Down Expand Up @@ -81,7 +81,7 @@
"allergies": ["Amoxicillin"],
"clinician_id": 600,
"date_of_birth": "08/11/1962",
"image_url": "https://www.digital-photo-secrets.com/images/elderly-man-outside.jpg",
"image_url": "https://i.pinimg.com/236x/29/e3/45/29e345e38ba9d96f77e88c135a9be9a0.jpg",
"medical_history": ["Diabetes", "Atrial Fibrillation"],
"medications": ["Metformin", "Xarelto"],
"mrn": "427064361",
Expand Down Expand Up @@ -133,7 +133,7 @@
"allergies": ["Vecuronium"],
"clinician_id": 600,
"date_of_birth": "01/10/1946",
"image_url": "https://www.digital-photo-secrets.com/images/elderly-man-outside.jpg",
"image_url": "https://i.pinimg.com/236x/29/e3/45/29e345e38ba9d96f77e88c135a9be9a0.jpg",
"medical_history": ["Hyperlipidemia", "Angina"],
"medications": ["Atorvastatin", "Nitro"],
"mrn": "486185135",
Expand Down Expand Up @@ -185,7 +185,7 @@
"allergies": ["Naproxen", "Penicillin", "Peanuts"],
"clinician_id": 600,
"date_of_birth": "06/06/1956",
"image_url": "https://www.digital-photo-secrets.com/images/elderly-man-outside.jpg",
"image_url": "https://i.pinimg.com/236x/29/e3/45/29e345e38ba9d96f77e88c135a9be9a0.jpg",
"medical_history": ["Dementia", "Atrial Fibrillation"],
"medications": ["Aricept", "Coumadin"],
"mrn": "113874820",
Expand All @@ -211,7 +211,7 @@
"allergies": ["None"],
"clinician_id": 600,
"date_of_birth": "02/10/1942",
"image_url": "https://www.digital-photo-secrets.com/images/elderly-man-outside.jpg",
"image_url": "https://i.pinimg.com/236x/29/e3/45/29e345e38ba9d96f77e88c135a9be9a0.jpg",
"medical_history": ["Angina", "Atrial Fibrillation"],
"medications": ["Aspirin", "Warfarin"],
"mrn": "123393926",
Expand Down Expand Up @@ -289,7 +289,7 @@
"allergies": ["Atracurium"],
"clinician_id": 600,
"date_of_birth": "07/03/1924",
"image_url": "https://www.digital-photo-secrets.com/images/elderly-man-outside.jpg",
"image_url": "https://i.pinimg.com/236x/29/e3/45/29e345e38ba9d96f77e88c135a9be9a0.jpg",
"medical_history": ["Angina"],
"medications": ["Nitro"],
"mrn": "275498735",
Expand All @@ -315,7 +315,7 @@
"allergies": ["Naproxen"],
"clinician_id": 600,
"date_of_birth": "03/19/1951",
"image_url": "https://www.digital-photo-secrets.com/images/elderly-man-outside.jpg",
"image_url": "https://i.pinimg.com/236x/29/e3/45/29e345e38ba9d96f77e88c135a9be9a0.jpg",
"medical_history": ["Diabetes", "Atrial Fibrillation"],
"medications": ["Insulin", "Warfarin"],
"mrn": "644683773",
Expand All @@ -341,7 +341,7 @@
"allergies": ["Peanuts"],
"clinician_id": 600,
"date_of_birth": "03/01/1954",
"image_url": "https://www.digital-photo-secrets.com/images/elderly-man-outside.jpg",
"image_url": "https://i.pinimg.com/236x/29/e3/45/29e345e38ba9d96f77e88c135a9be9a0.jpg",
"medical_history": ["Hyperlipidemia"],
"medications": ["Atorvastatin"],
"mrn": "909896042",
Expand All @@ -367,7 +367,7 @@
"allergies": ["Shell Fish", "Vecuronium"],
"clinician_id": 600,
"date_of_birth": "10/26/1950",
"image_url": "https://www.digital-photo-secrets.com/images/elderly-man-outside.jpg",
"image_url": "https://i.pinimg.com/236x/29/e3/45/29e345e38ba9d96f77e88c135a9be9a0.jpg",
"medical_history": ["Hyperlipidemia", "Diabetes"],
"medications": ["Atorvastatin", "Insulin"],
"mrn": "771397270",
Expand All @@ -393,7 +393,7 @@
"allergies": ["Naproxen", "Vecuronium"],
"clinician_id": 600,
"date_of_birth": "11/07/1939",
"image_url": "https://www.digital-photo-secrets.com/images/elderly-man-outside.jpg",
"image_url": "https://i.pinimg.com/236x/29/e3/45/29e345e38ba9d96f77e88c135a9be9a0.jpg",
"medical_history": ["Atrial Fibrillation", "Angina"],
"medications": ["Xarelto", "Aspirin"],
"mrn": "556207481",
Expand Down Expand Up @@ -471,7 +471,7 @@
"allergies": ["Atracurium", "Naproxen"],
"clinician_id": 600,
"date_of_birth": "02/10/1932",
"image_url": "https://www.digital-photo-secrets.com/images/elderly-man-outside.jpg",
"image_url": "https://i.pinimg.com/236x/29/e3/45/29e345e38ba9d96f77e88c135a9be9a0.jpg",
"medical_history": ["Atrial Fibrillation"],
"medications": ["Coumadin"],
"mrn": "259904182",
Expand All @@ -497,7 +497,7 @@
"allergies": ["Penicillin"],
"clinician_id": 600,
"date_of_birth": "03/13/1942",
"image_url": "https://www.digital-photo-secrets.com/images/elderly-man-outside.jpg",
"image_url": "https://i.pinimg.com/236x/29/e3/45/29e345e38ba9d96f77e88c135a9be9a0.jpg",
"medical_history": ["Angina", "Hyperlipidemia"],
"medications": ["Aspirin", "Atorvastatin"],
"mrn": "147093396",
Expand All @@ -523,7 +523,7 @@
"allergies": ["Peanuts"],
"clinician_id": 600,
"date_of_birth": "08/09/1951",
"image_url": "https://www.digital-photo-secrets.com/images/elderly-man-outside.jpg",
"image_url": "https://i.pinimg.com/236x/29/e3/45/29e345e38ba9d96f77e88c135a9be9a0.jpg",
"medical_history": ["Diabetes", "Hyperlipidemia"],
"medications": ["Novolog", "Atorvastatin"],
"mrn": "377089106",
Expand Down Expand Up @@ -575,7 +575,7 @@
"allergies": ["Peanuts"],
"clinician_id": 600,
"date_of_birth": "11/06/1925",
"image_url": "https://www.digital-photo-secrets.com/images/elderly-man-outside.jpg",
"image_url": "https://i.pinimg.com/236x/29/e3/45/29e345e38ba9d96f77e88c135a9be9a0.jpg",
"medical_history": ["Diabetes"],
"medications": ["Insulin"],
"mrn": "779311128",
Expand All @@ -601,7 +601,7 @@
"allergies": ["Naproxen"],
"clinician_id": 600,
"date_of_birth": "08/03/1923",
"image_url": "https://www.digital-photo-secrets.com/images/elderly-man-outside.jpg",
"image_url": "https://i.pinimg.com/236x/29/e3/45/29e345e38ba9d96f77e88c135a9be9a0.jpg",
"medical_history": ["Atrial Fibrillation"],
"medications": ["Warfarin"],
"mrn": "833578867",
Expand Down
27 changes: 27 additions & 0 deletions lib/src/features/authentication/data/remote.repository.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';

import '../domain/user_model.dart';

abstract class RemoteRepository {
factory RemoteRepository() => RemoteRepositoryImpl();

Future<User> login(String email, String password);
Future<void> logout();
}

class RemoteRepositoryImpl implements RemoteRepository {
@override
Future<User> login(String email, String password) async {
await Future.delayed(const Duration(seconds: 2));
return User(name: 'John Doe', email: email);
}

@override
Future<void> logout() async {
await Future.delayed(const Duration(seconds: 2));
}
}

final remoteRepositoryProvider = Provider<RemoteRepository>((ref) {
return RemoteRepository();
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:developer';

import 'package:flutter_riverpod/flutter_riverpod.dart';

import '../../data/remote.repository.dart';
import '../../domain/user_model.dart';

final authController =
Expand All @@ -11,16 +12,17 @@ final authController =
class AuthController extends AsyncNotifier<User?> {
Future<void> login(String email, String password) async {
try {
await Future.delayed(const Duration(seconds: 2));
state = AsyncData(User(name: 'John Doe', email: email));
final user =
await ref.read(remoteRepositoryProvider).login(email, password);
state = AsyncData(user);
} catch (e) {
log(e.toString());
}
}

Future<void> logout() async {
try {
await Future.delayed(const Duration(seconds: 2));
await ref.read(remoteRepositoryProvider).logout();
state = const AsyncData(null);
} catch (e) {
log(e.toString());
Expand Down
12 changes: 10 additions & 2 deletions lib/src/features/roster/data/remote.repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@ import 'dart:convert';
import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

class RemoteRepository {
abstract class RemoteRepository {
factory RemoteRepository() => RemoteRepositoryImpl();

Future<List<Map<String, dynamic>>> getPatients();
}

class RemoteRepositoryImpl implements RemoteRepository {
@override
Future<List<Map<String, dynamic>>> getPatients() async {
await Future.delayed(const Duration(seconds: 2));
final String response = await rootBundle.loadString('assets/data/patients.json');
final String response =
await rootBundle.loadString('assets/data/patients.json');
return List<Map<String, dynamic>>.from(json.decode(response));
}
}
Expand Down

0 comments on commit ff958b2

Please sign in to comment.