Example #1
0
        ///<summary>Called from Eclaims and includes multiple claims.  Returns the string that was sent.
        ///The string needs to be parsed to determine the transaction numbers used for each claim.</summary>
        public static string SendBatch(Clearinghouse clearinghouseClin, List <ClaimSendQueueItem> queueItems, int batchNum, EnumClaimMedType medType,
                                       bool isAutomatic)
        {
            //each batch is already guaranteed to be specific to one clearinghouse, one clinic, and one EnumClaimMedType
            //Clearinghouse clearhouse=ClearinghouseL.GetClearinghouse(queueItems[0].ClearinghouseNum);
            string saveFile = GetFileName(clearinghouseClin, batchNum, isAutomatic);

            if (saveFile == "")
            {
                return("");
            }
            string messageText;

            try{
                messageText = GenerateBatch(clearinghouseClin, queueItems, batchNum, medType);
            }
            catch (ODException odex) {
                MessageBox.Show(odex.Message, "x837");
                return("");
            }
            if (clearinghouseClin.IsClaimExportAllowed)
            {
                if (clearinghouseClin.CommBridge == EclaimsCommBridge.PostnTrack)
                {
                    //need to clear out all CRLF from entire file
                    messageText = messageText.Replace("\r", "");
                    messageText = messageText.Replace("\n", "");
                }
                if (ODBuild.IsWeb())
                {
                    try {
                        ODCloudClient.ExportClaim(saveFile, messageText, doOverwriteFile: clearinghouseClin.CommBridge != EclaimsCommBridge.RECS);
                    }
                    catch (ODException odEx) {
                        if (odEx.ErrorCodeAsEnum == ODException.ErrorCodes.FileExists && clearinghouseClin.CommBridge == EclaimsCommBridge.RECS)
                        {
                            MessageBox.Show(RECSFileExistsMsg, "x837");
                        }
                        else
                        {
                            MessageBox.Show(odEx.Message, "x837");
                        }
                        if (odEx.ErrorCodeAsEnum != ODException.ErrorCodes.ClaimArchiveFailed)                       //If archiving failed, we can continue with sending.
                        {
                            return("");
                        }
                    }
                    catch (Exception ex) {
                        MessageBox.Show(ex.Message, "x837");
                        return("");
                    }
                }
                else
                {
                    File.WriteAllText(saveFile, messageText, Encoding.ASCII);
                    CopyToArchive(saveFile);
                }
            }
            return(messageText);
        }
Example #2
0
        ///<summary>Sends data for Patient to a mailbox file and launches the program.</summary>
        public static void SendData(Program ProgramCur, Patient pat)
        {
            OpenDentBusiness.Shared.Sirona.Lans_g = Lans.g;
            string path = Programs.GetProgramPath(ProgramCur);
            List <ProgramProperty> listProgramProperties = ProgramProperties.GetForProgram(ProgramCur.ProgramNum);
            List <string>          listIniLines          = new List <string>();

            if (pat != null)
            {
                try {
                    #region Construct ini info
                    //line formats: first two bytes are the length of line including first two bytes and \r\n
                    //each field is terminated by null (byte 0).
                    //Append U token to siomin.sdx file
                    StringBuilder line  = new StringBuilder();
                    char          nTerm = (char)0;       //Convert.ToChar(0);
                    line.Append("U");                    //U signifies Update patient in sidexis. Gets ignored if new patient.
                    line.Append(nTerm);
                    line.Append(pat.LName);
                    line.Append(nTerm);
                    line.Append(pat.FName);
                    line.Append(nTerm);
                    line.Append(pat.Birthdate.ToString("dd.MM.yyyy"));
                    line.Append(nTerm);
                    //leave initial patient id blank. This updates sidexis to patNums used in Open Dental
                    line.Append(nTerm);
                    line.Append(pat.LName);
                    line.Append(nTerm);
                    line.Append(pat.FName);
                    line.Append(nTerm);
                    line.Append(pat.Birthdate.ToString("dd.MM.yyyy"));
                    line.Append(nTerm);
                    //Patient id:
                    ProgramProperty PPCur = ProgramProperties.GetCur(listProgramProperties, "Enter 0 to use PatientNum, or 1 to use ChartNum");;
                    if (PPCur.PropertyValue == "0")
                    {
                        line.Append(pat.PatNum.ToString());
                    }
                    else
                    {
                        line.Append(pat.ChartNumber);
                    }
                    line.Append(nTerm);
                    if (pat.Gender == PatientGender.Female)
                    {
                        line.Append("F");
                    }
                    else
                    {
                        line.Append("M");
                    }
                    line.Append(nTerm);
                    line.Append(Providers.GetAbbr(Patients.GetProvNum(pat)));
                    line.Append(nTerm);
                    line.Append("OpenDental");
                    line.Append(nTerm);
                    line.Append("Sidexis");
                    line.Append(nTerm);
                    line.Append("\r\n");
                    listIniLines.Add(line.ToString());
                    //Append N token to siomin.sdx file
                    //N signifies create New patient in sidexis. If patient already exists,
                    //then it simply updates any old data.
                    line = new StringBuilder();
                    line.Append("N");
                    line.Append(nTerm);
                    line.Append(pat.LName);
                    line.Append(nTerm);
                    line.Append(pat.FName);
                    line.Append(nTerm);
                    line.Append(pat.Birthdate.ToString("dd.MM.yyyy"));
                    line.Append(nTerm);
                    //Patient id:
                    if (PPCur.PropertyValue == "0")
                    {
                        line.Append(pat.PatNum.ToString());
                    }
                    else
                    {
                        line.Append(pat.ChartNumber);
                    }
                    line.Append(nTerm);
                    if (pat.Gender == PatientGender.Female)
                    {
                        line.Append("F");
                    }
                    else
                    {
                        line.Append("M");
                    }
                    line.Append(nTerm);
                    line.Append(Providers.GetAbbr(Patients.GetProvNum(pat)));
                    line.Append(nTerm);
                    line.Append("OpenDental");
                    line.Append(nTerm);
                    line.Append("Sidexis");
                    line.Append(nTerm);
                    line.Append("\r\n");
                    listIniLines.Add(line.ToString());
                    //Append A token to siomin.sdx file
                    //A signifies Autoselect patient.
                    line = new StringBuilder();
                    line.Append("A");
                    line.Append(nTerm);
                    line.Append(pat.LName);
                    line.Append(nTerm);
                    line.Append(pat.FName);
                    line.Append(nTerm);
                    line.Append(pat.Birthdate.ToString("dd.MM.yyyy"));
                    line.Append(nTerm);
                    if (PPCur.PropertyValue == "0")
                    {
                        line.Append(pat.PatNum.ToString());
                    }
                    else
                    {
                        line.Append(pat.ChartNumber);
                    }
                    line.Append(nTerm);
                    if (ODBuild.IsWeb())
                    {
                        line.Append("{{SystemInformation.ComputerName}}");                        //Will be replaced on the client side
                    }
                    else
                    {
                        line.Append(SystemInformation.ComputerName);
                    }
                    line.Append(nTerm);
                    line.Append(DateTime.Now.ToString("dd.MM.yyyy"));
                    line.Append(nTerm);
                    line.Append(DateTime.Now.ToString("HH.mm.ss"));
                    line.Append(nTerm);
                    line.Append("OpenDental");
                    line.Append(nTerm);
                    line.Append("Sidexis");
                    line.Append(nTerm);
                    line.Append("0");                    //0=no image selection
                    line.Append(nTerm);
                    line.Append("\r\n");
                    listIniLines.Add(line.ToString());
                    #endregion
                    if (!ODBuild.IsWeb())
                    {
                        OpenDentBusiness.Shared.Sirona.WriteToSendBoxFile(path, listIniLines);
                    }
                }
                catch (Exception ex) {
                    FriendlyException.Show(Lan.g("Sirona", "Error preparing Sidexis for patient message."), ex);
                    return;
                }
            }            //if patient is loaded
            //Start Sidexis.exe whether patient loaded or not.
            try {
                if (ODBuild.IsWeb())
                {
                    ODCloudClient.SendToSirona(path, listIniLines);
                }
                else
                {
                    ODFileUtils.ProcessStart(path);
                }
            }
            catch (Exception ex) {
                FriendlyException.Show(path + " is not available.", ex);
            }
        }