NEW: Patient Manager Provider Setup pt1
This commit is contained in:
@@ -11,6 +11,7 @@ import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_ai_pro
|
|||||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_directory_provider.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_directory_provider.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_profile_provider.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_profile_provider.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_wallet_provider.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_wallet_provider.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_providers/patient_manager_provider.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:upgrader/upgrader.dart';
|
import 'package:upgrader/upgrader.dart';
|
||||||
@@ -113,6 +114,9 @@ class _MzansiInnovationHubState extends State<MzansiInnovationHub> {
|
|||||||
ChangeNotifierProvider(
|
ChangeNotifierProvider(
|
||||||
create: (context) => MihMineSweeperProvider(),
|
create: (context) => MihMineSweeperProvider(),
|
||||||
),
|
),
|
||||||
|
ChangeNotifierProvider(
|
||||||
|
create: (context) => PatientManagerProvider(),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
child: MaterialApp.router(
|
child: MaterialApp.router(
|
||||||
title: getTitle(),
|
title: getTitle(),
|
||||||
|
|||||||
@@ -1,15 +1,21 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_objects/files.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_objects/notes.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/patients.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_objects/patients.dart';
|
||||||
|
|
||||||
class PatientManagerProvider extends ChangeNotifier {
|
class PatientManagerProvider extends ChangeNotifier {
|
||||||
int patientProfileIndex;
|
int patientProfileIndex;
|
||||||
int patientManagerIndex;
|
int patientManagerIndex;
|
||||||
|
int fileViewerIndex;
|
||||||
bool personalMode;
|
bool personalMode;
|
||||||
Patient? selectedPatient;
|
Patient? selectedPatient;
|
||||||
|
List<Note>? consultationNotes;
|
||||||
|
List<PFile>? patientDocuments;
|
||||||
|
|
||||||
PatientManagerProvider({
|
PatientManagerProvider({
|
||||||
this.patientProfileIndex = 0,
|
this.patientProfileIndex = 0,
|
||||||
this.patientManagerIndex = 0,
|
this.patientManagerIndex = 0,
|
||||||
|
this.fileViewerIndex = 0,
|
||||||
this.personalMode = true,
|
this.personalMode = true,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -30,6 +36,11 @@ class PatientManagerProvider extends ChangeNotifier {
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setFileViewerIndex(int index) {
|
||||||
|
patientProfileIndex = index;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
void setPersonalMode(bool personalMode) {
|
void setPersonalMode(bool personalMode) {
|
||||||
this.personalMode = personalMode;
|
this.personalMode = personalMode;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
@@ -39,4 +50,14 @@ class PatientManagerProvider extends ChangeNotifier {
|
|||||||
this.selectedPatient = selectedPatient;
|
this.selectedPatient = selectedPatient;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setConsultationNotes({required List<Note>? consultationNotes}) {
|
||||||
|
this.consultationNotes = consultationNotes ?? [];
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setPatientDocuments({required List<PFile>? patientDocuments}) {
|
||||||
|
this.patientDocuments = patientDocuments ?? [];
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,10 +26,9 @@ import 'package:ken_logger/ken_logger.dart';
|
|||||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_wallet/components/mih_barcode_scanner.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_wallet/components/mih_barcode_scanner.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_wallet/mih_wallet.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_wallet/mih_wallet.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_manager/pat_manager.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_manager/pat_manager.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/add_or_view_patient.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/components/full_screen_file.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/components/full_screen_file.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/patient_edit.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/patient_profile.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/patient_profile.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/patient_set_up.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:supertokens_flutter/supertokens.dart';
|
import 'package:supertokens_flutter/supertokens.dart';
|
||||||
|
|
||||||
@@ -53,7 +52,6 @@ class MihGoRouterPaths {
|
|||||||
static const String businessProfileView = '/business-profile/view';
|
static const String businessProfileView = '/business-profile/view';
|
||||||
static const String patientProfile = '/patient-profile';
|
static const String patientProfile = '/patient-profile';
|
||||||
static const String patientProfileSetup = '/patient-profile/set-up';
|
static const String patientProfileSetup = '/patient-profile/set-up';
|
||||||
static const String patientProfileEdit = '/patient-profile/edit';
|
|
||||||
static const String mzansiWallet = '/mzansi-wallet';
|
static const String mzansiWallet = '/mzansi-wallet';
|
||||||
static const String mzansiDirectory = '/mzansi-directory';
|
static const String mzansiDirectory = '/mzansi-directory';
|
||||||
static const String mihAccess = '/mih-access';
|
static const String mihAccess = '/mih-access';
|
||||||
@@ -66,7 +64,7 @@ class MihGoRouterPaths {
|
|||||||
static const String barcodeScanner = '/scanner';
|
static const String barcodeScanner = '/scanner';
|
||||||
static const String calculator = '/calculator';
|
static const String calculator = '/calculator';
|
||||||
static const String mzansiAi = '/mzansi-ai';
|
static const String mzansiAi = '/mzansi-ai';
|
||||||
static const String mihMineSweeper = '/mih-mine-sweeper';
|
static const String mihMineSweeper = '/mih-minesweeper';
|
||||||
static const String packageDevTest = '/package-dev';
|
static const String packageDevTest = '/package-dev';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,7 +272,7 @@ class MihGoRouter {
|
|||||||
path: MihGoRouterPaths.mzansiWallet,
|
path: MihGoRouterPaths.mzansiWallet,
|
||||||
builder: (BuildContext context, GoRouterState state) {
|
builder: (BuildContext context, GoRouterState state) {
|
||||||
KenLogger.success("MihGoRouter: mzansiWallet");
|
KenLogger.success("MihGoRouter: mzansiWallet");
|
||||||
if (context.watch<MzansiProfileProvider>().business == null) {
|
if (context.watch<MzansiProfileProvider>().user == null) {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
context.go(MihGoRouterPaths.mihHome);
|
context.go(MihGoRouterPaths.mihHome);
|
||||||
});
|
});
|
||||||
@@ -322,7 +320,7 @@ class MihGoRouter {
|
|||||||
name: "mihAccess",
|
name: "mihAccess",
|
||||||
path: MihGoRouterPaths.mihAccess,
|
path: MihGoRouterPaths.mihAccess,
|
||||||
builder: (BuildContext context, GoRouterState state) {
|
builder: (BuildContext context, GoRouterState state) {
|
||||||
if (context.watch<MzansiProfileProvider>().business == null) {
|
if (context.watch<MzansiProfileProvider>().user == null) {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
context.go(MihGoRouterPaths.mihHome);
|
context.go(MihGoRouterPaths.mihHome);
|
||||||
});
|
});
|
||||||
@@ -338,36 +336,27 @@ class MihGoRouter {
|
|||||||
name: "patientProfile",
|
name: "patientProfile",
|
||||||
path: MihGoRouterPaths.patientProfile,
|
path: MihGoRouterPaths.patientProfile,
|
||||||
builder: (BuildContext context, GoRouterState state) {
|
builder: (BuildContext context, GoRouterState state) {
|
||||||
final PatientViewArguments? args =
|
final String? argPatientAppId = state.extra as String?;
|
||||||
state.extra as PatientViewArguments?;
|
if (context.watch<MzansiProfileProvider>().user == null) {
|
||||||
if (args == null) {
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
context.go(MihGoRouterPaths.mihHome);
|
context.go(MihGoRouterPaths.mihHome);
|
||||||
});
|
});
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
}
|
}
|
||||||
return AddOrViewPatient(
|
return PatientProfile(patientAppId: argPatientAppId);
|
||||||
key: UniqueKey(),
|
|
||||||
arguments: args,
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
name: "patientProfileEdit",
|
name: "patientProfileSetup",
|
||||||
path: MihGoRouterPaths.patientProfileEdit,
|
path: MihGoRouterPaths.patientProfileSetup,
|
||||||
builder: (BuildContext context, GoRouterState state) {
|
builder: (BuildContext context, GoRouterState state) {
|
||||||
final PatientEditArguments? args =
|
if (context.watch<MzansiProfileProvider>().user == null) {
|
||||||
state.extra as PatientEditArguments?;
|
|
||||||
if (args == null) {
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
context.go(MihGoRouterPaths.mihHome);
|
context.go(MihGoRouterPaths.mihHome);
|
||||||
});
|
});
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
}
|
}
|
||||||
return EditPatient(
|
return PatientSetUp();
|
||||||
signedInUser: args.signedInUser,
|
|
||||||
selectedPatient: args.selectedPatient,
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
@@ -391,15 +380,14 @@ class MihGoRouter {
|
|||||||
name: "patientManagerPatient",
|
name: "patientManagerPatient",
|
||||||
path: MihGoRouterPaths.patientManagerPatient,
|
path: MihGoRouterPaths.patientManagerPatient,
|
||||||
builder: (BuildContext context, GoRouterState state) {
|
builder: (BuildContext context, GoRouterState state) {
|
||||||
final PatientViewArguments? args =
|
final String? argPatientAppId = state.extra as String?;
|
||||||
state.extra as PatientViewArguments?;
|
if (context.watch<MzansiProfileProvider>().user == null) {
|
||||||
if (args == null) {
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
context.go(MihGoRouterPaths.mihHome);
|
context.go(MihGoRouterPaths.mihHome);
|
||||||
});
|
});
|
||||||
return const SizedBox.shrink();
|
return const SizedBox.shrink();
|
||||||
}
|
}
|
||||||
return PatientProfile(arguments: args);
|
return PatientProfile(patientAppId: argPatientAppId);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
// ========================== Mzansi Directory ==================================
|
// ========================== Mzansi Directory ==================================
|
||||||
@@ -407,7 +395,7 @@ class MihGoRouter {
|
|||||||
name: "mzansiDirectory",
|
name: "mzansiDirectory",
|
||||||
path: MihGoRouterPaths.mzansiDirectory,
|
path: MihGoRouterPaths.mzansiDirectory,
|
||||||
builder: (BuildContext context, GoRouterState state) {
|
builder: (BuildContext context, GoRouterState state) {
|
||||||
if (context.watch<MzansiProfileProvider>().business == null) {
|
if (context.watch<MzansiProfileProvider>().user == null) {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
context.go(MihGoRouterPaths.mihHome);
|
context.go(MihGoRouterPaths.mihHome);
|
||||||
});
|
});
|
||||||
@@ -436,10 +424,16 @@ class MihGoRouter {
|
|||||||
),
|
),
|
||||||
// ========================== MIH Calculator ==================================
|
// ========================== MIH Calculator ==================================
|
||||||
GoRoute(
|
GoRoute(
|
||||||
name: "mihMineSweeper",
|
name: "mihMinesweeper",
|
||||||
path: MihGoRouterPaths.mihMineSweeper,
|
path: MihGoRouterPaths.mihMineSweeper,
|
||||||
builder: (BuildContext context, GoRouterState state) {
|
builder: (BuildContext context, GoRouterState state) {
|
||||||
KenLogger.success("MihGoRouter: mihMineSweeper");
|
KenLogger.success("MihGoRouter: mihMineSweeper");
|
||||||
|
if (context.watch<MzansiProfileProvider>().user == null) {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
context.go(MihGoRouterPaths.mihHome);
|
||||||
|
});
|
||||||
|
return const SizedBox.shrink();
|
||||||
|
}
|
||||||
return MihMineSweeper();
|
return MihMineSweeper();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,79 +0,0 @@
|
|||||||
import 'package:mzansi_innovation_hub/main.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/patients.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/patient_add.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/patient_profile.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_patient_services.dart';
|
|
||||||
|
|
||||||
class AddOrViewPatient extends StatefulWidget {
|
|
||||||
//final AppUser signedInUser;
|
|
||||||
final PatientViewArguments arguments;
|
|
||||||
const AddOrViewPatient({
|
|
||||||
super.key,
|
|
||||||
required this.arguments,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<AddOrViewPatient> createState() => _AddOrViewPatientState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _AddOrViewPatientState extends State<AddOrViewPatient> {
|
|
||||||
late double width;
|
|
||||||
late double height;
|
|
||||||
late Widget loading;
|
|
||||||
late Future<Patient?> patient;
|
|
||||||
|
|
||||||
Future<Patient?> fetchPatientData() async {
|
|
||||||
return await MihPatientServices()
|
|
||||||
.getPatientDetails(widget.arguments.signedInUser.app_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
patient = fetchPatientData();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
print("AddOrViewPatient");
|
|
||||||
var size = MediaQuery.of(context).size;
|
|
||||||
setState(() {
|
|
||||||
width = size.width;
|
|
||||||
height = size.height;
|
|
||||||
});
|
|
||||||
return FutureBuilder(
|
|
||||||
future: patient,
|
|
||||||
builder: (ctx, snapshot) {
|
|
||||||
if (snapshot.connectionState == ConnectionState.done &&
|
|
||||||
snapshot.hasData) {
|
|
||||||
// Extracting data from snapshot object
|
|
||||||
//final data = snapshot.data as String;
|
|
||||||
return PatientProfile(
|
|
||||||
arguments: PatientViewArguments(
|
|
||||||
widget.arguments.signedInUser,
|
|
||||||
snapshot.requireData,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
widget.arguments.type,
|
|
||||||
));
|
|
||||||
} else if (snapshot.connectionState == ConnectionState.waiting) {
|
|
||||||
loading = Container(
|
|
||||||
width: width,
|
|
||||||
height: height,
|
|
||||||
color: MihColors.getPrimaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
|
||||||
child: const Mihloadingcircle(),
|
|
||||||
);
|
|
||||||
|
|
||||||
return loading;
|
|
||||||
} else {
|
|
||||||
return AddPatient(signedInUser: widget.arguments.signedInUser);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,39 +1,31 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:mzansi_innovation_hub/main.dart';
|
import 'package:mzansi_innovation_hub/main.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_button.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_form.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_alert.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_alert.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_window.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_text_form_field.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_toggle.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_providers/patient_manager_provider.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_patient_services.dart';
|
import 'package:mzansi_innovation_hub/mih_services/mih_patient_services.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
|
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_layout/mih_action.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_layout/mih_body.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_layout/mih_header.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_layout/mih_layout_builder.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_button.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_form.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_text_form_field.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_toggle.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_error_message.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
|
|
||||||
class AddPatient extends StatefulWidget {
|
class MihEditPatientDetailsWindow extends StatefulWidget {
|
||||||
final AppUser signedInUser;
|
const MihEditPatientDetailsWindow({super.key});
|
||||||
|
|
||||||
const AddPatient({
|
|
||||||
super.key,
|
|
||||||
required this.signedInUser,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<AddPatient> createState() => _AddPatientState();
|
State<MihEditPatientDetailsWindow> createState() =>
|
||||||
|
_MihEditPatientDetailsWindowState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _AddPatientState extends State<AddPatient> {
|
class _MihEditPatientDetailsWindowState
|
||||||
final idController = TextEditingController();
|
extends State<MihEditPatientDetailsWindow> {
|
||||||
|
var idController = TextEditingController();
|
||||||
final fnameController = TextEditingController();
|
final fnameController = TextEditingController();
|
||||||
final lnameController = TextEditingController();
|
final lnameController = TextEditingController();
|
||||||
final cellController = TextEditingController();
|
final cellController = TextEditingController();
|
||||||
@@ -45,51 +37,16 @@ class _AddPatientState extends State<AddPatient> {
|
|||||||
final medAidController = TextEditingController();
|
final medAidController = TextEditingController();
|
||||||
final medMainMemController = TextEditingController();
|
final medMainMemController = TextEditingController();
|
||||||
final medAidCodeController = TextEditingController();
|
final medAidCodeController = TextEditingController();
|
||||||
|
|
||||||
late bool medAidPosition;
|
|
||||||
late bool medMainMemberPosition;
|
|
||||||
final baseAPI = AppEnviroment.baseApiUrl;
|
|
||||||
late int futureDocOfficeId;
|
|
||||||
//late bool medRequired;
|
|
||||||
final ValueNotifier<bool> medRequired = ValueNotifier(false);
|
|
||||||
final FocusNode _focusNode = FocusNode();
|
final FocusNode _focusNode = FocusNode();
|
||||||
final _formKey = GlobalKey<FormState>();
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
late bool medAidPosition;
|
||||||
|
late bool medMainMemberPosition;
|
||||||
|
final ValueNotifier<bool> medRequired = ValueNotifier(false);
|
||||||
|
|
||||||
bool isFieldsFilled() {
|
Future<void> updatePatientApiCall(
|
||||||
if (medRequired.value) {
|
PatientManagerProvider patientManagerProvider) async {
|
||||||
if (idController.text.isEmpty ||
|
var statusCode = await MihPatientServices().updatePatientService(
|
||||||
fnameController.text.isEmpty ||
|
patientManagerProvider.selectedPatient!.app_id,
|
||||||
lnameController.text.isEmpty ||
|
|
||||||
cellController.text.isEmpty ||
|
|
||||||
emailController.text.isEmpty ||
|
|
||||||
medNoController.text.isEmpty ||
|
|
||||||
medNameController.text.isEmpty ||
|
|
||||||
medSchemeController.text.isEmpty ||
|
|
||||||
addressController.text.isEmpty ||
|
|
||||||
medAidController.text.isEmpty ||
|
|
||||||
medMainMemController.text.isEmpty ||
|
|
||||||
medAidCodeController.text.isEmpty) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (idController.text.isEmpty ||
|
|
||||||
fnameController.text.isEmpty ||
|
|
||||||
lnameController.text.isEmpty ||
|
|
||||||
cellController.text.isEmpty ||
|
|
||||||
emailController.text.isEmpty ||
|
|
||||||
addressController.text.isEmpty ||
|
|
||||||
medAidController.text.isEmpty) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> addPatientService() async {
|
|
||||||
int statusCode = await MihPatientServices().addPatientService(
|
|
||||||
idController.text,
|
idController.text,
|
||||||
fnameController.text,
|
fnameController.text,
|
||||||
lnameController.text,
|
lnameController.text,
|
||||||
@@ -102,14 +59,19 @@ class _AddPatientState extends State<AddPatient> {
|
|||||||
medNameController.text,
|
medNameController.text,
|
||||||
medSchemeController.text,
|
medSchemeController.text,
|
||||||
addressController.text,
|
addressController.text,
|
||||||
widget.signedInUser,
|
patientManagerProvider,
|
||||||
);
|
);
|
||||||
if (statusCode == 201) {
|
if (statusCode == 200) {
|
||||||
String message =
|
successPopUp(
|
||||||
"${fnameController.text} ${lnameController.text} patient profile has been successfully added!\n";
|
"Successfully Updated Profile!",
|
||||||
successPopUp("Successfully created Patient Profile", message);
|
"${fnameController.text} ${lnameController.text}'s information has been updated successfully! Their medical records and details are now current.",
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
internetConnectionPopUp();
|
MihAlertServices().errorAlert(
|
||||||
|
"Error Updating Profile",
|
||||||
|
"There was an error updating your profile. Please try again later.",
|
||||||
|
context,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,17 +102,18 @@ class _AddPatientState extends State<AddPatient> {
|
|||||||
Center(
|
Center(
|
||||||
child: MihButton(
|
child: MihButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
// context.goNamed(
|
||||||
|
// "patientProfile",
|
||||||
|
// extra: PatientViewArguments(
|
||||||
|
// widget.signedInUser,
|
||||||
|
// widget.selectedPatient,
|
||||||
|
// null,
|
||||||
|
// null,
|
||||||
|
// "personal",
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
|
context.pop();
|
||||||
context.pop();
|
context.pop();
|
||||||
context.goNamed(
|
|
||||||
'patientProfile',
|
|
||||||
extra: PatientViewArguments(
|
|
||||||
widget.signedInUser,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
"personal",
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
buttonColor: MihColors.getGreenColor(
|
buttonColor: MihColors.getGreenColor(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
@@ -173,45 +136,21 @@ class _AddPatientState extends State<AddPatient> {
|
|||||||
alertColour: MihColors.getGreenColor(
|
alertColour: MihColors.getGreenColor(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
);
|
);
|
||||||
|
// return MIHSuccessMessage(
|
||||||
|
// successType: "Success",
|
||||||
|
// successMessage: message,
|
||||||
|
// );
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void internetConnectionPopUp() {
|
Widget displayForm(
|
||||||
showDialog(
|
PatientManagerProvider patientManagerProvider, double width) {
|
||||||
context: context,
|
|
||||||
builder: (context) {
|
|
||||||
return const MIHErrorMessage(errorType: "Internet Connection");
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void messagePopUp(error) {
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (context) {
|
|
||||||
return AlertDialog(
|
|
||||||
title: Text(error),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void isRequired() {
|
|
||||||
//print("listerner triggered");
|
|
||||||
if (medAidController.text == "Yes") {
|
|
||||||
medRequired.value = true;
|
|
||||||
} else {
|
|
||||||
medRequired.value = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget displayForm(double width) {
|
|
||||||
return SingleChildScrollView(
|
return SingleChildScrollView(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: MzansiInnovationHub.of(context)!.theme.screenType == "desktop"
|
padding: MzansiInnovationHub.of(context)!.theme.screenType == "desktop"
|
||||||
? EdgeInsets.symmetric(horizontal: width * 0.2)
|
? EdgeInsets.symmetric(horizontal: width * 0.05)
|
||||||
: EdgeInsets.symmetric(horizontal: width * 0.075),
|
: const EdgeInsets.symmetric(horizontal: 0),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
MihForm(
|
MihForm(
|
||||||
@@ -485,7 +424,7 @@ class _AddPatientState extends State<AddPatient> {
|
|||||||
child: MihButton(
|
child: MihButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (_formKey.currentState!.validate()) {
|
if (_formKey.currentState!.validate()) {
|
||||||
submitForm();
|
updatePatientApiCall(patientManagerProvider);
|
||||||
} else {
|
} else {
|
||||||
MihAlertServices().formNotFilledCompletely(context);
|
MihAlertServices().formNotFilledCompletely(context);
|
||||||
}
|
}
|
||||||
@@ -494,7 +433,7 @@ class _AddPatientState extends State<AddPatient> {
|
|||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
width: 300,
|
width: 300,
|
||||||
child: Text(
|
child: Text(
|
||||||
"Add",
|
"Update",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: MihColors.getPrimaryColor(
|
color: MihColors.getPrimaryColor(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
@@ -514,60 +453,12 @@ class _AddPatientState extends State<AddPatient> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void submitForm() {
|
void isRequired() {
|
||||||
addPatientService();
|
if (medAidController.text == "Yes") {
|
||||||
}
|
medRequired.value = true;
|
||||||
|
} else if (medAidController.text == "No") {
|
||||||
MIHAction getActionButton() {
|
medRequired.value = false;
|
||||||
return MIHAction(
|
} else {}
|
||||||
icon: const Icon(Icons.arrow_back),
|
|
||||||
iconSize: 35,
|
|
||||||
onTap: () {
|
|
||||||
context.goNamed(
|
|
||||||
'mihHome',
|
|
||||||
extra: true,
|
|
||||||
);
|
|
||||||
FocusScope.of(context).unfocus();
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
MIHHeader getHeader() {
|
|
||||||
return const MIHHeader(
|
|
||||||
headerAlignment: MainAxisAlignment.center,
|
|
||||||
headerItems: [
|
|
||||||
Text(
|
|
||||||
"Set Up Patient Profile",
|
|
||||||
style: TextStyle(
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
fontSize: 25,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
MIHBody getBody(double width) {
|
|
||||||
return MIHBody(
|
|
||||||
borderOn: false,
|
|
||||||
bodyItems: [
|
|
||||||
KeyboardListener(
|
|
||||||
focusNode: _focusNode,
|
|
||||||
autofocus: true,
|
|
||||||
onKeyEvent: (event) async {
|
|
||||||
if (event is KeyDownEvent &&
|
|
||||||
event.logicalKey == LogicalKeyboardKey.enter) {
|
|
||||||
if (_formKey.currentState!.validate()) {
|
|
||||||
submitForm();
|
|
||||||
} else {
|
|
||||||
MihAlertServices().formNotFilledCompletely(context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: displayForm(width),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -583,9 +474,9 @@ class _AddPatientState extends State<AddPatient> {
|
|||||||
addressController.dispose();
|
addressController.dispose();
|
||||||
medAidController.dispose();
|
medAidController.dispose();
|
||||||
medAidCodeController.removeListener(isRequired);
|
medAidCodeController.removeListener(isRequired);
|
||||||
medRequired.dispose();
|
|
||||||
medMainMemController.dispose();
|
medMainMemController.dispose();
|
||||||
medAidCodeController.dispose();
|
medAidCodeController.dispose();
|
||||||
|
medRequired.dispose();
|
||||||
_focusNode.dispose();
|
_focusNode.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
@@ -593,67 +484,76 @@ class _AddPatientState extends State<AddPatient> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
medAidController.addListener(isRequired);
|
medAidController.addListener(isRequired);
|
||||||
|
PatientManagerProvider patientManagerProvider =
|
||||||
|
context.read<PatientManagerProvider>();
|
||||||
setState(() {
|
setState(() {
|
||||||
fnameController.text = widget.signedInUser.fname;
|
idController.text = patientManagerProvider.selectedPatient!.id_no;
|
||||||
lnameController.text = widget.signedInUser.lname;
|
fnameController.text = patientManagerProvider.selectedPatient!.first_name;
|
||||||
emailController.text = widget.signedInUser.email;
|
lnameController.text = patientManagerProvider.selectedPatient!.last_name;
|
||||||
medAidPosition = false;
|
cellController.text = patientManagerProvider.selectedPatient!.cell_no;
|
||||||
medMainMemberPosition = false;
|
emailController.text = patientManagerProvider.selectedPatient!.email;
|
||||||
medAidController.text = "No";
|
medNameController.text =
|
||||||
medMainMemController.text = "No";
|
patientManagerProvider.selectedPatient!.medical_aid_name;
|
||||||
|
medNoController.text =
|
||||||
|
patientManagerProvider.selectedPatient!.medical_aid_no;
|
||||||
|
medSchemeController.text =
|
||||||
|
patientManagerProvider.selectedPatient!.medical_aid_scheme;
|
||||||
|
addressController.text = patientManagerProvider.selectedPatient!.address;
|
||||||
|
medAidController.text =
|
||||||
|
patientManagerProvider.selectedPatient!.medical_aid;
|
||||||
|
medMainMemController.text =
|
||||||
|
patientManagerProvider.selectedPatient!.medical_aid_main_member;
|
||||||
|
medAidCodeController.text =
|
||||||
|
patientManagerProvider.selectedPatient!.medical_aid_code;
|
||||||
});
|
});
|
||||||
|
if (medAidController.text == "Yes") {
|
||||||
|
medAidPosition = true;
|
||||||
|
} else {
|
||||||
|
medAidPosition = false;
|
||||||
|
medAidController.text = "No";
|
||||||
|
}
|
||||||
|
if (medMainMemController.text == "Yes") {
|
||||||
|
medMainMemberPosition = true;
|
||||||
|
} else {
|
||||||
|
medMainMemberPosition = false;
|
||||||
|
medMainMemController.text = "No";
|
||||||
|
}
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
double screenWidth = MediaQuery.of(context).size.width;
|
var size = MediaQuery.of(context).size;
|
||||||
return MIHLayoutBuilder(
|
return MihPackageWindow(
|
||||||
actionButton: getActionButton(),
|
fullscreen: false,
|
||||||
header: getHeader(),
|
windowTitle: "Edit Patient Details",
|
||||||
secondaryActionButton: null,
|
onWindowTapClose: () {
|
||||||
body: getBody(screenWidth),
|
context.pop();
|
||||||
actionDrawer: null,
|
},
|
||||||
secondaryActionDrawer: null,
|
windowBody: getBody(size.width),
|
||||||
bottomNavBar: null,
|
);
|
||||||
pullDownToRefresh: false,
|
}
|
||||||
onPullDown: () async {},
|
|
||||||
|
Widget getBody(double width) {
|
||||||
|
return Consumer<PatientManagerProvider>(
|
||||||
|
builder: (BuildContext context,
|
||||||
|
PatientManagerProvider patientManagerProvider, Widget? child) {
|
||||||
|
return KeyboardListener(
|
||||||
|
focusNode: _focusNode,
|
||||||
|
autofocus: true,
|
||||||
|
onKeyEvent: (event) async {
|
||||||
|
if (event is KeyDownEvent &&
|
||||||
|
event.logicalKey == LogicalKeyboardKey.enter) {
|
||||||
|
if (_formKey.currentState!.validate()) {
|
||||||
|
updatePatientApiCall(patientManagerProvider);
|
||||||
|
} else {
|
||||||
|
MihAlertServices().formNotFilledCompletely(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: displayForm(patientManagerProvider, width),
|
||||||
|
);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
// return Scaffold(
|
|
||||||
// // appBar: const MIHAppBar(
|
|
||||||
// // barTitle: "Add Patient",
|
|
||||||
// // propicFile: null,
|
|
||||||
// // ),
|
|
||||||
// //drawer: MIHAppDrawer(signedInUser: widget.signedInUser),
|
|
||||||
// body: SafeArea(
|
|
||||||
// child: Stack(
|
|
||||||
// children: [
|
|
||||||
// KeyboardListener(
|
|
||||||
// focusNode: _focusNode,
|
|
||||||
// autofocus: true,
|
|
||||||
// onKeyEvent: (event) async {
|
|
||||||
// if (event is KeyDownEvent &&
|
|
||||||
// event.logicalKey == LogicalKeyboardKey.enter) {
|
|
||||||
// submitForm();
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// child: displayForm(),
|
|
||||||
// ),
|
|
||||||
// Positioned(
|
|
||||||
// top: 10,
|
|
||||||
// left: 5,
|
|
||||||
// width: 50,
|
|
||||||
// height: 50,
|
|
||||||
// child: IconButton(
|
|
||||||
// onPressed: () {
|
|
||||||
// Navigator.of(context).pop();
|
|
||||||
// },
|
|
||||||
// icon: const Icon(Icons.arrow_back),
|
|
||||||
// ),
|
|
||||||
// )
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,48 +1,30 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
|
||||||
|
|
||||||
import 'package:fl_downloader/fl_downloader.dart';
|
import 'package:fl_downloader/fl_downloader.dart';
|
||||||
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:mzansi_innovation_hub/main.dart';
|
import 'package:mzansi_innovation_hub/main.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_profile_provider.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_providers/patient_manager_provider.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
|
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_window.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_window.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_delete_message.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_error_message.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_error_message.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_success_message.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_success_message.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business_user.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/files.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/patients.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/list_builders/build_file_view.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/list_builders/build_file_view.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
import 'package:supertokens_flutter/http.dart' as http;
|
import 'package:supertokens_flutter/http.dart' as http;
|
||||||
import 'package:http/http.dart' as http2;
|
import 'package:http/http.dart' as http2;
|
||||||
import "package:universal_html/html.dart" as html;
|
import "package:universal_html/html.dart" as html;
|
||||||
|
|
||||||
class BuildFilesList extends StatefulWidget {
|
class BuildFilesList extends StatefulWidget {
|
||||||
final AppUser signedInUser;
|
|
||||||
final List<PFile> files;
|
|
||||||
final Patient selectedPatient;
|
|
||||||
final Business? business;
|
|
||||||
final BusinessUser? businessUser;
|
|
||||||
final String type;
|
|
||||||
final String env;
|
|
||||||
const BuildFilesList({
|
const BuildFilesList({
|
||||||
super.key,
|
super.key,
|
||||||
required this.files,
|
|
||||||
required this.signedInUser,
|
|
||||||
required this.selectedPatient,
|
|
||||||
required this.business,
|
|
||||||
required this.businessUser,
|
|
||||||
required this.type,
|
|
||||||
required this.env,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -68,71 +50,72 @@ class _BuildFilesListState extends State<BuildFilesList> {
|
|||||||
return teporaryFileUrl;
|
return teporaryFileUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> deleteFileApiCall(String filePath, int fileID) async {
|
// Future<void> deleteFileApiCall(PatientManagerProvider patientManagerProvider,
|
||||||
var response = await MihFileApi.deleteFile(
|
// String filePath, int fileID) async {
|
||||||
widget.selectedPatient.app_id,
|
// var response = await MihFileApi.deleteFile(
|
||||||
widget.env,
|
// patientManagerProvider.selectedPatient!.app_id,
|
||||||
"patient_files",
|
// widget.env,
|
||||||
filePath.split("/").last,
|
// "patient_files",
|
||||||
context,
|
// filePath.split("/").last,
|
||||||
);
|
// context,
|
||||||
if (response == 200) {
|
// );
|
||||||
// delete file from database
|
// if (response == 200) {
|
||||||
await deletePatientFileLocationToDB(fileID);
|
// // delete file from database
|
||||||
} else {
|
// await deletePatientFileLocationToDB(fileID);
|
||||||
String message =
|
// } else {
|
||||||
"The File has not been deleted successfully. Please try again.";
|
// String message =
|
||||||
successPopUp(message);
|
// "The File has not been deleted successfully. Please try again.";
|
||||||
}
|
// successPopUp(message);
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
Future<void> deletePatientFileLocationToDB(int fileID) async {
|
// Future<void> deletePatientFileLocationToDB(int fileID) async {
|
||||||
showDialog(
|
// showDialog(
|
||||||
context: context,
|
// context: context,
|
||||||
builder: (context) {
|
// builder: (context) {
|
||||||
return const Mihloadingcircle();
|
// return const Mihloadingcircle();
|
||||||
},
|
// },
|
||||||
);
|
// );
|
||||||
var response2 = await http.delete(
|
// var response2 = await http.delete(
|
||||||
Uri.parse("$baseAPI/patient_files/delete/"),
|
// Uri.parse("$baseAPI/patient_files/delete/"),
|
||||||
headers: <String, String>{
|
// headers: <String, String>{
|
||||||
"Content-Type": "application/json; charset=UTF-8"
|
// "Content-Type": "application/json; charset=UTF-8"
|
||||||
},
|
// },
|
||||||
body: jsonEncode(<String, dynamic>{
|
// body: jsonEncode(<String, dynamic>{
|
||||||
"idpatient_files": fileID,
|
// "idpatient_files": fileID,
|
||||||
"env": widget.env,
|
// "env": widget.env,
|
||||||
}),
|
// }),
|
||||||
);
|
// );
|
||||||
if (response2.statusCode == 200) {
|
// if (response2.statusCode == 200) {
|
||||||
context.pop(); //Remove Loading Dialog
|
// context.pop(); //Remove Loading Dialog
|
||||||
context.pop(); //Remove Delete Dialog
|
// context.pop(); //Remove Delete Dialog
|
||||||
context.pop(); //Remove File View Dialog
|
// context.pop(); //Remove File View Dialog
|
||||||
context.pop(); //Remove File List Dialog
|
// context.pop(); //Remove File List Dialog
|
||||||
//print(widget.business);
|
// //print(widget.business);
|
||||||
if (widget.business == null) {
|
// if (widget.business == null) {
|
||||||
context.pushNamed('patientManagerPatient',
|
// context.pushNamed('patientManagerPatient',
|
||||||
extra: PatientViewArguments(
|
// extra: PatientViewArguments(
|
||||||
widget.signedInUser,
|
// widget.signedInUser,
|
||||||
widget.selectedPatient,
|
// widget.selectedPatient,
|
||||||
widget.businessUser,
|
// widget.businessUser,
|
||||||
widget.business,
|
// widget.business,
|
||||||
"personal"));
|
// "personal"));
|
||||||
} else {
|
// } else {
|
||||||
context.pushNamed('patientManagerPatient',
|
// context.pushNamed('patientManagerPatient',
|
||||||
extra: PatientViewArguments(
|
// extra: PatientViewArguments(
|
||||||
widget.signedInUser,
|
// widget.signedInUser,
|
||||||
widget.selectedPatient,
|
// widget.selectedPatient,
|
||||||
widget.businessUser,
|
// widget.businessUser,
|
||||||
widget.business,
|
// widget.business,
|
||||||
"business"));
|
// "business"));
|
||||||
}
|
// }
|
||||||
String message =
|
// String message =
|
||||||
"The File has been deleted successfully. This means it will no longer be visible on your and cannot be used for future appointments.";
|
// "The File has been deleted successfully. This means it will no longer be visible on your and cannot be used for future appointments.";
|
||||||
successPopUp(message);
|
// successPopUp(message);
|
||||||
} else {
|
// } else {
|
||||||
internetConnectionPopUp();
|
// internetConnectionPopUp();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
void internetConnectionPopUp() {
|
void internetConnectionPopUp() {
|
||||||
showDialog(
|
showDialog(
|
||||||
@@ -155,18 +138,18 @@ class _BuildFilesListState extends State<BuildFilesList> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void deleteFilePopUp(String filePath, int fileID) {
|
// void deleteFilePopUp(String filePath, int fileID) {
|
||||||
showDialog(
|
// showDialog(
|
||||||
context: context,
|
// context: context,
|
||||||
barrierDismissible: false,
|
// barrierDismissible: false,
|
||||||
builder: (context) => MIHDeleteMessage(
|
// builder: (context) => MIHDeleteMessage(
|
||||||
deleteType: "File",
|
// deleteType: "File",
|
||||||
onTap: () async {
|
// onTap: () async {
|
||||||
await deleteFileApiCall(filePath, fileID);
|
// await deleteFileApiCall(filePath, fileID);
|
||||||
},
|
// },
|
||||||
),
|
// ),
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
|
|
||||||
String getFileName(String path) {
|
String getFileName(String path) {
|
||||||
//print(pdfLink.split(".")[1]);
|
//print(pdfLink.split(".")[1]);
|
||||||
@@ -202,9 +185,10 @@ class _BuildFilesListState extends State<BuildFilesList> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void viewFilePopUp(String fileName, String filePath, int fileID, String url) {
|
void viewFilePopUp(PatientManagerProvider patientManagerProvider,
|
||||||
|
String fileName, String filePath, int fileID, String url) {
|
||||||
bool hasAccessToDelete = false;
|
bool hasAccessToDelete = false;
|
||||||
if (widget.type == "business") {
|
if (!patientManagerProvider.personalMode) {
|
||||||
hasAccessToDelete = true;
|
hasAccessToDelete = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,7 +291,7 @@ class _BuildFilesListState extends State<BuildFilesList> {
|
|||||||
backgroundColor: MihColors.getGreenColor(
|
backgroundColor: MihColors.getGreenColor(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
deleteFilePopUp(filePath, fileID);
|
// deleteFilePopUp(filePath, fileID);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -368,133 +352,138 @@ class _BuildFilesListState extends State<BuildFilesList> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (widget.files.isNotEmpty) {
|
return Consumer2<MzansiProfileProvider, PatientManagerProvider>(
|
||||||
return ListView.separated(
|
builder: (BuildContext context, MzansiProfileProvider profileProvider,
|
||||||
shrinkWrap: true,
|
PatientManagerProvider patientManagerProvider, Widget? child) {
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
if (patientManagerProvider.patientDocuments!.isNotEmpty) {
|
||||||
separatorBuilder: (BuildContext context, int index) {
|
return ListView.separated(
|
||||||
return Divider(
|
shrinkWrap: true,
|
||||||
color: MihColors.getSecondaryColor(
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
separatorBuilder: (BuildContext context, int index) {
|
||||||
);
|
return Divider(
|
||||||
},
|
|
||||||
itemCount: widget.files.length,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
return ListTile(
|
|
||||||
title: Text(
|
|
||||||
widget.files[index].file_name,
|
|
||||||
style: TextStyle(
|
|
||||||
color: MihColors.getSecondaryColor(
|
color: MihColors.getSecondaryColor(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
),
|
);
|
||||||
),
|
|
||||||
subtitle: Text(
|
|
||||||
widget.files[index].insert_date,
|
|
||||||
style: TextStyle(
|
|
||||||
color: MihColors.getSecondaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
// trailing: Icon(
|
|
||||||
// Icons.arrow_forward,
|
|
||||||
// color: MihColors.getSecondaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
|
||||||
// ),
|
|
||||||
onTap: () async {
|
|
||||||
await getFileUrlApiCall(widget.files[index].file_path)
|
|
||||||
.then((urlHere) {
|
|
||||||
//print(url);
|
|
||||||
setState(() {
|
|
||||||
fileUrl = urlHere;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
viewFilePopUp(
|
|
||||||
widget.files[index].file_name,
|
|
||||||
widget.files[index].file_path,
|
|
||||||
widget.files[index].idpatient_files,
|
|
||||||
fileUrl);
|
|
||||||
},
|
},
|
||||||
);
|
itemCount: patientManagerProvider.patientDocuments!.length,
|
||||||
},
|
itemBuilder: (context, index) {
|
||||||
);
|
return ListTile(
|
||||||
} else {
|
title: Text(
|
||||||
return Padding(
|
patientManagerProvider.patientDocuments![index].file_name,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
|
||||||
child: Column(
|
|
||||||
// mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
// crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
const SizedBox(height: 50),
|
|
||||||
Stack(
|
|
||||||
alignment: AlignmentDirectional.center,
|
|
||||||
children: [
|
|
||||||
Icon(
|
|
||||||
MihIcons.mihRing,
|
|
||||||
size: 165,
|
|
||||||
color: MihColors.getSecondaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
|
||||||
),
|
|
||||||
Icon(
|
|
||||||
Icons.file_present,
|
|
||||||
size: 110,
|
|
||||||
color: MihColors.getSecondaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
Text(
|
|
||||||
"No Documents have been added to this profile.",
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
overflow: TextOverflow.visible,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 25,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: MihColors.getSecondaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 25),
|
|
||||||
Center(
|
|
||||||
child: RichText(
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
text: TextSpan(
|
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 20,
|
|
||||||
fontWeight: FontWeight.normal,
|
|
||||||
color: MihColors.getSecondaryColor(
|
color: MihColors.getSecondaryColor(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
subtitle: Text(
|
||||||
|
patientManagerProvider.patientDocuments![index].insert_date,
|
||||||
|
style: TextStyle(
|
||||||
|
color: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// trailing: Icon(
|
||||||
|
// Icons.arrow_forward,
|
||||||
|
// color: MihColors.getSecondaryColor(MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
|
// ),
|
||||||
|
onTap: () async {
|
||||||
|
await getFileUrlApiCall(patientManagerProvider
|
||||||
|
.patientDocuments![index].file_path)
|
||||||
|
.then((urlHere) {
|
||||||
|
//print(url);
|
||||||
|
setState(() {
|
||||||
|
fileUrl = urlHere;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
viewFilePopUp(
|
||||||
|
patientManagerProvider,
|
||||||
|
patientManagerProvider.patientDocuments![index].file_name,
|
||||||
|
patientManagerProvider.patientDocuments![index].file_path,
|
||||||
|
patientManagerProvider
|
||||||
|
.patientDocuments![index].idpatient_files,
|
||||||
|
fileUrl);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||||
|
child: Column(
|
||||||
|
// mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
// crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
const SizedBox(height: 50),
|
||||||
|
Stack(
|
||||||
|
alignment: AlignmentDirectional.center,
|
||||||
children: [
|
children: [
|
||||||
TextSpan(text: "Press "),
|
Icon(
|
||||||
WidgetSpan(
|
MihIcons.mihRing,
|
||||||
alignment: PlaceholderAlignment.middle,
|
size: 165,
|
||||||
child: Icon(
|
color: MihColors.getSecondaryColor(
|
||||||
Icons.menu,
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
size: 20,
|
"Dark"),
|
||||||
|
),
|
||||||
|
Icon(
|
||||||
|
Icons.file_present,
|
||||||
|
size: 110,
|
||||||
|
color: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
Text(
|
||||||
|
"No Documents have been added to this profile.",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
overflow: TextOverflow.visible,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 25,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 25),
|
||||||
|
Center(
|
||||||
|
child: RichText(
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
text: TextSpan(
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.normal,
|
||||||
color: MihColors.getSecondaryColor(
|
color: MihColors.getSecondaryColor(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
"Dark"),
|
"Dark"),
|
||||||
),
|
),
|
||||||
|
children: [
|
||||||
|
TextSpan(text: "Press "),
|
||||||
|
WidgetSpan(
|
||||||
|
alignment: PlaceholderAlignment.middle,
|
||||||
|
child: Icon(
|
||||||
|
Icons.menu,
|
||||||
|
size: 20,
|
||||||
|
color: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TextSpan(text: " to add "),
|
||||||
|
!patientManagerProvider.personalMode
|
||||||
|
? TextSpan(
|
||||||
|
text: " or generate a the first document")
|
||||||
|
: TextSpan(text: " the first document"),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
TextSpan(text: " to add "),
|
),
|
||||||
widget.business != null
|
|
||||||
? TextSpan(text: " or generate a the first document")
|
|
||||||
: TextSpan(text: " the first document"),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
],
|
);
|
||||||
),
|
}
|
||||||
);
|
},
|
||||||
// return const Center(
|
);
|
||||||
// child: Text(
|
|
||||||
// "No Documents Available",
|
|
||||||
// style: TextStyle(fontSize: 25, color: Colors.grey),
|
|
||||||
// textAlign: TextAlign.center,
|
|
||||||
// ),
|
|
||||||
// );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,38 +1,25 @@
|
|||||||
import 'dart:convert';
|
|
||||||
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:mzansi_innovation_hub/main.dart';
|
import 'package:mzansi_innovation_hub/main.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_button.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_alert.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_window.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_window.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_text_form_field.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_text_form_field.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_delete_message.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_delete_message.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_error_message.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_error_message.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_success_message.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_profile_provider.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_providers/patient_manager_provider.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business_user.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/notes.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_objects/notes.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/patients.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:supertokens_flutter/http.dart' as http;
|
import 'package:mzansi_innovation_hub/mih_services/mih_patient_services.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class BuildNotesList extends StatefulWidget {
|
class BuildNotesList extends StatefulWidget {
|
||||||
final AppUser signedInUser;
|
|
||||||
final List<Note> notes;
|
|
||||||
final Patient selectedPatient;
|
|
||||||
final Business? business;
|
|
||||||
final BusinessUser? businessUser;
|
|
||||||
final String type;
|
|
||||||
const BuildNotesList({
|
const BuildNotesList({
|
||||||
super.key,
|
super.key,
|
||||||
required this.notes,
|
|
||||||
required this.signedInUser,
|
|
||||||
required this.selectedPatient,
|
|
||||||
required this.business,
|
|
||||||
required this.businessUser,
|
|
||||||
required this.type,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -48,45 +35,80 @@ class _BuildNotesListState extends State<BuildNotesList> {
|
|||||||
int indexOn = 0;
|
int indexOn = 0;
|
||||||
final baseAPI = AppEnviroment.baseApiUrl;
|
final baseAPI = AppEnviroment.baseApiUrl;
|
||||||
|
|
||||||
Future<void> deleteNoteApiCall(int NoteId) async {
|
Future<void> deleteNoteApiCall(
|
||||||
var response = await http.delete(
|
PatientManagerProvider patientManagerProvider, int NoteId) async {
|
||||||
Uri.parse("$baseAPI/notes/delete/"),
|
int statusCode = await MihPatientServices()
|
||||||
headers: <String, String>{
|
.deletePatientConsultaionNote(NoteId, patientManagerProvider);
|
||||||
"Content-Type": "application/json; charset=UTF-8"
|
|
||||||
},
|
|
||||||
body: jsonEncode(<String, dynamic>{"idpatient_notes": NoteId}),
|
|
||||||
);
|
|
||||||
//print("Here4");
|
//print("Here4");
|
||||||
//print(response.statusCode);
|
//print(response.statusCode);
|
||||||
if (response.statusCode == 200) {
|
if (statusCode == 200) {
|
||||||
Navigator.of(context).pop();
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
if (widget.business == null) {
|
|
||||||
Navigator.of(context).pushNamed('/patient-manager/patient',
|
|
||||||
arguments: PatientViewArguments(
|
|
||||||
widget.signedInUser,
|
|
||||||
widget.selectedPatient,
|
|
||||||
widget.businessUser,
|
|
||||||
widget.business,
|
|
||||||
"personal"));
|
|
||||||
} else {
|
|
||||||
Navigator.of(context).pushNamed('/patient-manager/patient',
|
|
||||||
arguments: PatientViewArguments(
|
|
||||||
widget.signedInUser,
|
|
||||||
widget.selectedPatient,
|
|
||||||
widget.businessUser,
|
|
||||||
widget.business,
|
|
||||||
"business"));
|
|
||||||
}
|
|
||||||
setState(() {});
|
|
||||||
String message =
|
String message =
|
||||||
"The note has been deleted successfully. This means it will no longer be visible on your and cannot be used for future appointments.";
|
"The note has been deleted successfully. This means it will no longer be visible on your and cannot be used for future appointments.";
|
||||||
successPopUp(message);
|
successPopUp("Successfuly Deleted", message);
|
||||||
} else {
|
} else {
|
||||||
internetConnectionPopUp();
|
internetConnectionPopUp();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void successPopUp(String title, String message) {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return MihPackageAlert(
|
||||||
|
alertIcon: Icon(
|
||||||
|
Icons.check_circle_outline_rounded,
|
||||||
|
size: 150,
|
||||||
|
color: MihColors.getGreenColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
|
),
|
||||||
|
alertTitle: title,
|
||||||
|
alertBody: Column(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
message,
|
||||||
|
style: TextStyle(
|
||||||
|
color: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
|
fontSize: 15,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 25),
|
||||||
|
Center(
|
||||||
|
child: MihButton(
|
||||||
|
onPressed: () {
|
||||||
|
context.pop();
|
||||||
|
context.pop();
|
||||||
|
},
|
||||||
|
buttonColor: MihColors.getGreenColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
|
elevation: 10,
|
||||||
|
width: 300,
|
||||||
|
child: Text(
|
||||||
|
"Dismiss",
|
||||||
|
style: TextStyle(
|
||||||
|
color: MihColors.getPrimaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
alertColour: MihColors.getGreenColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
|
);
|
||||||
|
// return MIHSuccessMessage(
|
||||||
|
// successType: "Success",
|
||||||
|
// successMessage: message,
|
||||||
|
// );
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void internetConnectionPopUp() {
|
void internetConnectionPopUp() {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
@@ -96,32 +118,22 @@ class _BuildNotesListState extends State<BuildNotesList> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void successPopUp(String message) {
|
void deletePatientPopUp(
|
||||||
showDialog(
|
PatientManagerProvider patientManagerProvider, int NoteId) {
|
||||||
context: context,
|
|
||||||
builder: (context) {
|
|
||||||
return MIHSuccessMessage(
|
|
||||||
successType: "Success",
|
|
||||||
successMessage: message,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void deletePatientPopUp(int NoteId) {
|
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
barrierDismissible: false,
|
barrierDismissible: false,
|
||||||
builder: (context) => MIHDeleteMessage(
|
builder: (context) => MIHDeleteMessage(
|
||||||
deleteType: "Note",
|
deleteType: "Note",
|
||||||
onTap: () {
|
onTap: () {
|
||||||
deleteNoteApiCall(NoteId);
|
deleteNoteApiCall(patientManagerProvider, NoteId);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void viewNotePopUp(Note selectednote) {
|
void viewNotePopUp(MzansiProfileProvider profileProvider,
|
||||||
|
PatientManagerProvider patientManagerProvider, Note selectednote) {
|
||||||
setState(() {
|
setState(() {
|
||||||
noteTitleController.text = selectednote.note_name;
|
noteTitleController.text = selectednote.note_name;
|
||||||
noteTextController.text = selectednote.note_text;
|
noteTextController.text = selectednote.note_text;
|
||||||
@@ -130,8 +142,8 @@ class _BuildNotesListState extends State<BuildNotesList> {
|
|||||||
dateController.text = selectednote.insert_date;
|
dateController.text = selectednote.insert_date;
|
||||||
});
|
});
|
||||||
bool hasAccessToDelete = false;
|
bool hasAccessToDelete = false;
|
||||||
if (widget.type == "business" &&
|
if (!patientManagerProvider.personalMode &&
|
||||||
selectednote.doc_office == widget.business!.Name) {
|
selectednote.doc_office == profileProvider.business!.Name) {
|
||||||
hasAccessToDelete = true;
|
hasAccessToDelete = true;
|
||||||
}
|
}
|
||||||
showDialog(
|
showDialog(
|
||||||
@@ -159,7 +171,8 @@ class _BuildNotesListState extends State<BuildNotesList> {
|
|||||||
backgroundColor: MihColors.getGreenColor(
|
backgroundColor: MihColors.getGreenColor(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
deletePatientPopUp(selectednote.idpatient_notes);
|
deletePatientPopUp(
|
||||||
|
patientManagerProvider, selectednote.idpatient_notes);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
@@ -248,136 +261,141 @@ class _BuildNotesListState extends State<BuildNotesList> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (widget.notes.isNotEmpty) {
|
return Consumer2<MzansiProfileProvider, PatientManagerProvider>(
|
||||||
return ListView.separated(
|
builder: (BuildContext context, MzansiProfileProvider profileProvider,
|
||||||
shrinkWrap: true,
|
PatientManagerProvider patientManagerProvider, Widget? child) {
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
if (patientManagerProvider.consultationNotes!.isNotEmpty) {
|
||||||
separatorBuilder: (BuildContext context, int index) {
|
return ListView.separated(
|
||||||
return Divider(
|
shrinkWrap: true,
|
||||||
color: MihColors.getSecondaryColor(
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
separatorBuilder: (BuildContext context, int index) {
|
||||||
);
|
return Divider(
|
||||||
},
|
|
||||||
itemCount: widget.notes.length,
|
|
||||||
itemBuilder: (context, index) {
|
|
||||||
String notePreview = widget.notes[index].note_text;
|
|
||||||
if (notePreview.length > 30) {
|
|
||||||
notePreview = "${notePreview.substring(0, 30)} ...";
|
|
||||||
}
|
|
||||||
return ListTile(
|
|
||||||
title: Text(
|
|
||||||
"${widget.notes[index].note_name}\n${widget.notes[index].doc_office} - ${widget.notes[index].doctor}",
|
|
||||||
style: TextStyle(
|
|
||||||
color: MihColors.getSecondaryColor(
|
color: MihColors.getSecondaryColor(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
),
|
);
|
||||||
),
|
|
||||||
subtitle: Text(
|
|
||||||
"${widget.notes[index].insert_date}:\n$notePreview",
|
|
||||||
style: TextStyle(
|
|
||||||
color: MihColors.getSecondaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
|
||||||
),
|
|
||||||
), //Text(widget.notes[index].note_text),
|
|
||||||
trailing: Icon(
|
|
||||||
Icons.arrow_forward,
|
|
||||||
color: MihColors.getSecondaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
|
||||||
),
|
|
||||||
onTap: () {
|
|
||||||
viewNotePopUp(widget.notes[index]);
|
|
||||||
},
|
},
|
||||||
);
|
itemCount: patientManagerProvider.consultationNotes!.length,
|
||||||
},
|
itemBuilder: (context, index) {
|
||||||
);
|
String notePreview =
|
||||||
} else {
|
patientManagerProvider.consultationNotes![index].note_text;
|
||||||
return Padding(
|
if (notePreview.length > 30) {
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
notePreview = "${notePreview.substring(0, 30)} ...";
|
||||||
child: Column(
|
}
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
return ListTile(
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
title: Text(
|
||||||
mainAxisSize: MainAxisSize.max,
|
"${patientManagerProvider.consultationNotes![index].note_name}\n${patientManagerProvider.consultationNotes![index].doc_office} - ${patientManagerProvider.consultationNotes![index].doctor}",
|
||||||
children: [
|
style: TextStyle(
|
||||||
const SizedBox(height: 50),
|
color: MihColors.getSecondaryColor(
|
||||||
Stack(
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
alignment: AlignmentDirectional.center,
|
|
||||||
children: [
|
|
||||||
Icon(
|
|
||||||
MihIcons.mihRing,
|
|
||||||
size: 165,
|
|
||||||
color: MihColors.getSecondaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
|
||||||
),
|
|
||||||
Icon(
|
|
||||||
Icons.article_outlined,
|
|
||||||
size: 110,
|
|
||||||
color: MihColors.getSecondaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: Text(
|
|
||||||
"No Notes have been added to this profile.",
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
overflow: TextOverflow.visible,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 25,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: MihColors.getSecondaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
|
||||||
"Dark"),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
subtitle: Text(
|
||||||
),
|
"${patientManagerProvider.consultationNotes![index].insert_date}:\n$notePreview",
|
||||||
const SizedBox(height: 25),
|
style: TextStyle(
|
||||||
Visibility(
|
color: MihColors.getSecondaryColor(
|
||||||
visible: widget.business != null,
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
child: Center(
|
),
|
||||||
child: RichText(
|
), //Text(widget.notes[index].note_text),
|
||||||
textAlign: TextAlign.center,
|
trailing: Icon(
|
||||||
text: TextSpan(
|
Icons.arrow_forward,
|
||||||
style: TextStyle(
|
color: MihColors.getSecondaryColor(
|
||||||
fontSize: 20,
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
fontWeight: FontWeight.normal,
|
),
|
||||||
|
onTap: () {
|
||||||
|
viewNotePopUp(
|
||||||
|
profileProvider,
|
||||||
|
patientManagerProvider,
|
||||||
|
patientManagerProvider.consultationNotes![index],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 10.0),
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
children: [
|
||||||
|
const SizedBox(height: 50),
|
||||||
|
Stack(
|
||||||
|
alignment: AlignmentDirectional.center,
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
MihIcons.mihRing,
|
||||||
|
size: 165,
|
||||||
color: MihColors.getSecondaryColor(
|
color: MihColors.getSecondaryColor(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
"Dark"),
|
"Dark"),
|
||||||
),
|
),
|
||||||
children: [
|
Icon(
|
||||||
TextSpan(text: "Press "),
|
Icons.article_outlined,
|
||||||
WidgetSpan(
|
size: 110,
|
||||||
alignment: PlaceholderAlignment.middle,
|
color: MihColors.getSecondaryColor(
|
||||||
child: Icon(
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
Icons.menu,
|
"Dark"),
|
||||||
size: 20,
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
"No Notes have been added to this profile.",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
overflow: TextOverflow.visible,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 25,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
color: MihColors.getSecondaryColor(
|
color: MihColors.getSecondaryColor(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
"Dark"),
|
"Dark"),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
TextSpan(text: " to add the first note"),
|
),
|
||||||
],
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 25),
|
||||||
|
Visibility(
|
||||||
|
visible: !patientManagerProvider.personalMode,
|
||||||
|
child: Center(
|
||||||
|
child: RichText(
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
text: TextSpan(
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.normal,
|
||||||
|
color: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
),
|
||||||
|
children: [
|
||||||
|
TextSpan(text: "Press "),
|
||||||
|
WidgetSpan(
|
||||||
|
alignment: PlaceholderAlignment.middle,
|
||||||
|
child: Icon(
|
||||||
|
Icons.menu,
|
||||||
|
size: 20,
|
||||||
|
color: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
TextSpan(text: " to add the first note"),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
],
|
);
|
||||||
),
|
}
|
||||||
);
|
},
|
||||||
// return const Center(
|
);
|
||||||
// child: Text(
|
|
||||||
// "No Notes Available",
|
|
||||||
// style: TextStyle(fontSize: 25, color: Colors.grey),
|
|
||||||
// textAlign: TextAlign.center,
|
|
||||||
// ),
|
|
||||||
// );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ class _PatientProfileTileState extends State<PatientProfileTile> {
|
|||||||
onTap: () {
|
onTap: () {
|
||||||
context.goNamed(
|
context.goNamed(
|
||||||
'patientProfile',
|
'patientProfile',
|
||||||
extra: widget.arguments,
|
|
||||||
);
|
);
|
||||||
// Navigator.of(context).pushNamed(
|
// Navigator.of(context).pushNamed(
|
||||||
// '/patient-profile',
|
// '/patient-profile',
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'dart:convert';
|
|
||||||
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
||||||
import 'package:mzansi_innovation_hub/main.dart';
|
import 'package:mzansi_innovation_hub/main.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_profile_provider.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_providers/patient_manager_provider.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
|
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
|
||||||
@@ -12,33 +13,15 @@ import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_
|
|||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_window.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_window.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_text_form_field.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_text_form_field.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_error_message.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_error_message.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_success_message.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_success_message.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business_user.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/notes.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/patients.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/list_builders/build_notes_list.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/list_builders/build_notes_list.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:supertokens_flutter/http.dart' as http;
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class PatientConsultation extends StatefulWidget {
|
class PatientConsultation extends StatefulWidget {
|
||||||
final String patientAppId;
|
|
||||||
final Patient selectedPatient;
|
|
||||||
final AppUser signedInUser;
|
|
||||||
final Business? business;
|
|
||||||
final BusinessUser? businessUser;
|
|
||||||
final String type;
|
|
||||||
const PatientConsultation({
|
const PatientConsultation({
|
||||||
super.key,
|
super.key,
|
||||||
required this.patientAppId,
|
|
||||||
required this.selectedPatient,
|
|
||||||
required this.signedInUser,
|
|
||||||
required this.business,
|
|
||||||
required this.businessUser,
|
|
||||||
required this.type,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -46,7 +29,6 @@ class PatientConsultation extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _PatientConsultationState extends State<PatientConsultation> {
|
class _PatientConsultationState extends State<PatientConsultation> {
|
||||||
late Future<List<Note>> futueNotes;
|
|
||||||
final titleController = TextEditingController();
|
final titleController = TextEditingController();
|
||||||
final noteTextController = TextEditingController();
|
final noteTextController = TextEditingController();
|
||||||
final officeController = TextEditingController();
|
final officeController = TextEditingController();
|
||||||
@@ -56,33 +38,18 @@ class _PatientConsultationState extends State<PatientConsultation> {
|
|||||||
String endpoint = "${AppEnviroment.baseApiUrl}/notes/patients/";
|
String endpoint = "${AppEnviroment.baseApiUrl}/notes/patients/";
|
||||||
final _formKey = GlobalKey<FormState>();
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
|
||||||
Future<List<Note>> fetchNotes(String endpoint) async {
|
void addNotePopUp(MzansiProfileProvider profileProvider, double width) {
|
||||||
final response = await http.get(Uri.parse(
|
|
||||||
"${AppEnviroment.baseApiUrl}/notes/patients/${widget.selectedPatient.app_id}"));
|
|
||||||
if (response.statusCode == 200) {
|
|
||||||
Iterable l = jsonDecode(response.body);
|
|
||||||
List<Note> notes =
|
|
||||||
List<Note>.from(l.map((model) => Note.fromJson(model)));
|
|
||||||
//print("Here notes");
|
|
||||||
return notes;
|
|
||||||
} else {
|
|
||||||
internetConnectionPopUp();
|
|
||||||
throw Exception('failed to load patients');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void addNotePopUp(double width) {
|
|
||||||
DateTime now = new DateTime.now();
|
DateTime now = new DateTime.now();
|
||||||
DateTime date = new DateTime(now.year, now.month, now.day);
|
DateTime date = new DateTime(now.year, now.month, now.day);
|
||||||
var title = "";
|
var title = "";
|
||||||
print("Business User: ${widget.businessUser}");
|
print("Business User: ${profileProvider.businessUser}");
|
||||||
if (widget.businessUser?.title == "Doctor") {
|
if (profileProvider.businessUser?.title == "Doctor") {
|
||||||
title = "Dr.";
|
title = "Dr.";
|
||||||
}
|
}
|
||||||
setState(() {
|
setState(() {
|
||||||
officeController.text = widget.business!.Name;
|
officeController.text = profileProvider.business!.Name;
|
||||||
doctorController.text =
|
doctorController.text =
|
||||||
"$title ${widget.signedInUser.fname} ${widget.signedInUser.lname}";
|
"$title ${profileProvider.user!.fname} ${profileProvider.user!.lname}";
|
||||||
dateController.text = date.toString().substring(0, 10);
|
dateController.text = date.toString().substring(0, 10);
|
||||||
});
|
});
|
||||||
showDialog(
|
showDialog(
|
||||||
@@ -205,7 +172,7 @@ class _PatientConsultationState extends State<PatientConsultation> {
|
|||||||
child: MihButton(
|
child: MihButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (_formKey.currentState!.validate()) {
|
if (_formKey.currentState!.validate()) {
|
||||||
addPatientNoteAPICall();
|
// addPatientNoteAPICall();
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
} else {
|
} else {
|
||||||
MihAlertServices().formNotFilledCompletely(context);
|
MihAlertServices().formNotFilledCompletely(context);
|
||||||
@@ -236,38 +203,6 @@ class _PatientConsultationState extends State<PatientConsultation> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> addPatientNoteAPICall() async {
|
|
||||||
// String title = "";
|
|
||||||
// if (widget.businessUser!.title == "Doctor") {
|
|
||||||
// title = "Dr.";
|
|
||||||
// }
|
|
||||||
var response = await http.post(
|
|
||||||
Uri.parse("${AppEnviroment.baseApiUrl}/notes/insert/"),
|
|
||||||
headers: <String, String>{
|
|
||||||
"Content-Type": "application/json; charset=UTF-8"
|
|
||||||
},
|
|
||||||
body: jsonEncode(<String, dynamic>{
|
|
||||||
"note_name": titleController.text,
|
|
||||||
"note_text": noteTextController.text,
|
|
||||||
"doc_office": officeController.text,
|
|
||||||
"doctor": doctorController.text,
|
|
||||||
"app_id": widget.selectedPatient.app_id,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
if (response.statusCode == 201) {
|
|
||||||
setState(() {
|
|
||||||
futueNotes = fetchNotes(endpoint + widget.patientAppId.toString());
|
|
||||||
});
|
|
||||||
// Navigator.of(context)
|
|
||||||
// .pushNamed('/patient-manager', arguments: widget.userEmail);
|
|
||||||
String message =
|
|
||||||
"Your note has been successfully added to the patients medical record. You can now view it alongside their other important information.";
|
|
||||||
successPopUp(message);
|
|
||||||
} else {
|
|
||||||
internetConnectionPopUp();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isFieldsFilled() {
|
bool isFieldsFilled() {
|
||||||
if (titleController.text.isEmpty ||
|
if (titleController.text.isEmpty ||
|
||||||
noteTextController.text.isEmpty ||
|
noteTextController.text.isEmpty ||
|
||||||
@@ -321,7 +256,6 @@ class _PatientConsultationState extends State<PatientConsultation> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
futueNotes = fetchNotes(endpoint + widget.patientAppId);
|
|
||||||
noteTextController.addListener(() {
|
noteTextController.addListener(() {
|
||||||
setState(() {
|
setState(() {
|
||||||
_counter.value = noteTextController.text.characters.length;
|
_counter.value = noteTextController.text.characters.length;
|
||||||
@@ -340,71 +274,56 @@ class _PatientConsultationState extends State<PatientConsultation> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget getBody(double width) {
|
Widget getBody(double width) {
|
||||||
return Stack(
|
return Consumer2<MzansiProfileProvider, PatientManagerProvider>(
|
||||||
children: [
|
builder: (BuildContext context, MzansiProfileProvider profileProvider,
|
||||||
MihSingleChildScroll(
|
PatientManagerProvider patientManagerProvider, Widget? child) {
|
||||||
child: FutureBuilder(
|
return Stack(
|
||||||
future: futueNotes,
|
children: [
|
||||||
builder: (context, snapshot) {
|
MihSingleChildScroll(
|
||||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
child: Column(children: [
|
||||||
return const Center(
|
BuildNotesList(),
|
||||||
child: Mihloadingcircle(),
|
])),
|
||||||
);
|
Visibility(
|
||||||
} else if (snapshot.hasData) {
|
visible: !patientManagerProvider.personalMode,
|
||||||
final notesList = snapshot.data!;
|
child: Positioned(
|
||||||
return Column(children: [
|
right: 10,
|
||||||
BuildNotesList(
|
bottom: 10,
|
||||||
notes: notesList,
|
child: MihFloatingMenu(
|
||||||
signedInUser: widget.signedInUser,
|
icon: Icons.add,
|
||||||
selectedPatient: widget.selectedPatient,
|
animatedIcon: AnimatedIcons.menu_close,
|
||||||
business: widget.business,
|
children: [
|
||||||
businessUser: widget.businessUser,
|
SpeedDialChild(
|
||||||
type: widget.type,
|
child: Icon(
|
||||||
),
|
Icons.add,
|
||||||
]);
|
color: MihColors.getPrimaryColor(
|
||||||
} else {
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
return const Center(
|
"Dark"),
|
||||||
child: Text("Error Loading Notes"),
|
),
|
||||||
);
|
label: "Add Note",
|
||||||
}
|
labelBackgroundColor: MihColors.getGreenColor(
|
||||||
},
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
),
|
"Dark"),
|
||||||
),
|
labelStyle: TextStyle(
|
||||||
Visibility(
|
color: MihColors.getPrimaryColor(
|
||||||
visible: widget.type != "personal",
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
child: Positioned(
|
"Dark"),
|
||||||
right: 10,
|
fontWeight: FontWeight.bold,
|
||||||
bottom: 10,
|
),
|
||||||
child: MihFloatingMenu(
|
backgroundColor: MihColors.getGreenColor(
|
||||||
icon: Icons.add,
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
animatedIcon: AnimatedIcons.menu_close,
|
"Dark"),
|
||||||
children: [
|
onTap: () {
|
||||||
SpeedDialChild(
|
// addConsultationNotePopUp();
|
||||||
child: Icon(
|
addNotePopUp(profileProvider, width);
|
||||||
Icons.add,
|
},
|
||||||
color: MihColors.getPrimaryColor(
|
)
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
],
|
||||||
),
|
),
|
||||||
label: "Add Note",
|
),
|
||||||
labelBackgroundColor: MihColors.getGreenColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
|
||||||
labelStyle: TextStyle(
|
|
||||||
color: MihColors.getPrimaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
backgroundColor: MihColors.getGreenColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
|
||||||
onTap: () {
|
|
||||||
// addConsultationNotePopUp();
|
|
||||||
addNotePopUp(width);
|
|
||||||
},
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
),
|
);
|
||||||
],
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
import 'dart:convert';
|
|
||||||
|
|
||||||
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:mzansi_innovation_hub/main.dart';
|
import 'package:mzansi_innovation_hub/main.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_alert.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_profile_provider.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_providers/patient_manager_provider.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
|
import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_services/mih_patient_services.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
|
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_single_child_scroll.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_single_child_scroll.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_button.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_button.dart';
|
||||||
@@ -16,34 +19,16 @@ import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_
|
|||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_text_form_field.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_text_form_field.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_error_message.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_error_message.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_success_message.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/business_user.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/files.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/patients.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/components/prescip_input.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/components/prescip_input.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/list_builders/build_files_list.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/list_builders/build_files_list.dart';
|
||||||
import 'package:file_picker/file_picker.dart';
|
import 'package:file_picker/file_picker.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:supertokens_flutter/http.dart' as http;
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class PatientDocuments extends StatefulWidget {
|
class PatientDocuments extends StatefulWidget {
|
||||||
final int patientIndex;
|
|
||||||
final Patient selectedPatient;
|
|
||||||
final AppUser signedInUser;
|
|
||||||
final Business? business;
|
|
||||||
final BusinessUser? businessUser;
|
|
||||||
final String type;
|
|
||||||
const PatientDocuments({
|
const PatientDocuments({
|
||||||
super.key,
|
super.key,
|
||||||
required this.patientIndex,
|
|
||||||
required this.selectedPatient,
|
|
||||||
required this.signedInUser,
|
|
||||||
required this.business,
|
|
||||||
required this.businessUser,
|
|
||||||
required this.type,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -51,7 +36,6 @@ class PatientDocuments extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _PatientDocumentsState extends State<PatientDocuments> {
|
class _PatientDocumentsState extends State<PatientDocuments> {
|
||||||
late Future<List<PFile>> futueFiles;
|
|
||||||
final selectedFileController = TextEditingController();
|
final selectedFileController = TextEditingController();
|
||||||
final startDateController = TextEditingController();
|
final startDateController = TextEditingController();
|
||||||
final endDateTextController = TextEditingController();
|
final endDateTextController = TextEditingController();
|
||||||
@@ -68,9 +52,10 @@ class _PatientDocumentsState extends State<PatientDocuments> {
|
|||||||
final _formKey2 = GlobalKey<FormState>();
|
final _formKey2 = GlobalKey<FormState>();
|
||||||
late String env;
|
late String env;
|
||||||
|
|
||||||
Future<void> submitDocUploadForm() async {
|
Future<void> submitDocUploadForm(
|
||||||
|
PatientManagerProvider patientManagerProvider) async {
|
||||||
if (isFileFieldsFilled()) {
|
if (isFileFieldsFilled()) {
|
||||||
await uploadSelectedFile(selected);
|
await uploadSelectedFile(patientManagerProvider, selected);
|
||||||
} else {
|
} else {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
@@ -81,75 +66,49 @@ class _PatientDocumentsState extends State<PatientDocuments> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<PFile>> fetchFiles() async {
|
Future<void> addPatientFileLocationToDB(
|
||||||
final response = await http.get(Uri.parse(
|
PatientManagerProvider patientManagerProvider, PlatformFile? file) async {
|
||||||
"${AppEnviroment.baseApiUrl}/patient_files/get/${widget.selectedPatient.app_id}"));
|
|
||||||
//print(response.statusCode);
|
|
||||||
//print(response.body);
|
|
||||||
if (response.statusCode == 200) {
|
|
||||||
Iterable l = jsonDecode(response.body);
|
|
||||||
List<PFile> files =
|
|
||||||
List<PFile>.from(l.map((model) => PFile.fromJson(model)));
|
|
||||||
return files;
|
|
||||||
} else {
|
|
||||||
internetConnectionPopUp();
|
|
||||||
throw Exception('failed to load patients');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> addPatientFileLocationToDB(PlatformFile? file) async {
|
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return const Mihloadingcircle();
|
return const Mihloadingcircle();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
var fname = file!.name.replaceAll(RegExp(r' '), '-');
|
int statusCode =
|
||||||
var filePath = "${widget.selectedPatient.app_id}/patient_files/$fname";
|
await MihPatientServices().addPatientFile(file, patientManagerProvider);
|
||||||
var response2 = await http.post(
|
if (statusCode == 201) {
|
||||||
Uri.parse("${AppEnviroment.baseApiUrl}/patient_files/insert/"),
|
|
||||||
headers: <String, String>{
|
|
||||||
"Content-Type": "application/json; charset=UTF-8"
|
|
||||||
},
|
|
||||||
body: jsonEncode(<String, dynamic>{
|
|
||||||
"file_path": filePath,
|
|
||||||
"file_name": fname,
|
|
||||||
"app_id": widget.selectedPatient.app_id
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
//print("here5");
|
|
||||||
//print(response2.statusCode);
|
|
||||||
if (response2.statusCode == 201) {
|
|
||||||
setState(() {
|
setState(() {
|
||||||
selectedFileController.clear();
|
selectedFileController.clear();
|
||||||
futueFiles = fetchFiles();
|
|
||||||
});
|
});
|
||||||
|
var fname = file!.name.replaceAll(RegExp(r' '), '-');
|
||||||
// end loading circle
|
// end loading circle
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
String message =
|
String message =
|
||||||
"The file ${file.name.replaceAll(RegExp(r' '), '-')} has been successfully generated and added to ${widget.selectedPatient.first_name} ${widget.selectedPatient.last_name}'s record. You can now access and download it for their use.";
|
"The file $fname has been successfully generated and added to ${patientManagerProvider.selectedPatient!.first_name} ${patientManagerProvider.selectedPatient!.last_name}'s record. You can now access and download it for their use.";
|
||||||
successPopUp(message);
|
successPopUp("Successfully Uplouded File", message);
|
||||||
} else {
|
} else {
|
||||||
internetConnectionPopUp();
|
internetConnectionPopUp();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> uploadSelectedFile(PlatformFile? file) async {
|
Future<void> uploadSelectedFile(
|
||||||
|
PatientManagerProvider patientManagerProvider, PlatformFile? file) async {
|
||||||
var response = await MihFileApi.uploadFile(
|
var response = await MihFileApi.uploadFile(
|
||||||
widget.selectedPatient.app_id,
|
patientManagerProvider.selectedPatient!.app_id,
|
||||||
env,
|
env,
|
||||||
"patient_files",
|
"patient_files",
|
||||||
file,
|
file,
|
||||||
context,
|
context,
|
||||||
);
|
);
|
||||||
if (response == 200) {
|
if (response == 200) {
|
||||||
await addPatientFileLocationToDB(file);
|
await addPatientFileLocationToDB(patientManagerProvider, file);
|
||||||
} else {
|
} else {
|
||||||
internetConnectionPopUp();
|
internetConnectionPopUp();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> generateMedCert() async {
|
Future<void> generateMedCert(MzansiProfileProvider profileProvider,
|
||||||
|
PatientManagerProvider patientManagerProvider) async {
|
||||||
//start loading circle
|
//start loading circle
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
@@ -157,73 +116,30 @@ class _PatientDocumentsState extends State<PatientDocuments> {
|
|||||||
return const Mihloadingcircle();
|
return const Mihloadingcircle();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
DateTime now = DateTime.now();
|
int statusCodeCetificateGeneration =
|
||||||
// DateTime date = new DateTime(now.year, now.month, now.day);
|
await MihPatientServices().generateMedicalCertificate(
|
||||||
String fileName =
|
startDateController.text,
|
||||||
"Med-Cert-${widget.selectedPatient.first_name} ${widget.selectedPatient.last_name}-${now.toString().substring(0, 19)}.pdf"
|
endDateTextController.text,
|
||||||
.replaceAll(RegExp(r' '), '-');
|
retDateTextController.text,
|
||||||
var response1 = await http.post(
|
profileProvider,
|
||||||
Uri.parse("${AppEnviroment.baseApiUrl}/minio/generate/med-cert/"),
|
patientManagerProvider,
|
||||||
headers: <String, String>{
|
|
||||||
"Content-Type": "application/json; charset=UTF-8"
|
|
||||||
},
|
|
||||||
body: jsonEncode(<String, dynamic>{
|
|
||||||
"app_id": widget.selectedPatient.app_id,
|
|
||||||
"env": env,
|
|
||||||
"patient_full_name":
|
|
||||||
"${widget.selectedPatient.first_name} ${widget.selectedPatient.last_name}",
|
|
||||||
"fileName": fileName,
|
|
||||||
"id_no": widget.selectedPatient.id_no,
|
|
||||||
"docfname":
|
|
||||||
"DR. ${widget.signedInUser.fname} ${widget.signedInUser.lname}",
|
|
||||||
"startDate": startDateController.text,
|
|
||||||
"busName": widget.business!.Name,
|
|
||||||
"busAddr": "*TO BE ADDED IN THE FUTURE*",
|
|
||||||
"busNo": widget.business!.contact_no,
|
|
||||||
"busEmail": widget.business!.bus_email,
|
|
||||||
"endDate": endDateTextController.text,
|
|
||||||
"returnDate": retDateTextController.text,
|
|
||||||
"logo_path": widget.business!.logo_path,
|
|
||||||
"sig_path": widget.businessUser!.sig_path,
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
print(response1.statusCode);
|
DateTime now = DateTime.now();
|
||||||
if (response1.statusCode == 200) {
|
String fileName =
|
||||||
var response2 = await http.post(
|
"Med-Cert-${patientManagerProvider.selectedPatient!.first_name} ${patientManagerProvider.selectedPatient!.last_name}-${now.toString().substring(0, 19)}.pdf"
|
||||||
Uri.parse("${AppEnviroment.baseApiUrl}/patient_files/insert/"),
|
.replaceAll(RegExp(r' '), '-');
|
||||||
headers: <String, String>{
|
if (statusCodeCetificateGeneration == 200) {
|
||||||
"Content-Type": "application/json; charset=UTF-8"
|
context.pop(); //Loading removal
|
||||||
},
|
String message =
|
||||||
body: jsonEncode(<String, dynamic>{
|
"The medical certificate $fileName has been successfully generated and added to ${patientManagerProvider.selectedPatient!.first_name} ${patientManagerProvider.selectedPatient!.last_name}'s record. You can now access and download it for their use.";
|
||||||
"file_path":
|
successPopUp("Successfully Generated Certificate", message);
|
||||||
"${widget.selectedPatient.app_id}/patient_files/$fileName",
|
|
||||||
"file_name": fileName,
|
|
||||||
"app_id": widget.selectedPatient.app_id
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
//print(response2.statusCode);
|
|
||||||
if (response2.statusCode == 201) {
|
|
||||||
setState(() {
|
|
||||||
startDateController.clear();
|
|
||||||
endDateTextController.clear();
|
|
||||||
retDateTextController.clear();
|
|
||||||
futueFiles = fetchFiles();
|
|
||||||
});
|
|
||||||
// end loading circle
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
String message =
|
|
||||||
"The medical certificate $fileName has been successfully generated and added to ${widget.selectedPatient.first_name} ${widget.selectedPatient.last_name}'s record. You can now access and download it for their use.";
|
|
||||||
successPopUp(message);
|
|
||||||
} else {
|
|
||||||
internetConnectionPopUp();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
internetConnectionPopUp();
|
internetConnectionPopUp();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void uploudFilePopUp(double width) {
|
void uploudFilePopUp(
|
||||||
|
PatientManagerProvider patientManagerProvider, double width) {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
barrierDismissible: false,
|
barrierDismissible: false,
|
||||||
@@ -304,7 +220,7 @@ class _PatientDocumentsState extends State<PatientDocuments> {
|
|||||||
child: MihButton(
|
child: MihButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (_formKey.currentState!.validate()) {
|
if (_formKey.currentState!.validate()) {
|
||||||
submitDocUploadForm();
|
submitDocUploadForm(patientManagerProvider);
|
||||||
// uploadSelectedFile(selected);
|
// uploadSelectedFile(selected);
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
} else {
|
} else {
|
||||||
@@ -336,7 +252,10 @@ class _PatientDocumentsState extends State<PatientDocuments> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void medCertPopUp() {
|
void medCertPopUp(
|
||||||
|
MzansiProfileProvider profileProvider,
|
||||||
|
PatientManagerProvider patientManagerProvider,
|
||||||
|
) {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
barrierDismissible: false,
|
barrierDismissible: false,
|
||||||
@@ -387,7 +306,8 @@ class _PatientDocumentsState extends State<PatientDocuments> {
|
|||||||
child: MihButton(
|
child: MihButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
if (_formKey2.currentState!.validate()) {
|
if (_formKey2.currentState!.validate()) {
|
||||||
await generateMedCert();
|
await generateMedCert(
|
||||||
|
profileProvider, patientManagerProvider);
|
||||||
//Navigator.pop(context);
|
//Navigator.pop(context);
|
||||||
} else {
|
} else {
|
||||||
MihAlertServices().formNotFilledCompletely(context);
|
MihAlertServices().formNotFilledCompletely(context);
|
||||||
@@ -416,7 +336,10 @@ class _PatientDocumentsState extends State<PatientDocuments> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void prescritionPopUp() {
|
void prescritionPopUp(
|
||||||
|
MzansiProfileProvider profileProvider,
|
||||||
|
PatientManagerProvider patientManagerProvider,
|
||||||
|
) {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
barrierDismissible: false,
|
barrierDismissible: false,
|
||||||
@@ -442,10 +365,10 @@ class _PatientDocumentsState extends State<PatientDocuments> {
|
|||||||
noDaysController: noDaysController,
|
noDaysController: noDaysController,
|
||||||
noRepeatsController: noRepeatsController,
|
noRepeatsController: noRepeatsController,
|
||||||
outputController: outputController,
|
outputController: outputController,
|
||||||
selectedPatient: widget.selectedPatient,
|
selectedPatient: patientManagerProvider.selectedPatient!,
|
||||||
signedInUser: widget.signedInUser,
|
signedInUser: profileProvider.user!,
|
||||||
business: widget.business,
|
business: profileProvider.business,
|
||||||
businessUser: widget.businessUser,
|
businessUser: profileProvider.businessUser,
|
||||||
env: env,
|
env: env,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -472,8 +395,9 @@ class _PatientDocumentsState extends State<PatientDocuments> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget getMenu(double width) {
|
Widget getMenu(MzansiProfileProvider profileProvider,
|
||||||
if (widget.type == "personal") {
|
PatientManagerProvider patientManagerProvider, double width) {
|
||||||
|
if (patientManagerProvider.personalMode) {
|
||||||
return Positioned(
|
return Positioned(
|
||||||
right: 10,
|
right: 10,
|
||||||
bottom: 10,
|
bottom: 10,
|
||||||
@@ -498,7 +422,7 @@ class _PatientDocumentsState extends State<PatientDocuments> {
|
|||||||
backgroundColor: MihColors.getGreenColor(
|
backgroundColor: MihColors.getGreenColor(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
uploudFilePopUp(width);
|
uploudFilePopUp(patientManagerProvider, width);
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
@@ -529,7 +453,7 @@ class _PatientDocumentsState extends State<PatientDocuments> {
|
|||||||
backgroundColor: MihColors.getGreenColor(
|
backgroundColor: MihColors.getGreenColor(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
uploudFilePopUp(width);
|
uploudFilePopUp(patientManagerProvider, width);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
SpeedDialChild(
|
SpeedDialChild(
|
||||||
@@ -549,7 +473,7 @@ class _PatientDocumentsState extends State<PatientDocuments> {
|
|||||||
backgroundColor: MihColors.getGreenColor(
|
backgroundColor: MihColors.getGreenColor(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
medCertPopUp();
|
medCertPopUp(profileProvider, patientManagerProvider);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
SpeedDialChild(
|
SpeedDialChild(
|
||||||
@@ -569,7 +493,7 @@ class _PatientDocumentsState extends State<PatientDocuments> {
|
|||||||
backgroundColor: MihColors.getGreenColor(
|
backgroundColor: MihColors.getGreenColor(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
prescritionPopUp();
|
prescritionPopUp(profileProvider, patientManagerProvider);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -578,13 +502,56 @@ class _PatientDocumentsState extends State<PatientDocuments> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void successPopUp(String message) {
|
void successPopUp(String title, String message) {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return MIHSuccessMessage(
|
return MihPackageAlert(
|
||||||
successType: "Success",
|
alertIcon: Icon(
|
||||||
successMessage: message,
|
Icons.check_circle_outline_rounded,
|
||||||
|
size: 150,
|
||||||
|
color: MihColors.getGreenColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
|
),
|
||||||
|
alertTitle: title,
|
||||||
|
alertBody: Column(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
message,
|
||||||
|
style: TextStyle(
|
||||||
|
color: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
|
fontSize: 15,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 25),
|
||||||
|
Center(
|
||||||
|
child: MihButton(
|
||||||
|
onPressed: () {
|
||||||
|
context.pop();
|
||||||
|
context.pop();
|
||||||
|
},
|
||||||
|
buttonColor: MihColors.getGreenColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
|
elevation: 10,
|
||||||
|
width: 300,
|
||||||
|
child: Text(
|
||||||
|
"Dismiss",
|
||||||
|
style: TextStyle(
|
||||||
|
color: MihColors.getPrimaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
alertColour: MihColors.getGreenColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -617,7 +584,6 @@ class _PatientDocumentsState extends State<PatientDocuments> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
futueFiles = fetchFiles();
|
|
||||||
if (AppEnviroment.getEnv() == "Prod") {
|
if (AppEnviroment.getEnv() == "Prod") {
|
||||||
env = "Prod";
|
env = "Prod";
|
||||||
} else {
|
} else {
|
||||||
@@ -636,39 +602,20 @@ class _PatientDocumentsState extends State<PatientDocuments> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget getBody(double width) {
|
Widget getBody(double width) {
|
||||||
return Stack(
|
return Consumer2<MzansiProfileProvider, PatientManagerProvider>(
|
||||||
children: [
|
builder: (BuildContext context, MzansiProfileProvider profileProvider,
|
||||||
MihSingleChildScroll(
|
PatientManagerProvider patientManagerProvider, Widget? child) {
|
||||||
child: FutureBuilder(
|
return Stack(
|
||||||
future: futueFiles,
|
children: [
|
||||||
builder: (context, snapshot) {
|
MihSingleChildScroll(
|
||||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
child: Column(children: [
|
||||||
return const Center(
|
BuildFilesList(),
|
||||||
child: Mihloadingcircle(),
|
]),
|
||||||
);
|
),
|
||||||
} else if (snapshot.hasData) {
|
getMenu(profileProvider, patientManagerProvider, width),
|
||||||
final filesList = snapshot.data!;
|
],
|
||||||
return Column(children: [
|
);
|
||||||
BuildFilesList(
|
},
|
||||||
files: filesList,
|
|
||||||
signedInUser: widget.signedInUser,
|
|
||||||
selectedPatient: widget.selectedPatient,
|
|
||||||
business: widget.business,
|
|
||||||
businessUser: widget.businessUser,
|
|
||||||
type: widget.type,
|
|
||||||
env: env,
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
} else {
|
|
||||||
return const Center(
|
|
||||||
child: Text("Error Loading Notes"),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
getMenu(width),
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/main.dart';
|
import 'package:mzansi_innovation_hub/main.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_single_child_scroll.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_single_child_scroll.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_form.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_form.dart';
|
||||||
@@ -7,21 +6,16 @@ import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_
|
|||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_floating_menu.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_floating_menu.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_text_form_field.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_text_form_field.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_toggle.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_toggle.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/patients.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_profile_provider.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_providers/patient_manager_provider.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/components/mih_edit_patient_details_window.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class PatientInfo extends StatefulWidget {
|
class PatientInfo extends StatefulWidget {
|
||||||
final AppUser signedInUser;
|
|
||||||
final Patient selectedPatient;
|
|
||||||
final String type;
|
|
||||||
const PatientInfo({
|
const PatientInfo({
|
||||||
super.key,
|
super.key,
|
||||||
required this.signedInUser,
|
|
||||||
required this.selectedPatient,
|
|
||||||
required this.type,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -297,6 +291,40 @@ class _PatientInfoState extends State<PatientInfo> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void initialiseControllers(PatientManagerProvider patientManagerProvider) {
|
||||||
|
idController.text = patientManagerProvider.selectedPatient!.id_no;
|
||||||
|
fnameController.text = patientManagerProvider.selectedPatient!.first_name;
|
||||||
|
lnameController.text = patientManagerProvider.selectedPatient!.last_name;
|
||||||
|
cellController.text = patientManagerProvider.selectedPatient!.cell_no;
|
||||||
|
emailController.text = patientManagerProvider.selectedPatient!.email;
|
||||||
|
medNameController.text =
|
||||||
|
patientManagerProvider.selectedPatient!.medical_aid_name;
|
||||||
|
medNoController.text =
|
||||||
|
patientManagerProvider.selectedPatient!.medical_aid_no;
|
||||||
|
medSchemeController.text =
|
||||||
|
patientManagerProvider.selectedPatient!.medical_aid_scheme;
|
||||||
|
addressController.text = patientManagerProvider.selectedPatient!.address;
|
||||||
|
medAidController.text = patientManagerProvider.selectedPatient!.medical_aid;
|
||||||
|
medMainMemController.text =
|
||||||
|
patientManagerProvider.selectedPatient!.medical_aid_main_member;
|
||||||
|
medAidCodeController.text =
|
||||||
|
patientManagerProvider.selectedPatient!.medical_aid_code;
|
||||||
|
medAid = patientManagerProvider.selectedPatient!.medical_aid;
|
||||||
|
if (medAid == "Yes") {
|
||||||
|
medAidPosition = true;
|
||||||
|
} else {
|
||||||
|
medAidPosition = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void showEditPatientWindow() {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return MihEditPatientDetailsWindow();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
idController.dispose();
|
idController.dispose();
|
||||||
@@ -316,37 +344,6 @@ class _PatientInfoState extends State<PatientInfo> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
setState(() {
|
|
||||||
idController.value = TextEditingValue(text: widget.selectedPatient.id_no);
|
|
||||||
fnameController.value =
|
|
||||||
TextEditingValue(text: widget.selectedPatient.first_name);
|
|
||||||
lnameController.value =
|
|
||||||
TextEditingValue(text: widget.selectedPatient.last_name);
|
|
||||||
cellController.value =
|
|
||||||
TextEditingValue(text: widget.selectedPatient.cell_no);
|
|
||||||
emailController.value =
|
|
||||||
TextEditingValue(text: widget.selectedPatient.email);
|
|
||||||
medNameController.value =
|
|
||||||
TextEditingValue(text: widget.selectedPatient.medical_aid_name);
|
|
||||||
medNoController.value =
|
|
||||||
TextEditingValue(text: widget.selectedPatient.medical_aid_no);
|
|
||||||
medSchemeController.value =
|
|
||||||
TextEditingValue(text: widget.selectedPatient.medical_aid_scheme);
|
|
||||||
addressController.value =
|
|
||||||
TextEditingValue(text: widget.selectedPatient.address);
|
|
||||||
medAidController.value =
|
|
||||||
TextEditingValue(text: widget.selectedPatient.medical_aid);
|
|
||||||
medMainMemController.value = TextEditingValue(
|
|
||||||
text: widget.selectedPatient.medical_aid_main_member);
|
|
||||||
medAidCodeController.value =
|
|
||||||
TextEditingValue(text: widget.selectedPatient.medical_aid_code);
|
|
||||||
medAid = widget.selectedPatient.medical_aid;
|
|
||||||
});
|
|
||||||
if (medAid == "Yes") {
|
|
||||||
medAidPosition = true;
|
|
||||||
} else {
|
|
||||||
medAidPosition = false;
|
|
||||||
}
|
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -361,21 +358,47 @@ class _PatientInfoState extends State<PatientInfo> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget getBody(double width) {
|
Widget getBody(double width) {
|
||||||
return Stack(
|
return Consumer2<MzansiProfileProvider, PatientManagerProvider>(
|
||||||
children: [
|
builder: (BuildContext context, MzansiProfileProvider profileProvider,
|
||||||
MihSingleChildScroll(
|
PatientManagerProvider patientManagerProvider, Widget? child) {
|
||||||
child: Column(
|
initialiseControllers(patientManagerProvider);
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
return Stack(
|
||||||
children: [
|
children: [
|
||||||
MihForm(
|
MihSingleChildScroll(
|
||||||
formKey: _formKey,
|
child: Column(
|
||||||
formFields: [
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
Row(
|
children: [
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
MihForm(
|
||||||
//crossAxisAlignment: ,
|
formKey: _formKey,
|
||||||
children: [
|
formFields: [
|
||||||
Text(
|
Row(
|
||||||
"Personal",
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
//crossAxisAlignment: ,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Personal",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 25,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.mode ==
|
||||||
|
"Dark"),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
Divider(
|
||||||
|
color: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark")),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
getPatientDetailsField(),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
Center(
|
||||||
|
child: Text(
|
||||||
|
"Medical Aid",
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 25,
|
fontSize: 25,
|
||||||
@@ -385,78 +408,65 @@ class _PatientInfoState extends State<PatientInfo> {
|
|||||||
"Dark"),
|
"Dark"),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
]),
|
),
|
||||||
Divider(
|
Divider(
|
||||||
color: MihColors.getSecondaryColor(
|
color: MihColors.getSecondaryColor(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
"Dark")),
|
"Dark")),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
getPatientDetailsField(),
|
getMedAidDetailsFields(),
|
||||||
const SizedBox(height: 10),
|
],
|
||||||
Center(
|
),
|
||||||
child: Text(
|
],
|
||||||
"Medical Aid",
|
),
|
||||||
textAlign: TextAlign.center,
|
),
|
||||||
style: TextStyle(
|
Visibility(
|
||||||
fontSize: 25,
|
visible: patientManagerProvider.personalMode,
|
||||||
fontWeight: FontWeight.bold,
|
child: Positioned(
|
||||||
color: MihColors.getSecondaryColor(
|
right: 10,
|
||||||
|
bottom: 10,
|
||||||
|
child: MihFloatingMenu(
|
||||||
|
icon: Icons.add,
|
||||||
|
animatedIcon: AnimatedIcons.menu_close,
|
||||||
|
children: [
|
||||||
|
SpeedDialChild(
|
||||||
|
child: Icon(
|
||||||
|
Icons.edit,
|
||||||
|
color: MihColors.getPrimaryColor(
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
"Dark"),
|
"Dark"),
|
||||||
),
|
),
|
||||||
),
|
label: "Edit Profile",
|
||||||
),
|
labelBackgroundColor: MihColors.getGreenColor(
|
||||||
Divider(
|
|
||||||
color: MihColors.getSecondaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
"Dark")),
|
"Dark"),
|
||||||
const SizedBox(height: 10),
|
labelStyle: TextStyle(
|
||||||
getMedAidDetailsFields(),
|
color: MihColors.getPrimaryColor(
|
||||||
],
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
),
|
"Dark"),
|
||||||
],
|
fontWeight: FontWeight.bold,
|
||||||
),
|
|
||||||
),
|
|
||||||
Visibility(
|
|
||||||
visible: widget.type == "personal",
|
|
||||||
child: Positioned(
|
|
||||||
right: 10,
|
|
||||||
bottom: 10,
|
|
||||||
child: MihFloatingMenu(
|
|
||||||
icon: Icons.add,
|
|
||||||
animatedIcon: AnimatedIcons.menu_close,
|
|
||||||
children: [
|
|
||||||
SpeedDialChild(
|
|
||||||
child: Icon(
|
|
||||||
Icons.edit,
|
|
||||||
color: MihColors.getPrimaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
|
||||||
),
|
|
||||||
label: "Edit Profile",
|
|
||||||
labelBackgroundColor: MihColors.getGreenColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
|
||||||
labelStyle: TextStyle(
|
|
||||||
color: MihColors.getPrimaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
backgroundColor: MihColors.getGreenColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
|
||||||
onTap: () {
|
|
||||||
context.goNamed(
|
|
||||||
'patientProfileEdit',
|
|
||||||
extra: PatientEditArguments(
|
|
||||||
widget.signedInUser,
|
|
||||||
widget.selectedPatient,
|
|
||||||
),
|
),
|
||||||
);
|
backgroundColor: MihColors.getGreenColor(
|
||||||
},
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
)
|
"Dark"),
|
||||||
],
|
onTap: () {
|
||||||
|
// context.goNamed(
|
||||||
|
// 'patientProfileEdit',
|
||||||
|
// extra: PatientEditArguments(
|
||||||
|
// profileProvider.user!,
|
||||||
|
// patientManagerProvider.selectedPatient!,
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
|
showEditPatientWindow();
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
),
|
);
|
||||||
],
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,543 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/main.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_button.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_form.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_alert.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_text_form_field.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_toggle.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_error_message.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_profile_provider.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_providers/patient_manager_provider.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_services/mih_patient_services.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class PatientSetupForm extends StatefulWidget {
|
||||||
|
const PatientSetupForm({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<PatientSetupForm> createState() => _PatientSetupFormState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _PatientSetupFormState extends State<PatientSetupForm> {
|
||||||
|
final idController = TextEditingController();
|
||||||
|
final fnameController = TextEditingController();
|
||||||
|
final lnameController = TextEditingController();
|
||||||
|
final cellController = TextEditingController();
|
||||||
|
final emailController = TextEditingController();
|
||||||
|
final medNoController = TextEditingController();
|
||||||
|
final medNameController = TextEditingController();
|
||||||
|
final medSchemeController = TextEditingController();
|
||||||
|
final addressController = TextEditingController();
|
||||||
|
final medAidController = TextEditingController();
|
||||||
|
final medMainMemController = TextEditingController();
|
||||||
|
final medAidCodeController = TextEditingController();
|
||||||
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
final FocusNode _focusNode = FocusNode();
|
||||||
|
late bool medAidPosition;
|
||||||
|
late bool medMainMemberPosition;
|
||||||
|
final ValueNotifier<bool> medRequired = ValueNotifier(false);
|
||||||
|
|
||||||
|
Future<void> addPatientService(
|
||||||
|
MzansiProfileProvider profileProvider,
|
||||||
|
PatientManagerProvider patientManagerProvider,
|
||||||
|
) async {
|
||||||
|
int statusCode = await MihPatientServices().addPatientService(
|
||||||
|
idController.text,
|
||||||
|
fnameController.text,
|
||||||
|
lnameController.text,
|
||||||
|
emailController.text,
|
||||||
|
cellController.text,
|
||||||
|
medAidController.text,
|
||||||
|
medMainMemController.text,
|
||||||
|
medNoController.text,
|
||||||
|
medAidCodeController.text,
|
||||||
|
medNameController.text,
|
||||||
|
medSchemeController.text,
|
||||||
|
addressController.text,
|
||||||
|
profileProvider,
|
||||||
|
patientManagerProvider,
|
||||||
|
);
|
||||||
|
if (statusCode == 201) {
|
||||||
|
String message =
|
||||||
|
"${fnameController.text} ${lnameController.text} patient profile has been successfully added!\n";
|
||||||
|
successPopUp("Successfully created Patient Profile", message);
|
||||||
|
} else {
|
||||||
|
internetConnectionPopUp();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void successPopUp(String title, String message) {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return MihPackageAlert(
|
||||||
|
alertIcon: Icon(
|
||||||
|
Icons.check_circle_outline_rounded,
|
||||||
|
size: 150,
|
||||||
|
color: MihColors.getGreenColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
|
),
|
||||||
|
alertTitle: title,
|
||||||
|
alertBody: Column(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
message,
|
||||||
|
style: TextStyle(
|
||||||
|
color: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
|
fontSize: 15,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 25),
|
||||||
|
Center(
|
||||||
|
child: MihButton(
|
||||||
|
onPressed: () {
|
||||||
|
context.pop();
|
||||||
|
context.goNamed(
|
||||||
|
'patientProfile',
|
||||||
|
);
|
||||||
|
},
|
||||||
|
buttonColor: MihColors.getGreenColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
|
elevation: 10,
|
||||||
|
width: 300,
|
||||||
|
child: Text(
|
||||||
|
"Dismiss",
|
||||||
|
style: TextStyle(
|
||||||
|
color: MihColors.getPrimaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
alertColour: MihColors.getGreenColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void internetConnectionPopUp() {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return const MIHErrorMessage(errorType: "Internet Connection");
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void isRequired() {
|
||||||
|
//print("listerner triggered");
|
||||||
|
if (medAidController.text == "Yes") {
|
||||||
|
medRequired.value = true;
|
||||||
|
} else {
|
||||||
|
medRequired.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget displayForm(double width) {
|
||||||
|
return Consumer2<MzansiProfileProvider, PatientManagerProvider>(
|
||||||
|
builder: (BuildContext context, MzansiProfileProvider profileProvider,
|
||||||
|
PatientManagerProvider patientManagerProvider, Widget? child) {
|
||||||
|
return SingleChildScrollView(
|
||||||
|
child: Padding(
|
||||||
|
padding:
|
||||||
|
MzansiInnovationHub.of(context)!.theme.screenType == "desktop"
|
||||||
|
? EdgeInsets.symmetric(horizontal: width * 0.2)
|
||||||
|
: EdgeInsets.symmetric(horizontal: width * 0.075),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
MihForm(
|
||||||
|
formKey: _formKey,
|
||||||
|
formFields: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Personal",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 25.0,
|
||||||
|
color: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Divider(
|
||||||
|
color: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark")),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
MihTextFormField(
|
||||||
|
fillColor: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
inputColor: MihColors.getPrimaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
controller: idController,
|
||||||
|
multiLineInput: false,
|
||||||
|
requiredText: true,
|
||||||
|
hintText: "ID No.",
|
||||||
|
validator: (value) {
|
||||||
|
return MihValidationServices().isEmpty(value);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
MihTextFormField(
|
||||||
|
fillColor: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
inputColor: MihColors.getPrimaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
controller: fnameController,
|
||||||
|
multiLineInput: false,
|
||||||
|
requiredText: true,
|
||||||
|
readOnly: true,
|
||||||
|
hintText: "First Name",
|
||||||
|
validator: (value) {
|
||||||
|
return MihValidationServices().isEmpty(value);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
MihTextFormField(
|
||||||
|
fillColor: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
inputColor: MihColors.getPrimaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
controller: lnameController,
|
||||||
|
multiLineInput: false,
|
||||||
|
requiredText: true,
|
||||||
|
readOnly: true,
|
||||||
|
hintText: "Surname",
|
||||||
|
validator: (value) {
|
||||||
|
return MihValidationServices().isEmpty(value);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
MihTextFormField(
|
||||||
|
fillColor: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
inputColor: MihColors.getPrimaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
controller: cellController,
|
||||||
|
multiLineInput: false,
|
||||||
|
requiredText: true,
|
||||||
|
hintText: "Cell No.",
|
||||||
|
validator: (value) {
|
||||||
|
return MihValidationServices().isEmpty(value);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
MihTextFormField(
|
||||||
|
fillColor: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
inputColor: MihColors.getPrimaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
controller: emailController,
|
||||||
|
multiLineInput: false,
|
||||||
|
requiredText: true,
|
||||||
|
readOnly: true,
|
||||||
|
hintText: "Email",
|
||||||
|
validator: (value) {
|
||||||
|
return MihValidationServices().validateEmail(value);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
MihTextFormField(
|
||||||
|
height: 100,
|
||||||
|
fillColor: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
inputColor: MihColors.getPrimaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
controller: addressController,
|
||||||
|
multiLineInput: true,
|
||||||
|
requiredText: true,
|
||||||
|
hintText: "Address",
|
||||||
|
validator: (value) {
|
||||||
|
return MihValidationServices().isEmpty(value);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 15.0),
|
||||||
|
Center(
|
||||||
|
child: Text(
|
||||||
|
"Medical Aid Details",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 25.0,
|
||||||
|
color: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Divider(
|
||||||
|
color: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark")),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
MihToggle(
|
||||||
|
hintText: "Medical Aid",
|
||||||
|
initialPostion: medAidPosition,
|
||||||
|
fillColor: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
secondaryFillColor: MihColors.getPrimaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
onChange: (value) {
|
||||||
|
if (value) {
|
||||||
|
setState(() {
|
||||||
|
medAidController.text = "Yes";
|
||||||
|
medAidPosition = value;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
setState(() {
|
||||||
|
medAidController.text = "No";
|
||||||
|
medAidPosition = value;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
ValueListenableBuilder(
|
||||||
|
valueListenable: medRequired,
|
||||||
|
builder:
|
||||||
|
(BuildContext context, bool value, Widget? child) {
|
||||||
|
return Visibility(
|
||||||
|
visible: value,
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
MihToggle(
|
||||||
|
hintText: "Main Member",
|
||||||
|
initialPostion: medMainMemberPosition,
|
||||||
|
fillColor: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.mode ==
|
||||||
|
"Dark"),
|
||||||
|
secondaryFillColor: MihColors.getPrimaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.mode ==
|
||||||
|
"Dark"),
|
||||||
|
onChange: (value) {
|
||||||
|
if (value) {
|
||||||
|
setState(() {
|
||||||
|
medMainMemController.text = "Yes";
|
||||||
|
medMainMemberPosition = value;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
setState(() {
|
||||||
|
medMainMemController.text = "No";
|
||||||
|
medMainMemberPosition = value;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
MihTextFormField(
|
||||||
|
fillColor: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.mode ==
|
||||||
|
"Dark"),
|
||||||
|
inputColor: MihColors.getPrimaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.mode ==
|
||||||
|
"Dark"),
|
||||||
|
controller: medNoController,
|
||||||
|
multiLineInput: false,
|
||||||
|
requiredText: true,
|
||||||
|
hintText: "No.",
|
||||||
|
validator: (validationValue) {
|
||||||
|
if (value) {
|
||||||
|
return MihValidationServices()
|
||||||
|
.isEmpty(validationValue);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
MihTextFormField(
|
||||||
|
fillColor: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.mode ==
|
||||||
|
"Dark"),
|
||||||
|
inputColor: MihColors.getPrimaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.mode ==
|
||||||
|
"Dark"),
|
||||||
|
controller: medAidCodeController,
|
||||||
|
multiLineInput: false,
|
||||||
|
requiredText: true,
|
||||||
|
hintText: "Code",
|
||||||
|
validator: (validationValue) {
|
||||||
|
if (value) {
|
||||||
|
return MihValidationServices()
|
||||||
|
.isEmpty(validationValue);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
MihTextFormField(
|
||||||
|
fillColor: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.mode ==
|
||||||
|
"Dark"),
|
||||||
|
inputColor: MihColors.getPrimaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.mode ==
|
||||||
|
"Dark"),
|
||||||
|
controller: medNameController,
|
||||||
|
multiLineInput: false,
|
||||||
|
requiredText: true,
|
||||||
|
hintText: "Name",
|
||||||
|
validator: (validationValue) {
|
||||||
|
if (value) {
|
||||||
|
return MihValidationServices()
|
||||||
|
.isEmpty(validationValue);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
MihTextFormField(
|
||||||
|
fillColor: MihColors.getSecondaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.mode ==
|
||||||
|
"Dark"),
|
||||||
|
inputColor: MihColors.getPrimaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.mode ==
|
||||||
|
"Dark"),
|
||||||
|
controller: medSchemeController,
|
||||||
|
multiLineInput: false,
|
||||||
|
requiredText: true,
|
||||||
|
hintText: "Plan",
|
||||||
|
validator: (validationValue) {
|
||||||
|
if (value) {
|
||||||
|
return MihValidationServices()
|
||||||
|
.isEmpty(validationValue);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 20.0),
|
||||||
|
Center(
|
||||||
|
child: MihButton(
|
||||||
|
onPressed: () {
|
||||||
|
if (_formKey.currentState!.validate()) {
|
||||||
|
addPatientService(
|
||||||
|
profileProvider, patientManagerProvider);
|
||||||
|
} else {
|
||||||
|
MihAlertServices().formNotFilledCompletely(context);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
buttonColor: MihColors.getGreenColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
width: 300,
|
||||||
|
child: Text(
|
||||||
|
"Add",
|
||||||
|
style: TextStyle(
|
||||||
|
color: MihColors.getPrimaryColor(
|
||||||
|
MzansiInnovationHub.of(context)!.theme.mode ==
|
||||||
|
"Dark"),
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 30.0),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
idController.dispose();
|
||||||
|
fnameController.dispose();
|
||||||
|
lnameController.dispose();
|
||||||
|
cellController.dispose();
|
||||||
|
emailController.dispose();
|
||||||
|
medNoController.dispose();
|
||||||
|
medNameController.dispose();
|
||||||
|
medSchemeController.dispose();
|
||||||
|
addressController.dispose();
|
||||||
|
medAidController.dispose();
|
||||||
|
medAidCodeController.removeListener(isRequired);
|
||||||
|
medRequired.dispose();
|
||||||
|
medMainMemController.dispose();
|
||||||
|
medAidCodeController.dispose();
|
||||||
|
_focusNode.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
medAidController.addListener(isRequired);
|
||||||
|
MzansiProfileProvider profileProvider =
|
||||||
|
context.read<MzansiProfileProvider>();
|
||||||
|
setState(() {
|
||||||
|
fnameController.text = profileProvider.user!.fname;
|
||||||
|
lnameController.text = profileProvider.user!.lname;
|
||||||
|
emailController.text = profileProvider.user!.email;
|
||||||
|
medAidPosition = false;
|
||||||
|
medMainMemberPosition = false;
|
||||||
|
medAidController.text = "No";
|
||||||
|
medMainMemController.text = "No";
|
||||||
|
});
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
double screenWidth = MediaQuery.of(context).size.width;
|
||||||
|
return displayForm(screenWidth);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,903 +0,0 @@
|
|||||||
import 'dart:convert';
|
|
||||||
|
|
||||||
import 'package:go_router/go_router.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/main.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_alert.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_config/mih_colors.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_patient_services.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_layout/mih_action.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_layout/mih_body.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_layout/mih_header.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_layout/mih_layout_builder.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_button.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_form.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_text_form_field.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_toggle.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_error_message.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/patients.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:supertokens_flutter/supertokens.dart';
|
|
||||||
import 'package:supertokens_flutter/http.dart' as http;
|
|
||||||
|
|
||||||
class EditPatient extends StatefulWidget {
|
|
||||||
final Patient selectedPatient;
|
|
||||||
final AppUser signedInUser;
|
|
||||||
const EditPatient({
|
|
||||||
super.key,
|
|
||||||
required this.selectedPatient,
|
|
||||||
required this.signedInUser,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<EditPatient> createState() => _EditPatientState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _EditPatientState extends State<EditPatient> {
|
|
||||||
var idController = TextEditingController();
|
|
||||||
final fnameController = TextEditingController();
|
|
||||||
final lnameController = TextEditingController();
|
|
||||||
final cellController = TextEditingController();
|
|
||||||
final emailController = TextEditingController();
|
|
||||||
final medNoController = TextEditingController();
|
|
||||||
final medNameController = TextEditingController();
|
|
||||||
final medSchemeController = TextEditingController();
|
|
||||||
final addressController = TextEditingController();
|
|
||||||
final medAidController = TextEditingController();
|
|
||||||
final medMainMemController = TextEditingController();
|
|
||||||
final medAidCodeController = TextEditingController();
|
|
||||||
final baseAPI = AppEnviroment.baseApiUrl;
|
|
||||||
final docOfficeIdApiUrl = "${AppEnviroment.baseApiUrl}/users/profile/";
|
|
||||||
final apiUrlEdit = "${AppEnviroment.baseApiUrl}/patients/update/";
|
|
||||||
final apiUrlDelete = "${AppEnviroment.baseApiUrl}/patients/delete/";
|
|
||||||
final _formKey = GlobalKey<FormState>();
|
|
||||||
|
|
||||||
late bool medAidPosition;
|
|
||||||
late bool medMainMemberPosition;
|
|
||||||
late int futureDocOfficeId;
|
|
||||||
late String userEmail;
|
|
||||||
// bool medRequired = false;
|
|
||||||
final ValueNotifier<bool> medRequired = ValueNotifier(false);
|
|
||||||
|
|
||||||
late double width;
|
|
||||||
late double height;
|
|
||||||
|
|
||||||
final FocusNode _focusNode = FocusNode();
|
|
||||||
|
|
||||||
// Future getOfficeIdByUser(String endpoint) async {
|
|
||||||
// final response = await http.get(Uri.parse(endpoint));
|
|
||||||
// if (response.statusCode == 200) {
|
|
||||||
// String body = response.body;
|
|
||||||
// var decodedData = jsonDecode(body);
|
|
||||||
// AppUser u = AppUser.fromJson(decodedData as Map<String, dynamic>);
|
|
||||||
// setState(() {
|
|
||||||
// //futureDocOfficeId = u.docOffice_id;
|
|
||||||
// //print(futureDocOfficeId);
|
|
||||||
// });
|
|
||||||
// } else {
|
|
||||||
// internetConnectionPopUp();
|
|
||||||
// throw Exception('failed to load patients');
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
Future<void> updatePatientApiCall() async {
|
|
||||||
var statusCode = await MihPatientServices().updatePatientService(
|
|
||||||
widget.selectedPatient.app_id,
|
|
||||||
idController.text,
|
|
||||||
fnameController.text,
|
|
||||||
lnameController.text,
|
|
||||||
emailController.text,
|
|
||||||
cellController.text,
|
|
||||||
medAidController.text,
|
|
||||||
medMainMemController.text,
|
|
||||||
medNoController.text,
|
|
||||||
medAidCodeController.text,
|
|
||||||
medNameController.text,
|
|
||||||
medSchemeController.text,
|
|
||||||
addressController.text,
|
|
||||||
);
|
|
||||||
if (statusCode == 200) {
|
|
||||||
successPopUp(
|
|
||||||
"Successfully Updated Profile!",
|
|
||||||
"${fnameController.text} ${lnameController.text}'s information has been updated successfully! Their medical records and details are now current.",
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
MihAlertServices().errorAlert(
|
|
||||||
"Error Updating Profile",
|
|
||||||
"There was an error updating your profile. Please try again later.",
|
|
||||||
context,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
// var response = await http.put(
|
|
||||||
// Uri.parse(apiUrlEdit),
|
|
||||||
// headers: <String, String>{
|
|
||||||
// "Content-Type": "application/json; charset=UTF-8"
|
|
||||||
// },
|
|
||||||
// body: jsonEncode(<String, dynamic>{
|
|
||||||
// "id_no": idController.text,
|
|
||||||
// "first_name": fnameController.text,
|
|
||||||
// "last_name": lnameController.text,
|
|
||||||
// "email": emailController.text,
|
|
||||||
// "cell_no": cellController.text,
|
|
||||||
// "medical_aid": medAidController.text,
|
|
||||||
// "medical_aid_main_member": medMainMemController.text,
|
|
||||||
// "medical_aid_no": medNoController.text,
|
|
||||||
// "medical_aid_code": medAidCodeController.text,
|
|
||||||
// "medical_aid_name": medNameController.text,
|
|
||||||
// "medical_aid_scheme": medSchemeController.text,
|
|
||||||
// "address": addressController.text,
|
|
||||||
// "app_id": widget.selectedPatient.app_id,
|
|
||||||
// }),
|
|
||||||
// );
|
|
||||||
// print(response.statusCode);
|
|
||||||
// if (response.statusCode == 200) {
|
|
||||||
// Navigator.of(context).pop();
|
|
||||||
// Navigator.of(context).pop();
|
|
||||||
// Navigator.of(context).pushNamed('/patient-profile',
|
|
||||||
// arguments: PatientViewArguments(
|
|
||||||
// widget.signedInUser, null, null, null, "personal"));
|
|
||||||
// //Navigator.of(context).pushNamed('/');
|
|
||||||
// String message =
|
|
||||||
// "${fnameController.text} ${lnameController.text}'s information has been updated successfully! Their medical records and details are now current.";
|
|
||||||
// successPopUp(message);
|
|
||||||
// } else {
|
|
||||||
// internetConnectionPopUp();
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
void successPopUp(String title, String message) {
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (context) {
|
|
||||||
return MihPackageAlert(
|
|
||||||
alertIcon: Icon(
|
|
||||||
Icons.check_circle_outline_rounded,
|
|
||||||
size: 150,
|
|
||||||
color: MihColors.getGreenColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
|
||||||
),
|
|
||||||
alertTitle: title,
|
|
||||||
alertBody: Column(
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
message,
|
|
||||||
style: TextStyle(
|
|
||||||
color: MihColors.getSecondaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
|
||||||
fontSize: 15,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 25),
|
|
||||||
Center(
|
|
||||||
child: MihButton(
|
|
||||||
onPressed: () {
|
|
||||||
context.goNamed(
|
|
||||||
"patientProfile",
|
|
||||||
extra: PatientViewArguments(
|
|
||||||
widget.signedInUser,
|
|
||||||
widget.selectedPatient,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
"personal",
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
buttonColor: MihColors.getGreenColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
|
||||||
elevation: 10,
|
|
||||||
width: 300,
|
|
||||||
child: Text(
|
|
||||||
"Dismiss",
|
|
||||||
style: TextStyle(
|
|
||||||
color: MihColors.getPrimaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
|
||||||
"Dark"),
|
|
||||||
fontSize: 20,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
alertColour: MihColors.getGreenColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
|
||||||
);
|
|
||||||
// return MIHSuccessMessage(
|
|
||||||
// successType: "Success",
|
|
||||||
// successMessage: message,
|
|
||||||
// );
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> deletePatientApiCall() async {
|
|
||||||
//print("Here1");
|
|
||||||
//userEmail = getLoginUserEmail() as String;
|
|
||||||
//print(userEmail);
|
|
||||||
//print("Here2");
|
|
||||||
//await getOfficeIdByUser(docOfficeIdApiUrl + userEmail);
|
|
||||||
//print("Office ID: ${futureDocOfficeId.toString()}");
|
|
||||||
//print("OPatient ID No: ${idController.text}");
|
|
||||||
//print("Here3");
|
|
||||||
var response = await http.delete(
|
|
||||||
Uri.parse(apiUrlDelete),
|
|
||||||
headers: <String, String>{
|
|
||||||
"Content-Type": "application/json; charset=UTF-8"
|
|
||||||
},
|
|
||||||
body: jsonEncode(
|
|
||||||
<String, dynamic>{"app_id": widget.selectedPatient.app_id}),
|
|
||||||
);
|
|
||||||
//print("Here4");
|
|
||||||
//print(response.statusCode);
|
|
||||||
if (response.statusCode == 200) {
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
Navigator.of(context).popAndPushNamed('/patient-profile',
|
|
||||||
arguments: PatientViewArguments(
|
|
||||||
widget.signedInUser, null, null, null, "personal"));
|
|
||||||
String message =
|
|
||||||
"${fnameController.text} ${lnameController.text}'s record has been deleted successfully. This means it will no longer be visible in patient manager and cannot be used for future appointments.";
|
|
||||||
successPopUp("Error", message);
|
|
||||||
} else {
|
|
||||||
internetConnectionPopUp();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> getLoginUserEmail() async {
|
|
||||||
var uid = await SuperTokens.getUserId();
|
|
||||||
var response = await http.get(Uri.parse("$baseAPI/user/$uid"));
|
|
||||||
if (response.statusCode == 200) {
|
|
||||||
var user = jsonDecode(response.body);
|
|
||||||
userEmail = user["email"];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void messagePopUp(error) {
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (context) {
|
|
||||||
return AlertDialog(
|
|
||||||
title: Text(error),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void internetConnectionPopUp() {
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (context) {
|
|
||||||
return const MIHErrorMessage(errorType: "Internet Connection");
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void deletePatientPopUp() {
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
barrierDismissible: false,
|
|
||||||
builder: (context) => Dialog(
|
|
||||||
child: Stack(
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
padding: const EdgeInsets.all(10.0),
|
|
||||||
width: 700.0,
|
|
||||||
height: (height / 3) * 2,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: MihColors.getPrimaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
|
||||||
borderRadius: BorderRadius.circular(25.0),
|
|
||||||
border: Border.all(
|
|
||||||
color: MihColors.getSecondaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
|
||||||
width: 5.0),
|
|
||||||
),
|
|
||||||
child: SingleChildScrollView(
|
|
||||||
child: Column(
|
|
||||||
//mainAxisSize: MainAxisSize.max,
|
|
||||||
children: [
|
|
||||||
Icon(
|
|
||||||
Icons.warning_amber_rounded,
|
|
||||||
size: 100,
|
|
||||||
color: MihColors.getSecondaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
|
||||||
"Dark"),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 15),
|
|
||||||
Text(
|
|
||||||
"Are you sure you want to delete this?",
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(
|
|
||||||
color: MihColors.getSecondaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
|
||||||
"Dark"),
|
|
||||||
fontSize: 25.0,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 25.0),
|
|
||||||
child: Text(
|
|
||||||
"This action is permanent! Deleting ${fnameController.text} ${lnameController.text} will remove him\\her from your account. You won't be able to recover it once it's gone.",
|
|
||||||
style: TextStyle(
|
|
||||||
color: MihColors.getSecondaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
|
||||||
"Dark"),
|
|
||||||
fontSize: 15.0,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 15),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 25.0),
|
|
||||||
child: Text(
|
|
||||||
"Here's what you'll be deleting:",
|
|
||||||
style: TextStyle(
|
|
||||||
color: MihColors.getSecondaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
|
||||||
"Dark"),
|
|
||||||
fontSize: 20.0,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 25.0),
|
|
||||||
child: SizedBox(
|
|
||||||
width: 450,
|
|
||||||
child: Text(
|
|
||||||
"1) Patient Profile Information.\n2) Patient Notes\n3) Patient Files.",
|
|
||||||
textAlign: TextAlign.left,
|
|
||||||
style: TextStyle(
|
|
||||||
color: MihColors.getSecondaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
|
||||||
"Dark"),
|
|
||||||
fontSize: 15.0,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
MihButton(
|
|
||||||
onPressed: deletePatientApiCall,
|
|
||||||
buttonColor: MihColors.getRedColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
|
||||||
"Dark"),
|
|
||||||
width: 300,
|
|
||||||
child: Text(
|
|
||||||
"Delete",
|
|
||||||
style: TextStyle(
|
|
||||||
color: MihColors.getPrimaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
|
||||||
"Dark"),
|
|
||||||
fontSize: 20,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Positioned(
|
|
||||||
top: 5,
|
|
||||||
right: 5,
|
|
||||||
width: 50,
|
|
||||||
height: 50,
|
|
||||||
child: IconButton(
|
|
||||||
onPressed: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
icon: Icon(
|
|
||||||
Icons.close,
|
|
||||||
color: MihColors.getRedColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
|
||||||
size: 35,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isFieldsFilled() {
|
|
||||||
if (medRequired.value) {
|
|
||||||
if (idController.text.isEmpty ||
|
|
||||||
fnameController.text.isEmpty ||
|
|
||||||
lnameController.text.isEmpty ||
|
|
||||||
cellController.text.isEmpty ||
|
|
||||||
emailController.text.isEmpty ||
|
|
||||||
medNoController.text.isEmpty ||
|
|
||||||
medNameController.text.isEmpty ||
|
|
||||||
medSchemeController.text.isEmpty ||
|
|
||||||
addressController.text.isEmpty ||
|
|
||||||
medAidController.text.isEmpty ||
|
|
||||||
medMainMemController.text.isEmpty ||
|
|
||||||
medAidCodeController.text.isEmpty) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (idController.text.isEmpty ||
|
|
||||||
fnameController.text.isEmpty ||
|
|
||||||
lnameController.text.isEmpty ||
|
|
||||||
cellController.text.isEmpty ||
|
|
||||||
emailController.text.isEmpty ||
|
|
||||||
addressController.text.isEmpty ||
|
|
||||||
medAidController.text.isEmpty) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void isRequired() {
|
|
||||||
print("listerner triggered");
|
|
||||||
if (medAidController.text == "Yes") {
|
|
||||||
medRequired.value = true;
|
|
||||||
} else if (medAidController.text == "No") {
|
|
||||||
medRequired.value = false;
|
|
||||||
} else {
|
|
||||||
//print("here");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget displayForm(double width) {
|
|
||||||
return SingleChildScrollView(
|
|
||||||
child: Padding(
|
|
||||||
padding: MzansiInnovationHub.of(context)!.theme.screenType == "desktop"
|
|
||||||
? EdgeInsets.symmetric(horizontal: width * 0.2)
|
|
||||||
: EdgeInsets.symmetric(horizontal: width * 0.075),
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
MihForm(
|
|
||||||
formKey: _formKey,
|
|
||||||
formFields: [
|
|
||||||
Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
"Personal",
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
fontSize: 25.0,
|
|
||||||
color: MihColors.getSecondaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
|
||||||
"Dark"),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
Divider(
|
|
||||||
color: MihColors.getSecondaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark")),
|
|
||||||
const SizedBox(height: 10.0),
|
|
||||||
MihTextFormField(
|
|
||||||
fillColor: MihColors.getSecondaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
|
||||||
inputColor: MihColors.getPrimaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
|
||||||
controller: idController,
|
|
||||||
multiLineInput: false,
|
|
||||||
requiredText: true,
|
|
||||||
hintText: "ID No.",
|
|
||||||
validator: (value) {
|
|
||||||
return MihValidationServices().isEmpty(value);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10.0),
|
|
||||||
MihTextFormField(
|
|
||||||
fillColor: MihColors.getSecondaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
|
||||||
inputColor: MihColors.getPrimaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
|
||||||
controller: fnameController,
|
|
||||||
multiLineInput: false,
|
|
||||||
requiredText: true,
|
|
||||||
readOnly: true,
|
|
||||||
hintText: "First Name",
|
|
||||||
validator: (value) {
|
|
||||||
return MihValidationServices().isEmpty(value);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10.0),
|
|
||||||
MihTextFormField(
|
|
||||||
fillColor: MihColors.getSecondaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
|
||||||
inputColor: MihColors.getPrimaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
|
||||||
controller: lnameController,
|
|
||||||
multiLineInput: false,
|
|
||||||
requiredText: true,
|
|
||||||
readOnly: true,
|
|
||||||
hintText: "Surname",
|
|
||||||
validator: (value) {
|
|
||||||
return MihValidationServices().isEmpty(value);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10.0),
|
|
||||||
MihTextFormField(
|
|
||||||
fillColor: MihColors.getSecondaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
|
||||||
inputColor: MihColors.getPrimaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
|
||||||
controller: cellController,
|
|
||||||
multiLineInput: false,
|
|
||||||
requiredText: true,
|
|
||||||
hintText: "Cell No.",
|
|
||||||
validator: (value) {
|
|
||||||
return MihValidationServices().isEmpty(value);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10.0),
|
|
||||||
MihTextFormField(
|
|
||||||
fillColor: MihColors.getSecondaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
|
||||||
inputColor: MihColors.getPrimaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
|
||||||
controller: emailController,
|
|
||||||
multiLineInput: false,
|
|
||||||
requiredText: true,
|
|
||||||
readOnly: true,
|
|
||||||
hintText: "Email",
|
|
||||||
validator: (value) {
|
|
||||||
return MihValidationServices().validateEmail(value);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10.0),
|
|
||||||
MihTextFormField(
|
|
||||||
height: 100,
|
|
||||||
fillColor: MihColors.getSecondaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
|
||||||
inputColor: MihColors.getPrimaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
|
||||||
controller: addressController,
|
|
||||||
multiLineInput: true,
|
|
||||||
requiredText: true,
|
|
||||||
hintText: "Address",
|
|
||||||
validator: (value) {
|
|
||||||
return MihValidationServices().isEmpty(value);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(height: 15.0),
|
|
||||||
Center(
|
|
||||||
child: Text(
|
|
||||||
"Medical Aid Details",
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
fontSize: 25.0,
|
|
||||||
color: MihColors.getSecondaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
|
||||||
"Dark"),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Divider(
|
|
||||||
color: MihColors.getSecondaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark")),
|
|
||||||
const SizedBox(height: 10.0),
|
|
||||||
MihToggle(
|
|
||||||
hintText: "Medical Aid",
|
|
||||||
initialPostion: medAidPosition,
|
|
||||||
fillColor: MihColors.getSecondaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
|
||||||
secondaryFillColor: MihColors.getPrimaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
|
||||||
onChange: (value) {
|
|
||||||
if (value) {
|
|
||||||
setState(() {
|
|
||||||
medAidController.text = "Yes";
|
|
||||||
medAidPosition = value;
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
setState(() {
|
|
||||||
medAidController.text = "No";
|
|
||||||
medAidPosition = value;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ValueListenableBuilder(
|
|
||||||
valueListenable: medRequired,
|
|
||||||
builder: (BuildContext context, bool value, Widget? child) {
|
|
||||||
return Visibility(
|
|
||||||
visible: value,
|
|
||||||
child: Column(
|
|
||||||
children: [
|
|
||||||
const SizedBox(height: 10.0),
|
|
||||||
MihToggle(
|
|
||||||
hintText: "Main Member",
|
|
||||||
initialPostion: medMainMemberPosition,
|
|
||||||
fillColor: MihColors.getSecondaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
|
||||||
"Dark"),
|
|
||||||
secondaryFillColor: MihColors.getPrimaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
|
||||||
"Dark"),
|
|
||||||
onChange: (value) {
|
|
||||||
if (value) {
|
|
||||||
setState(() {
|
|
||||||
medMainMemController.text = "Yes";
|
|
||||||
medMainMemberPosition = value;
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
setState(() {
|
|
||||||
medMainMemController.text = "No";
|
|
||||||
medMainMemberPosition = value;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10.0),
|
|
||||||
MihTextFormField(
|
|
||||||
fillColor: MihColors.getSecondaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
|
||||||
"Dark"),
|
|
||||||
inputColor: MihColors.getPrimaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
|
||||||
"Dark"),
|
|
||||||
controller: medNoController,
|
|
||||||
multiLineInput: false,
|
|
||||||
requiredText: true,
|
|
||||||
hintText: "No.",
|
|
||||||
validator: (validationValue) {
|
|
||||||
if (value) {
|
|
||||||
return MihValidationServices()
|
|
||||||
.isEmpty(validationValue);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10.0),
|
|
||||||
MihTextFormField(
|
|
||||||
fillColor: MihColors.getSecondaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
|
||||||
"Dark"),
|
|
||||||
inputColor: MihColors.getPrimaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
|
||||||
"Dark"),
|
|
||||||
controller: medAidCodeController,
|
|
||||||
multiLineInput: false,
|
|
||||||
requiredText: true,
|
|
||||||
hintText: "Code",
|
|
||||||
validator: (validationValue) {
|
|
||||||
if (value) {
|
|
||||||
return MihValidationServices()
|
|
||||||
.isEmpty(validationValue);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10.0),
|
|
||||||
MihTextFormField(
|
|
||||||
fillColor: MihColors.getSecondaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
|
||||||
"Dark"),
|
|
||||||
inputColor: MihColors.getPrimaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
|
||||||
"Dark"),
|
|
||||||
controller: medNameController,
|
|
||||||
multiLineInput: false,
|
|
||||||
requiredText: true,
|
|
||||||
hintText: "Name",
|
|
||||||
validator: (validationValue) {
|
|
||||||
if (value) {
|
|
||||||
return MihValidationServices()
|
|
||||||
.isEmpty(validationValue);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10.0),
|
|
||||||
MihTextFormField(
|
|
||||||
fillColor: MihColors.getSecondaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
|
||||||
"Dark"),
|
|
||||||
inputColor: MihColors.getPrimaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
|
||||||
"Dark"),
|
|
||||||
controller: medSchemeController,
|
|
||||||
multiLineInput: false,
|
|
||||||
requiredText: true,
|
|
||||||
hintText: "Plan",
|
|
||||||
validator: (validationValue) {
|
|
||||||
if (value) {
|
|
||||||
return MihValidationServices()
|
|
||||||
.isEmpty(validationValue);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10.0),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
const SizedBox(height: 20.0),
|
|
||||||
Center(
|
|
||||||
child: MihButton(
|
|
||||||
onPressed: () {
|
|
||||||
if (_formKey.currentState!.validate()) {
|
|
||||||
submitForm();
|
|
||||||
} else {
|
|
||||||
MihAlertServices().formNotFilledCompletely(context);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
buttonColor: MihColors.getGreenColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode == "Dark"),
|
|
||||||
width: 300,
|
|
||||||
child: Text(
|
|
||||||
"Update",
|
|
||||||
style: TextStyle(
|
|
||||||
color: MihColors.getPrimaryColor(
|
|
||||||
MzansiInnovationHub.of(context)!.theme.mode ==
|
|
||||||
"Dark"),
|
|
||||||
fontSize: 20,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 20.0),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void submitForm() {
|
|
||||||
updatePatientApiCall();
|
|
||||||
}
|
|
||||||
|
|
||||||
MIHAction getActionButton() {
|
|
||||||
return MIHAction(
|
|
||||||
icon: const Icon(Icons.arrow_back),
|
|
||||||
iconSize: 35,
|
|
||||||
onTap: () {
|
|
||||||
context.goNamed(
|
|
||||||
'patientProfile',
|
|
||||||
extra: PatientViewArguments(
|
|
||||||
widget.signedInUser,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
"personal",
|
|
||||||
),
|
|
||||||
);
|
|
||||||
// Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
MIHHeader getHeader() {
|
|
||||||
return const MIHHeader(
|
|
||||||
headerAlignment: MainAxisAlignment.center,
|
|
||||||
headerItems: [
|
|
||||||
Text(
|
|
||||||
"Edit Patient Details",
|
|
||||||
style: TextStyle(
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
fontSize: 25,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
MIHBody getBody(double width) {
|
|
||||||
return MIHBody(
|
|
||||||
borderOn: false,
|
|
||||||
bodyItems: [
|
|
||||||
KeyboardListener(
|
|
||||||
focusNode: _focusNode,
|
|
||||||
autofocus: true,
|
|
||||||
onKeyEvent: (event) async {
|
|
||||||
if (event is KeyDownEvent &&
|
|
||||||
event.logicalKey == LogicalKeyboardKey.enter) {
|
|
||||||
if (_formKey.currentState!.validate()) {
|
|
||||||
submitForm();
|
|
||||||
} else {
|
|
||||||
MihAlertServices().formNotFilledCompletely(context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: displayForm(width),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
idController.dispose();
|
|
||||||
fnameController.dispose();
|
|
||||||
lnameController.dispose();
|
|
||||||
cellController.dispose();
|
|
||||||
emailController.dispose();
|
|
||||||
medNoController.dispose();
|
|
||||||
medNameController.dispose();
|
|
||||||
medSchemeController.dispose();
|
|
||||||
addressController.dispose();
|
|
||||||
medAidController.dispose();
|
|
||||||
medAidCodeController.removeListener(isRequired);
|
|
||||||
medMainMemController.dispose();
|
|
||||||
medAidCodeController.dispose();
|
|
||||||
medRequired.dispose();
|
|
||||||
_focusNode.dispose();
|
|
||||||
super.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
getLoginUserEmail();
|
|
||||||
medAidController.addListener(isRequired);
|
|
||||||
setState(() {
|
|
||||||
idController.text = widget.selectedPatient.id_no;
|
|
||||||
fnameController.text = widget.selectedPatient.first_name;
|
|
||||||
lnameController.text = widget.selectedPatient.last_name;
|
|
||||||
cellController.text = widget.selectedPatient.cell_no;
|
|
||||||
emailController.text = widget.selectedPatient.email;
|
|
||||||
medNameController.text = widget.selectedPatient.medical_aid_name;
|
|
||||||
medNoController.text = widget.selectedPatient.medical_aid_no;
|
|
||||||
medSchemeController.text = widget.selectedPatient.medical_aid_scheme;
|
|
||||||
addressController.text = widget.selectedPatient.address;
|
|
||||||
medAidController.text = widget.selectedPatient.medical_aid;
|
|
||||||
medMainMemController.text =
|
|
||||||
widget.selectedPatient.medical_aid_main_member;
|
|
||||||
medAidCodeController.text = widget.selectedPatient.medical_aid_code;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (medAidController.text == "Yes") {
|
|
||||||
medAidPosition = true;
|
|
||||||
} else {
|
|
||||||
medAidPosition = false;
|
|
||||||
medAidController.text = "No";
|
|
||||||
}
|
|
||||||
if (medMainMemController.text == "Yes") {
|
|
||||||
medMainMemberPosition = true;
|
|
||||||
} else {
|
|
||||||
medMainMemberPosition = false;
|
|
||||||
medMainMemController.text = "No";
|
|
||||||
}
|
|
||||||
super.initState();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
var size = MediaQuery.of(context).size;
|
|
||||||
setState(() {
|
|
||||||
width = size.width;
|
|
||||||
height = size.height;
|
|
||||||
});
|
|
||||||
return MIHLayoutBuilder(
|
|
||||||
actionButton: getActionButton(),
|
|
||||||
header: getHeader(),
|
|
||||||
secondaryActionButton: null,
|
|
||||||
body: getBody(width),
|
|
||||||
actionDrawer: null,
|
|
||||||
secondaryActionDrawer: null,
|
|
||||||
bottomNavBar: null,
|
|
||||||
pullDownToRefresh: false,
|
|
||||||
onPullDown: () async {},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,18 +2,21 @@ import 'package:go_router/go_router.dart';
|
|||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_action.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_action.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/arguments.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/package_tools/patient_claim_or_statement.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_profile_provider.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_providers/patient_manager_provider.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/package_tools/patient_consultation.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/package_tools/patient_consultation.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/package_tools/patient_documents.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/package_tools/patient_documents.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/package_tools/patient_info.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/package_tools/patient_info.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_services/mih_patient_services.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class PatientProfile extends StatefulWidget {
|
class PatientProfile extends StatefulWidget {
|
||||||
final PatientViewArguments arguments;
|
final String? patientAppId;
|
||||||
const PatientProfile({
|
const PatientProfile({
|
||||||
super.key,
|
super.key,
|
||||||
required this.arguments,
|
required this.patientAppId,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -21,7 +24,42 @@ class PatientProfile extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _PatientProfileState extends State<PatientProfile> {
|
class _PatientProfileState extends State<PatientProfile> {
|
||||||
int _selcetedIndex = 0;
|
bool isLoading = true;
|
||||||
|
|
||||||
|
Future<void> initialisePatientData() async {
|
||||||
|
setState(() {
|
||||||
|
isLoading = true;
|
||||||
|
});
|
||||||
|
MzansiProfileProvider profileProvider =
|
||||||
|
context.read<MzansiProfileProvider>();
|
||||||
|
PatientManagerProvider patientManagerProvider =
|
||||||
|
context.read<PatientManagerProvider>();
|
||||||
|
String? app_id = widget.patientAppId ?? profileProvider.user!.app_id;
|
||||||
|
|
||||||
|
if (patientManagerProvider.selectedPatient == null) {
|
||||||
|
await MihPatientServices()
|
||||||
|
.getPatientDetails(app_id, patientManagerProvider);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (patientManagerProvider.selectedPatient == null) {
|
||||||
|
// go to set up patient package
|
||||||
|
context.goNamed("patientProfileSetup");
|
||||||
|
} else {
|
||||||
|
await MihPatientServices()
|
||||||
|
.getPatientConsultationNotes(patientManagerProvider);
|
||||||
|
await MihPatientServices().getPatientDocuments(patientManagerProvider);
|
||||||
|
}
|
||||||
|
setState(() {
|
||||||
|
isLoading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
initialisePatientData();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MihPackage(
|
return MihPackage(
|
||||||
@@ -29,21 +67,24 @@ class _PatientProfileState extends State<PatientProfile> {
|
|||||||
appTools: getTools(),
|
appTools: getTools(),
|
||||||
appBody: getToolBody(),
|
appBody: getToolBody(),
|
||||||
appToolTitles: getToolTitle(),
|
appToolTitles: getToolTitle(),
|
||||||
selectedbodyIndex: _selcetedIndex,
|
selectedbodyIndex:
|
||||||
|
context.watch<PatientManagerProvider>().patientProfileIndex,
|
||||||
onIndexChange: (newValue) {
|
onIndexChange: (newValue) {
|
||||||
setState(() {
|
context.read<PatientManagerProvider>().setPatientProfileIndex(newValue);
|
||||||
_selcetedIndex = newValue;
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
MihPackageAction getAction() {
|
MihPackageAction getAction() {
|
||||||
|
PatientManagerProvider patientManagerProvider =
|
||||||
|
context.read<PatientManagerProvider>();
|
||||||
return MihPackageAction(
|
return MihPackageAction(
|
||||||
icon: const Icon(Icons.arrow_back),
|
icon: const Icon(Icons.arrow_back),
|
||||||
iconSize: 35,
|
iconSize: 35,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (widget.arguments.type == "business") {
|
patientManagerProvider.setPatientProfileIndex(0);
|
||||||
|
patientManagerProvider.setPatientManagerIndex(0);
|
||||||
|
if (!patientManagerProvider.personalMode) {
|
||||||
context.pop();
|
context.pop();
|
||||||
} else {
|
} else {
|
||||||
context.goNamed(
|
context.goNamed(
|
||||||
@@ -56,64 +97,54 @@ class _PatientProfileState extends State<PatientProfile> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MihPackageTools getTools() {
|
MihPackageTools getTools() {
|
||||||
|
PatientManagerProvider patientManagerProvider =
|
||||||
|
context.read<PatientManagerProvider>();
|
||||||
Map<Widget, void Function()?> temp = {};
|
Map<Widget, void Function()?> temp = {};
|
||||||
temp[const Icon(Icons.perm_identity)] = () {
|
temp[const Icon(Icons.perm_identity)] = () {
|
||||||
setState(() {
|
patientManagerProvider.setPatientProfileIndex(0);
|
||||||
_selcetedIndex = 0;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
temp[const Icon(Icons.article_outlined)] = () {
|
temp[const Icon(Icons.article_outlined)] = () {
|
||||||
setState(() {
|
patientManagerProvider.setPatientProfileIndex(1);
|
||||||
_selcetedIndex = 1;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
temp[const Icon(Icons.file_present)] = () {
|
temp[const Icon(Icons.file_present)] = () {
|
||||||
setState(() {
|
patientManagerProvider.setPatientProfileIndex(2);
|
||||||
_selcetedIndex = 2;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
temp[const Icon(Icons.file_open_outlined)] = () {
|
temp[const Icon(Icons.file_open_outlined)] = () {
|
||||||
setState(() {
|
patientManagerProvider.setPatientProfileIndex(3);
|
||||||
_selcetedIndex = 3;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
return MihPackageTools(
|
return MihPackageTools(
|
||||||
tools: temp,
|
tools: temp,
|
||||||
selcetedIndex: _selcetedIndex,
|
selcetedIndex: patientManagerProvider.patientProfileIndex,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> getToolBody() {
|
List<Widget> getToolBody() {
|
||||||
|
if (isLoading) {
|
||||||
|
return [
|
||||||
|
Center(
|
||||||
|
child: Mihloadingcircle(),
|
||||||
|
),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
PatientManagerProvider patientManagerProvider =
|
||||||
|
context.read<PatientManagerProvider>();
|
||||||
|
if (patientManagerProvider.selectedPatient == null) {
|
||||||
|
return [
|
||||||
|
const SizedBox(),
|
||||||
|
];
|
||||||
|
}
|
||||||
List<Widget> toolBodies = [
|
List<Widget> toolBodies = [
|
||||||
PatientInfo(
|
PatientInfo(),
|
||||||
signedInUser: widget.arguments.signedInUser,
|
PatientConsultation(),
|
||||||
selectedPatient: widget.arguments.selectedPatient!,
|
PatientDocuments(),
|
||||||
type: widget.arguments.type,
|
// PatientClaimOrStatement(
|
||||||
),
|
// patientIndex: widget.arguments.selectedPatient!.idpatients,
|
||||||
PatientConsultation(
|
// selectedPatient: widget.arguments.selectedPatient!,
|
||||||
patientAppId: widget.arguments.selectedPatient!.app_id,
|
// signedInUser: widget.arguments.signedInUser,
|
||||||
selectedPatient: widget.arguments.selectedPatient!,
|
// business: widget.arguments.business,
|
||||||
signedInUser: widget.arguments.signedInUser,
|
// businessUser: widget.arguments.businessUser,
|
||||||
business: widget.arguments.business,
|
// type: widget.arguments.type,
|
||||||
businessUser: widget.arguments.businessUser,
|
// ),
|
||||||
type: widget.arguments.type,
|
|
||||||
),
|
|
||||||
PatientDocuments(
|
|
||||||
patientIndex: widget.arguments.selectedPatient!.idpatients,
|
|
||||||
selectedPatient: widget.arguments.selectedPatient!,
|
|
||||||
signedInUser: widget.arguments.signedInUser,
|
|
||||||
business: widget.arguments.business,
|
|
||||||
businessUser: widget.arguments.businessUser,
|
|
||||||
type: widget.arguments.type,
|
|
||||||
),
|
|
||||||
PatientClaimOrStatement(
|
|
||||||
patientIndex: widget.arguments.selectedPatient!.idpatients,
|
|
||||||
selectedPatient: widget.arguments.selectedPatient!,
|
|
||||||
signedInUser: widget.arguments.signedInUser,
|
|
||||||
business: widget.arguments.business,
|
|
||||||
businessUser: widget.arguments.businessUser,
|
|
||||||
type: widget.arguments.type,
|
|
||||||
),
|
|
||||||
];
|
];
|
||||||
return toolBodies;
|
return toolBodies;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,72 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_action.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_tools.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_providers/patient_manager_provider.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_packages/patient_manager/pat_profile/package_tools/patient_setup_form.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class PatientSetUp extends StatefulWidget {
|
||||||
|
const PatientSetUp({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<PatientSetUp> createState() => _PatientSetUpState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _PatientSetUpState extends State<PatientSetUp> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return MihPackage(
|
||||||
|
appActionButton: getAction(),
|
||||||
|
appTools: getTools(),
|
||||||
|
appBody: getToolBody(),
|
||||||
|
appToolTitles: getToolTitle(),
|
||||||
|
selectedbodyIndex:
|
||||||
|
context.watch<PatientManagerProvider>().patientProfileIndex,
|
||||||
|
onIndexChange: (newValue) {
|
||||||
|
context.read<PatientManagerProvider>().setPatientProfileIndex(newValue);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
MihPackageAction getAction() {
|
||||||
|
return MihPackageAction(
|
||||||
|
icon: const Icon(Icons.arrow_back),
|
||||||
|
iconSize: 35,
|
||||||
|
onTap: () {
|
||||||
|
context.goNamed(
|
||||||
|
'mihHome',
|
||||||
|
);
|
||||||
|
FocusScope.of(context).unfocus();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
MihPackageTools getTools() {
|
||||||
|
PatientManagerProvider patientManagerProvider =
|
||||||
|
context.read<PatientManagerProvider>();
|
||||||
|
Map<Widget, void Function()?> temp = {};
|
||||||
|
temp[const Icon(Icons.medical_services)] = () {
|
||||||
|
patientManagerProvider.setPatientProfileIndex(0);
|
||||||
|
};
|
||||||
|
return MihPackageTools(
|
||||||
|
tools: temp,
|
||||||
|
selcetedIndex: patientManagerProvider.patientProfileIndex,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Widget> getToolBody() {
|
||||||
|
List<Widget> toolBodies = [
|
||||||
|
PatientSetupForm(),
|
||||||
|
];
|
||||||
|
return toolBodies;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> getToolTitle() {
|
||||||
|
List<String> toolTitles = [
|
||||||
|
"Set Up Patient Profile",
|
||||||
|
];
|
||||||
|
return toolTitles;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
import '../../mih_components/mih_layout/mih_action.dart';
|
|
||||||
import '../../mih_components/mih_layout/mih_body.dart';
|
|
||||||
import '../../mih_components/mih_layout/mih_header.dart';
|
|
||||||
import '../../mih_components/mih_layout/mih_layout_builder.dart';
|
|
||||||
|
|
||||||
class MIHTest extends StatefulWidget {
|
|
||||||
const MIHTest({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<MIHTest> createState() => _MIHTestState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _MIHTestState extends State<MIHTest> {
|
|
||||||
// late YoutubePlayerController videoController;
|
|
||||||
// String videoLink = "https://www.youtube.com/watch?v=P2bM9eosJ_A";
|
|
||||||
// @override
|
|
||||||
// void initState() {
|
|
||||||
// videoController = YoutubePlayerController(
|
|
||||||
// initialVideoId: "P2bM9eosJ_A",
|
|
||||||
// );
|
|
||||||
// super.initState();
|
|
||||||
// }
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return MIHLayoutBuilder(
|
|
||||||
actionButton: MIHAction(
|
|
||||||
icon: const Icon(Icons.arrow_back),
|
|
||||||
iconSize: 35,
|
|
||||||
onTap: () {
|
|
||||||
Navigator.of(context).pushNamedAndRemoveUntil(
|
|
||||||
'/',
|
|
||||||
arguments: true,
|
|
||||||
(route) => false,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
header: const MIHHeader(
|
|
||||||
headerAlignment: MainAxisAlignment.center,
|
|
||||||
headerItems: [
|
|
||||||
Text(
|
|
||||||
"Test",
|
|
||||||
style: TextStyle(
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
fontSize: 25,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
secondaryActionButton: null,
|
|
||||||
body: const MIHBody(
|
|
||||||
borderOn: false,
|
|
||||||
bodyItems: [
|
|
||||||
// YoutubePlayer(
|
|
||||||
// controller: videoController,
|
|
||||||
// ),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
actionDrawer: null,
|
|
||||||
secondaryActionDrawer: null,
|
|
||||||
bottomNavBar: null,
|
|
||||||
pullDownToRefresh: false,
|
|
||||||
onPullDown: () async {},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,12 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/app_user.dart';
|
import 'package:file_picker/file_picker.dart';
|
||||||
|
import 'package:ken_logger/ken_logger.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_objects/files.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_objects/notes.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_objects/patients.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_objects/patients.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_providers/mzansi_profile_provider.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_providers/patient_manager_provider.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
import 'package:mzansi_innovation_hub/mih_config/mih_env.dart';
|
||||||
import 'package:supertokens_flutter/http.dart' as http;
|
import 'package:supertokens_flutter/http.dart' as http;
|
||||||
|
|
||||||
@@ -10,6 +15,7 @@ class MihPatientServices {
|
|||||||
|
|
||||||
Future<Patient?> getPatientDetails(
|
Future<Patient?> getPatientDetails(
|
||||||
String appId,
|
String appId,
|
||||||
|
PatientManagerProvider patientManagerProvider,
|
||||||
) async {
|
) async {
|
||||||
var response = await http.get(
|
var response = await http.get(
|
||||||
Uri.parse("${AppEnviroment.baseApiUrl}/patients/$appId"),
|
Uri.parse("${AppEnviroment.baseApiUrl}/patients/$appId"),
|
||||||
@@ -19,8 +25,11 @@ class MihPatientServices {
|
|||||||
);
|
);
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
String body = response.body;
|
String body = response.body;
|
||||||
|
KenLogger.success(response.body);
|
||||||
var jsonBody = jsonDecode(body);
|
var jsonBody = jsonDecode(body);
|
||||||
return Patient.fromJson(jsonBody);
|
Patient patient = Patient.fromJson(jsonBody);
|
||||||
|
patientManagerProvider.setSelectedPatient(selectedPatient: patient);
|
||||||
|
return patient;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -39,7 +48,8 @@ class MihPatientServices {
|
|||||||
String medName,
|
String medName,
|
||||||
String medScheme,
|
String medScheme,
|
||||||
String address,
|
String address,
|
||||||
AppUser signedInUser,
|
MzansiProfileProvider profileProvider,
|
||||||
|
PatientManagerProvider patientManagerProvider,
|
||||||
) async {
|
) async {
|
||||||
var response = await http.post(
|
var response = await http.post(
|
||||||
Uri.parse("$baseAPI/patients/insert/"),
|
Uri.parse("$baseAPI/patients/insert/"),
|
||||||
@@ -59,9 +69,31 @@ class MihPatientServices {
|
|||||||
"medical_aid_name": medName,
|
"medical_aid_name": medName,
|
||||||
"medical_aid_scheme": medScheme,
|
"medical_aid_scheme": medScheme,
|
||||||
"address": address,
|
"address": address,
|
||||||
"app_id": signedInUser.app_id,
|
"app_id": profileProvider.user!.app_id,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
if (response.statusCode == 201) {
|
||||||
|
await getPatientDetails(
|
||||||
|
profileProvider.user!.app_id, patientManagerProvider);
|
||||||
|
// patientManagerProvider.setSelectedPatient(
|
||||||
|
// selectedPatient: Patient(
|
||||||
|
// idpatients: 0,
|
||||||
|
// id_no: id_no,
|
||||||
|
// first_name: fname,
|
||||||
|
// last_name: lname,
|
||||||
|
// email: email,
|
||||||
|
// cell_no: cell,
|
||||||
|
// medical_aid: medAid,
|
||||||
|
// medical_aid_name: medName,
|
||||||
|
// medical_aid_no: medNo,
|
||||||
|
// medical_aid_main_member: medMainMem,
|
||||||
|
// medical_aid_code: medAidCode,
|
||||||
|
// medical_aid_scheme: medScheme,
|
||||||
|
// address: address,
|
||||||
|
// app_id: profileProvider.user!.app_id,
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
|
}
|
||||||
return response.statusCode;
|
return response.statusCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,6 +111,7 @@ class MihPatientServices {
|
|||||||
String medName,
|
String medName,
|
||||||
String medScheme,
|
String medScheme,
|
||||||
String address,
|
String address,
|
||||||
|
PatientManagerProvider patientManagerProvider,
|
||||||
) async {
|
) async {
|
||||||
var response = await http.put(
|
var response = await http.put(
|
||||||
Uri.parse("$baseAPI/patients/update/"),
|
Uri.parse("$baseAPI/patients/update/"),
|
||||||
@@ -101,6 +134,159 @@ class MihPatientServices {
|
|||||||
"app_id": app_id,
|
"app_id": app_id,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
await getPatientDetails(app_id, patientManagerProvider);
|
||||||
|
}
|
||||||
|
return response.statusCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<int> getPatientConsultationNotes(
|
||||||
|
PatientManagerProvider patientManagerProvider) async {
|
||||||
|
final response = await http.get(Uri.parse(
|
||||||
|
"${AppEnviroment.baseApiUrl}/notes/patients/${patientManagerProvider.selectedPatient!.app_id}"));
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
Iterable l = jsonDecode(response.body);
|
||||||
|
List<Note> notes =
|
||||||
|
List<Note>.from(l.map((model) => Note.fromJson(model)));
|
||||||
|
patientManagerProvider.setConsultationNotes(consultationNotes: notes);
|
||||||
|
}
|
||||||
|
return response.statusCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<int> addPatientNoteAPICall(
|
||||||
|
String title,
|
||||||
|
String noteText,
|
||||||
|
MzansiProfileProvider profileProvider,
|
||||||
|
PatientManagerProvider patientManagerProvider,
|
||||||
|
) async {
|
||||||
|
var response = await http.post(
|
||||||
|
Uri.parse("${AppEnviroment.baseApiUrl}/notes/insert/"),
|
||||||
|
headers: <String, String>{
|
||||||
|
"Content-Type": "application/json; charset=UTF-8"
|
||||||
|
},
|
||||||
|
body: jsonEncode(<String, dynamic>{
|
||||||
|
"note_name": title,
|
||||||
|
"note_text": noteText,
|
||||||
|
"doc_office": profileProvider.business!.Name,
|
||||||
|
"doctor":
|
||||||
|
"${profileProvider.user!.fname} ${profileProvider.user!.lname}",
|
||||||
|
"app_id": patientManagerProvider.selectedPatient!.app_id,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
if (response.statusCode == 201) {
|
||||||
|
await getPatientConsultationNotes(patientManagerProvider);
|
||||||
|
}
|
||||||
|
return response.statusCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<int> deletePatientConsultaionNote(
|
||||||
|
int NoteId,
|
||||||
|
PatientManagerProvider patientManagerProvider,
|
||||||
|
) async {
|
||||||
|
var response = await http.delete(
|
||||||
|
Uri.parse("$baseAPI/notes/delete/"),
|
||||||
|
headers: <String, String>{
|
||||||
|
"Content-Type": "application/json; charset=UTF-8"
|
||||||
|
},
|
||||||
|
body: jsonEncode(<String, dynamic>{"idpatient_notes": NoteId}),
|
||||||
|
);
|
||||||
|
if (response.statusCode == 201) {
|
||||||
|
await getPatientConsultationNotes(patientManagerProvider);
|
||||||
|
}
|
||||||
|
return response.statusCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<int> getPatientDocuments(
|
||||||
|
PatientManagerProvider patientManagerProvider) async {
|
||||||
|
final response = await http.get(Uri.parse(
|
||||||
|
"${AppEnviroment.baseApiUrl}/patient_files/get/${patientManagerProvider.selectedPatient!.app_id}"));
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
Iterable l = jsonDecode(response.body);
|
||||||
|
List<PFile> patientDocuments =
|
||||||
|
List<PFile>.from(l.map((model) => PFile.fromJson(model)));
|
||||||
|
patientManagerProvider.setPatientDocuments(
|
||||||
|
patientDocuments: patientDocuments);
|
||||||
|
}
|
||||||
|
return response.statusCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<int> addPatientFile(
|
||||||
|
PlatformFile? file,
|
||||||
|
PatientManagerProvider patientManagerProvider,
|
||||||
|
) async {
|
||||||
|
var fname = file!.name.replaceAll(RegExp(r' '), '-');
|
||||||
|
var filePath =
|
||||||
|
"${patientManagerProvider.selectedPatient!.app_id}/patient_files/$fname";
|
||||||
|
var response = await http.post(
|
||||||
|
Uri.parse("${AppEnviroment.baseApiUrl}/patient_files/insert/"),
|
||||||
|
headers: <String, String>{
|
||||||
|
"Content-Type": "application/json; charset=UTF-8"
|
||||||
|
},
|
||||||
|
body: jsonEncode(<String, dynamic>{
|
||||||
|
"file_path": filePath,
|
||||||
|
"file_name": fname,
|
||||||
|
"app_id": patientManagerProvider.selectedPatient!.app_id
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
if (response.statusCode == 201) {
|
||||||
|
await getPatientDocuments(patientManagerProvider);
|
||||||
|
}
|
||||||
|
return response.statusCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<int> generateMedicalCertificate(
|
||||||
|
String startDate,
|
||||||
|
String endDate,
|
||||||
|
String returnDate,
|
||||||
|
MzansiProfileProvider profileProvider,
|
||||||
|
PatientManagerProvider patientManagerProvider,
|
||||||
|
) async {
|
||||||
|
DateTime now = DateTime.now();
|
||||||
|
String fileName =
|
||||||
|
"Med-Cert-${patientManagerProvider.selectedPatient!.first_name} ${patientManagerProvider.selectedPatient!.last_name}-${now.toString().substring(0, 19)}.pdf"
|
||||||
|
.replaceAll(RegExp(r' '), '-');
|
||||||
|
var response = await http.post(
|
||||||
|
Uri.parse("${AppEnviroment.baseApiUrl}/minio/generate/med-cert/"),
|
||||||
|
headers: <String, String>{
|
||||||
|
"Content-Type": "application/json; charset=UTF-8"
|
||||||
|
},
|
||||||
|
body: jsonEncode(<String, dynamic>{
|
||||||
|
"app_id": patientManagerProvider.selectedPatient!.app_id,
|
||||||
|
"env": AppEnviroment.getEnv(),
|
||||||
|
"patient_full_name":
|
||||||
|
"${patientManagerProvider.selectedPatient!.first_name} ${patientManagerProvider.selectedPatient!.last_name}",
|
||||||
|
"fileName": fileName,
|
||||||
|
"id_no": patientManagerProvider.selectedPatient!.id_no,
|
||||||
|
"docfname":
|
||||||
|
"DR. ${profileProvider.user!.fname} ${profileProvider.user!.lname}",
|
||||||
|
"startDate": startDate,
|
||||||
|
"busName": profileProvider.business!.Name,
|
||||||
|
"busAddr": "*TO BE ADDED IN THE FUTURE*",
|
||||||
|
"busNo": profileProvider.business!.contact_no,
|
||||||
|
"busEmail": profileProvider.business!.bus_email,
|
||||||
|
"endDate": endDate,
|
||||||
|
"returnDate": returnDate,
|
||||||
|
"logo_path": profileProvider.business!.logo_path,
|
||||||
|
"sig_path": profileProvider.businessUser!.sig_path,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
var responseAddFiletoDB = await http.post(
|
||||||
|
Uri.parse("${AppEnviroment.baseApiUrl}/patient_files/insert/"),
|
||||||
|
headers: <String, String>{
|
||||||
|
"Content-Type": "application/json; charset=UTF-8"
|
||||||
|
},
|
||||||
|
body: jsonEncode(<String, dynamic>{
|
||||||
|
"file_path":
|
||||||
|
"${patientManagerProvider.selectedPatient!.app_id}/patient_files/$fileName",
|
||||||
|
"file_name": fileName,
|
||||||
|
"app_id": patientManagerProvider.selectedPatient!.app_id
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
if (responseAddFiletoDB.statusCode == 201) {
|
||||||
|
await getPatientDocuments(patientManagerProvider);
|
||||||
|
}
|
||||||
|
}
|
||||||
return response.statusCode;
|
return response.statusCode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import 'package:mzansi_innovation_hub/mih_services/mih_file_services.dart';
|
|||||||
import 'package:mzansi_innovation_hub/mih_services/mih_my_business_user_services.dart';
|
import 'package:mzansi_innovation_hub/mih_services/mih_my_business_user_services.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_notification_services.dart';
|
import 'package:mzansi_innovation_hub/mih_services/mih_notification_services.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_patient_services.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_user_services.dart';
|
import 'package:mzansi_innovation_hub/mih_services/mih_user_services.dart';
|
||||||
import 'package:supertokens_flutter/supertokens.dart';
|
import 'package:supertokens_flutter/supertokens.dart';
|
||||||
import 'package:supertokens_flutter/http.dart' as http;
|
import 'package:supertokens_flutter/http.dart' as http;
|
||||||
@@ -88,14 +87,14 @@ class MIHApiCalls {
|
|||||||
);
|
);
|
||||||
|
|
||||||
//get patient profile
|
//get patient profile
|
||||||
Patient? patient = await MihPatientServices().getPatientDetails(
|
// Patient? patient = await MihPatientServices().getPatientDetails(
|
||||||
uid,
|
// uid,
|
||||||
);
|
// );
|
||||||
if (patient != null) {
|
// if (patient != null) {
|
||||||
patientData = patient;
|
// patientData = patient;
|
||||||
} else {
|
// } else {
|
||||||
patientData = null;
|
// patientData = null;
|
||||||
}
|
// }
|
||||||
|
|
||||||
return HomeArguments(
|
return HomeArguments(
|
||||||
userData, bUserData, busData, patientData, notifi, userPic);
|
userData, bUserData, busData, patientData, notifi, userPic);
|
||||||
|
|||||||
Reference in New Issue
Block a user