Done allergies service
parent
82c2577d36
commit
3ffff9686d
Binary file not shown.
|
After Width: | Height: | Size: 2.5 KiB |
@ -0,0 +1,48 @@
|
|||||||
|
class Allergy {
|
||||||
|
int patientID;
|
||||||
|
int allergyDiseaseType;
|
||||||
|
int allergyDiseaseID;
|
||||||
|
String description;
|
||||||
|
dynamic descriptionN;
|
||||||
|
dynamic remarks;
|
||||||
|
dynamic avgDoctorRatingList;
|
||||||
|
dynamic doctorRatingDetailsList;
|
||||||
|
dynamic notesDoctorRatingList;
|
||||||
|
|
||||||
|
Allergy(
|
||||||
|
{this.patientID,
|
||||||
|
this.allergyDiseaseType,
|
||||||
|
this.allergyDiseaseID,
|
||||||
|
this.description,
|
||||||
|
this.descriptionN,
|
||||||
|
this.remarks,
|
||||||
|
this.avgDoctorRatingList,
|
||||||
|
this.doctorRatingDetailsList,
|
||||||
|
this.notesDoctorRatingList});
|
||||||
|
|
||||||
|
Allergy.fromJson(Map<String, dynamic> json) {
|
||||||
|
patientID = json['PatientID'];
|
||||||
|
allergyDiseaseType = json['AllergyDiseaseType'];
|
||||||
|
allergyDiseaseID = json['AllergyDiseaseID'];
|
||||||
|
description = json['Description'];
|
||||||
|
descriptionN = json['DescriptionN'];
|
||||||
|
remarks = json['Remarks'];
|
||||||
|
avgDoctorRatingList = json['AvgDoctorRatingList'];
|
||||||
|
doctorRatingDetailsList = json['DoctorRatingDetailsList'];
|
||||||
|
notesDoctorRatingList = json['NotesDoctorRatingList'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['PatientID'] = this.patientID;
|
||||||
|
data['AllergyDiseaseType'] = this.allergyDiseaseType;
|
||||||
|
data['AllergyDiseaseID'] = this.allergyDiseaseID;
|
||||||
|
data['Description'] = this.description;
|
||||||
|
data['DescriptionN'] = this.descriptionN;
|
||||||
|
data['Remarks'] = this.remarks;
|
||||||
|
data['AvgDoctorRatingList'] = this.avgDoctorRatingList;
|
||||||
|
data['DoctorRatingDetailsList'] = this.doctorRatingDetailsList;
|
||||||
|
data['NotesDoctorRatingList'] = this.notesDoctorRatingList;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
import 'package:diplomaticquarterapp/config/config.dart';
|
||||||
|
import 'package:diplomaticquarterapp/core/model/Allergy/Allergy.dart';
|
||||||
|
import 'package:diplomaticquarterapp/core/service/base_service.dart';
|
||||||
|
|
||||||
|
class AllergiesService extends BaseService {
|
||||||
|
List<Allergy> allergies = List();
|
||||||
|
|
||||||
|
getAllergies() async {
|
||||||
|
hasError = false;
|
||||||
|
super.error = "";
|
||||||
|
Map<String, dynamic> body = Map();
|
||||||
|
body['isDentalAllowedBackend'] = false;
|
||||||
|
body['OutSA'] = 0;
|
||||||
|
await baseAppClient.post(GET_PATIENT_ALLERGIES,
|
||||||
|
onSuccess: (response, statusCode) async {
|
||||||
|
allergies.clear();
|
||||||
|
response['Patient_Allergies'].forEach((allergy) {
|
||||||
|
allergies.add(Allergy.fromJson(allergy));
|
||||||
|
});
|
||||||
|
}, onFailure: (String error, int statusCode) {
|
||||||
|
hasError = true;
|
||||||
|
super.error = error;
|
||||||
|
}, body: body);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
|
||||||
|
import 'package:diplomaticquarterapp/core/model/Allergy/Allergy.dart';
|
||||||
|
import 'package:diplomaticquarterapp/core/service/medical/AllergiesService.dart';
|
||||||
|
import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart';
|
||||||
|
|
||||||
|
import '../../../locator.dart';
|
||||||
|
|
||||||
|
class AllergiesViewModel extends BaseViewModel {
|
||||||
|
AllergiesService _allergiesService = locator<AllergiesService>();
|
||||||
|
List<Allergy> get allergies => _allergiesService.allergies;
|
||||||
|
|
||||||
|
getAllergies() async {
|
||||||
|
setState(ViewState.Busy);
|
||||||
|
await _allergiesService.getAllergies();
|
||||||
|
if (_allergiesService.hasError) {
|
||||||
|
error = _allergiesService.error;
|
||||||
|
setState(ViewState.Error);
|
||||||
|
} else {
|
||||||
|
setState(ViewState.Idle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,161 @@
|
|||||||
|
import 'package:device_calendar/device_calendar.dart';
|
||||||
|
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
|
||||||
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class DayCheckBoxDialog extends StatefulWidget {
|
||||||
|
final Function(List<DayOfWeek>) onValueSelected;
|
||||||
|
final String title;
|
||||||
|
final List<DayOfWeek> selectedDaysOfWeek;
|
||||||
|
final List<DayOfWeek> daysOfWeek = [
|
||||||
|
DayOfWeek.Monday,
|
||||||
|
DayOfWeek.Tuesday,
|
||||||
|
DayOfWeek.Wednesday,
|
||||||
|
DayOfWeek.Thursday,
|
||||||
|
DayOfWeek.Friday,
|
||||||
|
DayOfWeek.Saturday,
|
||||||
|
DayOfWeek.Sunday,
|
||||||
|
];
|
||||||
|
|
||||||
|
DayCheckBoxDialog(
|
||||||
|
{Key key, this.onValueSelected, this.selectedDaysOfWeek, this.title});
|
||||||
|
|
||||||
|
@override
|
||||||
|
_DayCheckBoxDialogState createState() => _DayCheckBoxDialogState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _DayCheckBoxDialogState extends State<DayCheckBoxDialog> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SimpleDialog(
|
||||||
|
title: Container(
|
||||||
|
width: double.infinity,
|
||||||
|
child: Center(
|
||||||
|
child: Texts(
|
||||||
|
widget.title,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
))),
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
height: widget.daysOfWeek.length > 3
|
||||||
|
? MediaQuery.of(context).size.height * 0.6
|
||||||
|
: null,
|
||||||
|
child: SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Divider(),
|
||||||
|
...List.generate(
|
||||||
|
widget.daysOfWeek.length,
|
||||||
|
(index) => Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
height: 2,
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
children: <Widget>[
|
||||||
|
Expanded(
|
||||||
|
flex: 1,
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () {
|
||||||
|
setState(() {
|
||||||
|
if (widget.selectedDaysOfWeek
|
||||||
|
.contains(widget.daysOfWeek[index]))
|
||||||
|
widget.selectedDaysOfWeek
|
||||||
|
.remove(widget.daysOfWeek[index]);
|
||||||
|
else
|
||||||
|
widget.selectedDaysOfWeek
|
||||||
|
.add(widget.daysOfWeek[index]);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
child: ListTile(
|
||||||
|
title: Text(DateUtil.getDay(widget.daysOfWeek[index])),
|
||||||
|
leading: Checkbox(
|
||||||
|
value: widget.selectedDaysOfWeek
|
||||||
|
.contains(widget.daysOfWeek[index]),
|
||||||
|
onChanged: (value) {
|
||||||
|
setState(() {
|
||||||
|
if (widget.selectedDaysOfWeek
|
||||||
|
.contains(widget.daysOfWeek[index]))
|
||||||
|
widget.selectedDaysOfWeek
|
||||||
|
.remove(widget.daysOfWeek[index]);
|
||||||
|
else
|
||||||
|
widget.selectedDaysOfWeek
|
||||||
|
.add(widget.daysOfWeek[index]);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 5.0,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 5.0,
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
children: <Widget>[
|
||||||
|
Expanded(
|
||||||
|
flex: 1,
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Container(
|
||||||
|
child: Center(
|
||||||
|
child: Texts(
|
||||||
|
TranslationBase.of(context)
|
||||||
|
.cancel
|
||||||
|
.toUpperCase(),
|
||||||
|
color: Colors.red,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
width: 1,
|
||||||
|
height: 30,
|
||||||
|
color: Colors.grey[500],
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
flex: 1,
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () {
|
||||||
|
widget.onValueSelected(widget.selectedDaysOfWeek);
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Center(
|
||||||
|
child: Texts(
|
||||||
|
TranslationBase.of(context).ok,
|
||||||
|
fontWeight: FontWeight.w400,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,54 @@
|
|||||||
|
import 'package:diplomaticquarterapp/core/viewModels/medical/AllergiesViewModel.dart';
|
||||||
|
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
|
||||||
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class AllergiesPage extends StatelessWidget {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return BaseView<AllergiesViewModel>(
|
||||||
|
onModelReady: (model) => model.getAllergies(),
|
||||||
|
builder: (_, model, w) => AppScaffold(
|
||||||
|
isShowAppBar: true,
|
||||||
|
appBarTitle: TranslationBase.of(context).allergies,
|
||||||
|
baseViewModel: model,
|
||||||
|
body: ListView.builder(
|
||||||
|
itemCount: model.allergies.length,
|
||||||
|
itemBuilder: (context, index) => Container(
|
||||||
|
margin: EdgeInsets.all(15),
|
||||||
|
padding: EdgeInsets.all(10),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
shape: BoxShape.rectangle,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Image.asset(
|
||||||
|
'assets/images/new-design/allergiesDetails.png',
|
||||||
|
width: 50,
|
||||||
|
height: 50,
|
||||||
|
fit: BoxFit.cover,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
width: 15,
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Texts(TranslationBase.of(context).remarks+" :"),
|
||||||
|
Texts(TranslationBase.of(context).description + model.allergies[index].description ?? ''),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue