Create Doctor Response working fine

merge-requests/780/head
Elham Rababh 3 years ago
parent bf8ac21122
commit 854f42ce96

@ -1,8 +1,9 @@
import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/core/service/base/base_service.dart';
import 'package:doctor_app_flutter/models/doctor/list_gt_my_patients_question_model.dart';
import 'package:doctor_app_flutter/models/doctor/replay/request_create_doctor_response.dart';
import 'package:doctor_app_flutter/models/doctor/request_add_referred_doctor_remarks.dart';
import 'package:doctor_app_flutter/models/doctor/request_doctor_reply.dart';
import 'package:doctor_app_flutter/models/doctor/replay/request_doctor_reply.dart';
import 'package:doctor_app_flutter/models/patient/my_referral/my_referral_patient_model.dart';
import 'package:doctor_app_flutter/models/patient/request_my_referral_patient_model.dart';
@ -59,4 +60,19 @@ class DoctorReplyService extends BaseService {
},
);
}
Future createDoctorResponse(
CreateDoctorResponseModel createDoctorResponseModel) async {
hasError = false;
await baseAppClient.post(
CREATE_DOCTOR_RESPONSE,
body: createDoctorResponseModel.toJson(),
onSuccess: (dynamic body, int statusCode) {
print("succsss");
},
onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
},
);
}
}

@ -1,6 +1,7 @@
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/service/home/doctor_reply_service.dart';
import 'package:doctor_app_flutter/models/doctor/list_gt_my_patients_question_model.dart';
import 'package:doctor_app_flutter/models/doctor/replay/request_create_doctor_response.dart';
import '../../locator.dart';
import 'base_view_model.dart';
@ -31,4 +32,25 @@ class DoctorReplayViewModel extends BaseViewModel {
} else
setState(ViewState.Idle);
}
Future createDoctorResponse(
String response, ListGtMyPatientsQuestions model) async {
await getDoctorProfile();
CreateDoctorResponseModel createDoctorResponseModel =
CreateDoctorResponseModel(
transactionNo: model.transactionNo.toString(),
doctorResponse: response,
infoStatus: 3,
createdBy:this.doctorProfile.doctorID,
infoEnteredBy: this.doctorProfile.doctorID,
setupID:"010266"
);
setState(ViewState.BusyLocal);
await _doctorReplyService.createDoctorResponse(createDoctorResponseModel);
if (_doctorReplyService.hasError) {
error = _doctorReplyService.error;
setState(ViewState.ErrorLocal);
} else
setState(ViewState.Idle);
}
}

@ -0,0 +1,48 @@
class CreateDoctorResponseModel {
String setupID;
int projectID;
String transactionNo;
int infoEnteredBy;
int infoStatus;
int createdBy;
int editedBy;
String doctorResponse;
int doctorID;
CreateDoctorResponseModel(
{this.setupID,
this.projectID,
this.transactionNo,
this.infoEnteredBy,
this.infoStatus,
this.createdBy,
this.editedBy,
this.doctorResponse,
this.doctorID});
CreateDoctorResponseModel.fromJson(Map<String, dynamic> json) {
setupID = json['SetupID'];
projectID = json['ProjectID'];
transactionNo = json['TransactionNo'];
infoEnteredBy = json['InfoEnteredBy'];
infoStatus = json['InfoStatus'];
createdBy = json['CreatedBy'];
editedBy = json['EditedBy'];
doctorResponse = json['DoctorResponse'];
doctorID = json['DoctorID'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['SetupID'] = this.setupID;
data['ProjectID'] = this.projectID;
data['TransactionNo'] = this.transactionNo;
data['InfoEnteredBy'] = this.infoEnteredBy;
data['InfoStatus'] = this.infoStatus;
data['CreatedBy'] = this.createdBy;
data['EditedBy'] = this.editedBy;
data['DoctorResponse'] = this.doctorResponse;
data['DoctorID'] = this.doctorID;
return data;
}
}

@ -1,10 +1,16 @@
import 'package:doctor_app_flutter/config/size_config.dart';
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/viewModel/doctor_replay_view_model.dart';
import 'package:doctor_app_flutter/models/doctor/list_gt_my_patients_question_model.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/util/date-utils.dart';
import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart';
import 'package:doctor_app_flutter/util/helpers.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/shared/TextFields.dart';
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
@ -220,61 +226,61 @@ class DoctorReplayChat extends StatelessWidget {
),
),
// Positioned(
// bottom: 0,
// child: Container(
// width:MediaQuery.of(context).size.width * 1,
// // height: MediaQuery.of(context).size.height * 0.12,
// child: Column(
// mainAxisSize: MainAxisSize.min,
// children: <Widget>[
// FractionallySizedBox(
// child: Container(
//
// child: TextFields(
// borderRadius: 0,
// hintText: TranslationBase
// .of(context)
// .typeHereToReply,
// fontSize: 13.5,
//
// suffixIcon: FontAwesomeIcons.arrowRight,
// suffixIconColor: Colors.green,
// onSuffixTap: ()async {
// GifLoaderDialogUtils.showMyDialog(context);
// await model.replay(msgController.text, reply);
// if(model.state == ViewState.ErrorLocal) {
// Helpers.showErrorToast("An error happened while you are replaying");
// } else {
// DrAppToastMsg.showSuccesToast("Thank you for your replay ");
// await previousModel.getDoctorReply();
// Navigator.pop(context);
// }
// GifLoaderDialogUtils.hideDialog(context);
//
//
//
//
// },
// // hintColor: Colors.black,
// fontWeight: FontWeight.w600,
// maxLines: 50,
// minLines: 3,
// controller: msgController,
// validator: (value) {
// if (value == null || value == "")
// return TranslationBase.of(context)
// .emptyMessage;
// else
// return null;
// }),
//
// ),
// ),
// ],
// ),
// ),
// )
Positioned(
bottom: 0,
child: Container(
width:MediaQuery.of(context).size.width * 1,
height: MediaQuery.of(context).size.height * 0.12,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
FractionallySizedBox(
child: Container(
child: TextFields(
borderRadius: 0,
hintText: TranslationBase
.of(context)
.typeHereToReply,
fontSize: 13.5,
suffixIcon: FontAwesomeIcons.arrowRight,
suffixIconColor: Colors.green,
onSuffixTap: ()async {
GifLoaderDialogUtils.showMyDialog(context);
await model.createDoctorResponse(msgController.text, reply);
if(model.state == ViewState.ErrorLocal) {
Helpers.showErrorToast(model.error);
} else {
DrAppToastMsg.showSuccesToast("Thank you for your replay ");
await previousModel.getDoctorReply();
Navigator.pop(context);
}
GifLoaderDialogUtils.hideDialog(context);
},
// hintColor: Colors.black,
fontWeight: FontWeight.w600,
maxLines: 50,
minLines: 3,
controller: msgController,
validator: (value) {
if (value == null || value == "")
return TranslationBase.of(context)
.emptyMessage;
else
return null;
}),
),
),
],
),
),
)
],

Loading…
Cancel
Save