Family file fixes

merge-requests/400/head
haroon amjad 4 years ago
parent 2fc5425884
commit b0f4cfcff3

@ -641,7 +641,6 @@ class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver {
elevation: true,
onTap: () {
changeCurrentTab(2);
signalRUtil.sendMessage(['Bob', 'Says hi!']);
})
: null);
}

@ -3,7 +3,6 @@ import 'package:diplomaticquarterapp/core/model/family-file/add_family_file_requ
import 'package:diplomaticquarterapp/core/model/family-file/insert_share_file_request.dart';
import 'package:diplomaticquarterapp/core/service/client/base_app_client.dart';
import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart';
import 'package:diplomaticquarterapp/models/Authentication/check_activation_code_response.dart';
import 'package:diplomaticquarterapp/models/Authentication/send_activation_request.dart';
import 'package:diplomaticquarterapp/models/FamilyFiles/GetAllSharedRecordByStatusResponse.dart';
import 'package:diplomaticquarterapp/models/FamilyFiles/GetAllSharedRecordsByStatusReq.dart';
@ -13,40 +12,30 @@ import 'package:flutter/cupertino.dart';
// SharedPreferences sharedPref = new SharedPreferences();
enum APP_STATUS { LOADING, UNAUTHENTICATED, AUTHENTICATED }
AppSharedPreferences sharedPref = new AppSharedPreferences();
const String GET_SHARED_RECORD_BY_STATUS =
'Services/Authentication.svc/REST/GetAllSharedRecordsByStatus';
const String ADD_FAMILY_FILES =
'Services/Patients.svc/REST/ShareFamilyFileService';
const String SEND_FAMILY_FILE_ACTIVATION =
'Services/Authentication.svc/REST/SendActivationCodeForFamilyFile';
const String INSERT_PATIENT_FILE =
'Services/Authentication.svc/REST/Insert_SharePatientFile';
const String CHECK_ACTIVATION_CODE =
'Services/Authentication.svc/REST/CheckActivationCodeForFamilyFile';
const String UPDATE_FILE_STATUS =
'Services/Authentication.svc/REST/Update_FileStatus';
const String REMOVE_FILE_STATUS =
'Services/Authentication.svc/REST/ActiveDeactive_PatientFile';
const String ACTIVATION_CODE_URL =
"Services/Authentication.svc/REST/CheckActivationCode";
const String SENT_REQUEST_URL =
'Services/Authentication.svc/REST/GetAllSharedRecordsByStatus';
const String RECEVIED_REQUEST_URL =
'Services/Authentication.svc/REST/GetAllPendingRecordsByResponseId';
const ACCEPT_REJECT_FAMILY =
'Services/Authentication.svc/REST/Update_FileStatus';
const DEACTIVATE_FAMILY =
'Services/Authentication.svc/REST/DeactivateRequestByRensponse';
const String GET_SHARED_RECORD_BY_STATUS = 'Services/Authentication.svc/REST/GetAllSharedRecordsByStatus';
const String ADD_FAMILY_FILES = 'Services/Patients.svc/REST/ShareFamilyFileService';
const String SEND_FAMILY_FILE_ACTIVATION = 'Services/Authentication.svc/REST/SendActivationCodeForFamilyFile';
const String INSERT_PATIENT_FILE = 'Services/Authentication.svc/REST/Insert_SharePatientFile';
const String CHECK_ACTIVATION_CODE = 'Services/Authentication.svc/REST/CheckActivationCodeForFamilyFile';
const String UPDATE_FILE_STATUS = 'Services/Authentication.svc/REST/Update_FileStatus';
const String REMOVE_FILE_STATUS = 'Services/Authentication.svc/REST/ActiveDeactive_PatientFile';
const String ACTIVATION_CODE_URL = "Services/Authentication.svc/REST/CheckActivationCode";
const String SENT_REQUEST_URL = 'Services/Authentication.svc/REST/GetAllSharedRecordsByStatus';
const String RECEVIED_REQUEST_URL = 'Services/Authentication.svc/REST/GetAllPendingRecordsByResponseId';
const ACCEPT_REJECT_FAMILY = 'Services/Authentication.svc/REST/Update_FileStatus';
const DEACTIVATE_FAMILY = 'Services/Authentication.svc/REST/DeactivateRequestByRensponse';
class FamilyFilesProvider with ChangeNotifier {
bool isLogin = false;
bool isLoading = true;
dynamic authenticatedUser;
GetAllSharedRecordsByStatusResponse allSharedRecordsByStatusResponse;
Future<GetAllSharedRecordsByStatusResponse> getSharedRecordByStatus() async {
try {
dynamic localRes;
@ -54,8 +43,7 @@ class FamilyFilesProvider with ChangeNotifier {
var result = await sharedPref.getObject(MAIN_USER);
request.status = 0;
request.patientID = result["PatientID"];
await new BaseAppClient().post(GET_SHARED_RECORD_BY_STATUS,
onSuccess: (dynamic response, int statusCode) {
await new BaseAppClient().post(GET_SHARED_RECORD_BY_STATUS, onSuccess: (dynamic response, int statusCode) {
localRes = response;
}, onFailure: (String error, int statusCode) {
AppToast.showErrorToast(message: error);
@ -63,30 +51,26 @@ class FamilyFilesProvider with ChangeNotifier {
}, body: request.toJson());
sharedPref.setObject(FAMILY_FILE, localRes);
return Future.value(
GetAllSharedRecordsByStatusResponse.fromJson(localRes));
return Future.value(GetAllSharedRecordsByStatusResponse.fromJson(localRes));
} catch (error) {
print(error);
throw error;
}
}
Future<GetAllSharedRecordsByStatusResponse> getUserViewRequest(
responseID) async {
Future<GetAllSharedRecordsByStatusResponse> getUserViewRequest(responseID) async {
try {
dynamic localRes;
Map<String, dynamic> request = {};
request['ResponseID'] = responseID;
await new BaseAppClient().post(RECEVIED_REQUEST_URL,
onSuccess: (dynamic response, int statusCode) {
await new BaseAppClient().post(RECEVIED_REQUEST_URL, onSuccess: (dynamic response, int statusCode) {
localRes = response;
}, onFailure: (String error, int statusCode) {
return Future.error(error);
}, body: request);
if (localRes != null) {
// sharedPref.setObject(FAMILY_FILE, localRes);
allSharedRecordsByStatusResponse =
GetAllSharedRecordsByStatusResponse.fromJson(localRes);
allSharedRecordsByStatusResponse = GetAllSharedRecordsByStatusResponse.fromJson(localRes);
return Future.value(allSharedRecordsByStatusResponse);
} else
return Future.error("No Data");
@ -101,8 +85,7 @@ class FamilyFilesProvider with ChangeNotifier {
dynamic localRes;
Map<String, dynamic> request = {};
request['Status'] = 0;
await new BaseAppClient().post(SENT_REQUEST_URL,
onSuccess: (dynamic response, int statusCode) {
await new BaseAppClient().post(SENT_REQUEST_URL, onSuccess: (dynamic response, int statusCode) {
localRes = response;
}, onFailure: (String error, int statusCode) {
return Future.value(error);
@ -110,8 +93,7 @@ class FamilyFilesProvider with ChangeNotifier {
//throw error;
}, body: request);
//sharedPref.setObject(FAMILY_FILE, localRes);
return Future.value(
GetAllSharedRecordsByStatusResponse.fromJson(localRes));
return Future.value(GetAllSharedRecordsByStatusResponse.fromJson(localRes));
} catch (error) {
print(error);
throw error;
@ -123,8 +105,7 @@ class FamilyFilesProvider with ChangeNotifier {
dynamic localRes;
// var request = GetAllSharedRecordsByStatusReq();
//request.status = 0;
await new BaseAppClient().post(ADD_FAMILY_FILES,
onSuccess: (dynamic response, int statusCode) {
await new BaseAppClient().post(ADD_FAMILY_FILES, onSuccess: (dynamic response, int statusCode) {
localRes = response;
}, onFailure: (String error, int statusCode) {
AppToast.showErrorToast(message: error);
@ -144,8 +125,7 @@ class FamilyFilesProvider with ChangeNotifier {
dynamic localRes;
// var request = GetAllSharedRecordsByStatusReq();
//request.status = 0;
await new BaseAppClient().post(INSERT_PATIENT_FILE,
onSuccess: (dynamic response, int statusCode) {
await new BaseAppClient().post(INSERT_PATIENT_FILE, onSuccess: (dynamic response, int statusCode) {
localRes = response;
}, onFailure: (String error, int statusCode) {
throw error;
@ -158,8 +138,7 @@ class FamilyFilesProvider with ChangeNotifier {
}
}
Future<dynamic> sendActivationCode(
cellNumber, zipCode, patientIdentificationID) async {
Future<dynamic> sendActivationCode(cellNumber, zipCode, patientIdentificationID) async {
try {
dynamic localRes;
var request = SendActivationRequest();
@ -170,8 +149,7 @@ class FamilyFilesProvider with ChangeNotifier {
request.loginType = request.searchType = 1;
request.oTPSendType = 1;
request.isRegister = false;
await new BaseAppClient().post(SEND_FAMILY_FILE_ACTIVATION,
onSuccess: (dynamic response, int statusCode) {
await new BaseAppClient().post(SEND_FAMILY_FILE_ACTIVATION, onSuccess: (dynamic response, int statusCode) {
localRes = response;
}, onFailure: (String error, int statusCode) {
AppToast.showErrorToast(message: error);
@ -186,8 +164,7 @@ class FamilyFilesProvider with ChangeNotifier {
}
//TODO
Future<dynamic> checkActivationCode(
loginTokenID, activationCode, indentification, mobileNo) async {
Future<dynamic> checkActivationCode(loginTokenID, activationCode, indentification, mobileNo) async {
try {
dynamic localRes;
Map<String, dynamic> request = {};
@ -197,8 +174,7 @@ class FamilyFilesProvider with ChangeNotifier {
request['LogInTokenID'] = loginTokenID;
request['activationCode'] = activationCode;
// this.authService.authenticateRequest(request);
await new BaseAppClient().post(CHECK_ACTIVATION_CODE,
onSuccess: (dynamic response, int statusCode) {
await new BaseAppClient().post(CHECK_ACTIVATION_CODE, onSuccess: (dynamic response, int statusCode) {
localRes = response;
}, onFailure: (String error, int statusCode) {
AppToast.showErrorToast(message: error);
@ -218,8 +194,7 @@ class FamilyFilesProvider with ChangeNotifier {
Map<String, dynamic> request = {};
request['ID'] = id;
request['Status'] = stauts;
await new BaseAppClient().post(UPDATE_FILE_STATUS,
onSuccess: (dynamic response, int statusCode) {
await new BaseAppClient().post(UPDATE_FILE_STATUS, onSuccess: (dynamic response, int statusCode) {
localRes = response;
}, onFailure: (String error, int statusCode) {
AppToast.showErrorToast(message: error);
@ -237,8 +212,7 @@ class FamilyFilesProvider with ChangeNotifier {
try {
dynamic localRes;
await new BaseAppClient().post(REMOVE_FILE_STATUS,
onSuccess: (dynamic response, int statusCode) {
await new BaseAppClient().post(REMOVE_FILE_STATUS, onSuccess: (dynamic response, int statusCode) {
localRes = response;
}, onFailure: (String error, int statusCode) {
AppToast.showErrorToast(message: error);
@ -252,34 +226,31 @@ class FamilyFilesProvider with ChangeNotifier {
}
}
Future<dynamic> silentLoggin(GetAllSharedRecordsByStatusList switchUser,
{onSuccess, mainUser}) async {
Future<dynamic> silentLoggin(GetAllSharedRecordsByStatusList switchUser, {onSuccess, mainUser}) async {
Map<String, dynamic> request = {};
if (mainUser == true) {
var currentUser =
AuthenticatedUser.fromJson(await sharedPref.getObject(MAIN_USER));
//const request = new SwitchUserRequest();
// request['LogInTokenID'] = '';
var currentUser = AuthenticatedUser.fromJson(await sharedPref.getObject(MAIN_USER));
request['PatientOutSA'] = currentUser.outSA; //? 1 : 0;
request['PatientMobileNumber'] =
currentUser.mobileNumber; //['MobileNumber'];
request['LoginType'] = await sharedPref.getInt(LAST_LOGIN);
request['MobileNo'] = currentUser.mobileNumber[0].toString() == "0" ? currentUser.mobileNumber.toString() : '0' + currentUser.mobileNumber.toString();
request['PatientMobileNumber'] = currentUser.mobileNumber; //['MobileNumber'];
request['SearchType'] = 2;
request['SuperUser'] = currentUser.patientID; //currentUser.PatientID;
request['PatientIdentificationID'] = '';
request['IsSilentLogin'] = true;
request['DeviceToken'] = await sharedPref.getString(PUSH_TOKEN);
request['PatientID'] = currentUser.patientID; //['PatientID'];
request['ZipCode'] = currentUser.outSA == 1 ? "971" : "966";
request['activationCode'] = '0000';
request['isRegister'] = false;
} else {
var currentUser =
AuthenticatedUser.fromJson(await sharedPref.getObject(USER_PROFILE));
var currentUser = AuthenticatedUser.fromJson(await sharedPref.getObject(USER_PROFILE));
//const request = new SwitchUserRequest();
// request['LogInTokenID'] = '';
request['PatientOutSA'] = currentUser.outSA; //? 1 : 0;
request['PatientMobileNumber'] =
switchUser.mobileNumber; //['MobileNumber'];
request['PatientMobileNumber'] = switchUser.mobileNumber; //['MobileNumber'];
request['SearchType'] = 2;
request['SuperUser'] = switchUser.patientID; //currentUser.PatientID;
request['PatientIdentificationID'] = '';
@ -292,8 +263,7 @@ class FamilyFilesProvider with ChangeNotifier {
try {
dynamic localRes;
await new BaseAppClient().post(ACTIVATION_CODE_URL,
onSuccess: (dynamic response, int statusCode) {
await new BaseAppClient().post(ACTIVATION_CODE_URL, onSuccess: (dynamic response, int statusCode) {
localRes = response;
}, onFailure: (String error, int statusCode) {
AppToast.showErrorToast(message: error);
@ -311,8 +281,7 @@ class FamilyFilesProvider with ChangeNotifier {
try {
dynamic localRes;
await new BaseAppClient().post(ACCEPT_REJECT_FAMILY,
onSuccess: (dynamic response, int statusCode) {
await new BaseAppClient().post(ACCEPT_REJECT_FAMILY, onSuccess: (dynamic response, int statusCode) {
localRes = response;
}, onFailure: (String error, int statusCode) {
AppToast.showErrorToast(message: error);
@ -330,8 +299,7 @@ class FamilyFilesProvider with ChangeNotifier {
try {
dynamic localRes;
await new BaseAppClient().post(DEACTIVATE_FAMILY,
onSuccess: (dynamic response, int statusCode) {
await new BaseAppClient().post(DEACTIVATE_FAMILY, onSuccess: (dynamic response, int statusCode) {
localRes = response;
}, onFailure: (String error, int statusCode) {
AppToast.showErrorToast(message: error);

@ -273,14 +273,14 @@ class _AppDrawerState extends State<AppDrawer> {
children: <Widget>[
AppText(
result.patientName,
color: result.responseID == user.patientID ? Color(0xFF40ACC9) : Color(0xff2B353E),
color: result.responseID == user.patientID ? Color(0xffC5272D) : Color(0xff2B353E),
fontWeight: FontWeight.w600,
fontSize: 11,
letterSpacing: -0.33,
),
AppText(
TranslationBase.of(context).fileno + ": " + result.responseID.toString(),
color: result.responseID == user.patientID ? Color(0xFF40ACC9) : Color(0xff989898),
color: result.responseID == user.patientID ? Color(0xffC5272D) : Color(0xff989898),
fontSize: 11,
letterSpacing: -0.33,
),
@ -546,13 +546,14 @@ class _AppDrawerState extends State<AppDrawer> {
var familyFile = await sharedPref.getObject(FAMILY_FILE);
var currentLang = await sharedPref.getString(APP_LANGUAGE);
var mainUser = await sharedPref.getObject(MAIN_USER);
var loginType = await sharedPref.getInt(LAST_LOGIN);
this.sharedPref.clear();
if (mainUser["PatientID"] != result.list.patientID) {
result.list.isFamily = true;
}
// result.list.cRSVerificationStatus = result['CRSVerificationStatus'];
this.sharedPref.setString(APP_LANGUAGE, currentLang);
this.sharedPref.setInt(LAST_LOGIN, loginType);
this.sharedPref.setObject(MAIN_USER, mainUser);
this.sharedPref.setObject(USER_PROFILE, result.list);
this.sharedPref.setObject(FAMILY_FILE, familyFile);
@ -562,7 +563,7 @@ class _AppDrawerState extends State<AppDrawer> {
await authenticatedUserObject.getUser(getUser: true);
Provider.of<ProjectViewModel>(context, listen: false).user = authenticatedUserObject.user;
Provider.of<ProjectViewModel>(context, listen: false).setUser(authenticatedUserObject.user);
await pharmacyModuleViewModel.generatePharmacyToken();
// await pharmacyModuleViewModel.generatePharmacyToken();
_vitalSignService.heightCm = "";
_vitalSignService.weightKg = "";

Loading…
Cancel
Save