change to have personal notes view
This commit is contained in:
@@ -9,12 +9,15 @@ import 'package:patient_manager/components/myTextInput.dart';
|
|||||||
import 'package:patient_manager/components/mybutton.dart';
|
import 'package:patient_manager/components/mybutton.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/notes.dart';
|
import 'package:patient_manager/objects/notes.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 int patientIndex;
|
final String patientAppId;
|
||||||
const PatientNotes({super.key, required this.patientIndex});
|
final AppUser signedInUser;
|
||||||
|
const PatientNotes(
|
||||||
|
{super.key, required this.patientAppId, required this.signedInUser});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<PatientNotes> createState() => _PatientNotesState();
|
State<PatientNotes> createState() => _PatientNotesState();
|
||||||
@@ -28,7 +31,8 @@ class _PatientNotesState extends State<PatientNotes> {
|
|||||||
late Future<List<Note>> futueNotes;
|
late Future<List<Note>> futueNotes;
|
||||||
|
|
||||||
Future<List<Note>> fetchNotes(String endpoint) async {
|
Future<List<Note>> fetchNotes(String endpoint) async {
|
||||||
final response = await http.get(Uri.parse(endpoint));
|
final response = await http.get(Uri.parse(
|
||||||
|
"${AppEnviroment.baseApiUrl}/notes/patients/${widget.patientAppId}"));
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
Iterable l = jsonDecode(response.body);
|
Iterable l = jsonDecode(response.body);
|
||||||
List<Note> notes =
|
List<Note> notes =
|
||||||
@@ -50,12 +54,12 @@ class _PatientNotesState extends State<PatientNotes> {
|
|||||||
body: jsonEncode(<String, dynamic>{
|
body: jsonEncode(<String, dynamic>{
|
||||||
"note_name": titleController.text,
|
"note_name": titleController.text,
|
||||||
"note_text": noteTextController.text,
|
"note_text": noteTextController.text,
|
||||||
"patient_id": widget.patientIndex,
|
"patient_id": widget.patientAppId,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
if (response.statusCode == 201) {
|
if (response.statusCode == 201) {
|
||||||
setState(() {
|
setState(() {
|
||||||
futueNotes = fetchNotes(endpoint + widget.patientIndex.toString());
|
futueNotes = fetchNotes(endpoint + widget.patientAppId.toString());
|
||||||
});
|
});
|
||||||
// Navigator.of(context)
|
// Navigator.of(context)
|
||||||
// .pushNamed('/patient-manager', arguments: widget.userEmail);
|
// .pushNamed('/patient-manager', arguments: widget.userEmail);
|
||||||
@@ -212,9 +216,42 @@ class _PatientNotesState extends State<PatientNotes> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<Widget> setIcons() {
|
||||||
|
if (widget.signedInUser.type == "personal") {
|
||||||
|
return [
|
||||||
|
Text(
|
||||||
|
"Notes",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 25,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.secondaryColor()),
|
||||||
|
),
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
return [
|
||||||
|
Text(
|
||||||
|
"Notes",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 25,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.secondaryColor()),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
onPressed: () {
|
||||||
|
addNotePopUp();
|
||||||
|
},
|
||||||
|
icon: Icon(Icons.add,
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.secondaryColor()),
|
||||||
|
)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
futueNotes = fetchNotes(endpoint + widget.patientIndex.toString());
|
futueNotes = fetchNotes(endpoint + widget.patientAppId);
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,27 +281,7 @@ class _PatientNotesState extends State<PatientNotes> {
|
|||||||
child: Column(children: [
|
child: Column(children: [
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: setIcons(),
|
||||||
Text(
|
|
||||||
"Notes",
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 25,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: MzanziInnovationHub.of(context)!
|
|
||||||
.theme
|
|
||||||
.secondaryColor()),
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
onPressed: () {
|
|
||||||
addNotePopUp();
|
|
||||||
},
|
|
||||||
icon: Icon(Icons.add,
|
|
||||||
color: MzanziInnovationHub.of(context)!
|
|
||||||
.theme
|
|
||||||
.secondaryColor()),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 20.0),
|
padding: const EdgeInsets.symmetric(horizontal: 20.0),
|
||||||
|
|||||||
@@ -2,14 +2,14 @@ class Note {
|
|||||||
final int idpatient_notes;
|
final int idpatient_notes;
|
||||||
final String note_name;
|
final String note_name;
|
||||||
final String note_text;
|
final String note_text;
|
||||||
final int patient_id;
|
|
||||||
final String insert_date;
|
final String insert_date;
|
||||||
|
final String app_id;
|
||||||
|
|
||||||
const Note({
|
const Note({
|
||||||
required this.idpatient_notes,
|
required this.idpatient_notes,
|
||||||
required this.note_name,
|
required this.note_name,
|
||||||
required this.note_text,
|
required this.note_text,
|
||||||
required this.patient_id,
|
required this.app_id,
|
||||||
required this.insert_date,
|
required this.insert_date,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -19,15 +19,15 @@ class Note {
|
|||||||
"idpatient_notes": int idpatient_notes,
|
"idpatient_notes": int idpatient_notes,
|
||||||
"note_name": String note_name,
|
"note_name": String note_name,
|
||||||
"note_text": String note_text,
|
"note_text": String note_text,
|
||||||
"patient_id": int patient_id,
|
|
||||||
"insert_date": String insert_date,
|
"insert_date": String insert_date,
|
||||||
|
"app_id": String app_id,
|
||||||
} =>
|
} =>
|
||||||
Note(
|
Note(
|
||||||
idpatient_notes: idpatient_notes,
|
idpatient_notes: idpatient_notes,
|
||||||
note_name: note_name,
|
note_name: note_name,
|
||||||
note_text: note_text,
|
note_text: note_text,
|
||||||
patient_id: patient_id,
|
|
||||||
insert_date: insert_date,
|
insert_date: insert_date,
|
||||||
|
app_id: app_id,
|
||||||
),
|
),
|
||||||
_ => throw const FormatException('Failed to load album.'),
|
_ => throw const FormatException('Failed to load album.'),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -26,8 +26,10 @@ class PatientView extends StatefulWidget {
|
|||||||
class _PatientViewState extends State<PatientView> {
|
class _PatientViewState extends State<PatientView> {
|
||||||
Future<Patient?> fetchPatient() async {
|
Future<Patient?> fetchPatient() async {
|
||||||
//print("Patien manager page: $endpoint");
|
//print("Patien manager page: $endpoint");
|
||||||
final response = await http.get(Uri.parse(
|
var patientAppId = widget.signedInUser.app_id;
|
||||||
"${AppEnviroment.baseApiUrl}/patients/${widget.signedInUser.app_id}"));
|
|
||||||
|
final response = await http
|
||||||
|
.get(Uri.parse("${AppEnviroment.baseApiUrl}/patients/$patientAppId"));
|
||||||
// print("Here");
|
// print("Here");
|
||||||
// print("Body: ${response.body}");
|
// print("Body: ${response.body}");
|
||||||
// print("Code: ${response.statusCode}");
|
// print("Code: ${response.statusCode}");
|
||||||
@@ -91,7 +93,8 @@ class _PatientViewState extends State<PatientView> {
|
|||||||
SizedBox(
|
SizedBox(
|
||||||
width: 650,
|
width: 650,
|
||||||
child: PatientNotes(
|
child: PatientNotes(
|
||||||
patientIndex: snapshot.data!.idpatients,
|
patientAppId: snapshot.data!.app_id,
|
||||||
|
signedInUser: widget.signedInUser,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
|
|||||||
Reference in New Issue
Block a user