Beispiel #1
0
 private void butAdd_Click(object sender, System.EventArgs e)
 {
     Def DefCur=new Def();
     DefCur.ItemOrder=DefsList.Length;
     DefCur.Category=(DefCat)SelectedCat;
     DefCur.ItemName="";
     DefCur.ItemValue="";//necessary
     if(lookupCat[listCategory.SelectedIndex]==DefCat.ImageCats) {
         FormDefEditImages FormDEI=new FormDefEditImages(DefCur);
         FormDEI.IsNew=true;
         FormDEI.ShowDialog();
         if(FormDEI.DialogResult!=DialogResult.OK) {
             return;
         }
     }
     else {
         FormDefEdit FormDE=new FormDefEdit(DefCur);
         FormDE.IsNew=true;
         FormDE.ShowDialog();
         if(FormDE.DialogResult!=DialogResult.OK) {
             return;
         }
     }
     DefsSelected=DefsList.Length;//this is one more than allowed, but it's ok
     DefsIsSelected=true;
     changed=true;
     FillDefs();
 }
Beispiel #2
0
		///<summary></summary>
		public static long Insert(Def def) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				def.DefNum=Meth.GetLong(MethodBase.GetCurrentMethod(),def);
				return def.DefNum;
			}
			return Crud.DefCrud.Insert(def);
		}
Beispiel #3
0
		///<summary></summary>
		public static void Update(Def def) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				Meth.GetVoid(MethodBase.GetCurrentMethod(),def);
				return;
			}
			Crud.DefCrud.Update(def);
		}
Beispiel #4
0
        public override void OnEndPrint(PrintDocument document, PrintEventArgs e)
        {
            base.OnEndPrint(document, e);
            document.PrinterSettings.PrintToFile = _isPrintToFile;

            if (ShowAfterPrint)
                System.Diagnostics.Process.Start(this.FileName);

            Document doc = new Document();
            doc.DateCreated = File.GetLastWriteTime(this.FileName);
            if (_sit == PrintSituation.Claim)
            {
                doc.DocCategory = DefC.GetByExactName(DefCat.ImageCats, "EClaims");
                if (doc.DocCategory == 0)
                {
                    Def d = new Def() { Category = DefCat.ImageCats, ItemName = "EClaims" };
                    doc.DocCategory = Defs.Insert(d);
                    DataValid.SetInvalid(InvalidType.Defs);
                }
            }
            else
            {
                doc.DocCategory = DefC.GetList(DefCat.ImageCats)[0].DefNum;//First category.
            }
            doc.FileName = Path.GetFileName(this.FileName);
            doc.Description = doc.FileName;
            doc.PatNum = _patient.PatNum;
            Documents.Insert(doc);
        }
Beispiel #5
0
		///<summary>CAUTION.  This does not perform all validations.  It only properly validates for two def types right now.</summary>
		public static void Delete(Def def) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				Meth.GetVoid(MethodBase.GetCurrentMethod(),def);
				return;
			}
			if(def.Category!=DefCat.SupplyCats && def.Category!=DefCat.ClaimCustomTracking) {
				throw new ApplicationException("NOT Allowed to delete this type of def.");
			}
			string command="";
			if(def.Category==DefCat.SupplyCats) {
				command="SELECT COUNT(*) FROM supply WHERE Category="+POut.Long(def.DefNum);
			}
			else if(def.Category==DefCat.ClaimCustomTracking){
				command="SELECT COUNT(*) FROM claim WHERE CustomTracking="+POut.Long(def.DefNum);
			}
			if(Db.GetCount(command)!="0"){
				throw new ApplicationException(Lans.g("Defs","Def is in use.  Not allowed to delete."));
			}
			command="DELETE FROM definition WHERE DefNum="+POut.Long(def.DefNum);
			Db.NonQ(command);
			command="UPDATE definition SET ItemOrder=ItemOrder-1 "
				+"WHERE Category="+POut.Long((int)def.Category)
				+" AND ItemOrder > "+POut.Long(def.ItemOrder);
			Db.NonQ(command);
		}
Beispiel #6
0
		///<summary></summary>
		public static int MoveDown(bool isSelected,int selected,Def[] list){
			if(isSelected==false){
				MessageBox.Show(Lan.g("Defs","Please select an item first."));
				return selected;
			}
			if(selected==list.Length-1){
				return selected;
			}
			Defs.SetOrder(selected+1,list[selected].ItemOrder,list);
			Defs.SetOrder(selected,list[selected].ItemOrder+1,list);
			selected+=1;
			return selected;
		}		
Beispiel #7
0
Datei: Defs.cs Projekt: mnisl/OD
		public static void FillCache(DataTable table){
			//No need to check RemotingRole; no call to db.
			List<Def> list=Crud.DefCrud.TableToList(table);
			Def[][] arrayLong=new Def[Enum.GetValues(typeof(DefCat)).Length][];
			for(int j=0;j<Enum.GetValues(typeof(DefCat)).Length;j++) {
				arrayLong[j]=GetForCategory(j,true,list);
			}
			Def[][] arrayShort=new Def[Enum.GetValues(typeof(DefCat)).Length][];
			for(int j=0;j<Enum.GetValues(typeof(DefCat)).Length;j++) {
				arrayShort[j]=GetForCategory(j,false,list);
			}
			DefC.Long=arrayLong;
			DefC.Short=arrayShort;
		}
Beispiel #8
0
Datei: DefC.cs Projekt: mnisl/OD
		///<summary>Stores all defs in a 2D array except the hidden ones.  The first dimension is the category, in int format.  The second dimension is the index of the definition in this category.  This is dependent on how it was refreshed, and not on what is in the database.  If you need to reference a specific def, then the DefNum is more effective.</summary>
		public static Def[][] GetArrayShort() {
			bool isArrayNull=false;
			lock(_lockObj) {
				if(_short==null) {
					isArrayNull=true;
				}
			}
			if(isArrayNull) {
				Defs.RefreshCache();
			}
			Def[][] arrayDefs=new Def[Enum.GetValues(typeof(DefCat)).Length][];
			lock(_lockObj) {
				for(int i=0;i<arrayDefs.Length;i++) {
					Def[] arrayDefCopy=new Def[_short[i].Length];
					for(int j=0;j<_short[i].Length;j++) {
						arrayDefCopy[j]=_short[i][j].Copy();
					}
					arrayDefs[i]=arrayDefCopy;
				}
			}
			return arrayDefs;
		}
Beispiel #9
0
		///<summary></summary>
		public static void SetOrder(int mySelNum,int myItemOrder,Def[] list) {
			//No need to check RemotingRole; no call to db.
			Def def=list[mySelNum];
			def.ItemOrder=myItemOrder;
			//Cur=temp;
			Defs.Update(def);
		}
		///<summary>Can be called externally.  Surround with try catch.  Returns number of codes inserted.  Supply path to file to import or a list of procedure codes, or an xml string.  Make sure to set the other two values blank or null.</summary>
		public static int ImportProcCodes(string path,List<ProcedureCode> listCodes,string xmlData) {
			if(listCodes==null){
				listCodes=new List<ProcedureCode>();
			}
			//xmlData should already be tested ahead of time to make sure it's not blank.
			XmlSerializer serializer=new XmlSerializer(typeof(List<ProcedureCode>));
			if(path!="") {
				if(!File.Exists(path)) {
					throw new ApplicationException(Lan.g("FormProcCodes","File does not exist."));
				}
				try {
					using(TextReader reader=new StreamReader(path)) {
						listCodes=(List<ProcedureCode>)serializer.Deserialize(reader);
					}
				}
				catch {
					throw new ApplicationException(Lan.g("FormProcCodes","Invalid file format"));
				}
			}
			else if(xmlData!="") {
				try {
					using(TextReader reader=new StringReader(xmlData)) {
						listCodes=(List<ProcedureCode>)serializer.Deserialize(reader);
					}
				}
				catch {
					throw new ApplicationException(Lan.g("FormProcCodes","xml format"));
				}
			}
			int retVal=0;
			for(int i=0;i<listCodes.Count;i++) {
				if(ProcedureCodeC.HList.ContainsKey(listCodes[i].ProcCode)) {
					continue;//don't import duplicates.
				}
				listCodes[i].ProcCat=DefC.GetByExactName(DefCat.ProcCodeCats,listCodes[i].ProcCatDescript);
				if(listCodes[i].ProcCat==0) {//no category exists with that name
					Def def=new Def();
					def.Category=DefCat.ProcCodeCats;
					def.ItemName=listCodes[i].ProcCatDescript;
					def.ItemOrder=DefC.Long[(int)DefCat.ProcCodeCats].Length;
					Defs.Insert(def);
					Cache.Refresh(InvalidType.Defs);
					listCodes[i].ProcCat=def.DefNum;
				}
				ProcedureCodes.Insert(listCodes[i]);
				retVal++;
			}
			return retVal;
			//don't forget to refresh procedurecodes
		}
Beispiel #11
0
		///<summary></summary>
		public static void HideDef(Def def) {

			//No need to check RemotingRole; no call to db.
			def.IsHidden=true;
			Defs.Update(def);
		}
Beispiel #12
0
        ///<summary>If not using clinics then supply an empty list of clinicNums. dateStart and dateEnd can be MinVal/MaxVal to indicate "forever".</summary>
        public static DataTable GetActivePatientTable(DateTime dateStart, DateTime dateEnd, List <long> listProvNums, List <long> listClinicNums, List <long> listBillingTypes, bool hasAllProvs, bool hasAllClinics, bool hasAllBilling)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetTable(MethodBase.GetCurrentMethod(), dateStart, dateEnd, listProvNums, listClinicNums, listBillingTypes, hasAllProvs, hasAllClinics, hasAllBilling));
            }
            bool            hasClinicsEnabled = ReportsComplex.RunFuncOnReportServer(() => Prefs.HasClinicsEnabledNoCache);
            List <Provider> listProvs         = ReportsComplex.RunFuncOnReportServer(() => Providers.GetAll());
            List <Def>      listDefs          = ReportsComplex.RunFuncOnReportServer(() => Defs.GetDefsNoCache(DefCat.BillingTypes));
            List <Clinic>   listClinics       = ReportsComplex.RunFuncOnReportServer(() => Clinics.GetClinicsNoCache());
            DataTable       table             = new DataTable();

            table.Columns.Add("name");
            table.Columns.Add("priProv");
            table.Columns.Add("Address");
            table.Columns.Add("Address2");
            table.Columns.Add("City");
            table.Columns.Add("State");
            table.Columns.Add("Zip");
            table.Columns.Add("carrier");
            table.Columns.Add("HmPhone");
            table.Columns.Add("WkPhone");
            table.Columns.Add("WirelessPhone");
            table.Columns.Add("billingType");
            table.Columns.Add("secProv");
            table.Columns.Add("clinic");
            DataRow row;
            string  command = @"
				SELECT patient.PatNum,patient.LName,patient.FName,patient.MiddleI,patient.Preferred,carrier.CarrierName,patient.BillingType,patient.PriProv,patient.SecProv,
							patient.HmPhone,patient.WkPhone,patient.WirelessPhone,patient.Address,patient.Address2,patient.City,patient.State,patient.Zip,patient.ClinicNum,provider.Abbr
				FROM procedurelog 
				INNER JOIN patient ON patient.PatNum=procedurelog.PatNum AND PatStatus="                 + POut.Int((int)PatientStatus.Patient) + @"
				LEFT JOIN patplan ON patplan.PatNum=patient.PatNum AND patplan.Ordinal=1
				LEFT JOIN inssub ON inssub.InsSubNum=patplan.InsSubNum
				LEFT JOIN insplan ON insplan.PlanNum=inssub.PlanNum
				LEFT JOIN carrier ON carrier.CarrierNum=insplan.CarrierNum
				LEFT JOIN provider ON provider.ProvNum=patient.PriProv 
				WHERE procedurelog.ProcStatus="                 + POut.Int((int)ProcStat.C) + @"
					AND procedurelog.ProcDate BETWEEN "                     + POut.DateT(dateStart) + @" AND " + POut.DateT(dateEnd);

            if (!hasAllProvs)
            {
                command += @" AND (patient.PriProv IN(" + String.Join(",", listProvNums) + ") OR patient.SecProv IN(" + String.Join(",", listProvNums) + ")) ";
            }
            if (listClinicNums.Count > 0)
            {
                command += "AND patient.ClinicNum IN(" + String.Join(",", listClinicNums) + ") ";
            }
            command += "AND patient.BillingType IN(" + String.Join(",", listBillingTypes) + ") ";
            if (DataConnection.DBtype == DatabaseType.MySql)
            {
                command += "GROUP BY patient.PatNum";
            }
            else              //Oracle
            {
                command += @"GROUP BY patient.PatNum,patient.LName,patient.FName,patient.MiddleI,patient.Preferred,carrier.CarrierName
					,patient.BillingType,patient.PriProv,patient.SecProv,patient.HmPhone,patient.WkPhone,patient.WirelessPhone
					,patient.Address,patient.Address2,patient.City,patient.State,patient.Zip,patient.ClinicNum"                    ;
            }
            if (!hasClinicsEnabled)
            {
                command += " ORDER BY provider.Abbr,patient.LName,patient.FName";
            }
            else              //Using clinics
            {
                command += " ORDER BY patient.ClinicNum,provider.Abbr,patient.LName,patient.FName";
            }
            DataTable raw = ReportsComplex.RunFuncOnReportServer(() => ReportsComplex.GetTable(command));
            Patient   pat;

            for (int i = 0; i < raw.Rows.Count; i++)
            {
                Def billingType = listDefs.FirstOrDefault(x => x.DefNum == PIn.Long(raw.Rows[i]["BillingType"].ToString()));
                row                  = table.NewRow();
                pat                  = new Patient();
                pat.LName            = raw.Rows[i]["LName"].ToString();
                pat.FName            = raw.Rows[i]["FName"].ToString();
                pat.MiddleI          = raw.Rows[i]["MiddleI"].ToString();
                pat.Preferred        = raw.Rows[i]["Preferred"].ToString();
                row["name"]          = pat.GetNameLF();
                row["priProv"]       = Providers.GetAbbr(PIn.Long(raw.Rows[i]["PriProv"].ToString()));
                row["Address"]       = raw.Rows[i]["Address"].ToString();
                row["Address2"]      = raw.Rows[i]["Address2"].ToString();
                row["City"]          = raw.Rows[i]["City"].ToString();
                row["State"]         = raw.Rows[i]["State"].ToString();
                row["Zip"]           = raw.Rows[i]["Zip"].ToString();
                row["Carrier"]       = raw.Rows[i]["CarrierName"].ToString();
                row["HmPhone"]       = raw.Rows[i]["HmPhone"].ToString();
                row["WkPhone"]       = raw.Rows[i]["WkPhone"].ToString();
                row["WirelessPhone"] = raw.Rows[i]["WirelessPhone"].ToString();
                row["billingType"]   = (billingType == null) ? "" : billingType.ItemValue;
                row["secProv"]       = Providers.GetLName(PIn.Long(raw.Rows[i]["SecProv"].ToString()), listProvs);
                if (hasClinicsEnabled)                 //Using clinics
                {
                    string clinicDesc = Clinics.GetDesc(PIn.Long(raw.Rows[i]["ClinicNum"].ToString()), listClinics);
                    row["clinic"] = (clinicDesc == "")?Lans.g("FormRpPayPlans", "Unassigned"):clinicDesc;
                }
                table.Rows.Add(row);
            }
            return(table);
        }
Beispiel #13
0
        public static DataTable GetData(long feeSchedNum, long clinicNum, long provNum, bool isCategories, bool includeBlanks)
        {
            //No remoting check, no call to db
            DataTable data   = GetDataSet(feeSchedNum, clinicNum, provNum);
            DataTable retVal = new DataTable("ProcCodes");

            if (isCategories)
            {
                retVal.Columns.Add(new DataColumn("Category"));
            }
            retVal.Columns.Add(new DataColumn("Code"));
            retVal.Columns.Add(new DataColumn("Desc"));
            retVal.Columns.Add(new DataColumn("Abbr"));
            retVal.Columns.Add(new DataColumn("Fee"));
            List <ProcedureCode> listProcCodes = new List <ProcedureCode>();

            if (isCategories)
            {
                Def[][] arrayDefs = ReportsComplex.RunFuncOnReportServer(() => Defs.GetArrayShortNoCache());
                listProcCodes = ReportsComplex.RunFuncOnReportServer(() => ProcedureCodes.GetProcList(arrayDefs))
                                .OrderBy(x => x.ProcCat).ThenBy(x => x.ProcCode).ToList();         //Ordered by category
            }
            else
            {
                listProcCodes = ReportsComplex.RunFuncOnReportServer(() => ProcedureCodes.GetAllCodes());               //Ordered by ProcCode, used for the non-category version of the report if they want blanks.
            }
            bool       isFound;
            List <Def> listDefs = Defs.GetDefsNoCache(DefCat.ProcCodeCats);

            for (int i = 0; i < listProcCodes.Count; i++)
            {
                isFound = false;
                DataRow row = retVal.NewRow();
                if (isCategories)
                {
                    //reports should no longer use the cache.
                    Def def = listDefs.FirstOrDefault(x => x.DefNum == listProcCodes[i].ProcCat);
                    row[0] = def == null ? "" : def.ItemName;
                    row[1] = listProcCodes[i].ProcCode;
                    row[2] = listProcCodes[i].Descript;
                    row[3] = listProcCodes[i].AbbrDesc;
                }
                else
                {
                    row[0] = listProcCodes[i].ProcCode;
                    row[1] = listProcCodes[i].Descript;
                    row[2] = listProcCodes[i].AbbrDesc;
                }
                for (int j = 0; j < data.Rows.Count; j++)
                {
                    if (data.Rows[j]["ProcCode"].ToString() == listProcCodes[i].ProcCode)
                    {
                        isFound = true;
                        double amt = PIn.Double(data.Rows[j]["Amount"].ToString());
                        if (isCategories)
                        {
                            if (amt == -1)
                            {
                                row[4]  = "";
                                isFound = false;
                            }
                            else
                            {
                                row[4] = amt.ToString("n");
                            }
                        }
                        else
                        {
                            if (amt == -1)
                            {
                                row[3]  = "";
                                isFound = false;
                            }
                            else
                            {
                                row[3] = amt.ToString("n");
                            }
                        }
                        break;
                    }
                }
                if (includeBlanks && !isFound)
                {
                    retVal.Rows.Add(row);                     //Including a row that has a blank fee.
                }
                else if (isFound)
                {
                    retVal.Rows.Add(row);
                }
                //All other rows (empty rows where we don't want blanks) are not added to the dataset.
            }
            return(retVal);
        }
Beispiel #14
0
Datei: DefC.cs Projekt: mnisl/OD
		///<summary>Returns the named def.  If it can't find the name, then it returns the first def in the category.</summary>
		public static long GetByExactNameNeverZero(DefCat myCat,string itemName) {
			Def[][] arrayDefs=GetArrayLong();
			if(itemName=="") {
				return arrayDefs[(int)myCat][0].DefNum;//return the first one in the list
			}
			for(int i=0;i<arrayDefs[(int)myCat].GetLength(0);i++) {
				if(arrayDefs[(int)myCat][i].ItemName==itemName) {
					return arrayDefs[(int)myCat][i].DefNum;
				}
			}
			if(arrayDefs[(int)myCat].Length==0) {
				Def def=new Def();
				def.Category=myCat;
				def.ItemOrder=0;
				def.ItemName=itemName;
				Defs.Insert(def);
				Defs.RefreshCache();
			}
			Def[][] arrayDefsUpdated=GetArrayLong();//The cache could have changed by this point.  Grab it again just in case.
			return arrayDefsUpdated[(int)myCat][0].DefNum;//return the first one in the list
		}
Beispiel #15
0
 ///<summary>Returns the named def.  If it can't find the name, then it returns the first def in the category.</summary>
 public static long GetByExactNameNeverZero(DefCat myCat,string itemName)
 {
     if(itemName=="") {
         return DefC.Long[(int)myCat][0].DefNum;//return the first one in the list
     }
     for(int i=0;i<DefC.Long[(int)myCat].GetLength(0);i++) {
         if(DefC.Long[(int)myCat][i].ItemName==itemName) {
             return DefC.Long[(int)myCat][i].DefNum;
         }
     }
     if(DefC.Long[(int)myCat].Length==0) {
         Def def=new Def();
         def.Category=myCat;
         def.ItemOrder=0;
         def.ItemName=itemName;
         Defs.Insert(def);
         Defs.RefreshCache();
     }
     return DefC.Long[(int)myCat][0].DefNum;//return the first one in the list
 }
		///<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 NOT EXISTS(SELECT * FROM procedurelog WHERE procedurelog.CodeNum=procedurecode.CodeNum)
				AND ProcCode LIKE 'T%'";
			DataTable table=Db.GetTable(command);
			long codenum;
			for(int i=0;i<table.Rows.Count;i++) {
				codenum=PIn.Long(table.Rows[i]["CodeNum"].ToString());
				command="DELETE FROM fee WHERE CodeNum="+POut.Long(codenum);
				Db.NonQ(command);
				command="DELETE FROM procedurecode WHERE CodeNum="+POut.Long(codenum);
				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=DefC.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=DefC.GetDef(DefCat.ProcCodeCats,catNum);
				if(!def.IsHidden) {
					def.IsHidden=true;
					Defs.Update(def);
					Defs.RefreshCache();
				}
			}
			if(catNum==0) {
				def=new Def();
				def.Category=DefCat.ProcCodeCats;
				def.ItemName="Obsolete";
				def.ItemOrder=DefC.Long[(int)DefCat.ProcCodeCats].Length;
				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=DefC.GetByExactName(DefCat.ProcCodeCats,"Never Used");
			if(catNum!=0) {//if a category exists with that name
				def=DefC.GetDef(DefCat.ProcCodeCats,catNum);
				if(!def.IsHidden) {
					def.IsHidden=true;
					Defs.Update(def);
					Defs.RefreshCache();
				}
			}
		}
Beispiel #17
0
		///<summary>defCur should be the currently selected def from FormDefinitions.  defList is going to be the in-memory list of definitions currently displaying to the user.  defList typically is out of synch with the cache which is why we need to pass it in.</summary>
		public FormDefEdit(Def defCur,Def[] defsList){
			InitializeComponent();// Required for Windows Form Designer support
			Lan.F(this);
			DefCur=defCur.Copy();
			_defsList=defsList;
		}
Beispiel #18
0
 ///<summary></summary>
 public static void HideDef(Def def)
 {
     //No need to check RemotingRole; no call to db.
     def.IsHidden = true;
     Defs.Update(def);
 }
Beispiel #19
0
        ///<summary>CAUTION.  This does not perform all validations.  Throws exceptions.</summary>
        public static void Delete(Def def)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), def);
                return;
            }
            string        command;
            List <string> listCommands = new List <string>();

            switch (def.Category)
            {
            case DefCat.ClaimCustomTracking:
                listCommands.Add("SELECT COUNT(*) FROM securitylog WHERE DefNum=" + POut.Long(def.DefNum));
                listCommands.Add("SELECT COUNT(*) FROM claim WHERE CustomTracking=" + POut.Long(def.DefNum));
                break;

            case DefCat.ClaimErrorCode:
                listCommands.Add("SELECT COUNT(*) FROM claimtracking WHERE TrackingErrorDefNum=" + POut.Long(def.DefNum));
                break;

            case DefCat.InsurancePaymentType:
                listCommands.Add("SELECT COUNT(*) FROM claimpayment WHERE PayType=" + POut.Long(def.DefNum));
                break;

            case DefCat.SupplyCats:
                listCommands.Add("SELECT COUNT(*) FROM supply WHERE Category=" + POut.Long(def.DefNum));
                break;

            case DefCat.AccountQuickCharge:
                break;                        //Users can delete AcctProcQuickCharge entries.  Nothing has an FKey to a AcctProcQuickCharge Def so no need to check anything.

            case DefCat.AutoNoteCats:
                AutoNotes.RemoveFromCategory(def.DefNum);                                                  //set any autonotes assinged to this category to 0 (unassigned), user already warned about this
                listCommands.Add("SELECT COUNT(*) FROM autonote WHERE Category=" + POut.Long(def.DefNum)); //just in case update failed or concurrency issue
                break;

            case DefCat.WebSchedNewPatApptTypes:
                //Do not let the user delete the last WebSchedNewPatApptTypes definition.  Must be at least one.
                command = "SELECT COUNT(*) FROM definition WHERE Category=" + POut.Int((int)DefCat.WebSchedNewPatApptTypes);
                if (PIn.Int(Db.GetCount(command), false) <= 1)
                {
                    throw new ApplicationException("NOT Allowed to delete the last def of this type.");
                }
                break;

            default:
                throw new ApplicationException("NOT Allowed to delete this type of def.");
            }
            for (int i = 0; i < listCommands.Count; i++)
            {
                if (Db.GetCount(listCommands[i]) != "0")
                {
                    throw new ApplicationException(Lans.g("Defs", "Def is in use.  Not allowed to delete."));
                }
            }
            command = "DELETE FROM definition WHERE DefNum=" + POut.Long(def.DefNum);
            Db.NonQ(command);
            command = "UPDATE definition SET ItemOrder=ItemOrder-1 "
                      + "WHERE Category=" + POut.Long((int)def.Category)
                      + " AND ItemOrder > " + POut.Long(def.ItemOrder);
            Db.NonQ(command);
        }
Beispiel #20
0
        ///<summary>Returns true if this definition is in use within the program. Consider enhancing this method if you add a definition category.
        ///Does not check patient billing type or provider specialty since those are handled in their S-class.</summary>
        public static bool IsDefinitionInUse(Def def)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetBool(MethodBase.GetCurrentMethod(), def));
            }
            List <string> listStrCommands = new List <string>();

            switch (def.Category)
            {
            case DefCat.AdjTypes:
                if (new[] {
                    PrefName.BrokenAppointmentAdjustmentType,
                    PrefName.TreatPlanDiscountAdjustmentType,
                    PrefName.BillingChargeAdjustmentType,
                    PrefName.FinanceChargeAdjustmentType,
                    PrefName.SalesTaxAdjustmentType
                }.Any(x => PrefC.GetLong(x) == def.DefNum))
                {
                    return(true);
                }
                listStrCommands.Add("SELECT COUNT(*) FROM adjustment WHERE AdjType=" + POut.Long(def.DefNum));
                break;

            case DefCat.ApptConfirmed:
                if (new[] {
                    PrefName.AppointmentTimeArrivedTrigger,
                    PrefName.AppointmentTimeSeatedTrigger,
                    PrefName.AppointmentTimeDismissedTrigger,
                    PrefName.WebSchedNewPatConfirmStatus,
                    PrefName.WebSchedRecallConfirmStatus,
                }.Any(x => PrefC.GetLong(x) == def.DefNum))
                {
                    return(true);
                }
                if (new[] { PrefName.ApptEConfirmStatusSent, PrefName.ApptEConfirmStatusAccepted, PrefName.ApptEConfirmStatusDeclined, PrefName.ApptEConfirmStatusSendFailed }
                    .Any(x => PrefC.GetLong(x) == def.DefNum))
                {
                    return(true);
                }
                listStrCommands.Add("SELECT COUNT(*) FROM appointment WHERE Confirmed=" + POut.Long(def.DefNum));
                break;

            case DefCat.AutoNoteCats:
                listStrCommands.Add("SELECT COUNT(*) FROM autonote WHERE Category=" + POut.Long(def.DefNum));
                break;

            case DefCat.BillingTypes:
                if (new[] {
                    PrefName.PracticeDefaultBillType
                }.Any(x => PrefC.GetLong(x) == def.DefNum))
                {
                    return(true);
                }
                break;

            case DefCat.ContactCategories:
                listStrCommands.Add("SELECT COUNT(*) FROM contact WHERE Category=" + POut.Long(def.DefNum));
                break;

            case DefCat.Diagnosis:
                listStrCommands.Add("SELECT COUNT(*) FROM procedurelog WHERE Dx=" + POut.Long(def.DefNum));
                break;

            case DefCat.ImageCats:
                listStrCommands.Add("SELECT COUNT(*) FROM document WHERE DocCategory=" + POut.Long(def.DefNum));
                listStrCommands.Add("SELECT COUNT(*) FROM sheetfielddef WHERE FieldType=" + POut.Int((int)SheetFieldType.PatImage) + " AND FieldName=" + POut.Long(def.DefNum));
                break;

            case DefCat.PaymentTypes:
                if (def.DefNum.In(PrefC.GetLong(PrefName.RecurringChargesPayTypeCC), PrefC.GetLong(PrefName.AccountingCashPaymentType)))
                {
                    return(true);
                }
                listStrCommands.Add("SELECT COUNT(*) FROM payment WHERE PayType=" + POut.Long(def.DefNum));
                break;

            case DefCat.PaySplitUnearnedType:
                if (def.DefNum.In(PrefC.GetLong(PrefName.TpUnearnedType)))
                {
                    return(true);
                }
                listStrCommands.Add("SELECT COUNT(*) FROM paysplit WHERE UnearnedType=" + POut.Long(def.DefNum));
                break;

            case DefCat.Prognosis:
                listStrCommands.Add("SELECT COUNT(*) FROM procedurelog WHERE Prognosis=" + POut.Long(def.DefNum));
                break;

            case DefCat.RecallUnschedStatus:
                if (def.DefNum.In(
                        PrefC.GetLong(PrefName.RecallStatusMailed),
                        PrefC.GetLong(PrefName.RecallStatusTexted),
                        PrefC.GetLong(PrefName.RecallStatusEmailed),
                        PrefC.GetLong(PrefName.RecallStatusEmailedTexted)))
                {
                    return(true);
                }
                listStrCommands.Add("SELECT COUNT(*) FROM appointment WHERE UnschedStatus=" + POut.Long(def.DefNum));
                listStrCommands.Add("SELECT COUNT(*) FROM recall WHERE RecallStatus=" + POut.Long(def.DefNum));
                break;

            case DefCat.TaskPriorities:
                listStrCommands.Add("SELECT COUNT(*) FROM task WHERE PriorityDefNum=" + POut.Long(def.DefNum));
                break;

            case DefCat.TxPriorities:
                listStrCommands.Add("SELECT COUNT(*) FROM procedurelog WHERE Priority=" + POut.Long(def.DefNum));
                break;

            case DefCat.CommLogTypes:
                listStrCommands.Add("SELECT COUNT(*) FROM commlog WHERE CommType=" + POut.Long(def.DefNum));
                break;

            default:
                break;
            }
            return(listStrCommands.Any(x => Db.GetCount(x) != "0"));
        }
Beispiel #21
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();
                }
            }
        }
Beispiel #22
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 NOT EXISTS(SELECT * FROM procedurelog WHERE procedurelog.CodeNum=procedurecode.CodeNum)
				AND ProcCode LIKE 'T%'"                ;
            DataTable table   = Db.GetTable(command);
            long      codenum;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                codenum = PIn.Long(table.Rows[i]["CodeNum"].ToString());
                command = "DELETE FROM fee WHERE CodeNum=" + POut.Long(codenum);
                Db.NonQ(command);
                command = "DELETE FROM procedurecode WHERE CodeNum=" + POut.Long(codenum);
                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 = DefC.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 = DefC.GetDef(DefCat.ProcCodeCats, catNum);
                if (!def.IsHidden)
                {
                    def.IsHidden = true;
                    Defs.Update(def);
                    Defs.RefreshCache();
                }
            }
            if (catNum == 0)
            {
                def           = new Def();
                def.Category  = DefCat.ProcCodeCats;
                def.ItemName  = "Obsolete";
                def.ItemOrder = DefC.Long[(int)DefCat.ProcCodeCats].Length;
                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 = DefC.GetByExactName(DefCat.ProcCodeCats, "Never Used");
            if (catNum != 0)           //if a category exists with that name
            {
                def = DefC.GetDef(DefCat.ProcCodeCats, catNum);
                if (!def.IsHidden)
                {
                    def.IsHidden = true;
                    Defs.Update(def);
                    Defs.RefreshCache();
                }
            }
        }
Beispiel #23
0
		///<summary></summary>
		public FormDefEditImages(Def defCur) {
			InitializeComponent();// Required for Windows Form Designer support
			Lan.F(this);
			DefCur=defCur.Copy();
		}
Beispiel #24
0
        public static void ResetApptProcsQuickAdd()
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod());
                return;
            }
            string command = "DELETE FROM definition WHERE Category=3";

            Db.NonQ(command);
            string[] array = new string[] {
                "CompEx-4BW-Pano-Pro-Flo", "D0150,D0274,D0330,D1110,D1204",
                "CompEx-2BW-Pano-ChPro-Flo", "D0150,D0272,D0330,D1120,D1203",
                "PerEx-4BW-Pro-Flo", "D0120,D0274,D1110,D1204",
                "LimEx-PA", "D0140,D0220",
                "PerEx-4BW-Pro-Flo", "D0120,D0274,D1110,D1204",
                "PerEx-2BW-ChildPro-Flo", "D0120,D0272,D1120,D1203",
                "Comp Exam", "D0150",
                "Per Exam", "D0120",
                "Lim Exam", "D0140",
                "1 PA", "D0220",
                "2BW", "D0272",
                "4BW", "D0274",
                "Pano", "D0330",
                "Pro Adult", "D1110",
                "Fluor Adult", "D1204",
                "Pro Child", "D1120",
                "Fuor Child", "D1203",
                "PostOp", "N4101",
                "DentAdj", "N4102",
                "Consult", "D9310"
            };
            Def def;

            string[] codelist;
            bool     allvalid;
            int      itemorder = 0;

            for (int i = 0; i < array.Length; i += 2)
            {
                //first, test all procedures for valid
                codelist = array[i + 1].Split(',');
                allvalid = true;
                for (int c = 0; c < codelist.Length; c++)
                {
                    if (!ProcedureCodes.IsValidCode(codelist[c]))
                    {
                        allvalid = false;
                    }
                }
                if (!allvalid)
                {
                    continue;
                }
                def           = new Def();
                def.Category  = DefCat.ApptProcsQuickAdd;
                def.ItemOrder = itemorder;
                def.ItemName  = array[i];
                def.ItemValue = array[i + 1];
                Defs.Insert(def);
                itemorder++;
            }
        }
		public static void ResetApptProcsQuickAdd() {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				Meth.GetVoid(MethodBase.GetCurrentMethod());
				return;
			}
			string command= "DELETE FROM definition WHERE Category=3";
			Db.NonQ(command);
			string[] array=new string[] {
				"CompEx-4BW-Pano-Pro-Flo","D0150,D0274,D0330,D1110,D1208",
				"CompEx-2BW-Pano-ChPro-Flo","D0150,D0272,D0330,D1120,D1208",
				"PerEx-4BW-Pro-Flo","D0120,D0274,D1110,D1208",
				"LimEx-PA","D0140,D0220",
				"PerEx-4BW-Pro-Flo","D0120,D0274,D1110,D1208",
				"PerEx-2BW-ChildPro-Flo","D0120,D0272,D1120,D1208",
				"Comp Exam","D0150",
				"Per Exam","D0120",
				"Lim Exam","D0140",
				"1 PA","D0220",
				"2BW","D0272",
				"4BW","D0274",
				"Pano","D0330",
				"Pro Adult","D1110",
				"Fluor","D1208",
				"Pro Child","D1120",
				"PostOp","N4101",
				"DentAdj","N4102",
				"Consult","D9310"
			};
			Def def;
			string[] codelist;
			bool allvalid;
			int itemorder=0;
			for(int i=0;i<array.Length;i+=2) {
				//first, test all procedures for valid
				codelist=array[i+1].Split(',');
				allvalid=true;
				for(int c=0;c<codelist.Length;c++) {
					if(!ProcedureCodes.IsValidCode(codelist[c])) {
						allvalid=false;
					}
				}
				if(!allvalid) {
					continue;
				}
				def=new Def();
				def.Category=DefCat.ApptProcsQuickAdd;
				def.ItemOrder=itemorder;
				def.ItemName=array[i];
				def.ItemValue=array[i+1];
				Defs.Insert(def);
				itemorder++;
			}
		}
Beispiel #26
0
		private static void ProcessFile(string fullPath) {
			if(!PrefC.GetBool(PrefName.AtoZfolderUsed)) {
				MsgBox.Show("TigerView","TigerView is not currently supported when storing images in the database.");
				return;
			}
			string filename=Path.GetFileName(fullPath);
			//Get the patNum/chartNum from filename.  Example: tmb123.20091119.XXXXXX.tig where X is identifier
			string[] splitFileName=filename.Split(new char[] { '.' });
			if(splitFileName.Length!=4) { //Not correct format
				return;
			}
			string identifier=splitFileName[2]; //Third quadrant
			bool useChartNum=false;
			for(int i=0;i<identifier.Length;i++) { //Check to see if the identifer has anything but numbers, if so it has to be a chartnum or invalid
				if(!Char.IsNumber(identifier,i)) {
					useChartNum=true;
					break;
				}
			}
			if(!useChartNum) { //If it could be a valid patnum, check program pref
				ArrayList propertiesForProgram=ProgramProperties.GetForProgram(Programs.GetProgramNum(ProgramName.TigerView));
				ProgramProperty programProperty=ProgramProperties.GetCur(propertiesForProgram,"Enter 0 to use PatientNum, or 1 to use ChartNum");
				if(programProperty.PropertyValue=="1") {//ChartNum
					useChartNum=true;
				}
			}
			Patient patCur;
			if(!useChartNum) {//Use PatNum
				patCur=Patients.GetPat(PIn.Long(identifier));
			}
			else {//Use ChartNum
				patCur=Patients.GetPatByChartNumber(identifier);
			}
			if(patCur==null) { //Could not find a patient with given PatNum/ChartNum
				return;
			}
			long imageCatDefNum=0;
			for(int j=0;j<DefC.Long[(int)DefCat.ImageCats].Length;j++) { //Look for an image category with the name "Xray"
				if(DefC.Long[(int)DefCat.ImageCats][j].ItemName.ToLower()=="xray") {
					imageCatDefNum=DefC.Long[(int)DefCat.ImageCats][j].DefNum;
				}
			}
			if(imageCatDefNum==0) { //If no "Xray" category exists, insert new category with the name "Xray"
				Def def = new Def();
				def.ItemName="Xray";
				def.Category=DefCat.ImageCats;
				def.ItemValue="X"; //Will make this category show in the chart module
				def.ItemOrder=DefC.Long[(int)DefCat.ImageCats].Length;
				imageCatDefNum=Defs.Insert(def);
				Cache.Refresh(InvalidType.Defs);
			}
			string newFileName="TV_"+filename.Substring(0,filename.IndexOf('.')+1)+CodeBase.MiscUtils.CreateRandomAlphaNumericString(4);
			newFileName=newFileName.Replace('.','_'); //Get rid of any periods in the file name.
			newFileName+=".tig"; //Add extention on to file name after other '.' were replaced.
			string newpath=CodeBase.ODFileUtils.CombinePaths(ImageStore.GetPatientFolder(patCur,ImageStore.GetPreferredAtoZpath()),newFileName);
			Document docCur = new Document();
			docCur.DocCategory=imageCatDefNum;
			docCur.FileName=newFileName;
			docCur.PatNum=patCur.PatNum;
			docCur.ImgType=ImageType.Photo;
			docCur.DateCreated=DateTime.Now;
			docCur.Description=newFileName;
			System.IO.File.Move(fullPath,newpath);
			Documents.Insert(docCur,patCur);
		}