Post Allergies service

pull/190/head
Elham Rababah 4 years ago
parent 52554d1aef
commit a3dff8c9f8

@ -85,6 +85,7 @@ const END_CALL_WITH_CHARGE = 'LiveCareApi/DoctorApp/CompleteCallWithCharge';
const GET_ALLERGIES = 'Services/DoctorApplication.svc/REST/GetAllergies';
const GET_MASTER_LOOKUP_LIST = 'Services/DoctorApplication.svc/REST/GetMasterLookUpList';
const POST_ALLERGY = 'Services/DoctorApplication.svc/REST/PostAllergies';
var selectedPatientType = 1;

@ -3,6 +3,7 @@ import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart';
import 'package:doctor_app_flutter/core/service/base/base_service.dart';
import 'package:doctor_app_flutter/models/SOAP/get_Allergies_request_model.dart';
import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart';
import 'package:doctor_app_flutter/models/SOAP/post_allergy_request_model.dart';
class SOAPService extends BaseService {
List<MasterKeyModel> get listOfAllergies => _listOfAllergies;
@ -59,6 +60,17 @@ class SOAPService extends BaseService {
}, body: body);
}
Future postAllergy(PostAllergyRequestModel postAllergyRequestModel) async {
await baseAppClient.post(POST_ALLERGY,
onSuccess: (dynamic response, int statusCode) {
print("Success");
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: postAllergyRequestModel.toJson());
}
setMasterLookupInCorrectArray(entryList, MasterKeysService masterKeys) {
switch (masterKeys) {
case MasterKeysService.Allergies:

@ -4,6 +4,7 @@ import 'package:doctor_app_flutter/core/service/SOAP_service.dart';
import 'package:doctor_app_flutter/models/SOAP/Allergy_model.dart';
import 'package:doctor_app_flutter/models/SOAP/get_Allergies_request_model.dart';
import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart';
import 'package:doctor_app_flutter/models/SOAP/post_allergy_request_model.dart';
import '../../locator.dart';
import 'base_view_model.dart';
@ -48,4 +49,16 @@ class SOAPViewModel extends BaseViewModel {
} else
setState(ViewState.Idle);
}
Future postAllergy(PostAllergyRequestModel postAllergyRequestModel) async {
setState(ViewState.BusyLocal);
await _SOAPService.postAllergy(postAllergyRequestModel);
if (_SOAPService.hasError) {
error = _SOAPService.error;
setState(ViewState.ErrorLocal);
} else
setState(ViewState.Idle);
}
}

@ -0,0 +1,93 @@
class PostAllergyRequestModel {
List<ListHisProgNotePatientAllergyDiseaseVM>
listHisProgNotePatientAllergyDiseaseVM;
PostAllergyRequestModel({this.listHisProgNotePatientAllergyDiseaseVM});
PostAllergyRequestModel.fromJson(Map<String, dynamic> json) {
if (json['listHisProgNotePatientAllergyDiseaseVM'] != null) {
listHisProgNotePatientAllergyDiseaseVM =
new List<ListHisProgNotePatientAllergyDiseaseVM>();
json['listHisProgNotePatientAllergyDiseaseVM'].forEach((v) {
listHisProgNotePatientAllergyDiseaseVM
.add(new ListHisProgNotePatientAllergyDiseaseVM.fromJson(v));
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.listHisProgNotePatientAllergyDiseaseVM != null) {
data['listHisProgNotePatientAllergyDiseaseVM'] = this
.listHisProgNotePatientAllergyDiseaseVM
.map((v) => v.toJson())
.toList();
}
return data;
}
}
class ListHisProgNotePatientAllergyDiseaseVM {
int patientMRN;
int allergyDiseaseType;
int allergyDiseaseId;
int episodeId;
int appointmentNo;
int severity;
bool isChecked;
bool isUpdatedByNurse;
String remarks;
int createdBy;
String createdOn;
int editedBy;
String editedOn;
ListHisProgNotePatientAllergyDiseaseVM(
{this.patientMRN,
this.allergyDiseaseType,
this.allergyDiseaseId,
this.episodeId,
this.appointmentNo,
this.severity,
this.isChecked,
this.isUpdatedByNurse,
this.remarks,
this.createdBy,
this.createdOn,
this.editedBy,
this.editedOn});
ListHisProgNotePatientAllergyDiseaseVM.fromJson(Map<String, dynamic> json) {
patientMRN = json['patientMRN'];
allergyDiseaseType = json['allergyDiseaseType'];
allergyDiseaseId = json['allergyDiseaseId'];
episodeId = json['episodeId'];
appointmentNo = json['appointmentNo'];
severity = json['severity'];
isChecked = json['isChecked'];
isUpdatedByNurse = json['isUpdatedByNurse'];
remarks = json['remarks'];
createdBy = json['createdBy'];
createdOn = json['createdOn'];
editedBy = json['editedBy'];
editedOn = json['editedOn'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['patientMRN'] = this.patientMRN;
data['allergyDiseaseType'] = this.allergyDiseaseType;
data['allergyDiseaseId'] = this.allergyDiseaseId;
data['episodeId'] = this.episodeId;
data['appointmentNo'] = this.appointmentNo;
data['severity'] = this.severity;
data['isChecked'] = this.isChecked;
data['isUpdatedByNurse'] = this.isUpdatedByNurse;
data['remarks'] = this.remarks;
data['createdBy'] = this.createdBy;
data['createdOn'] = this.createdOn;
data['editedBy'] = this.editedBy;
data['editedOn'] = this.editedOn;
return data;
}
}

@ -1,5 +1,7 @@
import 'package:doctor_app_flutter/core/viewModel/doctor_replay_view_model.dart';
import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart';
import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart';
import 'package:doctor_app_flutter/models/SOAP/my_selected_allergy.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/translations_delegate_base.dart';
@ -26,7 +28,8 @@ class _AddSOAPIndexState extends State<AddSOAPIndex>
with TickerProviderStateMixin {
PageController _controller;
int _currentIndex = 0;
List<MySelectedAllergy> myAllergiesList= List();
List<MasterKeyModel> myHistoryList = List();
changePageViewIndex(pageIndex) {
_controller.jumpToPage(pageIndex);
}
@ -60,7 +63,7 @@ class _AddSOAPIndexState extends State<AddSOAPIndex>
padding: const EdgeInsets.all(8.0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
children: <Widget>[
AvatarWidget(
Icon(
patient.genderDescription == "Male"
@ -149,7 +152,7 @@ class _AddSOAPIndexState extends State<AddSOAPIndex>
},
scrollDirection: Axis.horizontal,
children: <Widget>[
SubjectivePage(changePageViewIndex: changePageViewIndex,),
SubjectivePage(changePageViewIndex: changePageViewIndex,myAllergiesList: myAllergiesList,myHistoryList: myHistoryList,),
ObjectivePage(changePageViewIndex: changePageViewIndex,),
AssessmentPage(changePageViewIndex: changePageViewIndex,),
PlanPage(changePageViewIndex: changePageViewIndex,)

@ -119,8 +119,10 @@ class _AddAllergiesWidgetState extends State<AddAllergiesWidget> {
builder: (context) {
return AddAllergies(
addAllergiesFun: (MySelectedAllergy mySelectedAllergy) {
widget.myAllergiesList.add(mySelectedAllergy);
Navigator.of(context).pop();
setState(() {
widget.myAllergiesList.add(mySelectedAllergy);
Navigator.of(context).pop();
});
},);
});
}

@ -1,8 +1,8 @@
import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart';
import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart';
import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart';
import 'package:doctor_app_flutter/models/SOAP/my_selected_allergy.dart';
import 'package:doctor_app_flutter/models/SOAP/post_allergy_request_model.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/patients/profile/SOAP/subjective/add_allergies_widget.dart';
@ -19,8 +19,10 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart';
class SubjectivePage extends StatefulWidget {
final Function changePageViewIndex;
final List<MySelectedAllergy> myAllergiesList;
final List<MasterKeyModel> myHistoryList ;
SubjectivePage({Key key, this.changePageViewIndex});
SubjectivePage({Key key, this.changePageViewIndex, this.myAllergiesList, this.myHistoryList});
@override
_SubjectivePageState createState() => _SubjectivePageState();
@ -30,9 +32,9 @@ class _SubjectivePageState extends State<SubjectivePage> {
bool isChiefExpand = false;
bool isHistoryExpand = false;
bool isAllergiesExpand = false;
List<MySelectedAllergy> myAllergiesList = List();
List<MasterKeyModel> myHistoryList = List();
TextEditingController messageController = TextEditingController();
TextEditingController illnessController = TextEditingController();
TextEditingController complaintsController = TextEditingController();
@override
Widget build(BuildContext context) {
@ -92,10 +94,12 @@ class _SubjectivePageState extends State<SubjectivePage> {
fontWeight: FontWeight.w600,
maxLines: 25,
minLines: 13,
controller: messageController,
controller: complaintsController,
validator: (value) {
if (value == null)
return TranslationBase.of(context).emptyMessage;
return TranslationBase
.of(context)
.emptyMessage;
else
return null;
}),
@ -112,10 +116,12 @@ class _SubjectivePageState extends State<SubjectivePage> {
fontWeight: FontWeight.w600,
maxLines: 25,
minLines: 13,
controller: messageController,
controller: illnessController,
validator: (value) {
if (value == null)
return TranslationBase.of(context).emptyMessage;
return TranslationBase
.of(context)
.emptyMessage;
else
return null;
}),
@ -215,7 +221,7 @@ class _SubjectivePageState extends State<SubjectivePage> {
),
bodyWidget:Column(
children: [
AddAllergiesWidget(myAllergiesList: myAllergiesList,),
AddAllergiesWidget(myAllergiesList: widget.myAllergiesList,),
SizedBox(
height: 30,
),
@ -239,16 +245,52 @@ class _SubjectivePageState extends State<SubjectivePage> {
title: TranslationBase
.of(context)
.next,
onPressed: () {
print( myHistoryList.toString());
widget.changePageViewIndex(1);
onPressed: () async {
addSubjectiveInfo(model: model,
myAllergiesList: widget.myAllergiesList,
myHistoryList: myHistoryList);
},
),
],
),
),
],
),
),
),
),),);
}
addSubjectiveInfo(
{SOAPViewModel model, List<MySelectedAllergy> myAllergiesList, List<
MasterKeyModel> myHistoryList }) async {
PostAllergyRequestModel postAllergyRequestModel = new PostAllergyRequestModel();
widget.myAllergiesList.forEach((allergy) {
if(postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM ==null)
postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM = [];
postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM.add(
ListHisProgNotePatientAllergyDiseaseVM(
allergyDiseaseId: allergy.selectedAllergy.id,
allergyDiseaseType: allergy.selectedAllergy.typeId,
patientMRN: 2500477,
episodeId: 200011502,
appointmentNo: 2016053271,
severity: allergy.selectedAllergySeverity.id,
remarks: allergy.remark,
createdBy: 1485,
createdOn: "2020-08-14T20:37:22.780Z",
editedBy: 1485,
editedOn: "2020-08-14T20:37:22.780Z",
isChecked: false,
isUpdatedByNurse: false
));
});
await model.postAllergy(postAllergyRequestModel);
widget.changePageViewIndex(1);
print(postAllergyRequestModel);
}
}

Loading…
Cancel
Save