post procedure

pull/201/head
hussam al-habibeh 4 years ago
parent fb962acbc0
commit c7bfe24207

@ -83,13 +83,12 @@ class BaseAppClient {
onFailure('Error While Fetching data', statusCode);
} else {
var parsed = json.decode(response.body.toString());
// if (!parsed['IsAuthenticated']) {
// // TODO: return it back when IsAuthenticated work fine in all service
// // await helpers.logout();
//
// helpers.showErrorToast('Your session expired Please login agian');
// } else
if (parsed['MessageStatus'] == 1) {
if (!parsed['IsAuthenticated']) {
// TODO: return it back when IsAuthenticated work fine in all service
// await helpers.logout();
//
// helpers.showErrorToast('Your session expired Please login agian');
} else if (parsed['MessageStatus'] == 1) {
onSuccess(parsed, statusCode);
} else {
String error =
@ -102,8 +101,8 @@ class BaseAppClient {
if (parsed["ValidationErrors"]["ValidationErrors"] != null &&
parsed["ValidationErrors"]["ValidationErrors"].length != 0) {
for (var i = 0;
i < parsed["ValidationErrors"]["ValidationErrors"].length;
i++) {
i < parsed["ValidationErrors"]["ValidationErrors"].length;
i++) {
error = error +
parsed["ValidationErrors"]["ValidationErrors"][i]
["Messages"][0] +

@ -122,6 +122,8 @@ const POST_ALLERGY = 'Services/DoctorApplication.svc/REST/PostAllergies';
const POST_HISTORY = 'Services/DoctorApplication.svc/REST/PostHistory';
const POST_CHIEF_COMPLAINT =
'Services/DoctorApplication.svc/REST/PostChiefcomplaint';
const GET_CATEGORISE_PROCEDURE =
'Services/DoctorApplication.svc/REST/GetCategories';
var selectedPatientType = 1;

@ -0,0 +1,18 @@
class CategoriseProcedureModel {
String categoryID;
String categoryName;
CategoriseProcedureModel({this.categoryID, this.categoryName});
CategoriseProcedureModel.fromJson(Map<String, dynamic> json) {
categoryID = json['CategoryID'];
categoryName = json['CategoryName'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['CategoryID'] = this.categoryID;
data['CategoryName'] = this.categoryName;
return data;
}
}

@ -33,13 +33,16 @@ class PrescriptionService extends BaseService {
Future postPrescription() async {
hasError = false;
//_prescriptionList.clear();
await baseAppClient.post(POST_PRESCRIPTION_LIST,
onSuccess: (dynamic response, int statusCode) {
_prescriptionList
.add(PrescriptionModel.fromJson(response['PrescriptionList']));
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: _postPrescriptionReqModel.toJson());
await baseAppClient.post(
GET_CATEGORISE_PROCEDURE,
onSuccess: (dynamic response, int statusCode) {
_prescriptionList
.add(PrescriptionModel.fromJson(response['PrescriptionList']));
},
onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
},
);
}
}

@ -1,12 +1,22 @@
import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/core/model/procedure/categories_procedure.dart';
import 'package:doctor_app_flutter/core/model/procedure/get_procedure_model.dart';
import 'package:doctor_app_flutter/core/model/procedure/get_procedure_req_model.dart';
import 'package:doctor_app_flutter/core/model/procedure/post_procedure_req_model.dart';
import 'package:doctor_app_flutter/core/service/base/base_service.dart';
import 'package:flutter/foundation.dart';
class ProcedureService extends BaseService {
List<GetProcedureModel> _procedureList = List();
List<GetProcedureModel> get procedureList => _procedureList;
List<CategoriseProcedureModel> _categoriesList = List();
List<CategoriseProcedureModel> get categoriesList => _categoriesList;
List<Procedures> procedureslist = List();
Procedures t1 = Procedures(
category: '02',
procedure: '02011002',
);
GetProcedureReqModel _getProcedureReqModel = GetProcedureReqModel(
clinicId: 0,
@ -34,15 +44,31 @@ class ProcedureService extends BaseService {
}, body: _getProcedureReqModel.toJson());
}
Future postProcedure() async {
Future getCategories() async {
hasError = false;
_categoriesList.clear();
await baseAppClient.post(
GET_CATEGORISE_PROCEDURE,
onSuccess: (dynamic response, int statusCode) {
_categoriesList
.add(CategoriseProcedureModel.fromJson(response['listCategories']));
},
onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
},
);
}
Future postProcedure(PostProcedureReqModel postProcedureReqModel) async {
hasError = false;
_procedureList.clear();
await baseAppClient.post(POST_PROCEDURE_LIST,
onSuccess: (dynamic response, int statusCode) {
_procedureList.add(GetProcedureModel.fromJson(response['ProcedureList']));
print("Success");
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: _postProcedureReqModel.toJson());
}, body: postProcedureReqModel.toJson());
}
}

@ -1,5 +1,7 @@
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/model/procedure/categories_procedure.dart';
import 'package:doctor_app_flutter/core/model/procedure/get_procedure_model.dart';
import 'package:doctor_app_flutter/core/model/procedure/post_procedure_req_model.dart';
import 'package:doctor_app_flutter/core/service/procedure_service.dart';
import 'package:doctor_app_flutter/core/viewModel/base_view_model.dart';
import 'package:doctor_app_flutter/locator.dart';
@ -8,6 +10,8 @@ class ProcedureViewModel extends BaseViewModel {
bool hasError = false;
ProcedureService _procedureService = locator<ProcedureService>();
List<GetProcedureModel> get procedureList => _procedureService.procedureList;
List<CategoriseProcedureModel> get categoriesList =>
_procedureService.categoriesList;
Future getProcedure() async {
hasError = false;
@ -20,4 +24,28 @@ class ProcedureViewModel extends BaseViewModel {
} else
setState(ViewState.Idle);
}
Future getCategories() async {
hasError = false;
//_insuranceCardService.clearInsuranceCard();
setState(ViewState.Busy);
await _procedureService.getCategories();
if (_procedureService.hasError) {
error = _procedureService.error;
setState(ViewState.ErrorLocal);
} else
setState(ViewState.Idle);
}
Future postProcedure(PostProcedureReqModel postProcedureReqModel) async {
hasError = false;
//_insuranceCardService.clearInsuranceCard();
setState(ViewState.Busy);
await _procedureService.postProcedure(postProcedureReqModel);
if (_procedureService.hasError) {
error = _procedureService.error;
setState(ViewState.ErrorLocal);
} else
setState(ViewState.Idle);
}
}

@ -76,7 +76,7 @@ class _NewPrescriptionScreenState extends State<NewPrescriptionScreen> {
fontWeight: FontWeight.bold,
),
SizedBox(
width: 20,
width: 5.0,
),
AppText(
patient.patientId.toString(),
@ -111,7 +111,7 @@ class _NewPrescriptionScreenState extends State<NewPrescriptionScreen> {
InkWell(
onTap: () {
addPrescriptionForm(context);
//model.postPrescription();
model.postPrescription();
},
child: CircleAvatar(
radius: 65,
@ -195,6 +195,7 @@ class _NewPrescriptionScreenState extends State<NewPrescriptionScreen> {
),
onTap: () {
addPrescriptionForm(context);
model.postPrescription();
},
),
SizedBox(

@ -1,10 +1,14 @@
import 'package:doctor_app_flutter/client/base_app_client.dart';
import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/config/size_config.dart';
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/model/procedure/post_procedure_req_model.dart';
import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart';
import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart';
import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/patients/profile/patient_profile_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/Text.dart';
@ -24,6 +28,7 @@ class ProcedureScreen extends StatefulWidget {
class _ProcedureScreenState extends State<ProcedureScreen> {
int testNum = 1;
PatiantInformtion patient;
TextEditingController procedureController = TextEditingController();
@override
Widget build(BuildContext context) {
final routeArgs = ModalRoute.of(context).settings.arguments as Map;
@ -72,7 +77,7 @@ class _ProcedureScreenState extends State<ProcedureScreen> {
fontWeight: FontWeight.bold,
),
SizedBox(
width: 20,
width: 5.0,
),
AppText(
patient.patientId.toString(),
@ -376,62 +381,99 @@ class _ProcedureScreenState extends State<ProcedureScreen> {
}
}
postProcedure({ProcedureViewModel model}) async {
model = new ProcedureViewModel();
PostProcedureReqModel postProcedureReqModel = new PostProcedureReqModel();
List<Controls> controls = List();
List<Procedures> controlsProcedure = List();
postProcedureReqModel.appointmentNo = 2016054575;
postProcedureReqModel.episodeID = 200012166;
postProcedureReqModel.patientMRN = 3120725;
postProcedureReqModel.vidaAuthTokenID =
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxNDg1IiwianRpIjoiZjQ4YTk0OTQtYTczZS00MDI3LWI2MjgtNzc4MjAwMzUyYWEzIiwiZW1haWwiOiJNb2hhbWVkLlJlc3dhbkBjbG91ZHNvbHV0aW9uLXNhLmNvbSIsImlkIjoiMTQ4NSIsIk5hbWUiOiJTSEFLRVJBIFBBUlZFRU4gKFVTRUQgQlkgRVNFUlZJQ0VTKSIsIkVtcGxveWVlSWQiOiIxNDg1IiwiRmFjaWxpdHlHcm91cElkIjoiMDEwMjY2IiwiRmFjaWxpdHlJZCI6IjE1IiwiUGhhcmFtY3lGYWNpbGl0eUlkIjoiNTUiLCJJU19QSEFSTUFDWV9DT05ORUNURUQiOiJUcnVlIiwiRG9jdG9ySWQiOiIxNDg1IiwiU0VTU0lPTklEIjoiMjE1ODUyMTAiLCJDbGluaWNJZCI6IjMiLCJyb2xlIjoiRE9DVE9SUyIsIm5iZiI6MTYwODM2NDU2OCwiZXhwIjoxNjA5MjI4NTY4LCJpYXQiOjE2MDgzNjQ1Njh9.YLbvq5nxPn8o9ZYkcbc5YAX7Jy23Mm0s33oRmE8GHDI';
controls.add(
Controls(code: 'Remarks', controlValue: 'Testing'),
);
controlsProcedure.add(
Procedures(category: "02", procedure: "02011002", controls: controls));
postProcedureReqModel.procedures = controlsProcedure;
await model.postProcedure(postProcedureReqModel);
DrAppToastMsg.showSuccesToast('Procedure had been added');
if (model.state == ViewState.ErrorLocal) {
helpers.showErrorToast(model.error);
}
}
void addSelectedProcedure(context) {
TextEditingController procedureController = TextEditingController();
showModalBottomSheet(
context: context,
builder: (BuildContext bc) {
return SingleChildScrollView(
child: Container(
height: 490,
child: Padding(
padding: EdgeInsets.all(12.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
AppText(
'Select Procedure'.toUpperCase(),
fontWeight: FontWeight.w900,
),
SizedBox(
height: 9.0,
),
Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
decoration: BoxDecoration(
borderRadius:
BorderRadius.all(Radius.circular(6.0)),
border: Border.all(
width: 1.0, color: HexColor("#CCCCCC"))),
child: AppTextFormField(
labelText: 'Add Delected Procedures'.toUpperCase(),
borderColor: Colors.white,
textInputType: TextInputType.text,
inputFormatter: ONLY_LETTERS,
return BaseView(
//onModelReady: (model) => model.getCategories(),
builder:
(BuildContext context, ProcedureViewModel model, Widget child) =>
SingleChildScrollView(
child: Container(
height: 490,
child: Padding(
padding: EdgeInsets.all(12.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
AppText(
'Select Procedure'.toUpperCase(),
fontWeight: FontWeight.w900,
),
// Text(model.categoriesList[0].categoryName),
SizedBox(
height: 9.0,
),
Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
decoration: BoxDecoration(
borderRadius:
BorderRadius.all(Radius.circular(6.0)),
border: Border.all(
width: 1.0, color: HexColor("#CCCCCC"))),
child: AppTextFormField(
labelText: 'Add Delected Procedures'.toUpperCase(),
borderColor: Colors.white,
textInputType: TextInputType.text,
inputFormatter: ONLY_LETTERS,
controller: procedureController,
),
),
),
SizedBox(
height: 280.0,
),
Container(
margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5),
child: Wrap(
alignment: WrapAlignment.center,
children: <Widget>[
AppButton(
title: TranslationBase.of(context).addMedication,
// onPressed: () {
// Navigator.pop(context);
// prescriptionWarning(context);
// },
),
],
SizedBox(
height: 280.0,
),
Container(
margin:
EdgeInsets.all(SizeConfig.widthMultiplier * 5),
child: Wrap(
alignment: WrapAlignment.center,
children: <Widget>[
AppButton(
title:
TranslationBase.of(context).addMedication,
onPressed: () {
Navigator.pop(context);
postProcedure();
},
),
],
),
),
),
],
)
],
],
)
],
),
),
),
),

Loading…
Cancel
Save