Beispiel #1
0
        public void VisitCallPatientTest()
        {
            long testVisitID = 201;

            var visit = VisitEN.GetService().GetByIDV(testVisitID);


            TestUtils.Security.SetCurrentUser(TestEnums.User.constDoctorID);
            var target = CallLogEN.GetService();
            var actual = target.VisitCallPatient(new CallLogVisitCallPatientSP()
            {
                VisitID = testVisitID
            });

            Assert.AreEqual(visit.PatientUserID, actual.ReceiverUserID);
            Assert.AreEqual(visit.PatientFullName, actual.ReceiverFullName);

            DateTime         afewSecondsAgoDate = DateTime.UtcNow.AddSeconds(-3);
            FilterExpression filter             = new FilterExpression();

            filter.AddFilter(vCallLog.ColumnNames.AppEntityID, (short)EntityEnums.AppEntityEnum.Visit);
            filter.AddFilter(vCallLog.ColumnNames.EntityRecordID, testVisitID);
            filter.AddFilter(vCallLog.ColumnNames.StartDate, afewSecondsAgoDate, FilterOperatorEnum.GreaterThan);
            filter.AddFilter(vCallLog.ColumnNames.ReceiverUserID, visit.PatientUserID);

            Assert.IsTrue(target.GetCount(filter) > 0, "CallLog should be written to CallLog table");

            FilterExpression f2 = new FilterExpression();

            f2.AddFilter(vMobilePushNotification.ColumnNames.InsertDate, afewSecondsAgoDate, FilterOperatorEnum.GreaterThan);
            f2.AddFilter(vMobilePushNotification.ColumnNames.MobilePushTemplateID, (byte)EntityEnums.MobilePushTemplateType.Call_PhoneRing);

            Assert.IsTrue(MobilePushNotificationEN.GetService().GetCount(f2) > 0, "MobilePushNotification should be called");
        }
Beispiel #2
0
        /// <summary>
        /// Sends push sanity to the current user
        /// </summary>
        public List <vUserDeviceSetting> SendPushSanity(SendPushSanitySP p)
        {
            List <vUserDeviceSetting> results = new List <vUserDeviceSetting>();

            var list = GetByUserID(p.UserID);

            foreach (var item in list)
            {
                if (item.PushNotificationIsActive == true)
                {
                    results.Add(MobilePushNotificationEN.GetService().TestPushSanity(item.DeviceGeneratedUUID));
                }
            }
            return(results);
        }
        /// <summary>
        /// Sends call notification for the patient based on the visit information
        /// </summary>s
        /// <param name="p">parameters</param>
        public CallLogCallPatientResponseSP VisitCallPatient(CallLogVisitCallPatientSP p)
        {
            long   visitID = p.VisitID;
            vVisit v       = VisitEN.GetService().GetByIDV(visitID, new GetByIDParameters());

            if (v == null)
            {
                throw new BRException(BusinessErrorStrings.Visit.Visit_Deleted);
            }
            OwnerDoctorSecurity.Check("call a patient", v, vVisit.ColumnNames.DoctorID);

            // inserting call log to the database
            var callLogService = CallLogEN.GetService();
            var callLog        = CallLogEN.GetEntityObjectT();

            callLog.StartDate       = DateTime.UtcNow;
            callLog.SenderUserID    = v.DoctorID;
            callLog.ReceiverUserID  = v.PatientUserID;
            callLog.DurationSeconds = 0;
            callLog.EntityRecordID  = v.VisitID;
            callLog.AppEntityID     = (short)EntityEnums.AppEntityEnum.Visit;
            callLogService.Insert(callLog, null);


            var mobilePushService = MobilePushNotificationEN.GetService();
            var mobilePush        = MobilePushNotificationEN.GetEntityObjectT();

            mobilePush.MobilePushTemplateID = (byte)EntityEnums.MobilePushTemplateType.Call_PhoneRing;
            mobilePush.ParamsJSON           = FWUtils.EntityUtils.JsonSerializeObject(new PhoneRingParameters()
            {
                CallLogID = callLog.CallLogID, SenderFullName = v.DoctorFullName
            });
            mobilePush.TemplateParamsJSON             = new TemplateParams("caller", v.DoctorFullName).SerializeToString();
            mobilePush.ReceiverUserID                 = callLog.ReceiverUserID;
            mobilePush.MobilePushNotificationStatusID = (byte)EntityEnums.NotificationStatusEnum.Pending;
            mobilePush.InsertDate   = DateTime.UtcNow;
            mobilePush.SenderUserID = v.DoctorID;
            mobilePushService.Insert(mobilePush, null);


            CallLogCallPatientResponseSP response = new CallLogCallPatientResponseSP();

            response.CallLogID             = callLog.CallLogID;
            response.ReceiverUserID        = v.PatientUserID;
            response.ReceiverFullName      = v.PatientFullName;
            response.ReceiverProfilePicUrl = AppFileEN.GetService().GetUserProfileImageUrl(v.PatientUserID);
            return(response);

            //var userDeviceSettingsService = UserDeviceSettingEN.GetService("");

            ////string messageBody = "Doctor " + v.DoctorFirstName + " " + v.DoctorLastName + " is calling.";
            ////string sound = "RingPhone.caf";
            ////int? timeToLiveSeconds = 0;
            ////string collapseKeyIfAny = null;
            ////bool? delayWhileIdle = null;
            ////userDeviceSettingsService.PushNotification(v.PatientUserID, messageBody, sound, timeToLiveSeconds, collapseKeyIfAny, delayWhileIdle);

            //UTD.Tricorder.Common.NotificationSystem.MobileNotificationMessage msg
            //    = new UTD.Tricorder.Common.NotificationSystem.MobileNotificationMessage();
            //msg.Type = UTD.Tricorder.Common.NotificationSystem.MobileNotificationTypeSEnum.PhoneRing;
            //msg.Title = "Visit Call"; // No title
            //msg.Alert = "Doctor " + v.DoctorFirstName + " " + v.DoctorLastName + " is calling you.";
            ////msg.ParamsJSON = "{visitId: '" + visitID.ToString() + "', patientId:'" + v.PatientUserID.ToString() + "'}"; // we may need to do authentication before answering calls
            //msg.ParamsJSON = FWUtils.EntityUtils.JsonSerializeObject(new PhoneRingParameters(visitID.ToString()));
            ////msg.TimeToLiveSeconds = 0;
            //msg.IsOneSufficient = false;
            //msg.Sound = "Rington2.mp3";
            //msg.DelayWhileIdle = false;

            //FWUtils.ExpLogUtils.Logger.WriteLog(new AppLog() { AppLogTypeID = (short)EntityEnums.AppLogType.Visit_CallPatient, UserID = v.PatientUserID, ExtraBigInt = visitID });

            //int devicesCount = userDeviceSettingsService.PushNotification(v.PatientUserID, msg);
            //if (devicesCount == 0)
            //{
            //    throw new BRException(BusinessErrorStrings.Visit.CallPatient_NoDeviceAttachedToThisUser);
            //}
        }