Esempio n. 1
0
        //Please write your properties and functions here. This part will not be replaced.

        public void CreatePaymentForVisit(vVisit visit)
        {
            if (visit == null)
            {
                throw new BRException(StringMsgs.BusinessErrors.RecordIsNotAvailable);
            }

            // We may pay for the visit before its completion
            //if (visit.VisitStatusID != (int)EntityEnums.VisitStatusEnum.EndSuccess)
            //    throw new BRException(BusinessErrorStrings.Payment.VisitStatus_Equals_EndSuccess);

            // Only one payment is allowed per visit
            //FilterExpression filter = new FilterExpression();
            //filter.AddFilter(new Filter(vPayment.ColumnNames.AppEntityID, (int) EntityEnums.PaymentEntityEnum.Visit));
            //filter.AddFilter(new Filter(vPayment.ColumnNames.AppEntityRecordIDValue, visit.VisitID));
            //if (GetCount(filter) > 0)
            //    throw new BRException(BusinessErrorStrings.Payment.VisitAlreadyHasAPaymentRecord);

            //if (visit.PaymentStatusID != (int)EntityEnums.PaymentStatusEnum.NotStarted)
            //    throw new BRException(BusinessErrorStrings.Payment.PaymentStatus_Equlas_NotStarted);
        }
Esempio n. 2
0
        //Please write your properties and functions here. This part will not be replaced.

        // Doctor selected a visit record, then CreatePaymentForVisit
        // Patient gets a notification to pay the amount
        // Patient selected payment method like Paypal (it uses UpdatePayPalKey to get Key from the bank)
        // Patient pays the money for the payment and
        //

        /// <summary>
        /// Precondition:
        /// Have Visit record in database with PaymentStatusID = NotStarted
        /// Steps:
        /// 1- Select a visit record (visitID) and enter amount and description required
        /// 2- CreatePaymentForVisit (PaymentStatusID = PendingWithoutPayKey)
        /// 3- UpdatePayPalKey (payment records in database PaymentStatusID = PendingWithPayKey)
        /// 4- PaymentReceived (PaymentStatusID = Done)
        /// </summary>
        public Payment CreatePaymentForVisit(PaymentCreatePaymentForVisitSP p)
        {
            PaymentBR biz = (PaymentBR)this.BusinessLogicObject;

            IVisitService visitService   = (IVisitService)EntityFactory.GetEntityServiceByName(vVisit.EntityName, "");
            vVisit        visit          = (vVisit)visitService.GetByID(p.VisitID, new GetByIDParameters(GetSourceTypeEnum.View));
            Visit         visitForUpdate = (Visit)visitService.GetByID(p.VisitID, new GetByIDParameters());

            biz.CreatePaymentForVisit(visit);


            Payment paymentForDoctor = new Payment();

            paymentForDoctor.SenderUserID           = visit.PatientUserID;
            paymentForDoctor.ReceiverUserID         = visit.DoctorID;
            paymentForDoctor.AppEntityID            = (int)EntityEnums.PaymentEntityEnum.Visit;
            paymentForDoctor.PaymentStatusID        = (int)EntityEnums.PaymentStatusEnum.PendingWithoutPayKey;
            paymentForDoctor.AppEntityRecordIDValue = visit.VisitID;
            paymentForDoctor.CreatedDateTime        = DateTime.UtcNow;
            paymentForDoctor.CompletedDateTime      = null;
            paymentForDoctor.PayKey = "";
            paymentForDoctor.Amount = p.Amount;
            paymentForDoctor.ServiceChargeAmount = p.ServiceChargeAmount;
            paymentForDoctor.PaymentMethodID     = (int)EntityEnums.PaymentMethodEnum.Undefined;
            paymentForDoctor.Description         = null;

            InsertParameters insertParameters = new InsertParameters();

            //visitForUpdate.PaymentStatusID = (int)EntityEnums.PaymentStatusEnum.PendingWithoutPayKey;
            DetailObjectInfo visitDetail = new DetailObjectInfo()
            {
                EntitySet              = visitForUpdate,
                EntityName             = vVisit.EntityName,
                AdditionalDataKey      = "",
                FnName                 = RuleFunctionSEnum.Update,
                FKColumnNameForAutoSet = ""
            };

            insertParameters.DetailEntityObjects.Add(visitDetail);


            // At this time, we just have one record for each visit.
            // We don't keep data for each receiver. So, it simplifies the problem.
            // ServiceChargeAmount is to show how much the user paid to us

            //Payment paymentForProvider = new Payment();
            //paymentForProvider.SenderUserID = visit.PatientUserID;
            //paymentForProvider.ReceiverUserID = visit.DoctorUserID;
            //paymentForProvider.PaymentEntityID = (int)EntityEnums.PaymentEntityEnum.Visit;
            //paymentForProvider.RelatedEntityRecordID = visit.VisitID;
            //paymentForProvider.CreatedDateTime = DateTime.UtcNow;
            //paymentForProvider.CompletedDateTime = null;
            //paymentForProvider.PayKey = "";
            //paymentForProvider.Amount = amount;
            //paymentForProvider.Description = null;

            //DetailObjectInfo companyPayment = new DetailObjectInfo() {
            //    EntitySet = paymentForProvider,
            //    EntityName = Payment.EntityName,
            //    AdditionalDataKey = this.AdditionalDataKey,
            //    FnName = RuleFunctionSEnum.Insert,
            //    FKColumnNameForAutoSet = "" };

            //insertParameters.DetailEntityObjects.Add(companyPayment);


            Insert(paymentForDoctor, insertParameters);
            return(paymentForDoctor);
        }
Esempio n. 3
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);
            //}
        }