/// <summary> /// Saves the section information for one visit /// </summary> /// <param name="p">parameters</param> public void SaveSection(VisitSaveSectionSP p) { if (string.IsNullOrEmpty(p.SectionValuesJson) == false) { if (FWUtils.EntityUtils.JsonIsValidThenDeserialize(p.SectionValuesJson) == null) { throw new ImpossibleExecutionException("SaveSection p.SectionValuesJson is not a valid json:" + p.SectionValuesJson); } } vVisit obj = GetByIDV(p.VisitID); if (obj == null) { throw new UserException(StringMsgs.BusinessErrors.RecordIsNotAvailable); } else { if (p.SectionName == "SysReview") { OwnerDoctorSecurity.Check("write a review for an appointment", obj, vVisit.ColumnNames.DoctorID); obj.DoctorSystemReviewJson = p.SectionValuesJson; } else { throw new ImpossibleExecutionException(p.SectionName); } Update(obj); } }
/// <summary> /// reverse visit status to scheduled /// </summary> /// <param name="visitId">visit identifier</param> public void UndoStatusToRescheduled(long visitId) { vVisit visit = (vVisit)GetByIDV(visitId, new GetByIDParameters()); OwnerDoctorSecurity.Check("change apppoinment status to scheduled", visit, vVisit.ColumnNames.DoctorID); ((VisitBR)BusinessLogicObject).UndoStatusToRescheduled(visit); visit.VisitStatusID = (int)EntityEnums.VisitStatusEnum.Scheduled; Update(visit); }
/// <summary> /// Completes a visit (changes status to end successfully) /// </summary> /// <param name="visitId">visit identifier</param> public void CompleteVisit(long visitId) { vVisit visit = (vVisit)GetByIDV(visitId, new GetByIDParameters()); OwnerDoctorSecurity.Check("complete a visit", visit, vVisit.ColumnNames.DoctorID); ((VisitBR)BusinessLogicObject).CompleteVisit(visit); visit.VisitStatusID = (int)EntityEnums.VisitStatusEnum.EndSuccess; Update(visit); }
/// <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); //} }