update api call and add doc_office & doctor to
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:patient_manager/components/inputsAndButtons/mihTextInput.dart';
|
||||||
import 'package:patient_manager/components/popUpMessages/mihDeleteMessage.dart';
|
import 'package:patient_manager/components/popUpMessages/mihDeleteMessage.dart';
|
||||||
import 'package:patient_manager/components/popUpMessages/mihErrorMessage.dart';
|
import 'package:patient_manager/components/popUpMessages/mihErrorMessage.dart';
|
||||||
import 'package:patient_manager/components/inputsAndButtons/mihMLTextInput.dart';
|
import 'package:patient_manager/components/inputsAndButtons/mihMLTextInput.dart';
|
||||||
@@ -8,17 +9,27 @@ import 'package:patient_manager/components/popUpMessages/mihSuccessMessage.dart'
|
|||||||
import 'package:patient_manager/env/env.dart';
|
import 'package:patient_manager/env/env.dart';
|
||||||
import 'package:patient_manager/main.dart';
|
import 'package:patient_manager/main.dart';
|
||||||
import 'package:patient_manager/objects/appUser.dart';
|
import 'package:patient_manager/objects/appUser.dart';
|
||||||
|
import 'package:patient_manager/objects/arguments.dart';
|
||||||
|
import 'package:patient_manager/objects/business.dart';
|
||||||
|
import 'package:patient_manager/objects/businessUser.dart';
|
||||||
//import 'package:patient_manager/components/mybutton.dart';
|
//import 'package:patient_manager/components/mybutton.dart';
|
||||||
import 'package:patient_manager/objects/notes.dart';
|
import 'package:patient_manager/objects/notes.dart';
|
||||||
|
import 'package:patient_manager/objects/patients.dart';
|
||||||
import 'package:supertokens_flutter/http.dart' as http;
|
import 'package:supertokens_flutter/http.dart' as http;
|
||||||
|
|
||||||
class BuildNotesList extends StatefulWidget {
|
class BuildNotesList extends StatefulWidget {
|
||||||
final AppUser signedInUser;
|
final AppUser signedInUser;
|
||||||
final List<Note> notes;
|
final List<Note> notes;
|
||||||
|
final Patient selectedPatient;
|
||||||
|
final Business? business;
|
||||||
|
final BusinessUser? businessUser;
|
||||||
const BuildNotesList({
|
const BuildNotesList({
|
||||||
super.key,
|
super.key,
|
||||||
required this.notes,
|
required this.notes,
|
||||||
required this.signedInUser,
|
required this.signedInUser,
|
||||||
|
required this.selectedPatient,
|
||||||
|
required this.business,
|
||||||
|
required this.businessUser,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -27,6 +38,9 @@ class BuildNotesList extends StatefulWidget {
|
|||||||
|
|
||||||
class _BuildNotesListState extends State<BuildNotesList> {
|
class _BuildNotesListState extends State<BuildNotesList> {
|
||||||
final noteTextController = TextEditingController();
|
final noteTextController = TextEditingController();
|
||||||
|
final businessNameController = TextEditingController();
|
||||||
|
final userNameController = TextEditingController();
|
||||||
|
final dateController = TextEditingController();
|
||||||
int indexOn = 0;
|
int indexOn = 0;
|
||||||
final baseAPI = AppEnviroment.baseApiUrl;
|
final baseAPI = AppEnviroment.baseApiUrl;
|
||||||
|
|
||||||
@@ -43,8 +57,23 @@ class _BuildNotesListState extends State<BuildNotesList> {
|
|||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
Navigator.of(context)
|
if (widget.business == null) {
|
||||||
.pushNamed('/patient-profile', arguments: widget.signedInUser);
|
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(() {});
|
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.";
|
||||||
@@ -88,9 +117,12 @@ class _BuildNotesListState extends State<BuildNotesList> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void viewNotePopUp(String title, String note, int noteId) {
|
void viewNotePopUp(Note selectednote) {
|
||||||
setState(() {
|
setState(() {
|
||||||
noteTextController.text = note;
|
noteTextController.text = selectednote.note_text;
|
||||||
|
businessNameController.text = selectednote.doc_office;
|
||||||
|
userNameController.text = selectednote.doctor;
|
||||||
|
dateController.text = selectednote.insert_date;
|
||||||
});
|
});
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
@@ -117,7 +149,7 @@ class _BuildNotesListState extends State<BuildNotesList> {
|
|||||||
height: 25,
|
height: 25,
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
title,
|
selectednote.note_name,
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: MzanziInnovationHub.of(context)!
|
color: MzanziInnovationHub.of(context)!
|
||||||
@@ -128,6 +160,36 @@ class _BuildNotesListState extends State<BuildNotesList> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 25.0),
|
const SizedBox(height: 25.0),
|
||||||
|
SizedBox(
|
||||||
|
width: 700,
|
||||||
|
child: MIHTextField(
|
||||||
|
controller: businessNameController,
|
||||||
|
hintText: "Office",
|
||||||
|
editable: false,
|
||||||
|
required: false,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
SizedBox(
|
||||||
|
width: 700,
|
||||||
|
child: MIHTextField(
|
||||||
|
controller: userNameController,
|
||||||
|
hintText: "Created By",
|
||||||
|
editable: false,
|
||||||
|
required: false,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
|
SizedBox(
|
||||||
|
width: 700,
|
||||||
|
child: MIHTextField(
|
||||||
|
controller: dateController,
|
||||||
|
hintText: "Created",
|
||||||
|
editable: false,
|
||||||
|
required: false,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10.0),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: MIHMLTextField(
|
child: MIHMLTextField(
|
||||||
controller: noteTextController,
|
controller: noteTextController,
|
||||||
@@ -175,7 +237,7 @@ class _BuildNotesListState extends State<BuildNotesList> {
|
|||||||
height: 50,
|
height: 50,
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
deletePatientPopUp(noteId);
|
deletePatientPopUp(selectednote.idpatient_notes);
|
||||||
},
|
},
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
Icons.delete,
|
Icons.delete,
|
||||||
@@ -210,7 +272,7 @@ class _BuildNotesListState extends State<BuildNotesList> {
|
|||||||
}
|
}
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text(
|
title: Text(
|
||||||
widget.notes[index].note_name,
|
"${widget.notes[index].note_name}\n${widget.notes[index].doc_office} - ${widget.notes[index].doctor}",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color:
|
color:
|
||||||
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
@@ -228,10 +290,7 @@ class _BuildNotesListState extends State<BuildNotesList> {
|
|||||||
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
viewNotePopUp(
|
viewNotePopUp(widget.notes[index]);
|
||||||
widget.notes[index].note_name,
|
|
||||||
"${widget.notes[index].insert_date}:\n${widget.notes[index].note_text}",
|
|
||||||
widget.notes[index].idpatient_notes);
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -11,17 +11,26 @@ import 'package:patient_manager/components/inputsAndButtons/mihButton.dart';
|
|||||||
import 'package:patient_manager/env/env.dart';
|
import 'package:patient_manager/env/env.dart';
|
||||||
import 'package:patient_manager/main.dart';
|
import 'package:patient_manager/main.dart';
|
||||||
import 'package:patient_manager/objects/appUser.dart';
|
import 'package:patient_manager/objects/appUser.dart';
|
||||||
|
import 'package:patient_manager/objects/business.dart';
|
||||||
|
import 'package:patient_manager/objects/businessUser.dart';
|
||||||
import 'package:patient_manager/objects/notes.dart';
|
import 'package:patient_manager/objects/notes.dart';
|
||||||
|
import 'package:patient_manager/objects/patients.dart';
|
||||||
import 'package:supertokens_flutter/http.dart' as http;
|
import 'package:supertokens_flutter/http.dart' as http;
|
||||||
|
|
||||||
class PatientNotes extends StatefulWidget {
|
class PatientNotes extends StatefulWidget {
|
||||||
final String patientAppId;
|
final String patientAppId;
|
||||||
|
final Patient selectedPatient;
|
||||||
final AppUser signedInUser;
|
final AppUser signedInUser;
|
||||||
|
final Business? business;
|
||||||
|
final BusinessUser? businessUser;
|
||||||
final String type;
|
final String type;
|
||||||
const PatientNotes({
|
const PatientNotes({
|
||||||
super.key,
|
super.key,
|
||||||
required this.patientAppId,
|
required this.patientAppId,
|
||||||
|
required this.selectedPatient,
|
||||||
required this.signedInUser,
|
required this.signedInUser,
|
||||||
|
required this.business,
|
||||||
|
required this.businessUser,
|
||||||
required this.type,
|
required this.type,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -38,7 +47,7 @@ class _PatientNotesState extends State<PatientNotes> {
|
|||||||
|
|
||||||
Future<List<Note>> fetchNotes(String endpoint) async {
|
Future<List<Note>> fetchNotes(String endpoint) async {
|
||||||
final response = await http.get(Uri.parse(
|
final response = await http.get(Uri.parse(
|
||||||
"${AppEnviroment.baseApiUrl}/notes/patients/${widget.patientAppId}"));
|
"${AppEnviroment.baseApiUrl}/notes/patients/${widget.selectedPatient.app_id}"));
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
Iterable l = jsonDecode(response.body);
|
Iterable l = jsonDecode(response.body);
|
||||||
List<Note> notes =
|
List<Note> notes =
|
||||||
@@ -52,15 +61,22 @@ class _PatientNotesState extends State<PatientNotes> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> addPatientNoteAPICall() async {
|
Future<void> addPatientNoteAPICall() async {
|
||||||
|
String title = "";
|
||||||
|
if (widget.businessUser!.title == "Doctor") {
|
||||||
|
title = "Dr.";
|
||||||
|
}
|
||||||
var response = await http.post(
|
var response = await http.post(
|
||||||
Uri.parse(apiUrlAddNote),
|
Uri.parse("${AppEnviroment.baseApiUrl}/notes/insert/"),
|
||||||
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>{
|
||||||
"note_name": titleController.text,
|
"note_name": titleController.text,
|
||||||
"note_text": noteTextController.text,
|
"note_text": noteTextController.text,
|
||||||
"app_id": widget.patientAppId,
|
"doc_office": widget.business!.Name,
|
||||||
|
"doctor":
|
||||||
|
"$title ${widget.signedInUser.fname} ${widget.signedInUser.lname}",
|
||||||
|
"app_id": widget.selectedPatient.app_id,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
if (response.statusCode == 201) {
|
if (response.statusCode == 201) {
|
||||||
@@ -161,6 +177,7 @@ class _PatientNotesState extends State<PatientNotes> {
|
|||||||
required: true,
|
required: true,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
const SizedBox(height: 30.0),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 300,
|
width: 300,
|
||||||
height: 50,
|
height: 50,
|
||||||
@@ -298,6 +315,9 @@ class _PatientNotesState extends State<PatientNotes> {
|
|||||||
BuildNotesList(
|
BuildNotesList(
|
||||||
notes: notesList,
|
notes: notesList,
|
||||||
signedInUser: widget.signedInUser,
|
signedInUser: widget.signedInUser,
|
||||||
|
selectedPatient: widget.selectedPatient,
|
||||||
|
business: widget.business,
|
||||||
|
businessUser: widget.businessUser,
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user