public async Task <HttpResponseMessage> GetDummyURL(MT_Patient_Forms_URLs PMD) { Db = con.SurgeryCenterDb(PMD.Slug); PFURLResponse Response = new PFURLResponse(); try { MT_Patient_Booking Pbooking = new MT_Patient_Booking(); Query ObjQuery = Db.Collection("MT_Patient_Forms_URLs").WhereEqualTo("PFU_Is_Active", true).WhereEqualTo("PFU_Booking_ID", PMD.PFU_Booking_ID); QuerySnapshot ObjQuerySnap = await ObjQuery.GetSnapshotAsync(); if (ObjQuerySnap != null) { Response.DURL = ObjQuerySnap.Documents[0].ConvertTo <MT_Patient_Forms_URLs>().PFU_Dummy_URL; Response.Status = con.StatusSuccess; Response.Message = con.MessageSuccess; } else { Response.Status = con.StatusDNE; Response.Message = con.MessageDNE; } } catch (Exception ex) { Response.Status = con.StatusFailed; Response.Message = con.MessageFailed + ", Exception : " + ex.Message; } return(ConvertToJSON(Response)); }
public async Task <HttpResponseMessage> EditBooking(MT_Patient_Booking PMD) { Db = con.SurgeryCenterDb(PMD.Slug); BookingResponse Response = new BookingResponse(); try { MT_Patient_Booking booking = new MT_Patient_Booking(); Query Qty = Db.Collection("MT_Patient_Booking").WhereEqualTo("PB_Unique_ID", PMD.PB_Unique_ID); QuerySnapshot ObjBooking = await Qty.GetSnapshotAsync(); if (ObjBooking != null) { booking = ObjBooking.Documents[0].ConvertTo <MT_Patient_Booking>(); Dictionary <string, object> initialData = new Dictionary <string, object> { { "PB_Patient_Name", PMD.PB_Patient_Name }, { "PB_Patient_Last_Name", PMD.PB_Patient_Last_Name }, { "PB_Booking_Date", con.ConvertTimeZone(PMD.PB_TimeZone, Convert.ToDateTime(PMD.PB_Booking_Date)) }, { "PB_Booking_Surgery_Center_ID", PMD.PB_Booking_Surgery_Center_ID }, { "PB_Booking_Surgery_Center_Name", PMD.PB_Booking_Surgery_Center_Name }, { "PB_Booking_Time", PMD.PB_Booking_Time }, { "PB_Booking_Duration", PMD.PB_Booking_Duration }, { "PB_Alerts", PMD.PB_Alerts }, { "PB_Notes", PMD.PB_Notes }, { "PB_Status", PMD.PB_Status }, { "PB_Modify_Date", con.ConvertTimeZone(PMD.PB_TimeZone, Convert.ToDateTime(PMD.PB_Modify_Date)) }, { "PB_TimeZone", PMD.PB_TimeZone }, }; if (PMD.PB_Incient_Detail != null) { Dictionary <string, object> Incient_Detail; if (booking.PB_Incient_Detail != null) { Incient_Detail = new Dictionary <string, object> { { "Inci_Type_ID", PMD.PB_Incient_Detail.Inci_Type_ID }, { "Inci_Type", PMD.PB_Incient_Detail.Inci_Type }, { "Inci_Claim_No", PMD.PB_Incient_Detail.Inci_Claim_No }, { "Inci_DOI", con.ConvertTimeZone(PMD.PB_Incient_Detail.Inci_TimeZone, Convert.ToDateTime(PMD.PB_Incient_Detail.Inci_DOI)) }, { "Inci_Employee_Name", PMD.PB_Incient_Detail.Inci_Employee_Name }, { "Inci_Employee_Address", PMD.PB_Incient_Detail.Inci_Employee_Address }, { "Inci_Employee_Phone_No", PMD.PB_Incient_Detail.Inci_Employee_Phone_No }, { "Inci_Is_This_Lien", PMD.PB_Incient_Detail.Inci_Is_This_Lien }, { "Inci_Attorney_Name", PMD.PB_Incient_Detail.Inci_Attorney_Name }, { "Inci_Attorney_Phone_No", PMD.PB_Incient_Detail.Inci_Attorney_Phone_No }, { "Inci_TimeOfIncident", PMD.PB_Incient_Detail.Inci_TimeOfIncident }, { "Inci_Comment", PMD.PB_Incient_Detail.Inci_Comment }, { "Inci_Modify_Date", con.ConvertTimeZone(PMD.PB_Incient_Detail.Inci_TimeZone, Convert.ToDateTime(PMD.PB_Incient_Detail.Inci_Modify_Date)) }, { "Inci_TimeZone", PMD.PB_Incient_Detail.Inci_TimeZone } }; } else { Incient_Detail = new Dictionary <string, object> { { "Inci_Unique_ID", con.GetUniqueKey() }, { "Inci_Type_ID", PMD.PB_Incient_Detail.Inci_Type_ID }, { "Inci_Type", PMD.PB_Incient_Detail.Inci_Type }, { "Inci_Claim_No", PMD.PB_Incient_Detail.Inci_Claim_No }, { "Inci_DOI", con.ConvertTimeZone(PMD.PB_Incient_Detail.Inci_TimeZone, Convert.ToDateTime(PMD.PB_Incient_Detail.Inci_DOI)) }, { "Inci_Employee_Name", PMD.PB_Incient_Detail.Inci_Employee_Name }, { "Inci_Employee_Address", PMD.PB_Incient_Detail.Inci_Employee_Address }, { "Inci_Employee_Phone_No", PMD.PB_Incient_Detail.Inci_Employee_Phone_No }, { "Inci_Is_This_Lien", PMD.PB_Incient_Detail.Inci_Is_This_Lien }, { "Inci_Attorney_Name", PMD.PB_Incient_Detail.Inci_Attorney_Name }, { "Inci_Attorney_Phone_No", PMD.PB_Incient_Detail.Inci_Attorney_Phone_No }, { "Inci_TimeOfIncident", PMD.PB_Incient_Detail.Inci_TimeOfIncident }, { "Inci_Comment", PMD.PB_Incient_Detail.Inci_Comment }, { "Inci_Created_By", PMD.PB_Incient_Detail.Inci_Created_By }, { "Inci_User_Name", PMD.PB_Incient_Detail.Inci_User_Name }, { "Inci_Create_Date", con.ConvertTimeZone(PMD.PB_Incient_Detail.Inci_TimeZone, Convert.ToDateTime(PMD.PB_Incient_Detail.Inci_Create_Date)) }, { "Inci_Modify_Date", con.ConvertTimeZone(PMD.PB_Incient_Detail.Inci_TimeZone, Convert.ToDateTime(PMD.PB_Incient_Detail.Inci_Modify_Date)) }, { "Inci_Is_Active", PMD.PB_Incient_Detail.Inci_Is_Active }, { "Inci_Is_Deleted", PMD.PB_Incient_Detail.Inci_Is_Deleted }, { "Inci_TimeZone", PMD.PB_Incient_Detail.Inci_TimeZone }, }; } initialData.Add("PB_Incient_Detail", Incient_Detail); } if (PMD.PB_Surgical_Procedure_Information != null) { Dictionary <string, object> Surgical_Procedure_Information; if (booking.PB_Surgical_Procedure_Information != null) { Surgical_Procedure_Information = new Dictionary <string, object> { { "SPI_Surgery_Center_ID", PMD.PB_Surgical_Procedure_Information.SPI_Surgery_Center_ID }, { "SPI_Surgery_Center_Name", PMD.PB_Surgical_Procedure_Information.SPI_Surgery_Center_Name }, { "SPI_Surgeon_ID", PMD.PB_Surgical_Procedure_Information.SPI_Surgeon_ID }, { "SPI_Surgeon_Name", PMD.PB_Surgical_Procedure_Information.SPI_Surgeon_Name }, { "SPI_Assi_Surgeon_ID", PMD.PB_Surgical_Procedure_Information.SPI_Assi_Surgeon_ID }, { "SPI_Assi_Surgeon_Name", PMD.PB_Surgical_Procedure_Information.SPI_Assi_Surgeon_Name }, { "SPI_Date", con.ConvertTimeZone(PMD.PB_Surgical_Procedure_Information.SPI_TimeZone, Convert.ToDateTime(PMD.PB_Surgical_Procedure_Information.SPI_Date), 1) }, { "SPI_Time", PMD.PB_Surgical_Procedure_Information.SPI_Time }, { "SPI_Duration", PMD.PB_Surgical_Procedure_Information.SPI_Duration }, { "SPI_Anesthesia_Type_ID", PMD.PB_Surgical_Procedure_Information.SPI_Anesthesia_Type_ID }, { "SPI_Anesthesia_Type", PMD.PB_Surgical_Procedure_Information.SPI_Anesthesia_Type }, { "SPI_Block_ID", PMD.PB_Surgical_Procedure_Information.SPI_Block_ID }, { "SPI_Block_Type", PMD.PB_Surgical_Procedure_Information.SPI_Block_Type }, { "SPI_Procedure_SelectedList", PMD.PB_Surgical_Procedure_Information.SPI_Procedure_SelectedList }, { "SPI_CPT_SelectedList", PMD.PB_Surgical_Procedure_Information.SPI_CPT_SelectedList }, { "SPI_ICD_SelectedList", PMD.PB_Surgical_Procedure_Information.SPI_ICD_SelectedList }, { "SPI_Modify_Date", con.ConvertTimeZone(PMD.PB_Surgical_Procedure_Information.SPI_TimeZone, Convert.ToDateTime(PMD.PB_Surgical_Procedure_Information.SPI_Modify_Date)) }, { "SPI_TimeZone", PMD.PB_Surgical_Procedure_Information.SPI_TimeZone } }; } else { Surgical_Procedure_Information = new Dictionary <string, object> { { "SPI_Unique_ID", con.GetUniqueKey() }, { "SPI_Surgery_Center_ID", PMD.PB_Surgical_Procedure_Information.SPI_Surgery_Center_ID }, { "SPI_Surgery_Center_Name", PMD.PB_Surgical_Procedure_Information.SPI_Surgery_Center_Name }, { "SPI_Surgeon_ID", PMD.PB_Surgical_Procedure_Information.SPI_Surgeon_ID }, { "SPI_Surgeon_Name", PMD.PB_Surgical_Procedure_Information.SPI_Surgeon_Name }, { "SPI_Assi_Surgeon_ID", PMD.PB_Surgical_Procedure_Information.SPI_Assi_Surgeon_ID }, { "SPI_Assi_Surgeon_Name", PMD.PB_Surgical_Procedure_Information.SPI_Assi_Surgeon_Name }, { "SPI_Date", con.ConvertTimeZone(PMD.PB_Surgical_Procedure_Information.SPI_TimeZone, Convert.ToDateTime(PMD.PB_Surgical_Procedure_Information.SPI_Date)) }, { "SPI_Time", PMD.PB_Surgical_Procedure_Information.SPI_Time }, { "SPI_Duration", PMD.PB_Surgical_Procedure_Information.SPI_Duration }, { "SPI_Anesthesia_Type_ID", PMD.PB_Surgical_Procedure_Information.SPI_Anesthesia_Type_ID }, { "SPI_Anesthesia_Type", PMD.PB_Surgical_Procedure_Information.SPI_Anesthesia_Type }, { "SPI_Block_ID", PMD.PB_Surgical_Procedure_Information.SPI_Block_ID }, { "SPI_Block_Type", PMD.PB_Surgical_Procedure_Information.SPI_Block_Type }, { "SPI_Procedure_SelectedList", PMD.PB_Surgical_Procedure_Information.SPI_Procedure_SelectedList }, { "SPI_CPT_SelectedList", PMD.PB_Surgical_Procedure_Information.SPI_CPT_SelectedList }, { "SPI_ICD_SelectedList", PMD.PB_Surgical_Procedure_Information.SPI_ICD_SelectedList }, { "SPI_Created_By", PMD.PB_Surgical_Procedure_Information.SPI_Created_By }, { "SPI_User_Name", PMD.PB_Surgical_Procedure_Information.SPI_User_Name }, { "SPI_Create_Date", con.ConvertTimeZone(PMD.PB_Surgical_Procedure_Information.SPI_TimeZone, Convert.ToDateTime(PMD.PB_Surgical_Procedure_Information.SPI_Create_Date)) }, { "SPI_Modify_Date", con.ConvertTimeZone(PMD.PB_Surgical_Procedure_Information.SPI_TimeZone, Convert.ToDateTime(PMD.PB_Surgical_Procedure_Information.SPI_Modify_Date)) }, { "SPI_Is_Active", PMD.PB_Surgical_Procedure_Information.SPI_Is_Active }, { "SPI_Is_Deleted", PMD.PB_Surgical_Procedure_Information.SPI_Is_Deleted }, { "SPI_TimeZone", PMD.PB_Surgical_Procedure_Information.SPI_TimeZone }, }; } initialData.Add("PB_Surgical_Procedure_Information", Surgical_Procedure_Information); } if (PMD.PB_Preoprative_Medical_Clearance != null) { Dictionary <string, object> Preoprative_Medical_Clearance; if (booking.PB_Preoprative_Medical_Clearance != null) { Preoprative_Medical_Clearance = new Dictionary <string, object> { { "PMC_Is_Require_Pre_Op_Medi_Clearance", PMD.PB_Preoprative_Medical_Clearance.PMC_Is_Require_Pre_Op_Medi_Clearance }, { "PMC_Clearing_Physician_Name", PMD.PB_Preoprative_Medical_Clearance.PMC_Clearing_Physician_Name }, { "PMC_Is_Require_EKG", PMD.PB_Preoprative_Medical_Clearance.PMC_Is_Require_EKG }, { "PMC_Modify_Date", con.ConvertTimeZone(PMD.PB_Preoprative_Medical_Clearance.PMC_TimeZone, Convert.ToDateTime(PMD.PB_Preoprative_Medical_Clearance.PMC_Modify_Date)) }, { "PMC_TimeZone", PMD.PB_Preoprative_Medical_Clearance.PMC_TimeZone } }; } else { Preoprative_Medical_Clearance = new Dictionary <string, object> { { "PMC_Unique_ID", con.GetUniqueKey() }, { "PMC_Is_Require_Pre_Op_Medi_Clearance", PMD.PB_Preoprative_Medical_Clearance.PMC_Is_Require_Pre_Op_Medi_Clearance }, { "PMC_Clearing_Physician_Name", PMD.PB_Preoprative_Medical_Clearance.PMC_Clearing_Physician_Name }, { "PMC_Is_Require_EKG", PMD.PB_Preoprative_Medical_Clearance.PMC_Is_Require_EKG }, { "PMC_Created_By", PMD.PB_Preoprative_Medical_Clearance.PMC_Created_By }, { "PMC_User_Name", PMD.PB_Preoprative_Medical_Clearance.PMC_User_Name }, { "PMC_Create_Date", con.ConvertTimeZone(PMD.PB_Preoprative_Medical_Clearance.PMC_TimeZone, Convert.ToDateTime(PMD.PB_Preoprative_Medical_Clearance.PMC_Create_Date)) }, { "PMC_Modify_Date", con.ConvertTimeZone(PMD.PB_Preoprative_Medical_Clearance.PMC_TimeZone, Convert.ToDateTime(PMD.PB_Preoprative_Medical_Clearance.PMC_Modify_Date)) }, { "PMC_Is_Active", PMD.PB_Preoprative_Medical_Clearance.PMC_Is_Active }, { "PMC_Is_Deleted", PMD.PB_Preoprative_Medical_Clearance.PMC_Is_Deleted }, { "PMC_TimeZone", PMD.PB_Preoprative_Medical_Clearance.PMC_TimeZone }, }; } initialData.Add("PB_Preoprative_Medical_Clearance", Preoprative_Medical_Clearance); } if (PMD.PB_Special_Request != null) { Dictionary <string, object> Special_Request; if (booking.PB_Special_Request != null) { Special_Request = new Dictionary <string, object> { { "SR_Is_Special_Equip_Req", PMD.PB_Special_Request.SR_Is_Special_Equip_Req }, { "SR_Equip_ID", PMD.PB_Special_Request.SR_Equip_ID }, { "SR_Equip_Name", PMD.PB_Special_Request.SR_Equip_Name }, { "SR_Supplies_ID", PMD.PB_Special_Request.SR_Supplies_ID }, { "SR_Supplies_Name", PMD.PB_Special_Request.SR_Supplies_Name }, { "SR_Instrumentation_ID", PMD.PB_Special_Request.SR_Instrumentation_ID }, { "SR_Instrumentation_Name", PMD.PB_Special_Request.SR_Instrumentation_Name }, { "SR_Other", PMD.PB_Special_Request.SR_Other }, { "SR_Modify_Date", con.ConvertTimeZone(PMD.PB_Special_Request.SR_TimeZone, Convert.ToDateTime(PMD.PB_Special_Request.SR_Modify_Date)) }, { "SR_TimeZone", PMD.PB_Special_Request.SR_TimeZone } }; } else { Special_Request = new Dictionary <string, object> { { "SR_Unique_ID", con.GetUniqueKey() }, { "SR_Is_Special_Equip_Req", PMD.PB_Special_Request.SR_Is_Special_Equip_Req }, { "SR_Equip_ID", PMD.PB_Special_Request.SR_Equip_ID }, { "SR_Equip_Name", PMD.PB_Special_Request.SR_Equip_Name }, { "SR_Supplies_ID", PMD.PB_Special_Request.SR_Supplies_ID }, { "SR_Supplies_Name", PMD.PB_Special_Request.SR_Supplies_Name }, { "SR_Instrumentation_ID", PMD.PB_Special_Request.SR_Instrumentation_ID }, { "SR_Instrumentation_Name", PMD.PB_Special_Request.SR_Instrumentation_Name }, { "SR_Other", PMD.PB_Special_Request.SR_Other }, { "SR_Created_By", PMD.PB_Special_Request.SR_Created_By }, { "SR_User_Name", PMD.PB_Special_Request.SR_User_Name }, { "SR_Create_Date", con.ConvertTimeZone(PMD.PB_Special_Request.SR_TimeZone, Convert.ToDateTime(PMD.PB_Special_Request.SR_Create_Date)) }, { "SR_Modify_Date", con.ConvertTimeZone(PMD.PB_Special_Request.SR_TimeZone, Convert.ToDateTime(PMD.PB_Special_Request.SR_Modify_Date)) }, { "SR_Is_Active", PMD.PB_Special_Request.SR_Is_Active }, { "SR_Is_Deleted", PMD.PB_Special_Request.SR_Is_Deleted }, { "SR_TimeZone", PMD.PB_Special_Request.SR_TimeZone }, }; } initialData.Add("PB_Special_Request", Special_Request); } if (PMD.PB_Insurance_Precertification_Authorization != null) { Dictionary <string, object> Insurance_Precertification_Authorization; if (booking.PB_Insurance_Precertification_Authorization != null) { Insurance_Precertification_Authorization = new Dictionary <string, object> { { "IPA_Insurace_Company_Phone_No", PMD.PB_Insurance_Precertification_Authorization.IPA_Insurace_Company_Phone_No }, { "IPA_Insurace_Company_Representative", PMD.PB_Insurance_Precertification_Authorization.IPA_Insurace_Company_Representative }, { "IPA_Authorization_Name", PMD.PB_Insurance_Precertification_Authorization.IPA_Authorization_Name }, { "IPA_DOA", con.ConvertTimeZone(PMD.PB_Insurance_Precertification_Authorization.IPA_TimeZone, Convert.ToDateTime(PMD.PB_Insurance_Precertification_Authorization.IPA_DOA)) }, { "IPA_Modify_Date", con.ConvertTimeZone(PMD.PB_Insurance_Precertification_Authorization.IPA_TimeZone, Convert.ToDateTime(PMD.PB_Insurance_Precertification_Authorization.IPA_Modify_Date)) }, { "IPA_TimeZone", PMD.PB_Insurance_Precertification_Authorization.IPA_TimeZone } }; } else { Insurance_Precertification_Authorization = new Dictionary <string, object> { { "IPA_Unique_ID", con.GetUniqueKey() }, { "IPA_Insurace_Company_Phone_No", PMD.PB_Insurance_Precertification_Authorization.IPA_Insurace_Company_Phone_No }, { "IPA_Insurace_Company_Representative", PMD.PB_Insurance_Precertification_Authorization.IPA_Insurace_Company_Representative }, { "IPA_Authorization_Name", PMD.PB_Insurance_Precertification_Authorization.IPA_Authorization_Name }, { "IPA_DOA", con.ConvertTimeZone(PMD.PB_Insurance_Precertification_Authorization.IPA_TimeZone, Convert.ToDateTime(PMD.PB_Insurance_Precertification_Authorization.IPA_DOA)) }, { "IPA_Created_By", PMD.PB_Insurance_Precertification_Authorization.IPA_Created_By }, { "IPA_User_Name", PMD.PB_Insurance_Precertification_Authorization.IPA_User_Name }, { "IPA_Create_Date", con.ConvertTimeZone(PMD.PB_Insurance_Precertification_Authorization.IPA_TimeZone, Convert.ToDateTime(PMD.PB_Insurance_Precertification_Authorization.IPA_Create_Date)) }, { "IPA_Modify_Date", con.ConvertTimeZone(PMD.PB_Insurance_Precertification_Authorization.IPA_TimeZone, Convert.ToDateTime(PMD.PB_Insurance_Precertification_Authorization.IPA_Modify_Date)) }, { "IPA_Is_Active", PMD.PB_Insurance_Precertification_Authorization.IPA_Is_Active }, { "IPA_Is_Deleted", PMD.PB_Insurance_Precertification_Authorization.IPA_Is_Deleted }, { "IPA_TimeZone", PMD.PB_Insurance_Precertification_Authorization.IPA_TimeZone }, }; } initialData.Add("PB_Insurance_Precertification_Authorization", Insurance_Precertification_Authorization); } //Main section DocumentReference docRef = Db.Collection("MT_Patient_Booking").Document(PMD.PB_Unique_ID); WriteResult Result = await docRef.UpdateAsync(initialData); if (Result != null) { Response.Status = con.StatusSuccess; Response.Message = con.MessageSuccess; Response.Data = PMD; } else { Response.Status = con.StatusNotInsert; Response.Message = con.MessageNotInsert; Response.Data = null; } } } catch (Exception ex) { Response.Status = con.StatusFailed; Response.Message = con.MessageFailed + ", Exception : " + ex.Message; } return(ConvertToJSON(Response)); }
public async Task <HttpResponseMessage> BookingSchedule(string Slug) { Db = con.SurgeryCenterDb(Slug); BookingResponse Response = new BookingResponse(); try { MT_Patient_Booking Booking = new MT_Patient_Booking(); MT_PatientInfomation Patient = new MT_PatientInfomation(); Query ObjQuery = Db.Collection("MT_Patient_Booking").WhereEqualTo("PB_Is_Deleted", false).WhereEqualTo("PB_Is_Active", true); QuerySnapshot ObjQuerySnap = await ObjQuery.GetSnapshotAsync(); if (ObjQuerySnap != null && ObjQuerySnap.Documents.Count > 0) { foreach (DocumentSnapshot docsnap in ObjQuerySnap.Documents) { Booking = docsnap.ConvertTo <MT_Patient_Booking>(); if (Booking.PB_Notifications != null) { if (Booking.PB_Patient_ID != null && Booking.PB_Patient_ID != "") { Query PatientQuery = Db.Collection("MT_PatientInfomation").WhereEqualTo("Patient_Is_Active", true).WhereEqualTo("Patient_Is_Deleted", false).WhereEqualTo("Patient_Unique_ID", Booking.PB_Patient_ID); QuerySnapshot ObjPatientQuerySnap = await PatientQuery.GetSnapshotAsync(); if (ObjPatientQuerySnap != null) { List <string> Namelist = new List <string>(); List <string> Emaillist = new List <string>(); Patient = ObjPatientQuerySnap.Documents[0].ConvertTo <MT_PatientInfomation>(); Email = Patient.Patient_Email; Phone = Patient.Patient_Primary_No; Name = Patient.Patient_First_Name + " " + Patient.Patient_Middle_Name + " " + Patient.Patient_Last_Name; Namelist.Add(Name); Emaillist.Add(Email); BookingDate = Booking.PB_Booking_Date; foreach (MT_Notifications noti in Booking.PB_Notifications) { if (noti.NFT_Actions != null) { foreach (Notification_Action action in noti.NFT_Actions) { if (action.NFA_Status == "Pending") { if (action.NFA_DayOrWeek == 0) { if (action.NFA_Be_Af == 0) { Days = (-1) * action.NFA_Days; } else if (action.NFA_Be_Af == 1) { Days = action.NFA_Days; } } else if (action.NFA_DayOrWeek == 1) { if (action.NFA_Be_Af == 0) { Days = (-7) * action.NFA_Days; } else if (action.NFA_Be_Af == 1) { Days = 7 * action.NFA_Days; } } NoticationSendingDay = BookingDate.AddDays(Days); if (DateTime.Now.Date.ToString("MM/dd/yyyy") == NoticationSendingDay.Date.ToString("MM/dd/yyyy")) { TimeSpan NotificationTiming = TimeSpan.Parse(action.NFA_Timing); TimeSpan timeOfDay = DateTime.Now.TimeOfDay; if (TimeSpan.Compare(timeOfDay, NotificationTiming) >= 0) { switch (action.NFA_Action_Type) { case "SMS": Sms sms = new Sms(); sms.Receiver_Contact_No = Phone; sms.Message_Body = action.NFA_Message; sms.Message_Date = con.ConvertTimeZone(action.NFA_TimeZone, Convert.ToDateTime(DateTime.Now)); sms.Message_Title = action.NFA_Action_Title; SMSObj.SendSMS(sms); Response = await UpdateAction(Booking.PB_Unique_ID, action.NFA_Unique_ID, Slug); break; case "Email": Email email = new Email(); email.To_Name = Namelist; email.To_Email = Emaillist; email.PlainTextContent = ""; email.HtmlContent = action.NFA_Message; await EmailObj.Send(email); Response = await UpdateAction(Booking.PB_Unique_ID, action.NFA_Unique_ID, Slug); break; case "Whatsapp": Whatsapp whatsapp = new Whatsapp(); whatsapp.Receiver_Contact_No = Phone; whatsapp.Message_Title = action.NFA_Action_Title; whatsapp.Message_Date = con.ConvertTimeZone(action.NFA_TimeZone, Convert.ToDateTime(DateTime.Now)); whatsapp.Message_Body = action.NFA_Message; WhatsappObj.SendMessageWithWhatsapp(whatsapp); Response = await UpdateAction(Booking.PB_Unique_ID, action.NFA_Unique_ID, Slug); break; case "Voice": Voice voice = new Voice(); voice.Voice_Call_Date = con.ConvertTimeZone(action.NFA_TimeZone, Convert.ToDateTime(DateTime.Now)); voice.Voice_Receiver_Name = Patient.Patient_First_Name; voice.Voice_Call_Body = action.NFA_Message; voice.Voice_Receiver_Contact_No = Phone; VoiceObj.SetVoiceCall(voice); Response = await UpdateAction(Booking.PB_Unique_ID, action.NFA_Unique_ID, Slug); break; default: break; } } } } } } } } } } } Response.Status = con.StatusSuccess; Response.Message = con.MessageSuccess; } else { Response.Status = con.StatusDNE; Response.Message = con.MessageDNE; } } catch (Exception ex) { Response.Status = con.StatusFailed; Response.Message = con.MessageFailed + ", Exception : " + ex.Message; } return(ConvertToJSON(Response)); }
private async Task <BookingResponse> UpdateAction(string BookingID, string ActionID, string Slug) { Db = con.SurgeryCenterDb(Slug); BookingResponse Response = new BookingResponse(); try { MT_Patient_Booking Booking = new MT_Patient_Booking(); List <MT_Notifications> notilist = new List <MT_Notifications>(); List <Notification_Action> Actionlist = new List <Notification_Action>(); Query QueryObj = Db.Collection("MT_Patient_Booking").WhereEqualTo("PB_Unique_ID", BookingID); QuerySnapshot ObjQuerySnap = await QueryObj.GetSnapshotAsync(); if (ObjQuerySnap != null) { Booking = ObjQuerySnap.Documents[0].ConvertTo <MT_Patient_Booking>(); if (Booking.PB_Notifications != null && Booking.PB_Notifications.Count > 0) { foreach (MT_Notifications noti in Booking.PB_Notifications) { if (noti.NFT_Actions != null && noti.NFT_Actions.Count > 0) { foreach (Notification_Action action in noti.NFT_Actions) { if (action.NFA_Unique_ID == ActionID) { action.NFA_Status = "Sent"; Actionlist.Add(action); } else { Actionlist.Add(action); } } noti.NFT_Actions = Actionlist; } notilist.Add(noti); } } Dictionary <string, object> initialData = new Dictionary <string, object> { { "PB_Notifications", notilist } }; DocumentReference documentRef = Db.Collection("MT_Patient_Booking").Document(BookingID); WriteResult Result = await documentRef.UpdateAsync(initialData); if (Result != null) { Response.Status = con.StatusSuccess; Response.Message = con.MessageSuccess; } else { Response.Status = con.StatusNotUpdate; Response.Message = con.MessageNotUpdate; } } } catch (Exception ex) { Response.Status = con.StatusFailed; Response.Message = con.MessageFailed + ", Exception : " + ex.Message; } return(Response); }
public async Task <HttpResponseMessage> CreateAsync(MT_Patient_Form_Data PFMD) { Db = con.SurgeryCenterDb(PFMD.Slug); PatientFormResponse Response = new PatientFormResponse(); try { UniqueID = con.GetUniqueKey(); PFMD.PFD_Unique_ID = UniqueID; DocumentReference docRef = Db.Collection("MT_Patient_Form_Data").Document(UniqueID); WriteResult Result = await docRef.SetAsync(PFMD); if (Result != null) { MT_Patient_Booking BookingInfo = new MT_Patient_Booking(); MT_Staff_Members staffinfo = new MT_Staff_Members(); MT_System_EmailTemplates sysemail = new MT_System_EmailTemplates(); Query ObjQuery = Db.Collection("MT_Patient_Booking").WhereEqualTo("PB_Is_Active", true).WhereEqualTo("PB_Is_Deleted", false).WhereEqualTo("PB_Unique_ID", PFMD.PFD_Booking_ID); QuerySnapshot ObjQuerySnap = await ObjQuery.GetSnapshotAsync(); if (ObjQuerySnap != null) { BookingInfo = ObjQuerySnap.Documents[0].ConvertTo <MT_Patient_Booking>(); ObjQuery = Db.Collection("MT_Staff_Members").WhereEqualTo("Staff_Is_Active", true).WhereEqualTo("Staff_Is_Deleted", false).WhereEqualTo("Staff_Unique_ID", BookingInfo.PB_Surgical_Procedure_Information.SPI_Surgeon_ID); ObjQuerySnap = await ObjQuery.GetSnapshotAsync(); if (ObjQuerySnap != null) { staffinfo = ObjQuerySnap.Documents[0].ConvertTo <MT_Staff_Members>(); ObjQuery = Db.Collection("MT_System_EmailTemplates").WhereEqualTo("SET_Is_Active", true).WhereEqualTo("SET_Is_Deleted", false).WhereEqualTo("SET_Name", "Appointment Cancellation"); ObjQuerySnap = await ObjQuery.GetSnapshotAsync(); if (ObjQuerySnap != null) { sysemail = ObjQuerySnap.Documents[0].ConvertTo <MT_System_EmailTemplates>(); Email email = new Email(); if (sysemail.SET_Bcc != null && sysemail.SET_Bcc.Length > 0) { email.Bcc_Email = sysemail.SET_Bcc.ToList(); } if (sysemail.SET_CC != null && sysemail.SET_CC.Length > 0) { email.Cc_Email = sysemail.SET_CC.ToList(); } List <string> PatiEmail = new List <string>(); List <string> PatiName = new List <string>(); PatiEmail.Add(staffinfo.Staff_Email); PatiName.Add(staffinfo.Staff_Name); email.To_Email = PatiEmail; email.To_Name = PatiName; email.From_Name = sysemail.SET_From_Name; email.From_Email = sysemail.SET_From_Email; email.HtmlContent = (sysemail.SET_Header == null ? "" : sysemail.SET_Header) + "<br/>" + "<br/>" + sysemail.SET_Message.ToString().Replace("[FirstName]", BookingInfo.PB_Patient_Name) .Replace("[Dr Name]", BookingInfo.PB_Surgical_Procedure_Information == null ? "" : BookingInfo.PB_Surgical_Procedure_Information.SPI_Surgeon_Name) .Replace("[mm/dd/yy]", BookingInfo.PB_Booking_Date.ToString("mm/dd/yy")) .Replace("[hr:mn]", BookingInfo.PB_Booking_Time.ToString()) .Replace("[FacilityName]", BookingInfo.PB_Booking_Surgery_Center_Name) + "<br/>" + "<br/>" + sysemail.SET_Footer.ToString().Replace("[FacilityName]", BookingInfo.PB_Booking_Surgery_Center_Name) .Replace("[Email]", (BookingInfo.PB_Patient_Email == null ? "" : BookingInfo.PB_Patient_Email)); email.Subject = "[FirstName], your appointment has been cancelled".Replace("[FirstName]", BookingInfo.PB_Patient_Name); //var message = await ObjEmailer.Send(email); Response.Status = con.StatusSuccess; Response.Message = con.MessageSuccess + " Email Status : " + ""; } else { Response.Status = con.StatusSuccess; Response.Message = con.MessageSuccess; Response.Data = PFMD; } } else { Response.Status = con.StatusSuccess; Response.Message = con.MessageSuccess; Response.Data = PFMD; } } else { Response.Status = con.StatusSuccess; Response.Message = con.MessageSuccess; Response.Data = PFMD; } } else { Response.Status = con.StatusNotInsert; Response.Message = con.MessageNotInsert; Response.Data = null; } } catch (Exception ex) { Response.Status = con.StatusFailed; Response.Message = con.MessageFailed + ", Exception : " + ex.Message; } return(ConvertToJSON(Response)); }