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

@ -122,6 +122,8 @@ const POST_ALLERGY = 'Services/DoctorApplication.svc/REST/PostAllergies';
const POST_HISTORY = 'Services/DoctorApplication.svc/REST/PostHistory'; const POST_HISTORY = 'Services/DoctorApplication.svc/REST/PostHistory';
const POST_CHIEF_COMPLAINT = const POST_CHIEF_COMPLAINT =
'Services/DoctorApplication.svc/REST/PostChiefcomplaint'; 'Services/DoctorApplication.svc/REST/PostChiefcomplaint';
const GET_CATEGORISE_PROCEDURE =
'Services/DoctorApplication.svc/REST/GetCategories';
var selectedPatientType = 1; 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 { Future postPrescription() async {
hasError = false; hasError = false;
//_prescriptionList.clear(); //_prescriptionList.clear();
await baseAppClient.post(POST_PRESCRIPTION_LIST, await baseAppClient.post(
onSuccess: (dynamic response, int statusCode) { GET_CATEGORISE_PROCEDURE,
_prescriptionList onSuccess: (dynamic response, int statusCode) {
.add(PrescriptionModel.fromJson(response['PrescriptionList'])); _prescriptionList
}, onFailure: (String error, int statusCode) { .add(PrescriptionModel.fromJson(response['PrescriptionList']));
hasError = true; },
super.error = error; onFailure: (String error, int statusCode) {
}, body: _postPrescriptionReqModel.toJson()); hasError = true;
super.error = error;
},
);
} }
} }

@ -1,12 +1,22 @@
import 'package:doctor_app_flutter/config/config.dart'; 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_model.dart';
import 'package:doctor_app_flutter/core/model/procedure/get_procedure_req_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/model/procedure/post_procedure_req_model.dart';
import 'package:doctor_app_flutter/core/service/base/base_service.dart'; import 'package:doctor_app_flutter/core/service/base/base_service.dart';
import 'package:flutter/foundation.dart';
class ProcedureService extends BaseService { class ProcedureService extends BaseService {
List<GetProcedureModel> _procedureList = List(); List<GetProcedureModel> _procedureList = List();
List<GetProcedureModel> get procedureList => _procedureList; 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( GetProcedureReqModel _getProcedureReqModel = GetProcedureReqModel(
clinicId: 0, clinicId: 0,
@ -34,15 +44,31 @@ class ProcedureService extends BaseService {
}, body: _getProcedureReqModel.toJson()); }, 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; hasError = false;
_procedureList.clear(); _procedureList.clear();
await baseAppClient.post(POST_PROCEDURE_LIST, await baseAppClient.post(POST_PROCEDURE_LIST,
onSuccess: (dynamic response, int statusCode) { onSuccess: (dynamic response, int statusCode) {
_procedureList.add(GetProcedureModel.fromJson(response['ProcedureList'])); print("Success");
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
hasError = true; hasError = true;
super.error = error; 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/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/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/service/procedure_service.dart';
import 'package:doctor_app_flutter/core/viewModel/base_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/base_view_model.dart';
import 'package:doctor_app_flutter/locator.dart'; import 'package:doctor_app_flutter/locator.dart';
@ -8,6 +10,8 @@ class ProcedureViewModel extends BaseViewModel {
bool hasError = false; bool hasError = false;
ProcedureService _procedureService = locator<ProcedureService>(); ProcedureService _procedureService = locator<ProcedureService>();
List<GetProcedureModel> get procedureList => _procedureService.procedureList; List<GetProcedureModel> get procedureList => _procedureService.procedureList;
List<CategoriseProcedureModel> get categoriesList =>
_procedureService.categoriesList;
Future getProcedure() async { Future getProcedure() async {
hasError = false; hasError = false;
@ -20,4 +24,28 @@ class ProcedureViewModel extends BaseViewModel {
} else } else
setState(ViewState.Idle); 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, fontWeight: FontWeight.bold,
), ),
SizedBox( SizedBox(
width: 20, width: 5.0,
), ),
AppText( AppText(
patient.patientId.toString(), patient.patientId.toString(),
@ -111,7 +111,7 @@ class _NewPrescriptionScreenState extends State<NewPrescriptionScreen> {
InkWell( InkWell(
onTap: () { onTap: () {
addPrescriptionForm(context); addPrescriptionForm(context);
//model.postPrescription(); model.postPrescription();
}, },
child: CircleAvatar( child: CircleAvatar(
radius: 65, radius: 65,
@ -195,6 +195,7 @@ class _NewPrescriptionScreenState extends State<NewPrescriptionScreen> {
), ),
onTap: () { onTap: () {
addPrescriptionForm(context); addPrescriptionForm(context);
model.postPrescription();
}, },
), ),
SizedBox( 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/config.dart';
import 'package:doctor_app_flutter/config/size_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/prescription_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/procedure_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/icons_app/doctor_app_icons.dart';
import 'package:doctor_app_flutter/models/patient/patiant_info_model.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/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/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/patients/profile/patient_profile_widget.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/patient_profile_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/Text.dart'; import 'package:doctor_app_flutter/widgets/shared/Text.dart';
@ -24,6 +28,7 @@ class ProcedureScreen extends StatefulWidget {
class _ProcedureScreenState extends State<ProcedureScreen> { class _ProcedureScreenState extends State<ProcedureScreen> {
int testNum = 1; int testNum = 1;
PatiantInformtion patient; PatiantInformtion patient;
TextEditingController procedureController = TextEditingController();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final routeArgs = ModalRoute.of(context).settings.arguments as Map; final routeArgs = ModalRoute.of(context).settings.arguments as Map;
@ -72,7 +77,7 @@ class _ProcedureScreenState extends State<ProcedureScreen> {
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
SizedBox( SizedBox(
width: 20, width: 5.0,
), ),
AppText( AppText(
patient.patientId.toString(), 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) { void addSelectedProcedure(context) {
TextEditingController procedureController = TextEditingController();
showModalBottomSheet( showModalBottomSheet(
context: context, context: context,
builder: (BuildContext bc) { builder: (BuildContext bc) {
return SingleChildScrollView( return BaseView(
child: Container( //onModelReady: (model) => model.getCategories(),
height: 490, builder:
child: Padding( (BuildContext context, ProcedureViewModel model, Widget child) =>
padding: EdgeInsets.all(12.0), SingleChildScrollView(
child: Column( child: Container(
crossAxisAlignment: CrossAxisAlignment.start, height: 490,
children: [ child: Padding(
AppText( padding: EdgeInsets.all(12.0),
'Select Procedure'.toUpperCase(), child: Column(
fontWeight: FontWeight.w900, crossAxisAlignment: CrossAxisAlignment.start,
), children: [
SizedBox( AppText(
height: 9.0, 'Select Procedure'.toUpperCase(),
), fontWeight: FontWeight.w900,
Column( ),
mainAxisAlignment: MainAxisAlignment.spaceBetween, // Text(model.categoriesList[0].categoryName),
children: [ SizedBox(
Container( height: 9.0,
decoration: BoxDecoration( ),
borderRadius: Column(
BorderRadius.all(Radius.circular(6.0)), mainAxisAlignment: MainAxisAlignment.spaceBetween,
border: Border.all( children: [
width: 1.0, color: HexColor("#CCCCCC"))), Container(
child: AppTextFormField( decoration: BoxDecoration(
labelText: 'Add Delected Procedures'.toUpperCase(), borderRadius:
borderColor: Colors.white, BorderRadius.all(Radius.circular(6.0)),
textInputType: TextInputType.text, border: Border.all(
inputFormatter: ONLY_LETTERS, 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(
SizedBox( height: 280.0,
height: 280.0, ),
), Container(
Container( margin:
margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5), EdgeInsets.all(SizeConfig.widthMultiplier * 5),
child: Wrap( child: Wrap(
alignment: WrapAlignment.center, alignment: WrapAlignment.center,
children: <Widget>[ children: <Widget>[
AppButton( AppButton(
title: TranslationBase.of(context).addMedication, title:
// onPressed: () { TranslationBase.of(context).addMedication,
// Navigator.pop(context); onPressed: () {
// prescriptionWarning(context); Navigator.pop(context);
// }, postProcedure();
), },
], ),
],
),
), ),
), ],
], )
) ],
], ),
), ),
), ),
), ),

Loading…
Cancel
Save