Ejemplo n.º 1
0
 ///<summary>Inserts one Cvx into the database.  Returns the new priKey.</summary>
 public static long Insert(Cvx cvx)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         cvx.CvxNum = DbHelper.GetNextOracleKey("cvx", "CvxNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(cvx, true));
             }
             catch (Oracle.ManagedDataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     cvx.CvxNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(cvx, false));
     }
 }
Ejemplo n.º 2
0
        ///<summary>Inserts one Cvx into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(Cvx cvx, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO cvx (";

            if (!useExistingPK && isRandomKeys)
            {
                cvx.CvxNum = ReplicationServers.GetKeyNoCache("cvx", "CvxNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "CvxNum,";
            }
            command += "CvxCode,Description,IsActive) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(cvx.CvxNum) + ",";
            }
            command +=
                "'" + POut.String(cvx.CvxCode) + "',"
                + "'" + POut.String(cvx.Description) + "',"
                + "'" + POut.String(cvx.IsActive) + "')";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                cvx.CvxNum = Db.NonQ(command, true, "CvxNum", "cvx");
            }
            return(cvx.CvxNum);
        }
Ejemplo n.º 3
0
        ///<summary>Inserts one Cvx into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(Cvx cvx, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                cvx.CvxNum = ReplicationServers.GetKey("cvx", "CvxNum");
            }
            string command = "INSERT INTO cvx (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "CvxNum,";
            }
            command += "CvxCode,Description,IsActive) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(cvx.CvxNum) + ",";
            }
            command +=
                "'" + POut.String(cvx.CvxCode) + "',"
                + "'" + POut.String(cvx.Description) + "',"
                + "'" + POut.String(cvx.IsActive) + "')";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                cvx.CvxNum = Db.NonQ(command, true, "CvxNum", "cvx");
            }
            return(cvx.CvxNum);
        }
Ejemplo n.º 4
0
 private void gridMain_CellDoubleClick(object sender, ODGridClickEventArgs e)
 {
     if (IsSelectionMode)
     {
         SelectedCvx  = (Cvx)gridMain.ListGridRows[e.Row].Tag;
         DialogResult = DialogResult.OK;
         return;
     }
 }
Ejemplo n.º 5
0
        ///<summary>Updates one Cvx in the database.</summary>
        public static void Update(Cvx cvx)
        {
            string command = "UPDATE cvx SET "
                             + "CvxCode    = '" + POut.String(cvx.CvxCode) + "', "
                             + "Description= '" + POut.String(cvx.Description) + "', "
                             + "IsActive   = '" + POut.String(cvx.IsActive) + "' "
                             + "WHERE CvxNum = " + POut.Long(cvx.CvxNum);

            Db.NonQ(command);
        }
Ejemplo n.º 6
0
 private void butOK_Click(object sender, EventArgs e)
 {
     //not even visible unless IsSelectionMode
     if (gridMain.GetSelectedIndex() == -1)
     {
         MsgBox.Show(this, "Please select an item first.");
         return;
     }
     SelectedCvx  = (Cvx)gridMain.ListGridRows[gridMain.GetSelectedIndex()].Tag;
     DialogResult = DialogResult.OK;
 }
Ejemplo n.º 7
0
Archivo: CvxCrud.cs Proyecto: mnisl/OD
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<Cvx> TableToList(DataTable table){
			List<Cvx> retVal=new List<Cvx>();
			Cvx cvx;
			for(int i=0;i<table.Rows.Count;i++) {
				cvx=new Cvx();
				cvx.CvxNum     = PIn.Long  (table.Rows[i]["CvxNum"].ToString());
				cvx.CvxCode    = PIn.String(table.Rows[i]["CvxCode"].ToString());
				cvx.Description= PIn.String(table.Rows[i]["Description"].ToString());
				cvx.IsActive   = PIn.String(table.Rows[i]["IsActive"].ToString());
				retVal.Add(cvx);
			}
			return retVal;
		}
Ejemplo n.º 8
0
 ///<summary>Inserts one Cvx into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(Cvx cvx)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(cvx, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             cvx.CvxNum = DbHelper.GetNextOracleKey("cvx", "CvxNum");                  //Cacheless method
         }
         return(InsertNoCache(cvx, true));
     }
 }
Ejemplo n.º 9
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <Cvx> TableToList(DataTable table)
        {
            List <Cvx> retVal = new List <Cvx>();
            Cvx        cvx;

            foreach (DataRow row in table.Rows)
            {
                cvx             = new Cvx();
                cvx.CvxNum      = PIn.Long(row["CvxNum"].ToString());
                cvx.CvxCode     = PIn.String(row["CvxCode"].ToString());
                cvx.Description = PIn.String(row["Description"].ToString());
                cvx.IsActive    = PIn.String(row["IsActive"].ToString());
                retVal.Add(cvx);
            }
            return(retVal);
        }
Ejemplo n.º 10
0
 ///<summary>Returns true if Update(Cvx,Cvx) would make changes to the database.
 ///Does not make any changes to the database and can be called before remoting role is checked.</summary>
 public static bool UpdateComparison(Cvx cvx, Cvx oldCvx)
 {
     if (cvx.CvxCode != oldCvx.CvxCode)
     {
         return(true);
     }
     if (cvx.Description != oldCvx.Description)
     {
         return(true);
     }
     if (cvx.IsActive != oldCvx.IsActive)
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 11
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <Cvx> TableToList(DataTable table)
        {
            List <Cvx> retVal = new List <Cvx>();
            Cvx        cvx;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                cvx             = new Cvx();
                cvx.CvxNum      = PIn.Long(table.Rows[i]["CvxNum"].ToString());
                cvx.CvxCode     = PIn.String(table.Rows[i]["CvxCode"].ToString());
                cvx.Description = PIn.String(table.Rows[i]["Description"].ToString());
                cvx.IsActive    = PIn.String(table.Rows[i]["IsActive"].ToString());
                retVal.Add(cvx);
            }
            return(retVal);
        }
Ejemplo n.º 12
0
        ///<summary>Updates one Cvx in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.  Returns true if an update occurred.</summary>
        public static bool Update(Cvx cvx, Cvx oldCvx)
        {
            string command = "";

            if (cvx.CvxCode != oldCvx.CvxCode)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "CvxCode = '" + POut.String(cvx.CvxCode) + "'";
            }
            if (cvx.Description != oldCvx.Description)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Description = '" + POut.String(cvx.Description) + "'";
            }
            if (cvx.IsActive != oldCvx.IsActive)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "IsActive = '" + POut.String(cvx.IsActive) + "'";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE cvx SET " + command
                      + " WHERE CvxNum = " + POut.Long(cvx.CvxNum);
            Db.NonQ(command);
            return(true);
        }
Ejemplo n.º 13
0
Archivo: CvxCrud.cs Proyecto: mnisl/OD
		///<summary>Inserts one Cvx into the database.  Returns the new priKey.</summary>
		public static long Insert(Cvx cvx){
			if(DataConnection.DBtype==DatabaseType.Oracle) {
				cvx.CvxNum=DbHelper.GetNextOracleKey("cvx","CvxNum");
				int loopcount=0;
				while(loopcount<100){
					try {
						return Insert(cvx,true);
					}
					catch(Oracle.DataAccess.Client.OracleException ex){
						if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
							cvx.CvxNum++;
							loopcount++;
						}
						else{
							throw ex;
						}
					}
				}
				throw new ApplicationException("Insert failed.  Could not generate primary key.");
			}
			else {
				return Insert(cvx,false);
			}
		}
Ejemplo n.º 14
0
Archivo: CvxCrud.cs Proyecto: mnisl/OD
		///<summary>Inserts one Cvx into the database.  Provides option to use the existing priKey.</summary>
		public static long Insert(Cvx cvx,bool useExistingPK){
			if(!useExistingPK && PrefC.RandomKeys) {
				cvx.CvxNum=ReplicationServers.GetKey("cvx","CvxNum");
			}
			string command="INSERT INTO cvx (";
			if(useExistingPK || PrefC.RandomKeys) {
				command+="CvxNum,";
			}
			command+="CvxCode,Description,IsActive) VALUES(";
			if(useExistingPK || PrefC.RandomKeys) {
				command+=POut.Long(cvx.CvxNum)+",";
			}
			command+=
				 "'"+POut.String(cvx.CvxCode)+"',"
				+"'"+POut.String(cvx.Description)+"',"
				+"'"+POut.String(cvx.IsActive)+"')";
			if(useExistingPK || PrefC.RandomKeys) {
				Db.NonQ(command);
			}
			else {
				cvx.CvxNum=Db.NonQ(command,true);
			}
			return cvx.CvxNum;
		}
Ejemplo n.º 15
0
 ///<summary>Inserts one Cvx into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(Cvx cvx)
 {
     return(InsertNoCache(cvx, false));
 }
Ejemplo n.º 16
0
Archivo: CvxCrud.cs Proyecto: mnisl/OD
		///<summary>Updates one Cvx in the database.</summary>
		public static void Update(Cvx cvx){
			string command="UPDATE cvx SET "
				+"CvxCode    = '"+POut.String(cvx.CvxCode)+"', "
				+"Description= '"+POut.String(cvx.Description)+"', "
				+"IsActive   = '"+POut.String(cvx.IsActive)+"' "
				+"WHERE CvxNum = "+POut.Long(cvx.CvxNum);
			Db.NonQ(command);
		}
Ejemplo n.º 17
0
Archivo: CvxCrud.cs Proyecto: mnisl/OD
		///<summary>Updates one Cvx in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.  Returns true if an update occurred.</summary>
		public static bool Update(Cvx cvx,Cvx oldCvx){
			string command="";
			if(cvx.CvxCode != oldCvx.CvxCode) {
				if(command!=""){ command+=",";}
				command+="CvxCode = '"+POut.String(cvx.CvxCode)+"'";
			}
			if(cvx.Description != oldCvx.Description) {
				if(command!=""){ command+=",";}
				command+="Description = '"+POut.String(cvx.Description)+"'";
			}
			if(cvx.IsActive != oldCvx.IsActive) {
				if(command!=""){ command+=",";}
				command+="IsActive = '"+POut.String(cvx.IsActive)+"'";
			}
			if(command==""){
				return false;
			}
			command="UPDATE cvx SET "+command
				+" WHERE CvxNum = "+POut.Long(cvx.CvxNum);
			Db.NonQ(command);
			return true;
		}
Ejemplo n.º 18
0
 ///<summary>Inserts one Cvx into the database.  Returns the new priKey.</summary>
 public static long Insert(Cvx cvx)
 {
     return(Insert(cvx, false));
 }
Ejemplo n.º 19
0
        private void FillGrid()
        {
            gridMain.BeginUpdate();
            gridMain.ListGridColumns.Clear();
            GridColumn col = new GridColumn("Date", 70);

            gridMain.ListGridColumns.Add(col);
            col = new GridColumn("Prov", 50);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn("Item Not Performed", 130);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn("Code", 102);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn("Code Description", 150);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn("Reason Code", 80);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn("Reason Description", 150);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn("Note", 150);
            gridMain.ListGridColumns.Add(col);
            listNotPerf = EhrNotPerformeds.Refresh(PatCur.PatNum);
            gridMain.ListGridRows.Clear();
            GridRow row;

            for (int i = 0; i < listNotPerf.Count; i++)
            {
                row = new GridRow();
                row.Cells.Add(listNotPerf[i].DateEntry.ToShortDateString());
                row.Cells.Add(Providers.GetAbbr(listNotPerf[i].ProvNum));
                //Item not performed------------------------------------------------------------
                switch (listNotPerf[i].CodeValue)
                {
                case "39156-5":                        //BMI exam
                    row.Cells.Add(EhrNotPerformedItem.BMIExam.ToString());
                    break;

                case "428191000124101":                        //CurrentMedsDocumented
                    row.Cells.Add(EhrNotPerformedItem.DocumentCurrentMeds.ToString());
                    break;

                case "11366-2":                        //History of tobacco use Narrative
                case "68535-4":                        //Have you used tobacco in the last 30 days
                case "68536-2":                        //Have you used smokeless tobacco in last 30 days
                    row.Cells.Add(EhrNotPerformedItem.TobaccoScreening.ToString());
                    break;

                default:                        //We will default to Influenza Vaccine, there are 26 codes, for this item
                    row.Cells.Add(EhrNotPerformedItem.InfluenzaVaccination.ToString());
                    break;
                }
                //Code not performed------------------------------------------------------------
                row.Cells.Add(listNotPerf[i].CodeValue + " (" + listNotPerf[i].CodeSystem + ")");
                //Description of code not performed---------------------------------------------
                string descript = "";
                //to get description, first determine which table the code is from.  EhrNotPerformed is allowed to be CPT, CVX, LOINC, SNOMEDCT.
                switch (listNotPerf[i].CodeSystem)
                {
                case "CPT":
                    Cpt cptCur = Cpts.GetByCode(listNotPerf[i].CodeValue);
                    if (cptCur != null)
                    {
                        descript = cptCur.Description;
                    }
                    break;

                case "CVX":
                    Cvx cvxCur = Cvxs.GetOneFromDb(listNotPerf[i].CodeValue);
                    if (cvxCur != null)
                    {
                        descript = cvxCur.Description;
                    }
                    break;

                case "LOINC":
                    Loinc lCur = Loincs.GetByCode(listNotPerf[i].CodeValue);
                    if (lCur != null)
                    {
                        descript = lCur.NameLongCommon;
                    }
                    break;

                case "SNOMEDCT":
                    Snomed sCur = Snomeds.GetByCode(listNotPerf[i].CodeValue);
                    if (sCur != null)
                    {
                        descript = sCur.Description;
                    }
                    break;
                }
                row.Cells.Add(descript);
                //Reason Code-------------------------------------------------------------------
                row.Cells.Add(listNotPerf[i].CodeValueReason + " (" + listNotPerf[i].CodeSystemReason + ")");
                //Reason Description------------------------------------------------------------
                descript = "";
                if (listNotPerf[i].CodeValueReason != "")
                {
                    //reason codes are only allowed to be SNOMEDCT codes
                    Snomed sCur = Snomeds.GetByCode(listNotPerf[i].CodeValueReason);
                    if (sCur != null)
                    {
                        descript = sCur.Description;
                    }
                }
                row.Cells.Add(descript);
                //Note--------------------------------------------------------------------------
                row.Cells.Add(listNotPerf[i].Note);
                gridMain.ListGridRows.Add(row);
            }
            gridMain.EndUpdate();
        }