コード例 #1
0
 ///<summary>Inserts one EhrCode into the database.  Returns the new priKey.</summary>
 public static long Insert(EhrCode ehrCode)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         ehrCode.EhrCodeNum = DbHelper.GetNextOracleKey("ehrcode", "EhrCodeNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(ehrCode, true));
             }
             catch (Oracle.DataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     ehrCode.EhrCodeNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(ehrCode, false));
     }
 }
コード例 #2
0
        private void butIntervention_Click(object sender, EventArgs e)
        {
            if (comboInterventionCode.SelectedIndex < 0)
            {
                MsgBox.Show(this, "You must select an intervention code.");
                return;
            }
            EhrCode  iCodeCur = _listInterventionCodes[comboInterventionCode.SelectedIndex];
            DateTime dateCur  = PIn.Date(textDateIntervention.Text);

            if (iCodeCur.CodeSystem == "RXNORM" && !checkPatientDeclined.Checked)           //if patient declines the medication, enter as a declined intervention
            //codeVal will be RxCui of medication, see if it already exists in Medication table
            {
                Medication medCur = Medications.GetMedicationFromDbByRxCui(PIn.Long(iCodeCur.CodeValue));
                if (medCur == null)               //no med with this RxCui, create one
                {
                    medCur = new Medication();
                    Medications.Insert(medCur);                    //so that we will have the primary key
                    medCur.GenericNum = medCur.MedicationNum;
                    medCur.RxCui      = PIn.Long(iCodeCur.CodeValue);
                    medCur.MedName    = RxNorms.GetDescByRxCui(iCodeCur.CodeValue);
                    Medications.Update(medCur);
                    Medications.RefreshCache();                    //refresh cache to include new medication
                }
                MedicationPat medPatCur = new MedicationPat();
                medPatCur.PatNum        = PatCur.PatNum;
                medPatCur.ProvNum       = PatCur.PriProv;
                medPatCur.MedicationNum = medCur.MedicationNum;
                medPatCur.RxCui         = medCur.RxCui;
                medPatCur.DateStart     = dateCur;
                FormMedPat FormMP = new FormMedPat();
                FormMP.MedicationPatCur = medPatCur;
                FormMP.IsNew            = true;
                FormMP.ShowDialog();
                if (FormMP.DialogResult != DialogResult.OK)
                {
                    return;
                }
                if (FormMP.MedicationPatCur.DateStart.Date < dateCur.AddMonths(-6).Date || FormMP.MedicationPatCur.DateStart.Date > dateCur.Date)
                {
                    MsgBox.Show(this, "The medication order just entered is not within the 6 months prior to the date of this intervention.  You can modify the "
                                + "date of the medication order in the patient's medical history section.");
                }
            }
            else
            {
                Intervention iCur = new Intervention();
                iCur.PatNum        = PatCur.PatNum;
                iCur.ProvNum       = PatCur.PriProv;
                iCur.DateEntry     = dateCur;
                iCur.CodeValue     = iCodeCur.CodeValue;
                iCur.CodeSystem    = iCodeCur.CodeSystem;
                iCur.CodeSet       = InterventionCodeSet.TobaccoCessation;
                iCur.IsPatDeclined = checkPatientDeclined.Checked;
                Interventions.Insert(iCur);
            }
            comboInterventionCode.SelectedIndex = -1;
            FillGridInterventions();
        }
コード例 #3
0
ファイル: EhrCodeCrud.cs プロジェクト: kjb7749/testImport
 ///<summary>Inserts one EhrCode into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(EhrCode ehrCode)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(ehrCode, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             ehrCode.EhrCodeNum = DbHelper.GetNextOracleKey("ehrcode", "EhrCodeNum");                  //Cacheless method
         }
         return(InsertNoCache(ehrCode, true));
     }
 }
コード例 #4
0
        ///<summary>Updates one EhrCode in the database.</summary>
        public static void Update(EhrCode ehrCode)
        {
            string command = "UPDATE ehrcode SET "
                             + "MeasureIds   = '" + POut.String(ehrCode.MeasureIds) + "', "
                             + "ValueSetName = '" + POut.String(ehrCode.ValueSetName) + "', "
                             + "ValueSetOID  = '" + POut.String(ehrCode.ValueSetOID) + "', "
                             + "QDMCategory  = '" + POut.String(ehrCode.QDMCategory) + "', "
                             + "CodeValue    = '" + POut.String(ehrCode.CodeValue) + "', "
                             + "Description  = '" + POut.String(ehrCode.Description) + "', "
                             + "CodeSystem   = '" + POut.String(ehrCode.CodeSystem) + "', "
                             + "CodeSystemOID= '" + POut.String(ehrCode.CodeSystemOID) + "', "
                             + "IsInDb       =  " + POut.Bool(ehrCode.IsInDb) + " "
                             + "WHERE EhrCodeNum = " + POut.Long(ehrCode.EhrCodeNum);

            Db.NonQ(command);
        }
コード例 #5
0
ファイル: EhrCodeCrud.cs プロジェクト: mnisl/OD
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<EhrCode> TableToList(DataTable table){
			List<EhrCode> retVal=new List<EhrCode>();
			EhrCode ehrCode;
			for(int i=0;i<table.Rows.Count;i++) {
				ehrCode=new EhrCode();
				ehrCode.EhrCodeNum   = PIn.Long  (table.Rows[i]["EhrCodeNum"].ToString());
				ehrCode.MeasureIds   = PIn.String(table.Rows[i]["MeasureIds"].ToString());
				ehrCode.ValueSetName = PIn.String(table.Rows[i]["ValueSetName"].ToString());
				ehrCode.ValueSetOID  = PIn.String(table.Rows[i]["ValueSetOID"].ToString());
				ehrCode.QDMCategory  = PIn.String(table.Rows[i]["QDMCategory"].ToString());
				ehrCode.CodeValue    = PIn.String(table.Rows[i]["CodeValue"].ToString());
				ehrCode.Description  = PIn.String(table.Rows[i]["Description"].ToString());
				ehrCode.CodeSystem   = PIn.String(table.Rows[i]["CodeSystem"].ToString());
				ehrCode.CodeSystemOID= PIn.String(table.Rows[i]["CodeSystemOID"].ToString());
				ehrCode.IsInDb       = PIn.Bool  (table.Rows[i]["IsInDb"].ToString());
				retVal.Add(ehrCode);
			}
			return retVal;
		}
コード例 #6
0
 ///<summary>Returns true if Update(EhrCode,EhrCode) 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(EhrCode ehrCode, EhrCode oldEhrCode)
 {
     if (ehrCode.MeasureIds != oldEhrCode.MeasureIds)
     {
         return(true);
     }
     if (ehrCode.ValueSetName != oldEhrCode.ValueSetName)
     {
         return(true);
     }
     if (ehrCode.ValueSetOID != oldEhrCode.ValueSetOID)
     {
         return(true);
     }
     if (ehrCode.QDMCategory != oldEhrCode.QDMCategory)
     {
         return(true);
     }
     if (ehrCode.CodeValue != oldEhrCode.CodeValue)
     {
         return(true);
     }
     if (ehrCode.Description != oldEhrCode.Description)
     {
         return(true);
     }
     if (ehrCode.CodeSystem != oldEhrCode.CodeSystem)
     {
         return(true);
     }
     if (ehrCode.CodeSystemOID != oldEhrCode.CodeSystemOID)
     {
         return(true);
     }
     if (ehrCode.IsInDb != oldEhrCode.IsInDb)
     {
         return(true);
     }
     return(false);
 }
コード例 #7
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <EhrCode> TableToList(DataTable table)
        {
            List <EhrCode> retVal = new List <EhrCode>();
            EhrCode        ehrCode;

            foreach (DataRow row in table.Rows)
            {
                ehrCode               = new EhrCode();
                ehrCode.EhrCodeNum    = PIn.Long(row["EhrCodeNum"].ToString());
                ehrCode.MeasureIds    = PIn.String(row["MeasureIds"].ToString());
                ehrCode.ValueSetName  = PIn.String(row["ValueSetName"].ToString());
                ehrCode.ValueSetOID   = PIn.String(row["ValueSetOID"].ToString());
                ehrCode.QDMCategory   = PIn.String(row["QDMCategory"].ToString());
                ehrCode.CodeValue     = PIn.String(row["CodeValue"].ToString());
                ehrCode.Description   = PIn.String(row["Description"].ToString());
                ehrCode.CodeSystem    = PIn.String(row["CodeSystem"].ToString());
                ehrCode.CodeSystemOID = PIn.String(row["CodeSystemOID"].ToString());
                ehrCode.IsInDb        = PIn.Bool(row["IsInDb"].ToString());
                retVal.Add(ehrCode);
            }
            return(retVal);
        }
コード例 #8
0
        ///<summary>Inserts one EhrCode into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(EhrCode ehrCode, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO ehrcode (";

            if (!useExistingPK && isRandomKeys)
            {
                ehrCode.EhrCodeNum = ReplicationServers.GetKeyNoCache("ehrcode", "EhrCodeNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "EhrCodeNum,";
            }
            command += "MeasureIds,ValueSetName,ValueSetOID,QDMCategory,CodeValue,Description,CodeSystem,CodeSystemOID,IsInDb) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(ehrCode.EhrCodeNum) + ",";
            }
            command +=
                "'" + POut.String(ehrCode.MeasureIds) + "',"
                + "'" + POut.String(ehrCode.ValueSetName) + "',"
                + "'" + POut.String(ehrCode.ValueSetOID) + "',"
                + "'" + POut.String(ehrCode.QDMCategory) + "',"
                + "'" + POut.String(ehrCode.CodeValue) + "',"
                + "'" + POut.String(ehrCode.Description) + "',"
                + "'" + POut.String(ehrCode.CodeSystem) + "',"
                + "'" + POut.String(ehrCode.CodeSystemOID) + "',"
                + POut.Bool(ehrCode.IsInDb) + ")";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                ehrCode.EhrCodeNum = Db.NonQ(command, true, "EhrCodeNum", "ehrCode");
            }
            return(ehrCode.EhrCodeNum);
        }
コード例 #9
0
ファイル: EhrCodeCrud.cs プロジェクト: mnisl/OD
		///<summary>Inserts one EhrCode into the database.  Returns the new priKey.</summary>
		public static long Insert(EhrCode ehrCode){
			if(DataConnection.DBtype==DatabaseType.Oracle) {
				ehrCode.EhrCodeNum=DbHelper.GetNextOracleKey("ehrcode","EhrCodeNum");
				int loopcount=0;
				while(loopcount<100){
					try {
						return Insert(ehrCode,true);
					}
					catch(Oracle.DataAccess.Client.OracleException ex){
						if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
							ehrCode.EhrCodeNum++;
							loopcount++;
						}
						else{
							throw ex;
						}
					}
				}
				throw new ApplicationException("Insert failed.  Could not generate primary key.");
			}
			else {
				return Insert(ehrCode,false);
			}
		}
コード例 #10
0
        ///<summary>Updates one EhrCode 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(EhrCode ehrCode, EhrCode oldEhrCode)
        {
            string command = "";

            if (ehrCode.MeasureIds != oldEhrCode.MeasureIds)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "MeasureIds = '" + POut.String(ehrCode.MeasureIds) + "'";
            }
            if (ehrCode.ValueSetName != oldEhrCode.ValueSetName)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ValueSetName = '" + POut.String(ehrCode.ValueSetName) + "'";
            }
            if (ehrCode.ValueSetOID != oldEhrCode.ValueSetOID)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ValueSetOID = '" + POut.String(ehrCode.ValueSetOID) + "'";
            }
            if (ehrCode.QDMCategory != oldEhrCode.QDMCategory)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "QDMCategory = '" + POut.String(ehrCode.QDMCategory) + "'";
            }
            if (ehrCode.CodeValue != oldEhrCode.CodeValue)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "CodeValue = '" + POut.String(ehrCode.CodeValue) + "'";
            }
            if (ehrCode.Description != oldEhrCode.Description)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Description = '" + POut.String(ehrCode.Description) + "'";
            }
            if (ehrCode.CodeSystem != oldEhrCode.CodeSystem)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "CodeSystem = '" + POut.String(ehrCode.CodeSystem) + "'";
            }
            if (ehrCode.CodeSystemOID != oldEhrCode.CodeSystemOID)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "CodeSystemOID = '" + POut.String(ehrCode.CodeSystemOID) + "'";
            }
            if (ehrCode.IsInDb != oldEhrCode.IsInDb)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "IsInDb = " + POut.Bool(ehrCode.IsInDb) + "";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE ehrcode SET " + command
                      + " WHERE EhrCodeNum = " + POut.Long(ehrCode.EhrCodeNum);
            Db.NonQ(command);
            return(true);
        }
コード例 #11
0
 ///<summary>Inserts one EhrCode into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(EhrCode ehrCode)
 {
     return(InsertNoCache(ehrCode, false));
 }
コード例 #12
0
 ///<summary>Inserts one EhrCode into the database.  Returns the new priKey.</summary>
 public static long Insert(EhrCode ehrCode)
 {
     return(Insert(ehrCode, false));
 }
コード例 #13
0
ファイル: EhrCodeCrud.cs プロジェクト: mnisl/OD
		///<summary>Inserts one EhrCode into the database.  Provides option to use the existing priKey.</summary>
		public static long Insert(EhrCode ehrCode,bool useExistingPK){
			if(!useExistingPK && PrefC.RandomKeys) {
				ehrCode.EhrCodeNum=ReplicationServers.GetKey("ehrcode","EhrCodeNum");
			}
			string command="INSERT INTO ehrcode (";
			if(useExistingPK || PrefC.RandomKeys) {
				command+="EhrCodeNum,";
			}
			command+="MeasureIds,ValueSetName,ValueSetOID,QDMCategory,CodeValue,Description,CodeSystem,CodeSystemOID,IsInDb) VALUES(";
			if(useExistingPK || PrefC.RandomKeys) {
				command+=POut.Long(ehrCode.EhrCodeNum)+",";
			}
			command+=
				 "'"+POut.String(ehrCode.MeasureIds)+"',"
				+"'"+POut.String(ehrCode.ValueSetName)+"',"
				+"'"+POut.String(ehrCode.ValueSetOID)+"',"
				+"'"+POut.String(ehrCode.QDMCategory)+"',"
				+"'"+POut.String(ehrCode.CodeValue)+"',"
				+"'"+POut.String(ehrCode.Description)+"',"
				+"'"+POut.String(ehrCode.CodeSystem)+"',"
				+"'"+POut.String(ehrCode.CodeSystemOID)+"',"
				+    POut.Bool  (ehrCode.IsInDb)+")";
			if(useExistingPK || PrefC.RandomKeys) {
				Db.NonQ(command);
			}
			else {
				ehrCode.EhrCodeNum=Db.NonQ(command,true);
			}
			return ehrCode.EhrCodeNum;
		}
コード例 #14
0
ファイル: EhrCodeCrud.cs プロジェクト: mnisl/OD
		///<summary>Updates one EhrCode 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(EhrCode ehrCode,EhrCode oldEhrCode){
			string command="";
			if(ehrCode.MeasureIds != oldEhrCode.MeasureIds) {
				if(command!=""){ command+=",";}
				command+="MeasureIds = '"+POut.String(ehrCode.MeasureIds)+"'";
			}
			if(ehrCode.ValueSetName != oldEhrCode.ValueSetName) {
				if(command!=""){ command+=",";}
				command+="ValueSetName = '"+POut.String(ehrCode.ValueSetName)+"'";
			}
			if(ehrCode.ValueSetOID != oldEhrCode.ValueSetOID) {
				if(command!=""){ command+=",";}
				command+="ValueSetOID = '"+POut.String(ehrCode.ValueSetOID)+"'";
			}
			if(ehrCode.QDMCategory != oldEhrCode.QDMCategory) {
				if(command!=""){ command+=",";}
				command+="QDMCategory = '"+POut.String(ehrCode.QDMCategory)+"'";
			}
			if(ehrCode.CodeValue != oldEhrCode.CodeValue) {
				if(command!=""){ command+=",";}
				command+="CodeValue = '"+POut.String(ehrCode.CodeValue)+"'";
			}
			if(ehrCode.Description != oldEhrCode.Description) {
				if(command!=""){ command+=",";}
				command+="Description = '"+POut.String(ehrCode.Description)+"'";
			}
			if(ehrCode.CodeSystem != oldEhrCode.CodeSystem) {
				if(command!=""){ command+=",";}
				command+="CodeSystem = '"+POut.String(ehrCode.CodeSystem)+"'";
			}
			if(ehrCode.CodeSystemOID != oldEhrCode.CodeSystemOID) {
				if(command!=""){ command+=",";}
				command+="CodeSystemOID = '"+POut.String(ehrCode.CodeSystemOID)+"'";
			}
			if(ehrCode.IsInDb != oldEhrCode.IsInDb) {
				if(command!=""){ command+=",";}
				command+="IsInDb = "+POut.Bool(ehrCode.IsInDb)+"";
			}
			if(command==""){
				return false;
			}
			command="UPDATE ehrcode SET "+command
				+" WHERE EhrCodeNum = "+POut.Long(ehrCode.EhrCodeNum);
			Db.NonQ(command);
			return true;
		}
コード例 #15
0
ファイル: EhrCodeCrud.cs プロジェクト: mnisl/OD
		///<summary>Updates one EhrCode in the database.</summary>
		public static void Update(EhrCode ehrCode){
			string command="UPDATE ehrcode SET "
				+"MeasureIds   = '"+POut.String(ehrCode.MeasureIds)+"', "
				+"ValueSetName = '"+POut.String(ehrCode.ValueSetName)+"', "
				+"ValueSetOID  = '"+POut.String(ehrCode.ValueSetOID)+"', "
				+"QDMCategory  = '"+POut.String(ehrCode.QDMCategory)+"', "
				+"CodeValue    = '"+POut.String(ehrCode.CodeValue)+"', "
				+"Description  = '"+POut.String(ehrCode.Description)+"', "
				+"CodeSystem   = '"+POut.String(ehrCode.CodeSystem)+"', "
				+"CodeSystemOID= '"+POut.String(ehrCode.CodeSystemOID)+"', "
				+"IsInDb       =  "+POut.Bool  (ehrCode.IsInDb)+" "
				+"WHERE EhrCodeNum = "+POut.Long(ehrCode.EhrCodeNum);
			Db.NonQ(command);
		}