Ejemplo n.º 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");
        }
Ejemplo n.º 2
0
        public void EndCallTest()
        {
            long testVisitID = 202;

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

            System.Threading.Thread.Sleep(3000);

            target.EndCall(new CallLogEndCallSP()
            {
                CallLogID = actual.CallLogID
            });

            var updatedCall = target.GetByIDV(actual.CallLogID, new GetByIDParameters());

            Assert.AreEqual((byte)EntityEnums.CallStatus.Ended, updatedCall.CallStatusID);
            Assert.IsTrue(updatedCall.DurationSeconds >= 1 && updatedCall.DurationSeconds <= 10, "DurationSeconds should be greater than one and less than 10");
            Assert.IsTrue(updatedCall.EndDate.HasValue, "EndDate should have value when call ended");
            Assert.IsTrue(Convert.ToInt32((updatedCall.EndDate.Value - updatedCall.StartDate).TotalSeconds) == updatedCall.DurationSeconds, "DurationSeconds should be contain totalseconds of the call");
        }
Ejemplo n.º 3
0
        public void CancelCallTest()
        {
            long testVisitID = 204;

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

            target.CancelCall(new CallLogCancelCallSP()
            {
                CallLogID = actual.CallLogID
            });

            var updatedCall = target.GetByIDV(actual.CallLogID, new GetByIDParameters());

            Assert.AreEqual((byte)EntityEnums.CallStatus.Cancelled, updatedCall.CallStatusID);
        }
Ejemplo n.º 4
0
        public void ServerStartVideoCall(long callLogID)
        {
            try
            {
                // to make sure that call log is valid for video communication
                var callLog = CallLogEN.GetService().GetByIDT(callLogID);

                // if it was receiver, we inform the sender. If it was sender, we inform receiver
                if (Context.Request.User.Identity.Name == callLog.ReceiverUserID.ToString())
                {
                    Clients.User(callLog.SenderUserID.ToString()).clientStartVideoCall(Context.ConnectionId, callLogID);
                }
                else
                {
                    Clients.User(callLog.ReceiverUserID.ToString()).clientStartVideoCall(Context.ConnectionId, callLogID);
                }
            }
            catch (Exception ex)
            {
                FWUtils.ExpLogUtils.ExceptionLogger.LogError(ex, null);
            }
        }
Ejemplo n.º 5
0
        /// <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);
            //}
        }