change profile getter to check for patient profile

This commit is contained in:
2024-12-18 11:25:36 +02:00
parent 292c632e5a
commit 2c0560c475
4 changed files with 101 additions and 23 deletions

View File

@@ -46,6 +46,7 @@ class MIHApiCalls {
AppUser userData; AppUser userData;
Business? busData; Business? busData;
BusinessUser? bUserData; BusinessUser? bUserData;
Patient? patientData;
List<MIHNotification> notifi; List<MIHNotification> notifi;
String userPic; String userPic;
@@ -129,8 +130,30 @@ class MIHApiCalls {
notifi = []; notifi = [];
} }
//get patient profile
//print("Patien manager page: $endpoint");
final response = await http.get(
Uri.parse("${AppEnviroment.baseApiUrl}/patients/${userData.app_id}"));
// print("Here");
// print("Body: ${response.body}");
// print("Code: ${response.statusCode}");
// var errorCode = response.statusCode.toString();
// var errorBody = response.body;
if (response.statusCode == 200) {
print("Here1");
var decodedData = jsonDecode(response.body);
print("Here2");
Patient patients = Patient.fromJson(decodedData as Map<String, dynamic>);
print("Here3");
print(patients);
patientData = patients;
} else {
patientData = null;
}
//print(userPic); //print(userPic);
return HomeArguments(userData, bUserData, busData, notifi, userPic); return HomeArguments(
userData, bUserData, busData, patientData, notifi, userPic);
} }
/// This function is used to get business details by business _id. /// This function is used to get business details by business _id.

View File

@@ -35,6 +35,7 @@ class HomeArguments {
final AppUser signedInUser; final AppUser signedInUser;
final BusinessUser? businessUser; final BusinessUser? businessUser;
final Business? business; final Business? business;
final Patient? patient;
final List<MIHNotification> notifi; final List<MIHNotification> notifi;
final String profilePicUrl; final String profilePicUrl;
@@ -42,6 +43,7 @@ class HomeArguments {
this.signedInUser, this.signedInUser,
this.businessUser, this.businessUser,
this.business, this.business,
this.patient,
this.notifi, this.notifi,
this.profilePicUrl, this.profilePicUrl,
); );

View File

@@ -2,6 +2,7 @@ import 'dart:async';
import 'dart:convert'; import 'dart:convert';
// import 'dart:convert'; // import 'dart:convert';
import 'package:Mzansi_Innovation_Hub/mih_objects/patients.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_swipe_detector/flutter_swipe_detector.dart'; import 'package:flutter_swipe_detector/flutter_swipe_detector.dart';
@@ -43,6 +44,7 @@ class MIHHome extends StatefulWidget {
final AppUser signedInUser; final AppUser signedInUser;
final BusinessUser? businessUser; final BusinessUser? businessUser;
final Business? business; final Business? business;
final Patient? patient;
final List<MIHNotification> notifications; final List<MIHNotification> notifications;
final ImageProvider<Object>? propicFile; final ImageProvider<Object>? propicFile;
final bool isUserNew; final bool isUserNew;
@@ -55,6 +57,7 @@ class MIHHome extends StatefulWidget {
required this.signedInUser, required this.signedInUser,
required this.businessUser, required this.businessUser,
required this.business, required this.business,
required this.patient,
required this.notifications, required this.notifications,
required this.propicFile, required this.propicFile,
required this.isUserNew, required this.isUserNew,
@@ -169,29 +172,78 @@ class _MIHHomeState extends State<MIHHome> {
p: getPrim(), p: getPrim(),
s: getSec(), s: getSec(),
)); ));
tileList.add(MIHTile( print("Pat Prof: ${widget.patient}");
videoID: "NUDdoWrbXNc", if (widget.patient != null) {
onTap: () { tileList.add(MIHTile(
Navigator.of(context).pushNamed('/patient-profile', videoID: "NUDdoWrbXNc",
arguments: PatientViewArguments( onTap: () {
widget.signedInUser, null, null, null, "personal")); Navigator.of(context).pushNamed('/patient-profile',
}, arguments: PatientViewArguments(
tileName: "Patient Profile", widget.signedInUser, null, null, null, "personal"));
tileIcon: Center( },
child: FaIcon( tileName: "Patient Profile",
FontAwesomeIcons.bookMedical, tileIcon: Center(
color: getSec(), child: FaIcon(
size: 200, FontAwesomeIcons.bookMedical,
color: getSec(),
size: 200,
),
), ),
), // Icon(
// Icon( // Icons.medication,
// Icons.medication, // color: getSec(),
// color: getSec(), // size: 200,
// size: 200, // ),
// ), p: getPrim(),
p: getPrim(), s: getSec(),
s: getSec(), ));
)); } else {
tileList.add(MIHTile(
videoID: "NUDdoWrbXNc",
onTap: () {
Navigator.of(context).pushNamed('/patient-profile/set-up',
arguments: widget.signedInUser);
},
tileName: "Set Up Patient",
tileIcon: Center(
child: FaIcon(
FontAwesomeIcons.bookMedical,
color: getSec(),
size: 200,
),
),
// Icon(
// Icons.medication,
// color: getSec(),
// size: 200,
// ),
p: getPrim(),
s: getSec(),
));
}
// tileList.add(MIHTile(
// videoID: "NUDdoWrbXNc",
// onTap: () {
// Navigator.of(context).pushNamed('/patient-profile',
// arguments: PatientViewArguments(
// widget.signedInUser, null, null, null, "personal"));
// },
// tileName: "Patient Profile",
// tileIcon: Center(
// child: FaIcon(
// FontAwesomeIcons.bookMedical,
// color: getSec(),
// size: 200,
// ),
// ),
// // Icon(
// // Icons.medication,
// // color: getSec(),
// // size: 200,
// // ),
// p: getPrim(),
// s: getSec(),
// ));
tileList.add(MIHTile( tileList.add(MIHTile(
onTap: () { onTap: () {
Navigator.of(context).pushNamed( Navigator.of(context).pushNamed(

View File

@@ -99,6 +99,7 @@ class _MIHProfileGetterState extends State<MIHProfileGetter> {
signedInUser: snapshot.requireData.signedInUser, signedInUser: snapshot.requireData.signedInUser,
businessUser: snapshot.data!.businessUser, businessUser: snapshot.data!.businessUser,
business: snapshot.data!.business, business: snapshot.data!.business,
patient: snapshot.data!.patient,
notifications: snapshot.data!.notifi, notifications: snapshot.data!.notifi,
propicFile: isPictureAvailable(snapshot.data!.profilePicUrl), propicFile: isPictureAvailable(snapshot.data!.profilePicUrl),
isUserNew: isUserNew(snapshot.requireData.signedInUser), isUserNew: isUserNew(snapshot.requireData.signedInUser),