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