Family file fixes

merge-update-with-lab-changes
haroon amjad 4 years ago
parent 2fc5425884
commit b0f4cfcff3

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

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

Loading…
Cancel
Save