diff --git a/lib/config/config.dart b/lib/config/config.dart index 1a13d7e9..6031f4e1 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -136,7 +136,7 @@ const POST_ASSESSMENT = 'Services/DoctorApplication.svc/REST/PostAssessment'; const GET_CATEGORISE_PROCEDURE = - 'Services/DoctorApplication.svc/REST/GetCategories'; + 'Services/DoctorApplication.svc/REST/GetProcedure'; var selectedPatientType = 1; diff --git a/lib/core/model/post_prescrition_req_model.dart b/lib/core/model/post_prescrition_req_model.dart index 892854aa..6fc71199 100644 --- a/lib/core/model/post_prescrition_req_model.dart +++ b/lib/core/model/post_prescrition_req_model.dart @@ -7,12 +7,11 @@ class PostPrescriptionReqModel { List prescriptionRequestModel; PostPrescriptionReqModel( - {this.vidaAuthTokenID = - "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMDAyIiwianRpIjoiYTYxZjAyZjItNzUwZS00MTZkLWEzOTQtZTRjZmViZGVjMDE5IiwiZW1haWwiOiIiLCJpZCI6IjEwMDIiLCJOYW1lIjoiVEVNUCAtIERPQ1RPUiIsIkVtcGxveWVlSWQiOiIxNDg1IiwiRmFjaWxpdHlHcm91cElkIjoiMDEwMjY2IiwiRmFjaWxpdHlJZCI6IjE1IiwiUGhhcmFtY3lGYWNpbGl0eUlkIjoiNTUiLCJJU19QSEFSTUFDWV9DT05ORUNURUQiOiJUcnVlIiwiRG9jdG9ySWQiOiIxNDg1IiwiU0VTU0lPTklEIjoiMjE1ODUzNTIiLCJDbGluaWNJZCI6IjMiLCJyb2xlIjoiRE9DVE9SUyIsIm5iZiI6MTYwODUzMDAyNywiZXhwIjoxNjA5Mzk0MDI3LCJpYXQiOjE2MDg1MzAwMjd9.M1NTREPgz5vQH_GTZ_KGb0xQW5HEDs47AtNR3jbqnms", - this.clinicID = 1, - this.episodeID = 200012117, - this.appointmentNo = 2016054573, - this.patientMRN = 3120690, + {this.vidaAuthTokenID, + this.clinicID, + this.episodeID, + this.appointmentNo, + this.patientMRN, this.prescriptionRequestModel}); PostPrescriptionReqModel.fromJson(Map json) { @@ -58,19 +57,20 @@ class PrescriptionRequestModel { String remarks; String icdcode10Id; - PrescriptionRequestModel( - {this.itemId = 4, - this.doseStartDate = "2020-12-20T13:07:41.769Z", - this.duration = 2, - this.dose = 1, - this.doseUnitId = 1, - this.route = 1, - this.frequency = 1, - this.doseTime = 1, - this.covered = true, - this.approvalRequired = true, - this.remarks = "test1", - this.icdcode10Id = "test3"}); + PrescriptionRequestModel({ + this.itemId, + this.doseStartDate, + this.duration, + this.dose, + this.doseUnitId, + this.route, + this.frequency, + this.doseTime, + this.covered, + this.approvalRequired, + this.remarks, + this.icdcode10Id, + }); PrescriptionRequestModel.fromJson(Map json) { itemId = json['itemId']; diff --git a/lib/core/model/procedure/categories_procedure.dart b/lib/core/model/procedure/categories_procedure.dart index e7a7fd40..074d8a1b 100644 --- a/lib/core/model/procedure/categories_procedure.dart +++ b/lib/core/model/procedure/categories_procedure.dart @@ -1,18 +1,90 @@ class CategoriseProcedureModel { - String categoryID; - String categoryName; + List entityList; + int rowcount; + dynamic statusMessage; - CategoriseProcedureModel({this.categoryID, this.categoryName}); + CategoriseProcedureModel( + {this.entityList, this.rowcount, this.statusMessage}); CategoriseProcedureModel.fromJson(Map json) { - categoryID = json['CategoryID']; - categoryName = json['CategoryName']; + if (json['entityList'] != null) { + entityList = new List(); + json['entityList'].forEach((v) { + entityList.add(new EntityList.fromJson(v)); + }); + } + rowcount = json['rowcount']; + statusMessage = json['statusMessage']; + } + + Map toJson() { + final Map data = new Map(); + if (this.entityList != null) { + data['entityList'] = this.entityList.map((v) => v.toJson()).toList(); + } + data['rowcount'] = this.rowcount; + data['statusMessage'] = this.statusMessage; + return data; + } +} + +class EntityList { + bool allowedClinic; + String category; + String categoryID; + String genderValidation; + String group; + String orderedValidation; + dynamic price; + String procedureId; + String procedureName; + String specialPermission; + String subGroup; + String template; + + EntityList( + {this.allowedClinic, + this.category, + this.categoryID, + this.genderValidation, + this.group, + this.orderedValidation, + this.price, + this.procedureId, + this.procedureName, + this.specialPermission, + this.subGroup, + this.template}); + + EntityList.fromJson(Map json) { + allowedClinic = json['allowedClinic']; + category = json['category']; + categoryID = json['categoryID']; + genderValidation = json['genderValidation']; + group = json['group']; + orderedValidation = json['orderedValidation']; + price = json['price']; + procedureId = json['procedureId']; + procedureName = json['procedureName']; + specialPermission = json['specialPermission']; + subGroup = json['subGroup']; + template = json['template']; } Map toJson() { final Map data = new Map(); - data['CategoryID'] = this.categoryID; - data['CategoryName'] = this.categoryName; + data['allowedClinic'] = this.allowedClinic; + data['category'] = this.category; + data['categoryID'] = this.categoryID; + data['genderValidation'] = this.genderValidation; + data['group'] = this.group; + data['orderedValidation'] = this.orderedValidation; + data['price'] = this.price; + data['procedureId'] = this.procedureId; + data['procedureName'] = this.procedureName; + data['specialPermission'] = this.specialPermission; + data['subGroup'] = this.subGroup; + data['template'] = this.template; return data; } } diff --git a/lib/core/service/prescription_service.dart b/lib/core/service/prescription_service.dart index d51fcc3e..65e74dda 100644 --- a/lib/core/service/prescription_service.dart +++ b/lib/core/service/prescription_service.dart @@ -30,19 +30,20 @@ class PrescriptionService extends BaseService { }, body: _prescriptionReqModel.toJson()); } - Future postPrescription() async { + Future postPrescription( + PostPrescriptionReqModel postProcedureReqModel) async { hasError = false; //_prescriptionList.clear(); await baseAppClient.post( - GET_CATEGORISE_PROCEDURE, + POST_PRESCRIPTION_LIST, onSuccess: (dynamic response, int statusCode) { - _prescriptionList - .add(PrescriptionModel.fromJson(response['PrescriptionList'])); + print("Success"); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, + body: postProcedureReqModel.toJson(), ); } } diff --git a/lib/core/service/procedure_service.dart b/lib/core/service/procedure_service.dart index fdc18003..7ffd9310 100644 --- a/lib/core/service/procedure_service.dart +++ b/lib/core/service/procedure_service.dart @@ -13,11 +13,6 @@ class ProcedureService extends BaseService { List get categoriesList => _categoriesList; List procedureslist = List(); - Procedures t1 = Procedures( - category: '02', - procedure: '02011002', - ); - GetProcedureReqModel _getProcedureReqModel = GetProcedureReqModel( clinicId: 0, pageSize: 10, @@ -29,8 +24,17 @@ class ProcedureService extends BaseService { search: ["lab"], ); + GetProcedureReqModel _getProcedureCategoriseReqModel = GetProcedureReqModel( + clinicId: 0, + pageSize: 100, + pageIndex: 1, + patientMRN: 0, + //categoryId: null, + vidaAuthTokenID: + "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxNDg1IiwianRpIjoiZjQ4YTk0OTQtYTczZS00MDI3LWI2MjgtNzc4MjAwMzUyYWEzIiwiZW1haWwiOiJNb2hhbWVkLlJlc3dhbkBjbG91ZHNvbHV0aW9uLXNhLmNvbSIsImlkIjoiMTQ4NSIsIk5hbWUiOiJTSEFLRVJBIFBBUlZFRU4gKFVTRUQgQlkgRVNFUlZJQ0VTKSIsIkVtcGxveWVlSWQiOiIxNDg1IiwiRmFjaWxpdHlHcm91cElkIjoiMDEwMjY2IiwiRmFjaWxpdHlJZCI6IjE1IiwiUGhhcmFtY3lGYWNpbGl0eUlkIjoiNTUiLCJJU19QSEFSTUFDWV9DT05ORUNURUQiOiJUcnVlIiwiRG9jdG9ySWQiOiIxNDg1IiwiU0VTU0lPTklEIjoiMjE1ODUyMTAiLCJDbGluaWNJZCI6IjMiLCJyb2xlIjoiRE9DVE9SUyIsIm5iZiI6MTYwODM2NDU2OCwiZXhwIjoxNjA5MjI4NTY4LCJpYXQiOjE2MDgzNjQ1Njh9.YLbvq5nxPn8o9ZYkcbc5YAX7Jy23Mm0s33oRmE8GHDI", - PostProcedureReqModel _postProcedureReqModel = PostProcedureReqModel(); + search: ["lab"], + ); Future getProcedure() async { hasError = false; @@ -47,17 +51,14 @@ class ProcedureService extends BaseService { 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; - }, - ); + await baseAppClient.post(GET_CATEGORISE_PROCEDURE, + onSuccess: (dynamic response, int statusCode) { + _categoriesList + .add(CategoriseProcedureModel.fromJson(response['ProcedureList'])); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: _getProcedureCategoriseReqModel.toJson()); } Future postProcedure(PostProcedureReqModel postProcedureReqModel) async { diff --git a/lib/core/viewModel/prescription_view_model.dart b/lib/core/viewModel/prescription_view_model.dart index 4ab4b3f7..6c3fe7b2 100644 --- a/lib/core/viewModel/prescription_view_model.dart +++ b/lib/core/viewModel/prescription_view_model.dart @@ -24,11 +24,12 @@ class PrescriptionViewModel extends BaseViewModel { setState(ViewState.Idle); } - Future postPrescription() async { + Future postPrescription( + PostPrescriptionReqModel postProcedureReqModel) async { hasError = false; //_insuranceCardService.clearInsuranceCard(); setState(ViewState.Busy); - await _prescriptionService.postPrescription(); + await _prescriptionService.postPrescription(postProcedureReqModel); if (_prescriptionService.hasError) { error = _prescriptionService.error; setState(ViewState.ErrorLocal); diff --git a/lib/screens/prescription/add_prescription_form.dart b/lib/screens/prescription/add_prescription_form.dart index 40704009..5782a166 100644 --- a/lib/screens/prescription/add_prescription_form.dart +++ b/lib/screens/prescription/add_prescription_form.dart @@ -1,7 +1,12 @@ +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/post_prescrition_req_model.dart'; +import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; import 'package:doctor_app_flutter/models/livecare/transfer_to_admin.dart'; import 'package:doctor_app_flutter/screens/prescription/prescription_warnings.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/shared/app_buttons_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_text_form_field.dart'; @@ -10,6 +15,8 @@ import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; void addPrescriptionForm(context) { + TextEditingController durationController = TextEditingController(); + TextEditingController doseController = TextEditingController(); final GlobalKey _formKey = GlobalKey(); final double spaceBetweenTextFileds = 12; showModalBottomSheet( @@ -122,6 +129,7 @@ void addPrescriptionForm(context) { borderColor: Colors.white, textInputType: TextInputType.number, inputFormatter: ONLY_NUMBERS, + controller: doseController, ), ), SizedBox(height: spaceBetweenTextFileds), @@ -160,11 +168,18 @@ void addPrescriptionForm(context) { border: Border.all( width: 1.0, color: HexColor("#CCCCCC"))), child: AppTextFormField( - labelText: TranslationBase.of(context).duration, - borderColor: Colors.white, - textInputType: TextInputType.number, - inputFormatter: ONLY_NUMBERS, - ), + labelText: TranslationBase.of(context).duration, + borderColor: Colors.white, + textInputType: TextInputType.number, + inputFormatter: ONLY_NUMBERS, + controller: durationController, + validator: (value) { + if (value == null || value == "") + return TranslationBase.of(context) + .emptyMessage; + else + return null; + }), ), SizedBox(height: spaceBetweenTextFileds), Container( @@ -192,8 +207,11 @@ void addPrescriptionForm(context) { title: TranslationBase.of(context).addMedication, onPressed: () { + //prescriptionWarning(context); + postProcedure( + duration: durationController.text, + dose: doseController.text); Navigator.pop(context); - prescriptionWarning(context); }, ), ], @@ -210,3 +228,40 @@ void addPrescriptionForm(context) { ); }); } + +postProcedure({String duration, String dose}) async { + PrescriptionViewModel model = new PrescriptionViewModel(); + PostPrescriptionReqModel postProcedureReqModel = + new PostPrescriptionReqModel(); + List sss = List(); + + postProcedureReqModel.appointmentNo = 2016055175; + postProcedureReqModel.clinicID = 1; + postProcedureReqModel.episodeID = 200012335; + postProcedureReqModel.patientMRN = 1234; + postProcedureReqModel.vidaAuthTokenID = + "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMDAyIiwianRpIjoiOGFjNDRjZGQtOWE0Mi00M2YxLWE2YTQtMWQ4NzBmZmYwNTUyIiwiZW1haWwiOiIiLCJpZCI6IjEwMDIiLCJOYW1lIjoiVEVNUCAtIERPQ1RPUiIsIkVtcGxveWVlSWQiOiI0NzA5IiwiRmFjaWxpdHlHcm91cElkIjoiMDEwMjY2IiwiRmFjaWxpdHlJZCI6IjE1IiwiUGhhcmFtY3lGYWNpbGl0eUlkIjoiNTUiLCJJU19QSEFSTUFDWV9DT05ORUNURUQiOiJUcnVlIiwiRG9jdG9ySWQiOiI0NzA5IiwiU0VTU0lPTklEIjoiMjE1OTU2NDkiLCJDbGluaWNJZCI6IjEiLCJyb2xlIjpbIkRPQ1RPUlMiLCJIRUFEIERPQ1RPUlMiLCJBRE1JTklTVFJBVE9SUyIsIlJFQ0VQVElPTklTVCIsIkVSIE5VUlNFIiwiRVIgUkVDRVBUSU9OSVNUIiwiUEhBUk1BQ1kgQUNDT1VOVCBTVEFGRiIsIlBIQVJNQUNZIE5VUlNFIiwiSU5QQVRJRU5UIFBIQVJNQUNJU1QiLCJBRE1JU1NJT04gU1RBRkYiLCJBUFBST1ZBTCBTVEFGRiIsIkNPTlNFTlQgIiwiTUVESUNBTCBSRVBPUlQgLSBTSUNLIExFQVZFIE1BTkFHRVIiXSwibmJmIjoxNjA4NzM2NjY5LCJleHAiOjE2MDk2MDA2NjksImlhdCI6MTYwODczNjY2OX0.9EDgYrbe5fQA2CvgLdFT4s_PL7hD5R_Qggfpv4lDtUY"; + sss.add(PrescriptionRequestModel( + covered: true, + dose: int.parse(dose), + itemId: 8, + doseUnitId: 1, + route: 1, + frequency: 1, + remarks: "test2", + approvalRequired: true, + icdcode10Id: "test2", + doseTime: 1, + duration: int.parse(duration), + doseStartDate: "2020-12-20T13:07:41.769Z")); + postProcedureReqModel.prescriptionRequestModel = sss; + //postProcedureReqModel.procedures = controlsProcedure; + + await model.postPrescription(postProcedureReqModel); + + if (model.state == ViewState.ErrorLocal) { + helpers.showErrorToast(model.error); + } else { + DrAppToastMsg.showSuccesToast('Medication has been added'); + } +} diff --git a/lib/screens/prescription/prescription_screen.dart b/lib/screens/prescription/prescription_screen.dart index e29bcefc..742cfad8 100644 --- a/lib/screens/prescription/prescription_screen.dart +++ b/lib/screens/prescription/prescription_screen.dart @@ -111,7 +111,7 @@ class _NewPrescriptionScreenState extends State { InkWell( onTap: () { addPrescriptionForm(context); - model.postPrescription(); + //model.postPrescription(); }, child: CircleAvatar( radius: 65, @@ -195,7 +195,7 @@ class _NewPrescriptionScreenState extends State { ), onTap: () { addPrescriptionForm(context); - model.postPrescription(); + //model.postPrescription(); }, ), SizedBox( diff --git a/lib/screens/procedures/procedure_screen.dart b/lib/screens/procedures/procedure_screen.dart index 59cf5bdf..5b6b10f3 100644 --- a/lib/screens/procedures/procedure_screen.dart +++ b/lib/screens/procedures/procedure_screen.dart @@ -414,65 +414,82 @@ void addSelectedProcedure(context) { context: context, builder: (BuildContext bc) { return BaseView( - //onModelReady: (model) => model.getCategories(), + 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: [ + NetworkBaseView( + baseViewModel: model, + 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, + ), + if (model.categoriesList.length != 0) 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, - ), + height: 120.0, + child: ListView.builder( + scrollDirection: Axis.vertical, + shrinkWrap: true, + itemCount: model.categoriesList[0].rowcount, + itemBuilder: (BuildContext ctxt, int index) { + return Container( + child: AppText(model.categoriesList[0] + .entityList[index].procedureName), + ); + }), ), - SizedBox( - height: 280.0, - ), - Container( - margin: - EdgeInsets.all(SizeConfig.widthMultiplier * 5), - child: Wrap( - alignment: WrapAlignment.center, - children: [ - AppButton( - title: - TranslationBase.of(context).addMedication, - onPressed: () { - Navigator.pop(context); - postProcedure(); - }, - ), - ], + SizedBox( + height: 0.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: 80.0, + ), + Container( + margin: + EdgeInsets.all(SizeConfig.widthMultiplier * 5), + child: Wrap( + alignment: WrapAlignment.center, + children: [ + AppButton( + title: + TranslationBase.of(context).addMedication, + onPressed: () { + Navigator.pop(context); + postProcedure(); + }, + ), + ], + ), + ), + ], + ) + ], + ), ), ), ),