include patient view auguments
This commit is contained in:
@@ -2,17 +2,18 @@ import 'dart:convert';
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:patient_manager/env/env.dart';
|
import 'package:patient_manager/env/env.dart';
|
||||||
import 'package:patient_manager/objects/appUser.dart';
|
import 'package:patient_manager/objects/arguments.dart';
|
||||||
import 'package:patient_manager/objects/patients.dart';
|
import 'package:patient_manager/objects/patients.dart';
|
||||||
import 'package:patient_manager/pages/patientAdd.dart';
|
import 'package:patient_manager/pages/patientAdd.dart';
|
||||||
import 'package:patient_manager/pages/patientView.dart';
|
import 'package:patient_manager/pages/patientView.dart';
|
||||||
import 'package:supertokens_flutter/http.dart' as http;
|
import 'package:supertokens_flutter/http.dart' as http;
|
||||||
|
|
||||||
class AddOrViewPatient extends StatefulWidget {
|
class AddOrViewPatient extends StatefulWidget {
|
||||||
final AppUser signedInUser;
|
//final AppUser signedInUser;
|
||||||
|
final PatientViewArguments arguments;
|
||||||
const AddOrViewPatient({
|
const AddOrViewPatient({
|
||||||
super.key,
|
super.key,
|
||||||
required this.signedInUser,
|
required this.arguments,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -23,7 +24,7 @@ class _AddOrViewPatientState extends State<AddOrViewPatient> {
|
|||||||
Future<Patient?> fetchPatient() async {
|
Future<Patient?> fetchPatient() async {
|
||||||
//print("Patien manager page: $endpoint");
|
//print("Patien manager page: $endpoint");
|
||||||
final response = await http.get(Uri.parse(
|
final response = await http.get(Uri.parse(
|
||||||
"${AppEnviroment.baseApiUrl}/patients/${widget.signedInUser.app_id}"));
|
"${AppEnviroment.baseApiUrl}/patients/${widget.arguments.signedInUser.app_id}"));
|
||||||
// print("Here");
|
// print("Here");
|
||||||
// print("Body: ${response.body}");
|
// print("Body: ${response.body}");
|
||||||
// print("Code: ${response.statusCode}");
|
// print("Code: ${response.statusCode}");
|
||||||
@@ -55,10 +56,10 @@ class _AddOrViewPatientState extends State<AddOrViewPatient> {
|
|||||||
if (snapshot.hasData) {
|
if (snapshot.hasData) {
|
||||||
// Extracting data from snapshot object
|
// Extracting data from snapshot object
|
||||||
//final data = snapshot.data as String;
|
//final data = snapshot.data as String;
|
||||||
return PatientView(signedInUser: widget.signedInUser);
|
return PatientView(arguments: widget.arguments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return AddPatient(signedInUser: widget.signedInUser);
|
return AddPatient(signedInUser: widget.arguments.signedInUser);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import 'package:patient_manager/components/mySuccessMessage.dart';
|
|||||||
import 'package:patient_manager/env/env.dart';
|
import 'package:patient_manager/env/env.dart';
|
||||||
import 'package:patient_manager/main.dart';
|
import 'package:patient_manager/main.dart';
|
||||||
import 'package:patient_manager/objects/appUser.dart';
|
import 'package:patient_manager/objects/appUser.dart';
|
||||||
|
import 'package:patient_manager/objects/arguments.dart';
|
||||||
import 'package:patient_manager/objects/businessUser.dart';
|
import 'package:patient_manager/objects/businessUser.dart';
|
||||||
import 'package:supertokens_flutter/http.dart' as http;
|
import 'package:supertokens_flutter/http.dart' as http;
|
||||||
|
|
||||||
@@ -86,8 +87,8 @@ class _HomeTileGridState extends State<HomeTileGrid> {
|
|||||||
Icons.medication,
|
Icons.medication,
|
||||||
"Patient Profile",
|
"Patient Profile",
|
||||||
() {
|
() {
|
||||||
Navigator.of(context)
|
Navigator.of(context).pushNamed('/patient-profile',
|
||||||
.pushNamed('/patient-profile', arguments: widget.signedInUser);
|
arguments: PatientViewArguments(widget.signedInUser, "personal"));
|
||||||
// Navigator.popAndPushNamed(context, '/patient-manager',
|
// Navigator.popAndPushNamed(context, '/patient-manager',
|
||||||
// arguments: widget.userEmail);
|
// arguments: widget.userEmail);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,12 @@ import 'package:patient_manager/objects/patients.dart';
|
|||||||
|
|
||||||
class PatientDetails extends StatefulWidget {
|
class PatientDetails extends StatefulWidget {
|
||||||
final Patient selectedPatient;
|
final Patient selectedPatient;
|
||||||
const PatientDetails({super.key, required this.selectedPatient});
|
final String type;
|
||||||
|
const PatientDetails({
|
||||||
|
super.key,
|
||||||
|
required this.selectedPatient,
|
||||||
|
required this.type,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<PatientDetails> createState() => _PatientDetailsState();
|
State<PatientDetails> createState() => _PatientDetailsState();
|
||||||
@@ -149,6 +154,43 @@ class _PatientDetailsState extends State<PatientDetails> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<Widget> setIcons() {
|
||||||
|
if (widget.type == "personal") {
|
||||||
|
return [
|
||||||
|
Text(
|
||||||
|
"Patient Details",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 25,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.edit),
|
||||||
|
alignment: Alignment.topRight,
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pushNamed('/patient-manager/patient/edit',
|
||||||
|
arguments: widget.selectedPatient);
|
||||||
|
},
|
||||||
|
)
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
return [
|
||||||
|
Text(
|
||||||
|
"Patient Details",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 25,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
setState(() {
|
setState(() {
|
||||||
@@ -196,28 +238,7 @@ class _PatientDetailsState extends State<PatientDetails> {
|
|||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
//crossAxisAlignment: ,
|
//crossAxisAlignment: ,
|
||||||
children: [
|
children: setIcons(),
|
||||||
Text(
|
|
||||||
"Patient Details",
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 25,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color:
|
|
||||||
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(Icons.edit),
|
|
||||||
alignment: Alignment.topRight,
|
|
||||||
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.of(context).pushNamed(
|
|
||||||
'/patient-manager/patient/edit',
|
|
||||||
arguments: widget.selectedPatient);
|
|
||||||
},
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
Divider(
|
Divider(
|
||||||
color: MzanziInnovationHub.of(context)!.theme.secondaryColor()),
|
color: MzanziInnovationHub.of(context)!.theme.secondaryColor()),
|
||||||
|
|||||||
@@ -24,11 +24,13 @@ class PatientFiles extends StatefulWidget {
|
|||||||
final int patientIndex;
|
final int patientIndex;
|
||||||
final Patient selectedPatient;
|
final Patient selectedPatient;
|
||||||
final AppUser signedInUser;
|
final AppUser signedInUser;
|
||||||
|
final String type;
|
||||||
const PatientFiles({
|
const PatientFiles({
|
||||||
super.key,
|
super.key,
|
||||||
required this.patientIndex,
|
required this.patientIndex,
|
||||||
required this.selectedPatient,
|
required this.selectedPatient,
|
||||||
required this.signedInUser,
|
required this.signedInUser,
|
||||||
|
required this.type,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -561,7 +563,7 @@ class _PatientFilesState extends State<PatientFiles> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> setIcons() {
|
List<Widget> setIcons() {
|
||||||
if (widget.signedInUser.type == "personal") {
|
if (widget.type == "personal") {
|
||||||
return [
|
return [
|
||||||
Text(
|
Text(
|
||||||
"Files",
|
"Files",
|
||||||
|
|||||||
@@ -16,8 +16,13 @@ import 'package:supertokens_flutter/http.dart' as http;
|
|||||||
class PatientNotes extends StatefulWidget {
|
class PatientNotes extends StatefulWidget {
|
||||||
final String patientAppId;
|
final String patientAppId;
|
||||||
final AppUser signedInUser;
|
final AppUser signedInUser;
|
||||||
const PatientNotes(
|
final String type;
|
||||||
{super.key, required this.patientAppId, required this.signedInUser});
|
const PatientNotes({
|
||||||
|
super.key,
|
||||||
|
required this.patientAppId,
|
||||||
|
required this.signedInUser,
|
||||||
|
required this.type,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<PatientNotes> createState() => _PatientNotesState();
|
State<PatientNotes> createState() => _PatientNotesState();
|
||||||
@@ -217,7 +222,7 @@ class _PatientNotesState extends State<PatientNotes> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> setIcons() {
|
List<Widget> setIcons() {
|
||||||
if (widget.signedInUser.type == "personal") {
|
if (widget.type == "personal") {
|
||||||
return [
|
return [
|
||||||
Text(
|
Text(
|
||||||
"Notes",
|
"Notes",
|
||||||
|
|||||||
@@ -8,15 +8,16 @@ import 'package:patient_manager/components/patientFiles.dart';
|
|||||||
import 'package:patient_manager/components/patientNotes.dart';
|
import 'package:patient_manager/components/patientNotes.dart';
|
||||||
import 'package:patient_manager/env/env.dart';
|
import 'package:patient_manager/env/env.dart';
|
||||||
import 'package:patient_manager/main.dart';
|
import 'package:patient_manager/main.dart';
|
||||||
import 'package:patient_manager/objects/appUser.dart';
|
import 'package:patient_manager/objects/arguments.dart';
|
||||||
import 'package:patient_manager/objects/patients.dart';
|
import 'package:patient_manager/objects/patients.dart';
|
||||||
import 'package:supertokens_flutter/http.dart' as http;
|
import 'package:supertokens_flutter/http.dart' as http;
|
||||||
|
|
||||||
class PatientView extends StatefulWidget {
|
class PatientView extends StatefulWidget {
|
||||||
final AppUser signedInUser;
|
//final AppUser signedInUser;
|
||||||
|
final PatientViewArguments arguments;
|
||||||
const PatientView({
|
const PatientView({
|
||||||
super.key,
|
super.key,
|
||||||
required this.signedInUser,
|
required this.arguments,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -26,7 +27,7 @@ class PatientView extends StatefulWidget {
|
|||||||
class _PatientViewState extends State<PatientView> {
|
class _PatientViewState extends State<PatientView> {
|
||||||
Future<Patient?> fetchPatient() async {
|
Future<Patient?> fetchPatient() async {
|
||||||
//print("Patien manager page: $endpoint");
|
//print("Patien manager page: $endpoint");
|
||||||
var patientAppId = widget.signedInUser.app_id;
|
var patientAppId = widget.arguments.signedInUser.app_id;
|
||||||
|
|
||||||
final response = await http
|
final response = await http
|
||||||
.get(Uri.parse("${AppEnviroment.baseApiUrl}/patients/$patientAppId"));
|
.get(Uri.parse("${AppEnviroment.baseApiUrl}/patients/$patientAppId"));
|
||||||
@@ -73,7 +74,7 @@ class _PatientViewState extends State<PatientView> {
|
|||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: const MIHAppBar(barTitle: "Patient View"),
|
appBar: const MIHAppBar(barTitle: "Patient View"),
|
||||||
drawer: MIHAppDrawer(
|
drawer: MIHAppDrawer(
|
||||||
signedInUser: widget.signedInUser,
|
signedInUser: widget.arguments.signedInUser,
|
||||||
logo: MzanziInnovationHub.of(context)!.theme.logoImage(),
|
logo: MzanziInnovationHub.of(context)!.theme.logoImage(),
|
||||||
),
|
),
|
||||||
body: SingleChildScrollView(
|
body: SingleChildScrollView(
|
||||||
@@ -82,7 +83,10 @@ class _PatientViewState extends State<PatientView> {
|
|||||||
vertical: 10.0, horizontal: 15.0),
|
vertical: 10.0, horizontal: 15.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
PatientDetails(selectedPatient: snapshot.data!),
|
PatientDetails(
|
||||||
|
selectedPatient: snapshot.data!,
|
||||||
|
type: widget.arguments.type,
|
||||||
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 10.0,
|
height: 10.0,
|
||||||
),
|
),
|
||||||
@@ -96,7 +100,8 @@ class _PatientViewState extends State<PatientView> {
|
|||||||
width: 660,
|
width: 660,
|
||||||
child: PatientNotes(
|
child: PatientNotes(
|
||||||
patientAppId: snapshot.data!.app_id,
|
patientAppId: snapshot.data!.app_id,
|
||||||
signedInUser: widget.signedInUser,
|
signedInUser: widget.arguments.signedInUser,
|
||||||
|
type: widget.arguments.type,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
@@ -104,7 +109,8 @@ class _PatientViewState extends State<PatientView> {
|
|||||||
child: PatientFiles(
|
child: PatientFiles(
|
||||||
patientIndex: snapshot.data!.idpatients,
|
patientIndex: snapshot.data!.idpatients,
|
||||||
selectedPatient: snapshot.data!,
|
selectedPatient: snapshot.data!,
|
||||||
signedInUser: widget.signedInUser,
|
signedInUser: widget.arguments.signedInUser,
|
||||||
|
type: widget.arguments.type,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
@@ -119,7 +125,7 @@ class _PatientViewState extends State<PatientView> {
|
|||||||
return Center(
|
return Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
'${snapshot.error} occurred',
|
'${snapshot.error} occurred',
|
||||||
style: TextStyle(fontSize: 18),
|
style: const TextStyle(fontSize: 18),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import 'package:patient_manager/components/addOrViewPatient.dart';
|
|||||||
import 'package:patient_manager/components/mihAppBar.dart';
|
import 'package:patient_manager/components/mihAppBar.dart';
|
||||||
import 'package:patient_manager/components/signInOrRegister.dart';
|
import 'package:patient_manager/components/signInOrRegister.dart';
|
||||||
import 'package:patient_manager/objects/appUser.dart';
|
import 'package:patient_manager/objects/appUser.dart';
|
||||||
|
import 'package:patient_manager/objects/arguments.dart';
|
||||||
import 'package:patient_manager/objects/patients.dart';
|
import 'package:patient_manager/objects/patients.dart';
|
||||||
import 'package:patient_manager/pages/home.dart';
|
import 'package:patient_manager/pages/home.dart';
|
||||||
import 'package:patient_manager/pages/patientAdd.dart';
|
import 'package:patient_manager/pages/patientAdd.dart';
|
||||||
@@ -26,11 +27,11 @@ class RouteGenerator {
|
|||||||
return MaterialPageRoute(builder: (_) => const Home());
|
return MaterialPageRoute(builder: (_) => const Home());
|
||||||
|
|
||||||
case '/patient-profile':
|
case '/patient-profile':
|
||||||
if (args is AppUser) {
|
if (args is PatientViewArguments) {
|
||||||
//print("route generator: $args");
|
//print("route generator: $args");
|
||||||
return MaterialPageRoute(
|
return MaterialPageRoute(
|
||||||
builder: (_) => AddOrViewPatient(
|
builder: (_) => AddOrViewPatient(
|
||||||
signedInUser: args,
|
arguments: args,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -58,10 +59,10 @@ class RouteGenerator {
|
|||||||
return _errorRoute();
|
return _errorRoute();
|
||||||
|
|
||||||
case '/patient-manager/patient':
|
case '/patient-manager/patient':
|
||||||
if (args is AppUser) {
|
if (args is PatientViewArguments) {
|
||||||
return MaterialPageRoute(
|
return MaterialPageRoute(
|
||||||
builder: (_) => PatientView(
|
builder: (_) => PatientView(
|
||||||
signedInUser: args,
|
arguments: args,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user