personal patient view update
This commit is contained in:
@@ -21,7 +21,7 @@ class BuildFilesList extends StatefulWidget {
|
|||||||
class _BuildFilesListState extends State<BuildFilesList> {
|
class _BuildFilesListState extends State<BuildFilesList> {
|
||||||
int indexOn = 0;
|
int indexOn = 0;
|
||||||
|
|
||||||
void viewFilePopUp(String filename) {
|
void viewFilePopUp(String fileName, String filePath) {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
barrierDismissible: false,
|
barrierDismissible: false,
|
||||||
@@ -44,7 +44,7 @@ class _BuildFilesListState extends State<BuildFilesList> {
|
|||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
filename,
|
fileName,
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: MzanziInnovationHub.of(context)!
|
color: MzanziInnovationHub.of(context)!
|
||||||
@@ -58,14 +58,14 @@ class _BuildFilesListState extends State<BuildFilesList> {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: BuildFileView(
|
child: BuildFileView(
|
||||||
pdfLink:
|
pdfLink:
|
||||||
"${AppEnviroment.baseFileUrl}/mih/$filename")),
|
"${AppEnviroment.baseFileUrl}/mih/$filePath")),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 300,
|
width: 300,
|
||||||
height: 100,
|
height: 100,
|
||||||
child: MyButton(
|
child: MyButton(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
html.window.open(
|
html.window.open(
|
||||||
'${AppEnviroment.baseFileUrl}/mih/$filename',
|
'${AppEnviroment.baseFileUrl}/mih/$filePath',
|
||||||
'download');
|
'download');
|
||||||
},
|
},
|
||||||
buttonText: "Dowload",
|
buttonText: "Dowload",
|
||||||
@@ -135,7 +135,10 @@ class _BuildFilesListState extends State<BuildFilesList> {
|
|||||||
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
viewFilePopUp(widget.files[index].file_name);
|
viewFilePopUp(
|
||||||
|
widget.files[index].file_name,
|
||||||
|
widget.files[index].file_path,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -132,8 +132,68 @@ class _PatientFilesState extends State<PatientFiles> {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
//print("here1");
|
||||||
|
var request = http2.MultipartRequest(
|
||||||
|
'POST', Uri.parse("${AppEnviroment.baseApiUrl}/minio/upload/file/"));
|
||||||
|
request.headers['accept'] = 'application/json';
|
||||||
|
request.fields['app_id'] = widget.selectedPatient.app_id;
|
||||||
|
request.headers['Content-Type'] = 'multipart/form-data';
|
||||||
|
request.files.add(await http2.MultipartFile.fromBytes('file', file.bytes!,
|
||||||
|
filename: file.name.replaceAll(RegExp(r' '), '-')));
|
||||||
|
//print("here2");
|
||||||
|
var response1 = await request.send();
|
||||||
|
//print("here3");
|
||||||
|
//print(response1.statusCode);
|
||||||
|
if (response1.statusCode == 200) {
|
||||||
|
//print("here3");
|
||||||
|
var fname = file.name.replaceAll(RegExp(r' '), '-');
|
||||||
|
var filePath = "${widget.selectedPatient.app_id}/$fname";
|
||||||
|
var response2 = await http.post(
|
||||||
|
Uri.parse("${AppEnviroment.baseApiUrl}/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(() {
|
||||||
|
selectedFileController.clear();
|
||||||
|
futueFiles = fetchFiles();
|
||||||
|
});
|
||||||
|
// end loading circle
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
String message =
|
||||||
|
"The medical certificate ${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.";
|
||||||
|
successPopUp(message);
|
||||||
|
} else {
|
||||||
|
internetConnectionPopUp();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
internetConnectionPopUp();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var request = http2.MultipartRequest('POST', Uri.parse(endpointFileUpload));
|
Future<void> uploadSelectedFilev1(PlatformFile file) async {
|
||||||
|
//var strem = new http.ByteStream.fromBytes(file.bytes.)
|
||||||
|
//start loading circle
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return const Center(
|
||||||
|
child: CircularProgressIndicator(),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
var request = http2.MultipartRequest(
|
||||||
|
'POST', Uri.parse("${AppEnviroment.baseApiUrl}/files/upload/file/"));
|
||||||
|
request.fields['app_id'] = widget.selectedPatient.app_id;
|
||||||
request.headers['Content-Type'] = 'multipart/form-data';
|
request.headers['Content-Type'] = 'multipart/form-data';
|
||||||
request.files.add(await http2.MultipartFile.fromBytes('file', file.bytes!,
|
request.files.add(await http2.MultipartFile.fromBytes('file', file.bytes!,
|
||||||
filename: file.name.replaceAll(RegExp(r' '), '-')));
|
filename: file.name.replaceAll(RegExp(r' '), '-')));
|
||||||
|
|||||||
@@ -2,15 +2,15 @@ class PFile {
|
|||||||
final int idpatient_files;
|
final int idpatient_files;
|
||||||
final String file_path;
|
final String file_path;
|
||||||
final String file_name;
|
final String file_name;
|
||||||
final String app_id;
|
|
||||||
final String insert_date;
|
final String insert_date;
|
||||||
|
final String app_id;
|
||||||
|
|
||||||
const PFile(
|
const PFile(
|
||||||
this.idpatient_files,
|
this.idpatient_files,
|
||||||
this.file_path,
|
this.file_path,
|
||||||
this.file_name,
|
this.file_name,
|
||||||
this.app_id,
|
|
||||||
this.insert_date,
|
this.insert_date,
|
||||||
|
this.app_id,
|
||||||
);
|
);
|
||||||
|
|
||||||
factory PFile.fromJson(dynamic json) {
|
factory PFile.fromJson(dynamic json) {
|
||||||
|
|||||||
Reference in New Issue
Block a user