include patient view auguments

This commit is contained in:
2024-08-08 11:40:49 +02:00
parent 470311f4ec
commit ab7c9209ac
7 changed files with 85 additions and 48 deletions

View File

@@ -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);
},
);
}

View File

@@ -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);
}

View File

@@ -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()),

View File

@@ -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",

View File

@@ -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",