Ejemplo n.º 1
0
        ///<summary>Returns the Provider Taxonomy code for the given specialty. Always 10 characters, validated.</summary>
        public static string GetTaxonomy(Provider provider)
        {
            if (provider.TaxonomyCodeOverride != "")
            {
                return(provider.TaxonomyCodeOverride);
            }
            string spec     = "1223G0001X";      //general
            Def    provSpec = Defs.GetDef(DefCat.ProviderSpecialties, provider.Specialty);

            if (provSpec == null)
            {
                return(spec);
            }
            switch (provSpec.ItemName)
            {
            case "General": spec = "1223G0001X"; break;

            case "Hygienist": spec = "124Q00000X"; break;

            case "PublicHealth": spec = "1223D0001X"; break;

            case "Endodontics": spec = "1223E0200X"; break;

            case "Pathology": spec = "1223P0106X"; break;

            case "Radiology": spec = "1223X0008X"; break;

            case "Surgery": spec = "1223S0112X"; break;

            case "Ortho": spec = "1223X0400X"; break;

            case "Pediatric": spec = "1223P0221X"; break;

            case "Perio": spec = "1223P0300X"; break;

            case "Prosth": spec = "1223P0700X"; break;

            case "Denturist": spec = "122400000X"; break;

            case "Assistant": spec = "126800000X"; break;

            case "LabTech": spec = "126900000X"; break;
            }
            return(spec);
        }
Ejemplo n.º 2
0
        ///<summary>Any filenames mentioned in the fileList which are not attached to the given patient are properly attached to that patient. Returns the total number of documents that were newly attached to the patient.</summary>
        public static int InsertMissing(Patient patient, List <string> fileList)
        {
            //No need to check RemotingRole; no call to db.
            int       countAdded = 0;
            DataTable table      = Documents.GetFileNamesForPatient(patient.PatNum);

            for (int j = 0; j < fileList.Count; j++)
            {
                string fileName = Path.GetFileName(fileList[j]);
                if (!IsAcceptableFileName(fileName))
                {
                    continue;
                }
                bool inList = false;
                for (int i = 0; i < table.Rows.Count && !inList; i++)
                {
                    inList = (table.Rows[i]["FileName"].ToString() == fileName);
                }
                if (!inList)                //OD found new images in the patient's folder that aren't part of the DB.
                {
                    Document doc = new Document();
                    if (PrefC.AtoZfolderUsed == DataStorageType.LocalAtoZ)
                    {
                        doc.DateCreated = File.GetLastWriteTime(fileList[j]);
                    }
                    else                      //Cloud
                    {
                        doc.DateCreated = DateTime.Now;
                    }
                    DateTime datePrevious = doc.DateTStamp;
                    doc.Description = fileName;
                    doc.DocCategory = Defs.GetFirstForCategory(DefCat.ImageCats, true).DefNum;
                    doc.FileName    = fileName;
                    doc.PatNum      = patient.PatNum;
                    Insert(doc, patient);
                    countAdded++;
                    string docCat = Defs.GetDef(DefCat.ImageCats, doc.DocCategory).ItemName;
                    SecurityLogs.MakeLogEntry(Permissions.ImageEdit, patient.PatNum, Lans.g("ContrImages", "Document Created: A file") + ", " + doc.FileName + ", "
                                              + Lans.g("ContrImages", "placed into the patient's AtoZ images folder from outside of the program was detected and a record automatically inserted into the first image category") + ", " + docCat, doc.DocNum, datePrevious);
                }
            }
            return(countAdded);
        }
Ejemplo n.º 3
0
        public static string GetChangesDescription(TaskHist taskCur, TaskHist taskNext)
        {
            if (taskCur.Descript.StartsWith("This task was cut from task list ") || taskCur.Descript.StartsWith("This task was copied from task "))
            {
                return(taskCur.Descript);
            }
            if (taskCur.DateTimeEntry == DateTime.MinValue)
            {
                return(Lans.g("TaskHists", "New task."));
            }
            StringBuilder strb = new StringBuilder();

            strb.Append("");
            if (taskNext.TaskListNum != taskCur.TaskListNum)
            {
                string   descOne  = Lans.g("TaskHists", "(DELETED)");
                string   descTwo  = Lans.g("TaskHists", "(DELETED)");
                TaskList taskList = TaskLists.GetOne(taskCur.TaskListNum);
                if (taskList != null)
                {
                    descOne = taskList.Descript;
                }
                taskList = TaskLists.GetOne(taskNext.TaskListNum);
                if (taskList != null)
                {
                    descTwo = taskList.Descript;
                }
                strb.Append(Lans.g("TaskHists", "Task list changed from") + " " + descOne + " " + Lans.g("TaskHists", "to") + " " + descTwo + ".\r\n");
            }
            if (taskNext.ObjectType != taskCur.ObjectType)
            {
                strb.Append(Lans.g("TaskHists", "Task attachment changed from") + " "
                            + taskCur.ObjectType.ToString() + " " + Lans.g("TaskHists", "to") + " " + taskNext.ObjectType.ToString() + ".\r\n");
            }
            if (taskNext.KeyNum != taskCur.KeyNum)
            {
                strb.Append(Lans.g("TaskHists", "Task account attachment changed.") + "\r\n");
            }
            if (taskNext.Descript != taskCur.Descript && !taskNext.Descript.StartsWith("This task was cut from task list ") &&
                !taskNext.Descript.StartsWith("This task was copied from task "))
            {
                //We change the description of a task when it is cut/copied.
                //This prevents the history grid from showing a description changed when it wasn't changed by the user.
                strb.Append(Lans.g("TaskHists", "Task description changed.") + "\r\n");
            }
            if (taskNext.TaskStatus != taskCur.TaskStatus)
            {
                strb.Append(Lans.g("TaskHists", "Task status changed from") + " "
                            + taskCur.TaskStatus.ToString() + " " + Lans.g("TaskHists", "to") + " " + taskNext.TaskStatus.ToString() + ".\r\n");
            }
            if (taskNext.DateTimeEntry != taskCur.DateTimeEntry)
            {
                strb.Append(Lans.g("TaskHists", "Task date added changed from") + " "
                            + taskCur.DateTimeEntry.ToString()
                            + " " + Lans.g("TaskHists", "to") + " "
                            + taskNext.DateTimeEntry.ToString() + ".\r\n");
            }
            if (taskNext.UserNum != taskCur.UserNum)
            {
                strb.Append(Lans.g("TaskHists", "Task author changed from ")
                            + Userods.GetUser(taskCur.UserNum).UserName
                            + " " + Lans.g("TaskHists", "to") + " "
                            + Userods.GetUser(taskNext.UserNum).UserName + ".\r\n");
            }
            if (taskNext.DateTimeFinished != taskCur.DateTimeFinished)
            {
                strb.Append(Lans.g("TaskHists", "Task date finished changed from") + " "
                            + taskCur.DateTimeFinished.ToString()
                            + " " + Lans.g("TaskHists", "to") + " "
                            + taskNext.DateTimeFinished.ToString() + ".\r\n");
            }
            if (taskNext.PriorityDefNum != taskCur.PriorityDefNum)
            {
                strb.Append(Lans.g("TaskHists", "Task priority changed from") + " "
                            + Defs.GetDef(DefCat.TaskPriorities, taskCur.PriorityDefNum).ItemName
                            + " " + Lans.g("TaskHists", "to") + " "
                            + Defs.GetDef(DefCat.TaskPriorities, taskNext.PriorityDefNum).ItemName + ".\r\n");
            }
            if (taskCur.IsNoteChange)              //Using taskOld because the notes changed from the old one to the new one.
            {
                strb.Append(Lans.g("TaskHists", "Task notes changed."));
            }
            return(strb.ToString());
        }
Ejemplo n.º 4
0
        ///<summary>Sends an SFTP message to TSI to suspend the account for the guarantor passed in.  Returns empty string if successful.
        ///Returns a translated error message that should be displayed to the user if anything goes wrong.</summary>
        public static string SuspendGuar(Patient guar)
        {
            PatAging patAging = Patients.GetAgingListFromGuarNums(new List <long>()
            {
                guar.PatNum
            }).FirstOrDefault();

            if (patAging == null)           //this would only happen if the patient was not in the db??, just in case
            {
                return(Lans.g("TsiTransLogs", "An error occurred when trying to send a suspend message to TSI."));
            }
            long    clinicNum = (PrefC.HasClinicsEnabled?guar.ClinicNum:0);
            Program prog      = Programs.GetCur(ProgramName.Transworld);

            if (prog == null)           //shouldn't be possible, the program link should always exist, just in case
            {
                return(Lans.g("TsiTransLogs", "The Transworld program link does not exist.  Contact support."));
            }
            Dictionary <long, List <ProgramProperty> > dictAllProps = ProgramProperties.GetForProgram(prog.ProgramNum)
                                                                      .GroupBy(x => x.ClinicNum)
                                                                      .ToDictionary(x => x.Key, x => x.ToList());

            if (dictAllProps.Count == 0)           //shouldn't be possible, there should always be a set of props for ClinicNum 0 even if disabled, just in case
            {
                return(Lans.g("TsiTransLogs", "The Transworld program link is not setup properly."));
            }
            if (PrefC.HasClinicsEnabled && !dictAllProps.ContainsKey(clinicNum) && dictAllProps.ContainsKey(0))
            {
                clinicNum = 0;
            }
            string clinicDesc = clinicNum == 0?"Headquarters":Clinics.GetDesc(clinicNum);

            if (!dictAllProps.ContainsKey(clinicNum) ||
                !ValidateClinicSftpDetails(dictAllProps[clinicNum], true))                    //the props should be valid, but this will test the connection using the props
            {
                return(Lans.g("TsiTransLogs", "The Transworld program link is not enabled") + " "
                       + (PrefC.HasClinicsEnabled?(Lans.g("TsiTransLogs", "for the guarantor's clinic") + ", " + clinicDesc + ", "):"")
                       + Lans.g("TsiTransLogs", "or is not setup properly."));
            }
            List <ProgramProperty> listProps = dictAllProps[clinicNum];
            long newBillType = PrefC.GetLong(PrefName.TransworldPaidInFullBillingType);

            if (newBillType == 0 || Defs.GetDef(DefCat.BillingTypes, newBillType) == null)
            {
                return(Lans.g("TsiTransLogs", "The default paid in full billing type is not set.  An automated suspend message cannot be sent until the "
                              + "default paid in full billing type is set in the Transworld program link")
                       + (PrefC.HasClinicsEnabled?(" " + Lans.g("TsiTransLogs", "for the guarantor's clinic") + ", " + clinicDesc):"") + ".");
            }
            string clientId = "";

            if (patAging.ListTsiLogs.Count > 0)
            {
                clientId = patAging.ListTsiLogs[0].ClientId;
            }
            if (string.IsNullOrEmpty(clientId))
            {
                clientId = listProps.Find(x => x.PropertyDesc == "ClientIdAccelerator")?.PropertyValue;
            }
            if (string.IsNullOrEmpty(clientId))
            {
                clientId = listProps.Find(x => x.PropertyDesc == "ClientIdCollection")?.PropertyValue;
            }
            if (string.IsNullOrEmpty(clientId))
            {
                return(Lans.g("TsiTransLogs", "There is no client ID in the Transworld program link")
                       + (PrefC.HasClinicsEnabled?(" " + Lans.g("TsiTransLogs", "for the guarantor's clinic") + ", " + clinicDesc):"") + ".");
            }
            string sftpAddress = listProps.Find(x => x.PropertyDesc == "SftpServerAddress")?.PropertyValue ?? "";
            int    sftpPort;

            if (!int.TryParse(listProps.Find(x => x.PropertyDesc == "SftpServerPort")?.PropertyValue ?? "", out sftpPort))
            {
                sftpPort = 22;              //default to port 22
            }
            string userName     = listProps.Find(x => x.PropertyDesc == "SftpUsername")?.PropertyValue ?? "";
            string userPassword = listProps.Find(x => x.PropertyDesc == "SftpPassword")?.PropertyValue ?? "";

            if (new[] { sftpAddress, userName, userPassword }.Any(x => string.IsNullOrEmpty(x)))
            {
                return(Lans.g("TsiTransLogs", "The SFTP address, username, or password for the Transworld program link") + " "
                       + (PrefC.HasClinicsEnabled?(Lans.g("TsiTransLogs", "for the guarantor's clinic") + ", " + clinicDesc + ", "):"") + Lans.g("TsiTransLogs", "is blank."));
            }
            string msg = TsiMsgConstructor.GenerateUpdate(patAging.PatNum, clientId, TsiTransType.SS, 0.00, patAging.AmountDue);

            try {
                byte[]          fileContents = Encoding.ASCII.GetBytes(TsiMsgConstructor.GetUpdateFileHeader() + "\r\n" + msg);
                TaskStateUpload state        = new Sftp.Upload(sftpAddress, userName, userPassword, sftpPort)
                {
                    Folder        = "/xfer/incoming",
                    FileName      = "TsiUpdates_" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".txt",
                    FileContent   = fileContents,
                    HasExceptions = true
                };
                state.Execute(false);
            }
            catch (Exception ex) {
                return(Lans.g("TsiTransLogs", "There was an error sending the update message to Transworld")
                       + (PrefC.HasClinicsEnabled?(" " + Lans.g("TsiTransLogs", "using the program properties for the guarantor's clinic") + ", " + clinicDesc):"") + ".\r\n"
                       + ex.Message);
            }
            //Upload was successful
            TsiTransLog log = new TsiTransLog()
            {
                PatNum    = patAging.PatNum,
                UserNum   = Security.CurUser.UserNum,
                TransType = TsiTransType.SS,
                //TransDateTime=DateTime.Now,//set on insert, not editable by user
                //DemandType=TsiDemandType.Accelerator,//only valid for placement msgs
                //ServiceCode=TsiServiceCode.Diplomatic,//only valid for placement msgs
                ClientId       = clientId,
                TransAmt       = 0.00,
                AccountBalance = patAging.AmountDue,
                FKeyType       = TsiFKeyType.None, //only used for account trans updates
                FKey           = 0,                //only used for account trans updates
                RawMsgText     = msg,
                ClinicNum      = clinicNum
                                 //,TransJson=""//only valid for placement msgs
            };

            TsiTransLogs.Insert(log);
            //update family billing type to the paid in full billing type pref
            Patients.UpdateFamilyBillingType(newBillType, patAging.PatNum);
            return("");
        }
Ejemplo n.º 5
0
        ///<summary>Used to check whether codes starting with T exist and are in a visible category.  If so, it moves them to the Obsolete category.  If the T code has never been used, then it deletes it.</summary>
        public static void TcodesClear()
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod());
                return;
            }
            //first delete any unused T codes
            string        command         = @"SELECT CodeNum,ProcCode FROM procedurecode
				WHERE CodeNum NOT IN(SELECT CodeNum FROM procedurelog)
				AND CodeNum NOT IN(SELECT CodeNum FROM autocodeitem)
				AND CodeNum NOT IN(SELECT CodeNum FROM procbuttonitem)
				AND CodeNum NOT IN(SELECT CodeNum FROM recalltrigger)
				AND CodeNum NOT IN(SELECT CodeNum FROM benefit)
				AND ProcCode NOT IN(SELECT CodeValue FROM encounter WHERE CodeSystem='CDT')
				AND ProcCode LIKE 'T%'"                ;
            DataTable     table           = Db.GetTable(command);
            List <long>   listCodeNums    = new List <long>();
            List <string> listRecallCodes = RecallTypes.GetDeepCopy()
                                            .SelectMany(x => x.Procedures.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                                            .ToList();

            for (int i = 0; i < table.Rows.Count; i++)
            {
                if (!listRecallCodes.Contains(PIn.String(table.Rows[i]["ProcCode"].ToString())))                 //The ProcCode is not attached to a recall type.
                {
                    listCodeNums.Add(PIn.Long(table.Rows[i]["CodeNum"].ToString()));
                }
            }
            if (listCodeNums.Count > 0)
            {
                ProcedureCodes.ClearFkey(listCodeNums);                //Zero securitylog FKey column for rows to be deleted.
                command = "SELECT FeeNum FROM fee WHERE CodeNum IN(" + String.Join(",", listCodeNums) + ")";
                List <long> listFeeNums = Db.GetListLong(command);
                Fees.DeleteMany(listFeeNums);
                command = "DELETE FROM proccodenote WHERE CodeNum IN(" + String.Join(",", listCodeNums) + ")";
                Db.NonQ(command);
                command = "DELETE FROM procedurecode WHERE CodeNum IN(" + String.Join(",", listCodeNums) + ")";
                Db.NonQ(command);
            }
            //then, move any other T codes to obsolete category
            command = @"SELECT DISTINCT ProcCat FROM procedurecode,definition 
				WHERE procedurecode.ProcCode LIKE 'T%'
				AND definition.IsHidden=0
				AND procedurecode.ProcCat=definition.DefNum"                ;
            table   = Db.GetTable(command);
            long catNum = Defs.GetByExactName(DefCat.ProcCodeCats, "Obsolete");         //check to make sure an Obsolete category exists.
            Def  def;

            if (catNum != 0)           //if a category exists with that name
            {
                def = Defs.GetDef(DefCat.ProcCodeCats, catNum);
                if (!def.IsHidden)
                {
                    def.IsHidden = true;
                    Defs.Update(def);
                    Defs.RefreshCache();
                }
            }
            if (catNum == 0)
            {
                List <Def> listDefs = Defs.GetDefsForCategory(DefCat.ProcCodeCats);
                def           = new Def();
                def.Category  = DefCat.ProcCodeCats;
                def.ItemName  = "Obsolete";
                def.ItemOrder = listDefs.Count;
                def.IsHidden  = true;
                Defs.Insert(def);
                Defs.RefreshCache();
                catNum = def.DefNum;
            }
            for (int i = 0; i < table.Rows.Count; i++)
            {
                command = "UPDATE procedurecode SET ProcCat=" + POut.Long(catNum)
                          + " WHERE ProcCat=" + table.Rows[i][0].ToString()
                          + " AND procedurecode.ProcCode LIKE 'T%'";
                Db.NonQ(command);
            }
            //finally, set Never Used category to be hidden.  This isn't really part of clearing Tcodes, but is required
            //because many customers won't have that category hidden
            catNum = Defs.GetByExactName(DefCat.ProcCodeCats, "Never Used");
            if (catNum != 0)           //if a category exists with that name
            {
                def = Defs.GetDef(DefCat.ProcCodeCats, catNum);
                if (!def.IsHidden)
                {
                    def.IsHidden = true;
                    Defs.Update(def);
                    Defs.RefreshCache();
                }
            }
        }