Ejemplo n.º 1
0
        ///<summary>Inserts one MedicationPat into the database.  Provides option to use the existing priKey.</summary>
        internal static long Insert(MedicationPat medicationPat, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                medicationPat.MedicationPatNum = ReplicationServers.GetKey("medicationpat", "MedicationPatNum");
            }
            string command = "INSERT INTO medicationpat (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "MedicationPatNum,";
            }
            command += "PatNum,MedicationNum,PatNote,DateStart,DateStop,ProvNum) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(medicationPat.MedicationPatNum) + ",";
            }
            command +=
                POut.Long(medicationPat.PatNum) + ","
                + POut.Long(medicationPat.MedicationNum) + ","
                + "'" + POut.String(medicationPat.PatNote) + "',"
                //DateTStamp can only be set by MySQL
                + POut.Date(medicationPat.DateStart) + ","
                + POut.Date(medicationPat.DateStop) + ","
                + POut.Long(medicationPat.ProvNum) + ")";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                medicationPat.MedicationPatNum = Db.NonQ(command, true);
            }
            return(medicationPat.MedicationPatNum);
        }
Ejemplo n.º 2
0
        ///<summary></summary>
        public static void Delete(MedicationPat Cur)
        {
            string command = "DELETE from medicationpat WHERE medicationpatNum = '"
                             + Cur.MedicationPatNum.ToString() + "'";

            General.NonQ(command);
        }
Ejemplo n.º 3
0
 ///<summary>Inserts one MedicationPat into the database.  Returns the new priKey.</summary>
 internal static long Insert(MedicationPat medicationPat)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         medicationPat.MedicationPatNum = DbHelper.GetNextOracleKey("medicationpat", "MedicationPatNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(medicationPat, true));
             }
             catch (Oracle.DataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     medicationPat.MedicationPatNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(medicationPat, false));
     }
 }
Ejemplo n.º 4
0
        private void butAdd_Click(object sender, EventArgs e)
        {
            //select medication from list.  Additional meds can be added to the list from within that dlg
            FormMedications FormM = new FormMedications();

            FormM.IsSelectionMode = true;
            FormM.ShowDialog();
            if (FormM.DialogResult != DialogResult.OK)
            {
                return;
            }
            MedicationPat MedicationPatCur = new MedicationPat();

            MedicationPatCur.PatNum        = PatCur.PatNum;
            MedicationPatCur.MedicationNum = FormM.SelectedMedicationNum;
            MedicationPatCur.ProvNum       = PatCur.PriProv;
            FormMedPat FormMP = new FormMedPat();

            FormMP.MedicationPatCur = MedicationPatCur;
            FormMP.IsNew            = true;
            FormMP.ShowDialog();
            if (FormMP.DialogResult != DialogResult.OK)
            {
                return;
            }
            FillMeds();
        }
Ejemplo n.º 5
0
        ///<summary></summary>
        public static void Insert(MedicationPat Cur)
        {
            if (PrefB.RandomKeys)
            {
                Cur.MedicationPatNum = MiscData.GetKey("medicationpat", "MedicationPatNum");
            }
            string command = "INSERT INTO medicationpat (";

            if (PrefB.RandomKeys)
            {
                command += "MedicationPatNum,";
            }
            command += "patnum,medicationnum,patnote"
                       + ") VALUES(";
            if (PrefB.RandomKeys)
            {
                command += "'" + POut.PInt(Cur.MedicationPatNum) + "', ";
            }
            command +=
                "'" + POut.PInt(Cur.PatNum) + "', "
                + "'" + POut.PInt(Cur.MedicationNum) + "', "
                + "'" + POut.PString(Cur.PatNote) + "')";
            if (PrefB.RandomKeys)
            {
                General.NonQ(command);
            }
            else
            {
                Cur.MedicationPatNum = General.NonQ(command, true);
            }
        }
Ejemplo n.º 6
0
 ///<summary>Inserts one MedicationPat into the database.  Returns the new priKey.</summary>
 internal static long Insert(MedicationPat medicationPat)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         medicationPat.MedicationPatNum=DbHelper.GetNextOracleKey("medicationpat","MedicationPatNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(medicationPat,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     medicationPat.MedicationPatNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(medicationPat,false);
     }
 }
Ejemplo n.º 7
0
 ///<summary>Inserts one MedicationPat into the database.  Provides option to use the existing priKey.</summary>
 internal static long Insert(MedicationPat medicationPat,bool useExistingPK)
 {
     if(!useExistingPK && PrefC.RandomKeys) {
         medicationPat.MedicationPatNum=ReplicationServers.GetKey("medicationpat","MedicationPatNum");
     }
     string command="INSERT INTO medicationpat (";
     if(useExistingPK || PrefC.RandomKeys) {
         command+="MedicationPatNum,";
     }
     command+="PatNum,MedicationNum,PatNote,DateStart,DateStop,ProvNum) VALUES(";
     if(useExistingPK || PrefC.RandomKeys) {
         command+=POut.Long(medicationPat.MedicationPatNum)+",";
     }
     command+=
              POut.Long  (medicationPat.PatNum)+","
         +    POut.Long  (medicationPat.MedicationNum)+","
         +"'"+POut.String(medicationPat.PatNote)+"',"
         //DateTStamp can only be set by MySQL
         +    POut.Date  (medicationPat.DateStart)+","
         +    POut.Date  (medicationPat.DateStop)+","
         +    POut.Long  (medicationPat.ProvNum)+")";
     if(useExistingPK || PrefC.RandomKeys) {
         Db.NonQ(command);
     }
     else {
         medicationPat.MedicationPatNum=Db.NonQ(command,true);
     }
     return medicationPat.MedicationPatNum;
 }
Ejemplo n.º 8
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();
        }
Ejemplo n.º 9
0
        ///<summary></summary>
        public static void Update(MedicationPat Cur)
        {
            string command = "UPDATE medicationpat SET "
                             + "patnum = '" + POut.PInt(Cur.PatNum) + "'"
                             + ",medicationnum = '" + POut.PInt(Cur.MedicationNum) + "'"
                             + ",patnote = '" + POut.PString(Cur.PatNote) + "'"
                             + " WHERE medicationpatnum = '" + POut.PInt(Cur.MedicationPatNum) + "'";

            //MessageBox.Show(command);
            General.NonQ(command);
        }
Ejemplo n.º 10
0
        ///<summary>Converts one MedicationPat object to its mobile equivalent.  Warning! CustomerNum will always be 0.</summary>
        internal static MedicationPatm ConvertToM(MedicationPat medicationPat)
        {
            MedicationPatm medicationPatm = new MedicationPatm();

            //CustomerNum cannot be set.  Remains 0.
            medicationPatm.MedicationPatNum = medicationPat.MedicationPatNum;
            medicationPatm.PatNum           = medicationPat.PatNum;
            medicationPatm.MedicationNum    = medicationPat.MedicationNum;
            medicationPatm.PatNote          = medicationPat.PatNote;
            medicationPatm.DateStart        = medicationPat.DateStart;
            medicationPatm.DateStop         = medicationPat.DateStop;
            return(medicationPatm);
        }
Ejemplo n.º 11
0
        ///<summary>Updates one MedicationPat in the database.</summary>
        internal static void Update(MedicationPat medicationPat)
        {
            string command = "UPDATE medicationpat SET "
                             + "PatNum          =  " + POut.Long(medicationPat.PatNum) + ", "
                             + "MedicationNum   =  " + POut.Long(medicationPat.MedicationNum) + ", "
                             + "PatNote         = '" + POut.String(medicationPat.PatNote) + "', "
                             //DateTStamp can only be set by MySQL
                             + "DateStart       =  " + POut.Date(medicationPat.DateStart) + ", "
                             + "DateStop        =  " + POut.Date(medicationPat.DateStop) + ", "
                             + "ProvNum         =  " + POut.Long(medicationPat.ProvNum) + " "
                             + "WHERE MedicationPatNum = " + POut.Long(medicationPat.MedicationPatNum);

            Db.NonQ(command);
        }
Ejemplo n.º 12
0
 ///<summary>Inserts one MedicationPat into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(MedicationPat medicationPat)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(medicationPat, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             medicationPat.MedicationPatNum = DbHelper.GetNextOracleKey("medicationpat", "MedicationPatNum");                  //Cacheless method
         }
         return(InsertNoCache(medicationPat, true));
     }
 }
Ejemplo n.º 13
0
        ///<summary>Inserts the new medicationPat and returns it.</summary>
        public static MedicationPat CreateMedicationPat(long patNum, long medicationNum = 0, DateTime dateStart = default(DateTime),
                                                        DateTime dateStop = default(DateTime))
        {
            MedicationPat medPat = new MedicationPat();

            medPat.PatNum        = patNum;
            medPat.MedicationNum = medicationNum;
            if (medicationNum == 0)
            {
                medPat.MedicationNum = MedicationT.CreateMedication().MedicationNum;
            }
            medPat.DateStart = dateStart;
            medPat.DateStop  = dateStop;
            MedicationPats.Insert(medPat);
            return(medPat);
        }
Ejemplo n.º 14
0
        public static MedicationPat[] List;        //for current pat

        ///<summary></summary>
        public static void Refresh(int patNum)
        {
            string command =
                "SELECT * from medicationpat WHERE patnum = '" + patNum + "'";
            DataTable table = General.GetTable(command);

            List = new MedicationPat[table.Rows.Count];
            for (int i = 0; i < table.Rows.Count; i++)
            {
                List[i] = new MedicationPat();
                List[i].MedicationPatNum = PIn.PInt(table.Rows[i][0].ToString());
                List[i].PatNum           = PIn.PInt(table.Rows[i][1].ToString());
                List[i].MedicationNum    = PIn.PInt(table.Rows[i][2].ToString());
                List[i].PatNote          = PIn.PString(table.Rows[i][3].ToString());
                //HList.Add(List[i].MedicationNum,List[i]);
            }
        }
Ejemplo n.º 15
0
        ///<summary>Inserts one MedicationPat into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(MedicationPat medicationPat, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO medicationpat (";

            if (!useExistingPK && isRandomKeys)
            {
                medicationPat.MedicationPatNum = ReplicationServers.GetKeyNoCache("medicationpat", "MedicationPatNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "MedicationPatNum,";
            }
            command += "PatNum,MedicationNum,PatNote,DateStart,DateStop,ProvNum,MedDescript,RxCui,ErxGuid,IsCpoe) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(medicationPat.MedicationPatNum) + ",";
            }
            command +=
                POut.Long(medicationPat.PatNum) + ","
                + POut.Long(medicationPat.MedicationNum) + ","
                + DbHelper.ParamChar + "paramPatNote,"
                //DateTStamp can only be set by MySQL
                + POut.Date(medicationPat.DateStart) + ","
                + POut.Date(medicationPat.DateStop) + ","
                + POut.Long(medicationPat.ProvNum) + ","
                + "'" + POut.String(medicationPat.MedDescript) + "',"
                + POut.Long(medicationPat.RxCui) + ","
                + "'" + POut.String(medicationPat.ErxGuid) + "',"
                + POut.Bool(medicationPat.IsCpoe) + ")";
            if (medicationPat.PatNote == null)
            {
                medicationPat.PatNote = "";
            }
            OdSqlParameter paramPatNote = new OdSqlParameter("paramPatNote", OdDbType.Text, POut.StringParam(medicationPat.PatNote));

            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command, paramPatNote);
            }
            else
            {
                medicationPat.MedicationPatNum = Db.NonQ(command, true, "MedicationPatNum", "medicationPat", paramPatNote);
            }
            return(medicationPat.MedicationPatNum);
        }
Ejemplo n.º 16
0
 ///<summary>Returns true if Update(MedicationPat,MedicationPat) 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(MedicationPat medicationPat, MedicationPat oldMedicationPat)
 {
     if (medicationPat.PatNum != oldMedicationPat.PatNum)
     {
         return(true);
     }
     if (medicationPat.MedicationNum != oldMedicationPat.MedicationNum)
     {
         return(true);
     }
     if (medicationPat.PatNote != oldMedicationPat.PatNote)
     {
         return(true);
     }
     //DateTStamp can only be set by MySQL
     if (medicationPat.DateStart.Date != oldMedicationPat.DateStart.Date)
     {
         return(true);
     }
     if (medicationPat.DateStop.Date != oldMedicationPat.DateStop.Date)
     {
         return(true);
     }
     if (medicationPat.ProvNum != oldMedicationPat.ProvNum)
     {
         return(true);
     }
     if (medicationPat.MedDescript != oldMedicationPat.MedDescript)
     {
         return(true);
     }
     if (medicationPat.RxCui != oldMedicationPat.RxCui)
     {
         return(true);
     }
     if (medicationPat.ErxGuid != oldMedicationPat.ErxGuid)
     {
         return(true);
     }
     if (medicationPat.IsCpoe != oldMedicationPat.IsCpoe)
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 17
0
        ///<summary>Updates one MedicationPat in the database.</summary>
        public static void Update(MedicationPat medicationPat)
        {
            string command = "UPDATE medicationpat SET "
                             + "PatNum          =  " + POut.Long(medicationPat.PatNum) + ", "
                             + "MedicationNum   =  " + POut.Long(medicationPat.MedicationNum) + ", "
                             + "PatNote         = '" + POut.String(medicationPat.PatNote) + "', "
                             //DateTStamp can only be set by MySQL
                             + "DateStart       =  " + POut.Date(medicationPat.DateStart) + ", "
                             + "DateStop        =  " + POut.Date(medicationPat.DateStop) + ", "
                             + "ProvNum         =  " + POut.Long(medicationPat.ProvNum) + ", "
                             + "MedDescript     = '" + POut.String(medicationPat.MedDescript) + "', "
                             + "RxCui           =  " + POut.Long(medicationPat.RxCui) + ", "
                             + "NewCropGuid     = '" + POut.String(medicationPat.NewCropGuid) + "', "
                             + "IsCpoe          =  " + POut.Bool(medicationPat.IsCpoe) + " "
                             + "WHERE MedicationPatNum = " + POut.Long(medicationPat.MedicationPatNum);

            Db.NonQ(command);
        }
Ejemplo n.º 18
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        internal static List <MedicationPat> TableToList(DataTable table)
        {
            List <MedicationPat> retVal = new List <MedicationPat>();
            MedicationPat        medicationPat;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                medicationPat = new MedicationPat();
                medicationPat.MedicationPatNum = PIn.Long(table.Rows[i]["MedicationPatNum"].ToString());
                medicationPat.PatNum           = PIn.Long(table.Rows[i]["PatNum"].ToString());
                medicationPat.MedicationNum    = PIn.Long(table.Rows[i]["MedicationNum"].ToString());
                medicationPat.PatNote          = PIn.String(table.Rows[i]["PatNote"].ToString());
                medicationPat.DateTStamp       = PIn.DateT(table.Rows[i]["DateTStamp"].ToString());
                medicationPat.DateStart        = PIn.Date(table.Rows[i]["DateStart"].ToString());
                medicationPat.DateStop         = PIn.Date(table.Rows[i]["DateStop"].ToString());
                medicationPat.ProvNum          = PIn.Long(table.Rows[i]["ProvNum"].ToString());
                retVal.Add(medicationPat);
            }
            return(retVal);
        }
Ejemplo n.º 19
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<MedicationPat> TableToList(DataTable table){
			List<MedicationPat> retVal=new List<MedicationPat>();
			MedicationPat medicationPat;
			for(int i=0;i<table.Rows.Count;i++) {
				medicationPat=new MedicationPat();
				medicationPat.MedicationPatNum= PIn.Long  (table.Rows[i]["MedicationPatNum"].ToString());
				medicationPat.PatNum          = PIn.Long  (table.Rows[i]["PatNum"].ToString());
				medicationPat.MedicationNum   = PIn.Long  (table.Rows[i]["MedicationNum"].ToString());
				medicationPat.PatNote         = PIn.String(table.Rows[i]["PatNote"].ToString());
				medicationPat.DateTStamp      = PIn.DateT (table.Rows[i]["DateTStamp"].ToString());
				medicationPat.DateStart       = PIn.Date  (table.Rows[i]["DateStart"].ToString());
				medicationPat.DateStop        = PIn.Date  (table.Rows[i]["DateStop"].ToString());
				medicationPat.ProvNum         = PIn.Long  (table.Rows[i]["ProvNum"].ToString());
				medicationPat.MedDescript     = PIn.String(table.Rows[i]["MedDescript"].ToString());
				medicationPat.RxCui           = PIn.Long  (table.Rows[i]["RxCui"].ToString());
				medicationPat.NewCropGuid     = PIn.String(table.Rows[i]["NewCropGuid"].ToString());
				medicationPat.IsCpoe          = PIn.Bool  (table.Rows[i]["IsCpoe"].ToString());
				retVal.Add(medicationPat);
			}
			return retVal;
		}
Ejemplo n.º 20
0
 private void butRemove_Click(object sender, System.EventArgs e)
 {
     if (IsNew)
     {
         DialogResult = DialogResult.Cancel;
         return;
     }
     if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Remove this medication from this patient?  Patient notes will be lost."))
     {
         return;
     }
     MedicationPats.Delete(MedicationPatCur);
     if (MedicationPatCur.MedicationNum == 0)
     {
         SecurityLogs.MakeLogEntry(Permissions.PatMedicationListEdit, MedicationPatCur.PatNum, MedicationPatCur.MedDescript + " deleted");
     }
     else
     {
         SecurityLogs.MakeLogEntry(Permissions.PatMedicationListEdit, MedicationPatCur.PatNum, Medications.GetMedication(MedicationPatCur.MedicationNum).MedName + " deleted");
     }
     MedicationPatCur = null;          //This prevents other windows trying to use the medication pat after this window has closed.
     DialogResult     = DialogResult.OK;
 }
Ejemplo n.º 21
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <MedicationPat> TableToList(DataTable table)
        {
            List <MedicationPat> retVal = new List <MedicationPat>();
            MedicationPat        medicationPat;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                medicationPat = new MedicationPat();
                medicationPat.MedicationPatNum = PIn.Long(table.Rows[i]["MedicationPatNum"].ToString());
                medicationPat.PatNum           = PIn.Long(table.Rows[i]["PatNum"].ToString());
                medicationPat.MedicationNum    = PIn.Long(table.Rows[i]["MedicationNum"].ToString());
                medicationPat.PatNote          = PIn.String(table.Rows[i]["PatNote"].ToString());
                medicationPat.DateTStamp       = PIn.DateT(table.Rows[i]["DateTStamp"].ToString());
                medicationPat.DateStart        = PIn.Date(table.Rows[i]["DateStart"].ToString());
                medicationPat.DateStop         = PIn.Date(table.Rows[i]["DateStop"].ToString());
                medicationPat.ProvNum          = PIn.Long(table.Rows[i]["ProvNum"].ToString());
                medicationPat.MedDescript      = PIn.String(table.Rows[i]["MedDescript"].ToString());
                medicationPat.RxCui            = PIn.Long(table.Rows[i]["RxCui"].ToString());
                medicationPat.NewCropGuid      = PIn.String(table.Rows[i]["NewCropGuid"].ToString());
                medicationPat.IsCpoe           = PIn.Bool(table.Rows[i]["IsCpoe"].ToString());
                retVal.Add(medicationPat);
            }
            return(retVal);
        }
Ejemplo n.º 22
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <MedicationPat> TableToList(DataTable table)
        {
            List <MedicationPat> retVal = new List <MedicationPat>();
            MedicationPat        medicationPat;

            foreach (DataRow row in table.Rows)
            {
                medicationPat = new MedicationPat();
                medicationPat.MedicationPatNum = PIn.Long(row["MedicationPatNum"].ToString());
                medicationPat.PatNum           = PIn.Long(row["PatNum"].ToString());
                medicationPat.MedicationNum    = PIn.Long(row["MedicationNum"].ToString());
                medicationPat.PatNote          = PIn.String(row["PatNote"].ToString());
                medicationPat.DateTStamp       = PIn.DateT(row["DateTStamp"].ToString());
                medicationPat.DateStart        = PIn.Date(row["DateStart"].ToString());
                medicationPat.DateStop         = PIn.Date(row["DateStop"].ToString());
                medicationPat.ProvNum          = PIn.Long(row["ProvNum"].ToString());
                medicationPat.MedDescript      = PIn.String(row["MedDescript"].ToString());
                medicationPat.RxCui            = PIn.Long(row["RxCui"].ToString());
                medicationPat.ErxGuid          = PIn.String(row["ErxGuid"].ToString());
                medicationPat.IsCpoe           = PIn.Bool(row["IsCpoe"].ToString());
                retVal.Add(medicationPat);
            }
            return(retVal);
        }
Ejemplo n.º 23
0
        ///<summary>Updates one MedicationPat in the database.</summary>
        public static void Update(MedicationPat medicationPat)
        {
            string command = "UPDATE medicationpat SET "
                             + "PatNum          =  " + POut.Long(medicationPat.PatNum) + ", "
                             + "MedicationNum   =  " + POut.Long(medicationPat.MedicationNum) + ", "
                             + "PatNote         =  " + DbHelper.ParamChar + "paramPatNote, "
                             //DateTStamp can only be set by MySQL
                             + "DateStart       =  " + POut.Date(medicationPat.DateStart) + ", "
                             + "DateStop        =  " + POut.Date(medicationPat.DateStop) + ", "
                             + "ProvNum         =  " + POut.Long(medicationPat.ProvNum) + ", "
                             + "MedDescript     = '" + POut.String(medicationPat.MedDescript) + "', "
                             + "RxCui           =  " + POut.Long(medicationPat.RxCui) + ", "
                             + "ErxGuid         = '" + POut.String(medicationPat.ErxGuid) + "', "
                             + "IsCpoe          =  " + POut.Bool(medicationPat.IsCpoe) + " "
                             + "WHERE MedicationPatNum = " + POut.Long(medicationPat.MedicationPatNum);

            if (medicationPat.PatNote == null)
            {
                medicationPat.PatNote = "";
            }
            OdSqlParameter paramPatNote = new OdSqlParameter("paramPatNote", OdDbType.Text, POut.StringParam(medicationPat.PatNote));

            Db.NonQ(command, paramPatNote);
        }
Ejemplo n.º 24
0
 ///<summary>Updates one MedicationPat in the database.</summary>
 internal static void Update(MedicationPat medicationPat)
 {
     string command="UPDATE medicationpat SET "
         +"PatNum          =  "+POut.Long  (medicationPat.PatNum)+", "
         +"MedicationNum   =  "+POut.Long  (medicationPat.MedicationNum)+", "
         +"PatNote         = '"+POut.String(medicationPat.PatNote)+"', "
         //DateTStamp can only be set by MySQL
         +"DateStart       =  "+POut.Date  (medicationPat.DateStart)+", "
         +"DateStop        =  "+POut.Date  (medicationPat.DateStop)+", "
         +"ProvNum         =  "+POut.Long  (medicationPat.ProvNum)+" "
         +"WHERE MedicationPatNum = "+POut.Long(medicationPat.MedicationPatNum);
     Db.NonQ(command);
 }
Ejemplo n.º 25
0
        ///<summary>Updates one MedicationPat 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.</summary>
        public static void Update(MedicationPat medicationPat, MedicationPat oldMedicationPat)
        {
            string command = "";

            if (medicationPat.PatNum != oldMedicationPat.PatNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PatNum = " + POut.Long(medicationPat.PatNum) + "";
            }
            if (medicationPat.MedicationNum != oldMedicationPat.MedicationNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "MedicationNum = " + POut.Long(medicationPat.MedicationNum) + "";
            }
            if (medicationPat.PatNote != oldMedicationPat.PatNote)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PatNote = '" + POut.String(medicationPat.PatNote) + "'";
            }
            //DateTStamp can only be set by MySQL
            if (medicationPat.DateStart != oldMedicationPat.DateStart)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DateStart = " + POut.Date(medicationPat.DateStart) + "";
            }
            if (medicationPat.DateStop != oldMedicationPat.DateStop)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DateStop = " + POut.Date(medicationPat.DateStop) + "";
            }
            if (medicationPat.ProvNum != oldMedicationPat.ProvNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ProvNum = " + POut.Long(medicationPat.ProvNum) + "";
            }
            if (medicationPat.MedDescript != oldMedicationPat.MedDescript)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "MedDescript = '" + POut.String(medicationPat.MedDescript) + "'";
            }
            if (medicationPat.RxCui != oldMedicationPat.RxCui)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "RxCui = " + POut.Long(medicationPat.RxCui) + "";
            }
            if (medicationPat.NewCropGuid != oldMedicationPat.NewCropGuid)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "NewCropGuid = '" + POut.String(medicationPat.NewCropGuid) + "'";
            }
            if (medicationPat.IsCpoe != oldMedicationPat.IsCpoe)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "IsCpoe = " + POut.Bool(medicationPat.IsCpoe) + "";
            }
            if (command == "")
            {
                return;
            }
            command = "UPDATE medicationpat SET " + command
                      + " WHERE MedicationPatNum = " + POut.Long(medicationPat.MedicationPatNum);
            Db.NonQ(command);
        }
Ejemplo n.º 26
0
        ///<summary>Updates one MedicationPat 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(MedicationPat medicationPat, MedicationPat oldMedicationPat)
        {
            string command = "";

            if (medicationPat.PatNum != oldMedicationPat.PatNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PatNum = " + POut.Long(medicationPat.PatNum) + "";
            }
            if (medicationPat.MedicationNum != oldMedicationPat.MedicationNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "MedicationNum = " + POut.Long(medicationPat.MedicationNum) + "";
            }
            if (medicationPat.PatNote != oldMedicationPat.PatNote)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PatNote = " + DbHelper.ParamChar + "paramPatNote";
            }
            //DateTStamp can only be set by MySQL
            if (medicationPat.DateStart.Date != oldMedicationPat.DateStart.Date)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DateStart = " + POut.Date(medicationPat.DateStart) + "";
            }
            if (medicationPat.DateStop.Date != oldMedicationPat.DateStop.Date)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DateStop = " + POut.Date(medicationPat.DateStop) + "";
            }
            if (medicationPat.ProvNum != oldMedicationPat.ProvNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ProvNum = " + POut.Long(medicationPat.ProvNum) + "";
            }
            if (medicationPat.MedDescript != oldMedicationPat.MedDescript)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "MedDescript = '" + POut.String(medicationPat.MedDescript) + "'";
            }
            if (medicationPat.RxCui != oldMedicationPat.RxCui)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "RxCui = " + POut.Long(medicationPat.RxCui) + "";
            }
            if (medicationPat.ErxGuid != oldMedicationPat.ErxGuid)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ErxGuid = '" + POut.String(medicationPat.ErxGuid) + "'";
            }
            if (medicationPat.IsCpoe != oldMedicationPat.IsCpoe)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "IsCpoe = " + POut.Bool(medicationPat.IsCpoe) + "";
            }
            if (command == "")
            {
                return(false);
            }
            if (medicationPat.PatNote == null)
            {
                medicationPat.PatNote = "";
            }
            OdSqlParameter paramPatNote = new OdSqlParameter("paramPatNote", OdDbType.Text, POut.StringParam(medicationPat.PatNote));

            command = "UPDATE medicationpat SET " + command
                      + " WHERE MedicationPatNum = " + POut.Long(medicationPat.MedicationPatNum);
            Db.NonQ(command, paramPatNote);
            return(true);
        }
Ejemplo n.º 27
0
 ///<summary>Inserts one MedicationPat into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(MedicationPat medicationPat)
 {
     return(InsertNoCache(medicationPat, false));
 }
Ejemplo n.º 28
0
        ///<summary>Updates one MedicationPat 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.</summary>
        internal static void Update(MedicationPat medicationPat, MedicationPat oldMedicationPat)
        {
            string command = "";

            if (medicationPat.PatNum != oldMedicationPat.PatNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PatNum = " + POut.Long(medicationPat.PatNum) + "";
            }
            if (medicationPat.MedicationNum != oldMedicationPat.MedicationNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "MedicationNum = " + POut.Long(medicationPat.MedicationNum) + "";
            }
            if (medicationPat.PatNote != oldMedicationPat.PatNote)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PatNote = '" + POut.String(medicationPat.PatNote) + "'";
            }
            //DateTStamp can only be set by MySQL
            if (medicationPat.DateStart != oldMedicationPat.DateStart)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DateStart = " + POut.Date(medicationPat.DateStart) + "";
            }
            if (medicationPat.DateStop != oldMedicationPat.DateStop)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DateStop = " + POut.Date(medicationPat.DateStop) + "";
            }
            if (medicationPat.ProvNum != oldMedicationPat.ProvNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ProvNum = " + POut.Long(medicationPat.ProvNum) + "";
            }
            if (command == "")
            {
                return;
            }
            command = "UPDATE medicationpat SET " + command
                      + " WHERE MedicationPatNum = " + POut.Long(medicationPat.MedicationPatNum);
            Db.NonQ(command);
        }
Ejemplo n.º 29
0
		///<summary>Updates one MedicationPat 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(MedicationPat medicationPat,MedicationPat oldMedicationPat){
			string command="";
			if(medicationPat.PatNum != oldMedicationPat.PatNum) {
				if(command!=""){ command+=",";}
				command+="PatNum = "+POut.Long(medicationPat.PatNum)+"";
			}
			if(medicationPat.MedicationNum != oldMedicationPat.MedicationNum) {
				if(command!=""){ command+=",";}
				command+="MedicationNum = "+POut.Long(medicationPat.MedicationNum)+"";
			}
			if(medicationPat.PatNote != oldMedicationPat.PatNote) {
				if(command!=""){ command+=",";}
				command+="PatNote = '"+POut.String(medicationPat.PatNote)+"'";
			}
			//DateTStamp can only be set by MySQL
			if(medicationPat.DateStart != oldMedicationPat.DateStart) {
				if(command!=""){ command+=",";}
				command+="DateStart = "+POut.Date(medicationPat.DateStart)+"";
			}
			if(medicationPat.DateStop != oldMedicationPat.DateStop) {
				if(command!=""){ command+=",";}
				command+="DateStop = "+POut.Date(medicationPat.DateStop)+"";
			}
			if(medicationPat.ProvNum != oldMedicationPat.ProvNum) {
				if(command!=""){ command+=",";}
				command+="ProvNum = "+POut.Long(medicationPat.ProvNum)+"";
			}
			if(medicationPat.MedDescript != oldMedicationPat.MedDescript) {
				if(command!=""){ command+=",";}
				command+="MedDescript = '"+POut.String(medicationPat.MedDescript)+"'";
			}
			if(medicationPat.RxCui != oldMedicationPat.RxCui) {
				if(command!=""){ command+=",";}
				command+="RxCui = "+POut.Long(medicationPat.RxCui)+"";
			}
			if(medicationPat.NewCropGuid != oldMedicationPat.NewCropGuid) {
				if(command!=""){ command+=",";}
				command+="NewCropGuid = '"+POut.String(medicationPat.NewCropGuid)+"'";
			}
			if(medicationPat.IsCpoe != oldMedicationPat.IsCpoe) {
				if(command!=""){ command+=",";}
				command+="IsCpoe = "+POut.Bool(medicationPat.IsCpoe)+"";
			}
			if(command==""){
				return false;
			}
			command="UPDATE medicationpat SET "+command
				+" WHERE MedicationPatNum = "+POut.Long(medicationPat.MedicationPatNum);
			Db.NonQ(command);
			return true;
		}
Ejemplo n.º 30
0
		///<summary>Converts one MedicationPat object to its mobile equivalent.  Warning! CustomerNum will always be 0.</summary>
		internal static MedicationPatm ConvertToM(MedicationPat medicationPat){
			MedicationPatm medicationPatm=new MedicationPatm();
			//CustomerNum cannot be set.  Remains 0.
			medicationPatm.MedicationPatNum=medicationPat.MedicationPatNum;
			medicationPatm.PatNum          =medicationPat.PatNum;
			medicationPatm.MedicationNum   =medicationPat.MedicationNum;
			medicationPatm.PatNote         =medicationPat.PatNote;
			medicationPatm.DateStart       =medicationPat.DateStart;
			medicationPatm.DateStop        =medicationPat.DateStop;
			return medicationPatm;
		}
Ejemplo n.º 31
0
		///<summary>Updates one MedicationPat in the database.</summary>
		public static void Update(MedicationPat medicationPat){
			string command="UPDATE medicationpat SET "
				+"PatNum          =  "+POut.Long  (medicationPat.PatNum)+", "
				+"MedicationNum   =  "+POut.Long  (medicationPat.MedicationNum)+", "
				+"PatNote         = '"+POut.String(medicationPat.PatNote)+"', "
				//DateTStamp can only be set by MySQL
				+"DateStart       =  "+POut.Date  (medicationPat.DateStart)+", "
				+"DateStop        =  "+POut.Date  (medicationPat.DateStop)+", "
				+"ProvNum         =  "+POut.Long  (medicationPat.ProvNum)+", "
				+"MedDescript     = '"+POut.String(medicationPat.MedDescript)+"', "
				+"RxCui           =  "+POut.Long  (medicationPat.RxCui)+", "
				+"NewCropGuid     = '"+POut.String(medicationPat.NewCropGuid)+"', "
				+"IsCpoe          =  "+POut.Bool  (medicationPat.IsCpoe)+" "
				+"WHERE MedicationPatNum = "+POut.Long(medicationPat.MedicationPatNum);
			Db.NonQ(command);
		}
Ejemplo n.º 32
0
 ///<summary>Converts a DataTable to a list of objects.</summary>
 internal static List<MedicationPat> TableToList(DataTable table)
 {
     List<MedicationPat> retVal=new List<MedicationPat>();
     MedicationPat medicationPat;
     for(int i=0;i<table.Rows.Count;i++) {
         medicationPat=new MedicationPat();
         medicationPat.MedicationPatNum= PIn.Long  (table.Rows[i]["MedicationPatNum"].ToString());
         medicationPat.PatNum          = PIn.Long  (table.Rows[i]["PatNum"].ToString());
         medicationPat.MedicationNum   = PIn.Long  (table.Rows[i]["MedicationNum"].ToString());
         medicationPat.PatNote         = PIn.String(table.Rows[i]["PatNote"].ToString());
         medicationPat.DateTStamp      = PIn.DateT (table.Rows[i]["DateTStamp"].ToString());
         medicationPat.DateStart       = PIn.Date  (table.Rows[i]["DateStart"].ToString());
         medicationPat.DateStop        = PIn.Date  (table.Rows[i]["DateStop"].ToString());
         medicationPat.ProvNum         = PIn.Long  (table.Rows[i]["ProvNum"].ToString());
         retVal.Add(medicationPat);
     }
     return retVal;
 }
Ejemplo n.º 33
0
 ///<summary>Updates one MedicationPat 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.</summary>
 internal static void Update(MedicationPat medicationPat,MedicationPat oldMedicationPat)
 {
     string command="";
     if(medicationPat.PatNum != oldMedicationPat.PatNum) {
         if(command!=""){ command+=",";}
         command+="PatNum = "+POut.Long(medicationPat.PatNum)+"";
     }
     if(medicationPat.MedicationNum != oldMedicationPat.MedicationNum) {
         if(command!=""){ command+=",";}
         command+="MedicationNum = "+POut.Long(medicationPat.MedicationNum)+"";
     }
     if(medicationPat.PatNote != oldMedicationPat.PatNote) {
         if(command!=""){ command+=",";}
         command+="PatNote = '"+POut.String(medicationPat.PatNote)+"'";
     }
     //DateTStamp can only be set by MySQL
     if(medicationPat.DateStart != oldMedicationPat.DateStart) {
         if(command!=""){ command+=",";}
         command+="DateStart = "+POut.Date(medicationPat.DateStart)+"";
     }
     if(medicationPat.DateStop != oldMedicationPat.DateStop) {
         if(command!=""){ command+=",";}
         command+="DateStop = "+POut.Date(medicationPat.DateStop)+"";
     }
     if(medicationPat.ProvNum != oldMedicationPat.ProvNum) {
         if(command!=""){ command+=",";}
         command+="ProvNum = "+POut.Long(medicationPat.ProvNum)+"";
     }
     if(command==""){
         return;
     }
     command="UPDATE medicationpat SET "+command
         +" WHERE MedicationPatNum = "+POut.Long(medicationPat.MedicationPatNum);
     Db.NonQ(command);
 }
Ejemplo n.º 34
0
		public static void ProcessOBX(Patient pat,HL7DefSegment segDef,SegmentHL7 seg) {
			long rxnorm=0;
			for(int i=0;i<segDef.hl7DefFields.Count;i++) {
				int intItemOrder=segDef.hl7DefFields[i].OrdinalPos;
				switch(segDef.hl7DefFields[i].FieldName) {
					case "medicationRxNorm":
						if(seg.GetFieldComponent(intItemOrder,2).ToLower()!="rxnorm") {
							//if not an RXNORM code, do nothing.  Only RXNORM codes are currently supported
							EventLog.WriteEntry("OpenDentHL7","A medication was not added for patient "+pat.GetNameFLnoPref()
								+".  Only RxNorm codes are currently allowed in the OBX segment.  The code system name provided was "
								+seg.GetFieldComponent(intItemOrder,2)+".",EventLogEntryType.Information);
							return;
						}
						try {
							rxnorm=PIn.Long(seg.GetFieldComponent(intItemOrder,0));
						}
						catch(Exception ex) {//PIn.Long throws an exception if converting to an Int64 fails
							//do nothing, rxnorm will remain 0
						}
						continue;
					default:
						continue;
				}
			}
			if(rxnorm==0) {
				EventLog.WriteEntry("OpenDentHL7","A medication was not added for patient "
					+pat.GetNameFLnoPref()+".  The RxNorm code supplied in the OBX segment was invalid.",EventLogEntryType.Information);
				return;//not able to enter this medication if not given a valid rxnorm
			}
			Medication medCur=Medications.GetMedicationFromDbByRxCui(rxnorm);//an RxNorm could be attached to multiple medications, we will just add the first one we come to
			if(medCur==null) {
				EventLog.WriteEntry("OpenDentHL7","A medication was not added for patient "+pat.GetNameFLnoPref()
					+".  There is not a medication in the database with the RxNorm code of "+rxnorm.ToString()+".",EventLogEntryType.Information);
				return;
			}
			List<MedicationPat> listMedPatsCur=MedicationPats.Refresh(pat.PatNum,false);
			for(int i=0;i<listMedPatsCur.Count;i++) {
				if(listMedPatsCur[i].MedicationNum==medCur.MedicationNum) {
					return;//this patient already has this medication recorded and active
				}
			}
			MedicationPat medpatCur=new MedicationPat();
			medpatCur.PatNum=pat.PatNum;
			medpatCur.MedicationNum=medCur.MedicationNum;
			medpatCur.ProvNum=pat.PriProv;
			medpatCur.RxCui=medCur.RxCui;
			MedicationPats.Insert(medpatCur);
			if(_isVerboseLogging) {
				EventLog.WriteEntry("OpenDentHL7","Inserted a new medication for patient "+pat.GetNameFLnoPref()+" due to an incoming OBX segment.",EventLogEntryType.Information);
			}
			return;
		}
Ejemplo n.º 35
0
        private void butOK_Click(object sender, EventArgs e)
        {
            //validate--------------------------------------
            DateTime date;

            if (textDate.Text == "")
            {
                MsgBox.Show(this, "Please enter a date.");
                return;
            }
            try {
                date = DateTime.Parse(textDate.Text);
            }
            catch {
                MsgBox.Show(this, "Please fix date first.");
                return;
            }
            string codeVal = "";
            string codeSys = "";

            if (gridMain.GetSelectedIndex() == -1)           //no intervention code selected
            {
                MsgBox.Show(this, "You must select a code for this intervention.");
                return;
            }
            else
            {
                codeVal = listCodes[gridMain.GetSelectedIndex()].CodeValue;
                codeSys = listCodes[gridMain.GetSelectedIndex()].CodeSystem;
            }
            //save--------------------------------------
            //Intervention grid may contain medications, have to insert a new med if necessary and load FormMedPat for user to input data
            if (codeSys == "RXNORM" && !checkPatientDeclined.Checked)
            {
                //codeVal will be RxCui of medication, see if it already exists in Medication table
                Medication medCur = Medications.GetMedicationFromDbByRxCui(PIn.Long(codeVal));
                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(codeVal);
                    medCur.MedName    = RxNorms.GetDescByRxCui(codeVal);
                    Medications.Update(medCur);
                    Medications.RefreshCache();                    //refresh cache to include new medication
                }
                MedicationPat medPatCur = new MedicationPat();
                medPatCur.PatNum        = InterventionCur.PatNum;
                medPatCur.ProvNum       = InterventionCur.ProvNum;
                medPatCur.MedicationNum = medCur.MedicationNum;
                medPatCur.RxCui         = medCur.RxCui;
                medPatCur.DateStart     = date;
                FormMedPat FormMP = new FormMedPat();
                FormMP.MedicationPatCur = medPatCur;
                FormMP.IsNew            = true;
                FormMP.ShowDialog();
                if (FormMP.DialogResult != DialogResult.OK)
                {
                    return;
                }
                if (FormMP.MedicationPatCur.DateStart.Date < InterventionCur.DateEntry.AddMonths(-6).Date || FormMP.MedicationPatCur.DateStart.Date > InterventionCur.DateEntry.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.");
                }
                DialogResult = DialogResult.OK;
                return;
            }
            InterventionCur.DateEntry     = date;
            InterventionCur.CodeValue     = codeVal;
            InterventionCur.CodeSystem    = codeSys;
            InterventionCur.Note          = textNote.Text;
            InterventionCur.IsPatDeclined = checkPatientDeclined.Checked;
            string selectedCodeSet = comboCodeSet.SelectedItem.ToString().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[0];

            if (IsAllTypes)                   //CodeSet will be set by calling function unless showing all types, in which case we need to determine which InterventionCodeSet to assign
            {
                if (selectedCodeSet == "All") //All types showing and set to All, have to determine which InterventionCodeSet this code belongs to
                {
                    List <string> listVSFound = new List <string>();
                    foreach (KeyValuePair <string, string> kvp in dictValueCodeSets)
                    {
                        List <EhrCode> listCodes = EhrCodes.GetForValueSetOIDs(new List <string> {
                            kvp.Value
                        }, true);
                        for (int i = 0; i < listCodes.Count; i++)
                        {
                            if (listCodes[i].CodeValue == codeVal)
                            {
                                listVSFound.Add(kvp.Key);
                                break;
                            }
                        }
                    }
                    if (listVSFound.Count > 1)                   //Selected code found in more than one value set, ask the user which InterventionCodeSet to assign to this intervention
                    {
                        InputBox chooseSet = new InputBox(Lan.g(this, "The selected code belongs to more than one intervention code set.  Select the code set to assign to this intervention from the list below."), listVSFound);
                        if (chooseSet.ShowDialog() != DialogResult.OK)
                        {
                            return;
                        }
                        if (chooseSet.comboSelection.SelectedIndex == -1)
                        {
                            MsgBox.Show(this, "You must select an intervention code set for the selected code.");
                            return;
                        }
                        selectedCodeSet = chooseSet.comboSelection.SelectedItem.ToString().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[0];
                    }
                    else                      //the code must belong to at least one value set, since count in listVSFound is not greater than 1, it must be a code from exactly one set, use that for the InterventionCodeSet
                    {
                        selectedCodeSet = listVSFound[0].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[0];
                    }
                }
                InterventionCur.CodeSet = (InterventionCodeSet)Enum.Parse(typeof(InterventionCodeSet), selectedCodeSet);
            }
            //Nutrition is used for both nutrition and physical activity counseling for children, we have to determine which set this code belongs to
            else if (InterventionCur.CodeSet == InterventionCodeSet.Nutrition && selectedCodeSet != "Nutrition") //Nutrition set by calling form, user is showing all or physical activity codes only
            {
                if (selectedCodeSet == "All")                                                                    //showing all codes from Nutrition and PhysicalActivity interventions, determine which set it belongs to
                //No codes exist in both code sets, so if it is not in the PhysicalActivity code set, we can safely assume this is a Nutrition intervention
                {
                    List <EhrCode> listCodes = EhrCodes.GetForValueSetOIDs(new List <string> {
                        dictValueCodeSets[InterventionCodeSet.PhysicalActivity.ToString() + " Counseling"]
                    }, true);
                    for (int i = 0; i < listCodes.Count; i++)
                    {
                        if (listCodes[i].CodeValue == codeVal)
                        {
                            InterventionCur.CodeSet = InterventionCodeSet.PhysicalActivity;
                            break;
                        }
                    }
                }
                else
                {
                    InterventionCur.CodeSet = InterventionCodeSet.PhysicalActivity;
                }
            }
            else
            {
                //if not all types, and not Nutrition with All or PhysicalActivity selected in combo box, the code set sent in by calling form will remain the code set for this intervention
            }
            if (InterventionCur.IsNew)
            {
                Interventions.Insert(InterventionCur);
            }
            else
            {
                Interventions.Update(InterventionCur);
            }
            DialogResult = DialogResult.OK;
        }