예제 #1
0
 ///<summary>Updates only the changed fields of the SMS text message (if any).</summary>
 public static bool Update(SmsFromMobile smsFromMobile, SmsFromMobile oldSmsFromMobile)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         return(Meth.GetBool(MethodBase.GetCurrentMethod(), smsFromMobile, oldSmsFromMobile));
     }
     return(Crud.SmsFromMobileCrud.Update(smsFromMobile, oldSmsFromMobile));
 }
예제 #2
0
 ///<summary>Call ProcessInboundSms instead.</summary>
 private static long Insert(SmsFromMobile smsFromMobile)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         smsFromMobile.SmsFromMobileNum = Meth.GetLong(MethodBase.GetCurrentMethod(), smsFromMobile);
         return(smsFromMobile.SmsFromMobileNum);
     }
     return(Crud.SmsFromMobileCrud.Insert(smsFromMobile));
 }
예제 #3
0
        ///<summary>Attempts to find exact match for patient. If found, creates commlog, associates Patnum, and inserts into DB.
        ///Otherwise, it simply inserts SmsFromMobiles into the DB. ClinicNum should have already been set before calling this function.</summary>
        public static void ProcessInboundSms(List <SmsFromMobile> listMessages)
        {
            if (listMessages == null || listMessages.Count == 0)
            {
                return;
            }
            List <SmsBlockPhone> listBlockedPhones = SmsBlockPhones.GetDeepCopy();

            for (int i = 0; i < listMessages.Count; i++)
            {
                SmsFromMobile sms = listMessages[i];
                if (listBlockedPhones.Any(x => TelephoneNumbers.AreNumbersEqual(x.BlockWirelessNumber, sms.MobilePhoneNumber)))
                {
                    continue;                    //The office has blocked this number.
                }
                sms.DateTimeReceived = DateTime.Now;
                SmsPhone smsPhone    = SmsPhones.GetByPhone(sms.SmsPhoneNumber);
                string   countryCode = CultureInfo.CurrentCulture.Name.Substring(CultureInfo.CurrentCulture.Name.Length - 2);
                if (smsPhone != null)
                {
                    sms.ClinicNum = smsPhone.ClinicNum;
                    countryCode   = smsPhone.CountryCode;
                }
                //First try the clinic that belongs to this phone.
                List <long> listClinicNums = new List <long>();
                if (sms.ClinicNum != 0)
                {
                    listClinicNums.Add(sms.ClinicNum);
                }
                List <long[]> listPatNums = FindPatNums(sms.MobilePhoneNumber, countryCode, listClinicNums);
                if (listPatNums.Count == 0 && listClinicNums.Count > 0)              //Could not find that patient in this clinic so try again for all clinics.
                {
                    listPatNums = FindPatNums(sms.MobilePhoneNumber, countryCode);
                }
                sms.MatchCount = listPatNums.Count;
                //Item1=PatNum; Item2=Guarantor
                if (listPatNums.Count == 0 || listPatNums.Select(x => x[1]).Distinct().ToList().Count != 1)
                {
                    //We could not find definitive match, either 0 matches found, or more than one match found with different garantors
                    Insert(sms);
                    continue;
                }
                if (listPatNums.Count == 1)
                {
                    sms.PatNum = listPatNums[0][0];                  //PatNum
                }
                else
                {
                    sms.PatNum = listPatNums[0][1];                  //GuarantorNum;  more than one match, but all have the same garantor.
                }
                Commlog comm = new Commlog()
                {
                    CommDateTime   = sms.DateTimeReceived,
                    Mode_          = CommItemMode.Text,
                    Note           = sms.MsgText,
                    PatNum         = sms.PatNum,
                    CommType       = Commlogs.GetTypeAuto(CommItemTypeAuto.TEXT),
                    SentOrReceived = CommSentOrReceived.Received
                };
                sms.CommlogNum = Commlogs.Insert(comm);
                Insert(sms);
            }
            UpdateSmsNotification();
        }
예제 #4
0
        ///<summary>Attempts to find exact match for patient. If found, creates commlog, associates Patnum, and inserts into DB.
        ///Otherwise, it simply inserts SmsFromMobiles into the DB. ClinicNum should have already been set before calling this function.</summary>
        public static void ProcessInboundSms(List <SmsFromMobile> listMessages)
        {
            if (listMessages == null || listMessages.Count == 0)
            {
                return;
            }
            List <SmsBlockPhone> listBlockedPhones = SmsBlockPhones.GetDeepCopy();

            for (int i = 0; i < listMessages.Count; i++)
            {
                SmsFromMobile sms = listMessages[i];
                if (listBlockedPhones.Any(x => TelephoneNumbers.AreNumbersEqual(x.BlockWirelessNumber, sms.MobilePhoneNumber)))
                {
                    continue;                    //The office has blocked this number.
                }
                sms.DateTimeReceived = DateTime.Now;
                string countryCode = CultureInfo.CurrentCulture.Name.Substring(CultureInfo.CurrentCulture.Name.Length - 2);
                if (sms.SmsPhoneNumber != SmsPhones.SHORTCODE)
                {
                    SmsPhone smsPhone = SmsPhones.GetByPhone(sms.SmsPhoneNumber);
                    if (smsPhone != null)
                    {
                        sms.ClinicNum = smsPhone.ClinicNum;
                        countryCode   = smsPhone.CountryCode;
                    }
                }
                if (!PrefC.HasClinicsEnabled)
                {
                    //We want customer side records of this message to list SmsPhones.SHORTCODE as the number on which the message was sent.  This ensures we do
                    //not record this communication on a different valid SmsPhone/VLN that it didn't truly take place on.  However, on the HQ side, we want
                    //records of this communication to be listed as having taken place on the actual Short Code number.  In the case of a Short Code,
                    //sms.SmsPhoneNumber will read "SHORTCODE", which won't be found in the customer's SmsPhone table.  As a result, the code to use the
                    //customer's SmsPhone.ClinicNum and Country code cannot be used.  Since this code was intended to handle the case where the customer had
                    //turned clinics on->off, we will specifically check if the customer has disabled clinics and only then change the sms.ClinicNum.
                    //Otherwise, trust HQ sent the correct ClinicNum.  Since we expect to only use Short Codes in the US/Canada, we will trust the server we
                    //are processing inbound sms will have the correct country code, which will be used here.
                    sms.ClinicNum = 0;
                }
                //First try the clinic that belongs to this phone.
                List <long> listClinicNums = new List <long>();
                if (sms.ClinicNum != 0)
                {
                    listClinicNums.Add(sms.ClinicNum);
                }
                List <long[]> listPatNums = FindPatNums(sms.MobilePhoneNumber, countryCode, listClinicNums);
                if (listPatNums.Count == 0 && listClinicNums.Count > 0)            //Could not find that patient in this clinic so try again for all clinics.
                {
                    listPatNums = FindPatNums(sms.MobilePhoneNumber, countryCode);
                }
                sms.MatchCount = listPatNums.Count;
                //Item1=PatNum; Item2=Guarantor
                if (listPatNums.Count == 0 || listPatNums.Select(x => x[1]).Distinct().ToList().Count != 1)
                {
                    //We could not find definitive match, either 0 matches found, or more than one match found with different garantors
                    Insert(sms);
                    //Alert ODMobile where applicable.
                    PushNotificationUtils.ODM_NewTextMessage(sms);
                    continue;
                }
                if (listPatNums.Count == 1)
                {
                    sms.PatNum = listPatNums[0][0];                  //PatNum
                }
                else
                {
                    sms.PatNum = listPatNums[0][1];                  //GuarantorNum;  more than one match, but all have the same garantor.
                }
                Commlog comm = new Commlog()
                {
                    CommDateTime   = sms.DateTimeReceived,
                    Mode_          = CommItemMode.Text,
                    Note           = sms.MsgText,
                    PatNum         = sms.PatNum,
                    CommType       = Commlogs.GetTypeAuto(CommItemTypeAuto.TEXT),
                    SentOrReceived = CommSentOrReceived.Received
                };
                sms.CommlogNum = Commlogs.Insert(comm);
                Insert(sms);
                //Alert ODMobile where applicable.
                PushNotificationUtils.ODM_NewTextMessage(sms, sms.PatNum);
            }
            //We used to update the SmsNotification indicator via a queries and a signal here.  Now managed by the eConnector.
        }