Get Clinic List API Implemented, Architecture for HTTP requests implemented

merge-requests/2/head
Haroon Amjad 4 years ago
parent a0173c5b4d
commit 9eb9f01dbd

@ -1,9 +1,35 @@
import 'dart:io';
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/models/Request.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
const MAX_SMALL_SCREEN = 660;
const BASE_URL = '';
const BASE_URL = 'https://hmgwebservices.com/'; // Production Environment
//const BASE_URL = 'https://uat.hmgwebservices.com/'; // UAT Environment
//URL to get clinic list
const GET_CLINICS_LIST_URL = "Services/lists.svc/REST/GetClinicCentralized";
class AppGlobal {
static var context;
AppSharedPreferences sharedPref = AppSharedPreferences();
Request getPublicRequest() {
Request request = new Request();
request.VersionID = 5.3; //3.6;
request.Channel = 3;
// request.LanguageID = await sharedPref.getString(APP_LANGUAGE);
request.IPAdress = "10.20.10.20";
request.generalid = 'Cs2020@2016\$2958';
request.PatientOutSA = 0;
request.SessionID = null;
request.isDentalAllowedBackend = false;
request.DeviceTypeID = Platform.isIOS ? 1 : 2;
return request;
}
}

@ -0,0 +1,77 @@
class ListClinicCentralized {
int clinicID;
String clinicDescription;
Null clinicDescriptionN;
int age;
int gender;
bool isLiveCareClinicAndOnline;
int liveCareClinicID;
int liveCareServiceID;
ListClinicCentralized(
{this.clinicID,
this.clinicDescription,
this.clinicDescriptionN,
this.age,
this.gender,
this.isLiveCareClinicAndOnline,
this.liveCareClinicID,
this.liveCareServiceID});
ListClinicCentralized.fromJson(Map<String, dynamic> json) {
clinicID = json['ClinicID'];
clinicDescription = json['ClinicDescription'];
clinicDescriptionN = json['ClinicDescriptionN'];
age = json['Age'];
gender = json['Gender'];
isLiveCareClinicAndOnline = json['IsLiveCareClinicAndOnline'];
liveCareClinicID = json['LiveCareClinicID'];
liveCareServiceID = json['LiveCareServiceID'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['ClinicID'] = this.clinicID;
data['ClinicDescription'] = this.clinicDescription;
data['ClinicDescriptionN'] = this.clinicDescriptionN;
data['Age'] = this.age;
data['Gender'] = this.gender;
data['IsLiveCareClinicAndOnline'] = this.isLiveCareClinicAndOnline;
data['LiveCareClinicID'] = this.liveCareClinicID;
data['LiveCareServiceID'] = this.liveCareServiceID;
return data;
}
}
class ListGetBookScheduleConfigsList {
int iD;
String description;
Null descriptionN;
bool value;
bool isActive;
ListGetBookScheduleConfigsList(
{this.iD,
this.description,
this.descriptionN,
this.value,
this.isActive});
ListGetBookScheduleConfigsList.fromJson(Map<String, dynamic> json) {
iD = json['ID'];
description = json['Description'];
descriptionN = json['DescriptionN'];
value = json['Value'];
isActive = json['IsActive'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['ID'] = this.iD;
data['Description'] = this.description;
data['DescriptionN'] = this.descriptionN;
data['Value'] = this.value;
data['IsActive'] = this.isActive;
return data;
}
}

@ -0,0 +1,33 @@
class Request {
var ClinicID;
var PatientOutSA;
var PatientID;
var ProjectID;
var LanguageID;
var DeviceTypeID;
var AppointmentNo;
var IPAdress;
var VersionID;
var Channel;
var PatientTypeID;
var PatientType;
var isDentalAllowedBackend;
var IsIrisPrescription;
var TokenID;
var SessionID;
var PatientIdentificationID;
var PatientMobileNumber;
var BookedBy;
var Latitude;
var Longitude;
var OutSA;
var Note;
var IsActiveAppointment;
var RequestType;
var InvoiceNo;
var EncounterType;
var generalid;
var ServiceID;
var StrAppointmentDate;
var SKU;
}

@ -1,3 +1,6 @@
import 'package:diplomaticquarterapp/models/Clinics/ClinicListResponse.dart';
import 'package:diplomaticquarterapp/pages/BookAppointment/Search.dart';
import 'package:diplomaticquarterapp/services/clinic_services/get_clinic_service.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:flutter/material.dart';
@ -8,7 +11,15 @@ class SearchByClinic extends StatefulWidget {
class _SearchByClinicState extends State<SearchByClinic> {
bool nearestAppo = false;
String dropdownValue = 'Select Clinic';
String dropdownValue = null;
List<ListClinicCentralized> clinicsList = [];
@override
void initState() {
// TODO: implement initState
getClinicsList();
super.initState();
}
@override
Widget build(BuildContext context) {
@ -47,16 +58,18 @@ class _SearchByClinicState extends State<SearchByClinic> {
width: MediaQuery.of(context).size.width,
child: DropdownButtonHideUnderline(
child: DropdownButton<String>(
hint: new Text("Select Clinic"),
value: dropdownValue,
items: <String>['Select Clinic', 'A', 'B', 'C', 'D']
.map((String value) {
items: clinicsList
.map((ListClinicCentralized clinicSelected) {
return new DropdownMenuItem<String>(
value: value,
child: new Text(value),
// value: dropdownValue,
child: new Text(clinicSelected.clinicDescription),
);
}).toList(),
onChanged: (String newValue) {
onChanged: (newValue) {
setState(() {
print(newValue);
dropdownValue = newValue;
});
},
@ -66,4 +79,31 @@ class _SearchByClinicState extends State<SearchByClinic> {
),
);
}
getClinicsList() {
ClinicListService service = new ClinicListService();
service.getClinicsList().then((res) {
if (res['MessageStatus'] == 1) {
setState(() {
res['ListClinicCentralized'].forEach((v) {
clinicsList.add(new ListClinicCentralized.fromJson(v));
});
clinicsList.forEach((v) {
print(v.clinicID);
});
});
} else {
// handel error
setState(() {
// projectsList = ListProject;
});
}
}).catchError((err) {
setState(() {
// projectsList = ListProject;
});
print(err);
});
}
}

@ -54,7 +54,7 @@ class BookedButtons {
}
];
// static getContext(context) {
// BookedButtons.context = context;
// }
static setContext(context) {
BookedButtons.context = context;
}
}

@ -23,7 +23,7 @@ class _TodoListCardState extends State<TodoListCard> {
padding: EdgeInsets.all(10.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Row(
children: <Widget>[
@ -72,7 +72,6 @@ class _TodoListCardState extends State<TodoListCard> {
child: Container(
margin:
EdgeInsets.only(top: 20.0, left: 20.0, right: 20.0),
height: MediaQuery.of(context).size.height * 0.1,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
@ -113,7 +112,7 @@ class _TodoListCardState extends State<TodoListCard> {
Expanded(
flex: 1,
child: Container(
height: MediaQuery.of(context).size.height * 0.1,
// height: MediaQuery.of(context).size.height * 0.12,
margin: EdgeInsets.only(top: 20.0),
child: Column(
children: <Widget>[

@ -0,0 +1,37 @@
import 'package:diplomaticquarterapp/client/base_app_client.dart';
import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/models/Request.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
class ClinicListService {
AppSharedPreferences sharedPref = AppSharedPreferences();
AppGlobal appGlobal = new AppGlobal();
Future<Map> getClinicsList() async {
Map<String, dynamic> request;
var languageID = await sharedPref.getString(APP_LANGUAGE);
Request req = appGlobal.getPublicRequest();
request = {
"LanguageID": languageID == 'ar' ? 1 : 2,
"IPAdress": "10.20.10.20",
"VersionID": req.VersionID,
"Channel": req.Channel,
"generalid": 'Cs2020@2016\$2958',
"PatientOutSA": 0,
"TokenID": "",
"DeviceTypeID": req.DeviceTypeID,
"SessionID": null
};
dynamic localRes;
await BaseAppClient.post(GET_CLINICS_LIST_URL,
onSuccess: (response, statusCode) async {
localRes = response;
}, onFailure: (String error, int statusCode) {
throw error;
}, body: request);
return Future.value(localRes);
}
}
Loading…
Cancel
Save