Exemplo n.º 1
0
 ///<summary>Inserts one VaccineDef into the database.  Returns the new priKey.</summary>
 internal static long Insert(VaccineDef vaccineDef)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         vaccineDef.VaccineDefNum=DbHelper.GetNextOracleKey("vaccinedef","VaccineDefNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(vaccineDef,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     vaccineDef.VaccineDefNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(vaccineDef,false);
     }
 }
Exemplo n.º 2
0
 ///<summary>Inserts one VaccineDef into the database.  Provides option to use the existing priKey.</summary>
 internal static long Insert(VaccineDef vaccineDef,bool useExistingPK)
 {
     if(!useExistingPK && PrefC.RandomKeys) {
         vaccineDef.VaccineDefNum=ReplicationServers.GetKey("vaccinedef","VaccineDefNum");
     }
     string command="INSERT INTO vaccinedef (";
     if(useExistingPK || PrefC.RandomKeys) {
         command+="VaccineDefNum,";
     }
     command+="CVXCode,VaccineName,DrugManufacturerNum) VALUES(";
     if(useExistingPK || PrefC.RandomKeys) {
         command+=POut.Long(vaccineDef.VaccineDefNum)+",";
     }
     command+=
          "'"+POut.String(vaccineDef.CVXCode)+"',"
         +"'"+POut.String(vaccineDef.VaccineName)+"',"
         +    POut.Long  (vaccineDef.DrugManufacturerNum)+")";
     if(useExistingPK || PrefC.RandomKeys) {
         Db.NonQ(command);
     }
     else {
         vaccineDef.VaccineDefNum=Db.NonQ(command,true);
     }
     return vaccineDef.VaccineDefNum;
 }
Exemplo n.º 3
0
        ///<summary>Inserts one VaccineDef into the database.  Provides option to use the existing priKey.</summary>
        internal static long Insert(VaccineDef vaccineDef, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                vaccineDef.VaccineDefNum = ReplicationServers.GetKey("vaccinedef", "VaccineDefNum");
            }
            string command = "INSERT INTO vaccinedef (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "VaccineDefNum,";
            }
            command += "CVXCode,VaccineName,DrugManufacturerNum) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(vaccineDef.VaccineDefNum) + ",";
            }
            command +=
                "'" + POut.String(vaccineDef.CVXCode) + "',"
                + "'" + POut.String(vaccineDef.VaccineName) + "',"
                + POut.Long(vaccineDef.DrugManufacturerNum) + ")";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                vaccineDef.VaccineDefNum = Db.NonQ(command, true);
            }
            return(vaccineDef.VaccineDefNum);
        }
Exemplo n.º 4
0
 ///<summary>Inserts one VaccineDef into the database.  Returns the new priKey.</summary>
 internal static long Insert(VaccineDef vaccineDef)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         vaccineDef.VaccineDefNum = DbHelper.GetNextOracleKey("vaccinedef", "VaccineDefNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(vaccineDef, true));
             }
             catch (Oracle.DataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     vaccineDef.VaccineDefNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(vaccineDef, false));
     }
 }
Exemplo n.º 5
0
        ///<summary>Inserts one VaccineDef into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(VaccineDef vaccineDef, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO vaccinedef (";

            if (!useExistingPK && isRandomKeys)
            {
                vaccineDef.VaccineDefNum = ReplicationServers.GetKeyNoCache("vaccinedef", "VaccineDefNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "VaccineDefNum,";
            }
            command += "CVXCode,VaccineName,DrugManufacturerNum) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(vaccineDef.VaccineDefNum) + ",";
            }
            command +=
                "'" + POut.String(vaccineDef.CVXCode) + "',"
                + "'" + POut.String(vaccineDef.VaccineName) + "',"
                + POut.Long(vaccineDef.DrugManufacturerNum) + ")";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                vaccineDef.VaccineDefNum = Db.NonQ(command, true, "VaccineDefNum", "vaccineDef");
            }
            return(vaccineDef.VaccineDefNum);
        }
Exemplo n.º 6
0
        private void RXA(VaccinePat vaccine)
        {
            VaccineDef vaccineDef = VaccineDefs.GetOne(vaccine.VaccineDefNum);

            seg = new SegmentHL7(SegmentName.RXA);
            seg.SetField(0, "RXA");
            seg.SetField(1, "0");           //fixed
            seg.SetField(2, "1");           //fixed
            seg.SetField(3, vaccine.DateTimeStart.ToString("yyyyMMddHHmm"));
            seg.SetField(4, vaccine.DateTimeEnd.ToString("yyyyMMddHHmm"));
            seg.SetField(5, vaccineDef.CVXCode, vaccineDef.VaccineName, "HL70292");
            if (vaccine.AdministeredAmt == 0)
            {
                seg.SetField(6, "999");
            }
            else
            {
                seg.SetField(6, vaccine.AdministeredAmt.ToString());
            }
            if (vaccine.DrugUnitNum != 0)
            {
                DrugUnit drugUnit = DrugUnits.GetOne(vaccine.DrugUnitNum);
                seg.SetField(7, drugUnit.UnitIdentifier, drugUnit.UnitText, "ISO+");
            }
            seg.SetField(15, vaccine.LotNumber);           //optional.
            //17-Manufacturer.  Is this really optional?
            if (vaccineDef.DrugManufacturerNum != 0)       //always?
            {
                DrugManufacturer manufacturer = DrugManufacturers.GetOne(vaccineDef.DrugManufacturerNum);
                seg.SetField(17, manufacturer.ManufacturerCode, manufacturer.ManufacturerName, "HL70227");
            }
            seg.SetField(21, "A");           //21-Action code, A=Add
            msg.Segments.Add(seg);
        }
Exemplo n.º 7
0
        ///<summary>Updates one VaccineDef in the database.</summary>
        internal static void Update(VaccineDef vaccineDef)
        {
            string command = "UPDATE vaccinedef SET "
                             + "CVXCode            = '" + POut.String(vaccineDef.CVXCode) + "', "
                             + "VaccineName        = '" + POut.String(vaccineDef.VaccineName) + "', "
                             + "DrugManufacturerNum=  " + POut.Long(vaccineDef.DrugManufacturerNum) + " "
                             + "WHERE VaccineDefNum = " + POut.Long(vaccineDef.VaccineDefNum);

            Db.NonQ(command);
        }
Exemplo n.º 8
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<VaccineDef> TableToList(DataTable table){
			List<VaccineDef> retVal=new List<VaccineDef>();
			VaccineDef vaccineDef;
			for(int i=0;i<table.Rows.Count;i++) {
				vaccineDef=new VaccineDef();
				vaccineDef.VaccineDefNum      = PIn.Long  (table.Rows[i]["VaccineDefNum"].ToString());
				vaccineDef.CVXCode            = PIn.String(table.Rows[i]["CVXCode"].ToString());
				vaccineDef.VaccineName        = PIn.String(table.Rows[i]["VaccineName"].ToString());
				vaccineDef.DrugManufacturerNum= PIn.Long  (table.Rows[i]["DrugManufacturerNum"].ToString());
				retVal.Add(vaccineDef);
			}
			return retVal;
		}
Exemplo n.º 9
0
 ///<summary>Inserts one VaccineDef into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(VaccineDef vaccineDef)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(vaccineDef, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             vaccineDef.VaccineDefNum = DbHelper.GetNextOracleKey("vaccinedef", "VaccineDefNum");                  //Cacheless method
         }
         return(InsertNoCache(vaccineDef, true));
     }
 }
Exemplo n.º 10
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        internal static List <VaccineDef> TableToList(DataTable table)
        {
            List <VaccineDef> retVal = new List <VaccineDef>();
            VaccineDef        vaccineDef;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                vaccineDef = new VaccineDef();
                vaccineDef.VaccineDefNum       = PIn.Long(table.Rows[i]["VaccineDefNum"].ToString());
                vaccineDef.CVXCode             = PIn.String(table.Rows[i]["CVXCode"].ToString());
                vaccineDef.VaccineName         = PIn.String(table.Rows[i]["VaccineName"].ToString());
                vaccineDef.DrugManufacturerNum = PIn.Long(table.Rows[i]["DrugManufacturerNum"].ToString());
                retVal.Add(vaccineDef);
            }
            return(retVal);
        }
Exemplo n.º 11
0
 ///<summary>Returns true if Update(VaccineDef,VaccineDef) 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(VaccineDef vaccineDef, VaccineDef oldVaccineDef)
 {
     if (vaccineDef.CVXCode != oldVaccineDef.CVXCode)
     {
         return(true);
     }
     if (vaccineDef.VaccineName != oldVaccineDef.VaccineName)
     {
         return(true);
     }
     if (vaccineDef.DrugManufacturerNum != oldVaccineDef.DrugManufacturerNum)
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 12
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <VaccineDef> TableToList(DataTable table)
        {
            List <VaccineDef> retVal = new List <VaccineDef>();
            VaccineDef        vaccineDef;

            foreach (DataRow row in table.Rows)
            {
                vaccineDef = new VaccineDef();
                vaccineDef.VaccineDefNum       = PIn.Long(row["VaccineDefNum"].ToString());
                vaccineDef.CVXCode             = PIn.String(row["CVXCode"].ToString());
                vaccineDef.VaccineName         = PIn.String(row["VaccineName"].ToString());
                vaccineDef.DrugManufacturerNum = PIn.Long(row["DrugManufacturerNum"].ToString());
                retVal.Add(vaccineDef);
            }
            return(retVal);
        }
Exemplo n.º 13
0
        ///<summary>Updates one VaccineDef 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(VaccineDef vaccineDef, VaccineDef oldVaccineDef)
        {
            string command = "";

            if (vaccineDef.CVXCode != oldVaccineDef.CVXCode)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "CVXCode = '" + POut.String(vaccineDef.CVXCode) + "'";
            }
            if (vaccineDef.VaccineName != oldVaccineDef.VaccineName)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "VaccineName = '" + POut.String(vaccineDef.VaccineName) + "'";
            }
            if (vaccineDef.DrugManufacturerNum != oldVaccineDef.DrugManufacturerNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DrugManufacturerNum = " + POut.Long(vaccineDef.DrugManufacturerNum) + "";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE vaccinedef SET " + command
                      + " WHERE VaccineDefNum = " + POut.Long(vaccineDef.VaccineDefNum);
            Db.NonQ(command);
            return(true);
        }
Exemplo n.º 14
0
 ///<summary>Updates one VaccineDef 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(VaccineDef vaccineDef,VaccineDef oldVaccineDef)
 {
     string command="";
     if(vaccineDef.CVXCode != oldVaccineDef.CVXCode) {
         if(command!=""){ command+=",";}
         command+="CVXCode = '"+POut.String(vaccineDef.CVXCode)+"'";
     }
     if(vaccineDef.VaccineName != oldVaccineDef.VaccineName) {
         if(command!=""){ command+=",";}
         command+="VaccineName = '"+POut.String(vaccineDef.VaccineName)+"'";
     }
     if(vaccineDef.DrugManufacturerNum != oldVaccineDef.DrugManufacturerNum) {
         if(command!=""){ command+=",";}
         command+="DrugManufacturerNum = "+POut.Long(vaccineDef.DrugManufacturerNum)+"";
     }
     if(command==""){
         return;
     }
     command="UPDATE vaccinedef SET "+command
         +" WHERE VaccineDefNum = "+POut.Long(vaccineDef.VaccineDefNum);
     Db.NonQ(command);
 }
Exemplo n.º 15
0
        private void FormVaccinePatEdit_Load(object sender, EventArgs e)
        {
            Patient pat = Patients.GetLim(VaccinePatCur.PatNum);

            if (pat.Age != 0 && pat.Age < 3)
            {
                labelDocument.Text = "Document reason not given below.  Reason can include a contraindication due to a specific allergy, adverse effect, intollerance, or specific disease.";              //less leeway with reasons for kids.
            }
            _listVaccineDefs = VaccineDefs.GetDeepCopy();
            comboVaccine.Items.Clear();
            for (int i = 0; i < _listVaccineDefs.Count; i++)
            {
                comboVaccine.Items.Add(_listVaccineDefs[i].CVXCode + " - " + _listVaccineDefs[i].VaccineName);
                if (_listVaccineDefs[i].VaccineDefNum == VaccinePatCur.VaccineDefNum)
                {
                    comboVaccine.SelectedIndex = i;
                }
            }
            if (!IsNew && VaccinePatCur.VaccineDefNum != 0)
            {
                VaccineDef       vaccineDef   = VaccineDefs.GetOne(VaccinePatCur.VaccineDefNum);      //Need vaccine to get manufacturer.
                DrugManufacturer manufacturer = DrugManufacturers.GetOne(vaccineDef.DrugManufacturerNum);
                textManufacturer.Text = manufacturer.ManufacturerCode + " - " + manufacturer.ManufacturerName;
            }
            if (VaccinePatCur.DateTimeStart.Year > 1880)
            {
                textDateTimeStart.Text = VaccinePatCur.DateTimeStart.ToString();
            }
            if (VaccinePatCur.DateTimeEnd.Year > 1880)
            {
                textDateTimeStop.Text = VaccinePatCur.DateTimeEnd.ToString();
            }
            if (VaccinePatCur.AdministeredAmt != 0)
            {
                textAmount.Text = VaccinePatCur.AdministeredAmt.ToString();
            }
            _listDrugUnits = DrugUnits.GetDeepCopy();
            comboUnits.Items.Clear();
            comboUnits.Items.Add("none");
            comboUnits.SelectedIndex = 0;
            for (int i = 0; i < _listDrugUnits.Count; i++)
            {
                comboUnits.Items.Add(_listDrugUnits[i].UnitIdentifier);
                if (_listDrugUnits[i].DrugUnitNum == VaccinePatCur.DrugUnitNum)
                {
                    comboUnits.SelectedIndex = i + 1;
                }
            }
            textLotNum.Text = VaccinePatCur.LotNumber;
            if (VaccinePatCur.DateExpire.Year > 1880)
            {
                textDateExpiration.Text = VaccinePatCur.DateExpire.ToShortDateString();
            }
            listRefusalReason.Items.Clear();
            string[] arrayVaccineRefusalReasons = Enum.GetNames(typeof(VaccineRefusalReason));
            for (int i = 0; i < arrayVaccineRefusalReasons.Length; i++)
            {
                listRefusalReason.Items.Add(arrayVaccineRefusalReasons[i]);
                VaccineRefusalReason refusalReason = (VaccineRefusalReason)i;
                if (refusalReason == VaccinePatCur.RefusalReason)
                {
                    listRefusalReason.SelectedIndex = i;
                }
            }
            listCompletionStatus.Items.Clear();
            string[] arrayCompletionStatuses = Enum.GetNames(typeof(VaccineCompletionStatus));
            for (int i = 0; i < arrayCompletionStatuses.Length; i++)
            {
                listCompletionStatus.Items.Add(arrayCompletionStatuses[i]);
                VaccineCompletionStatus completionStatus = (VaccineCompletionStatus)i;
                if (completionStatus == VaccinePatCur.CompletionStatus)
                {
                    listCompletionStatus.SelectedIndex = i;
                }
            }
            textNote.Text = VaccinePatCur.Note;
            if (IsNew)
            {
                if (pat.ClinicNum == 0)
                {
                    VaccinePatCur.FilledCity = PrefC.GetString(PrefName.PracticeCity);
                    VaccinePatCur.FilledST   = PrefC.GetString(PrefName.PracticeST);
                }
                else
                {
                    Clinic clinic = Clinics.GetClinic(pat.ClinicNum);
                    VaccinePatCur.FilledCity = clinic.City;
                    VaccinePatCur.FilledST   = clinic.State;
                }
            }
            textFilledCity.Text = VaccinePatCur.FilledCity;
            textFilledSt.Text   = VaccinePatCur.FilledST;
            if (IsNew)
            {
                VaccinePatCur.UserNum = Security.CurUser.UserNum;
            }
            Userod user = Userods.GetUser(VaccinePatCur.UserNum);

            if (user != null)           //Will be null for vaccines entered in older versions, before the UserNum column was created.
            {
                textUser.Text = user.UserName;
            }
            _provNumSelectedOrdering = VaccinePatCur.ProvNumOrdering;
            comboProvNumOrdering.Items.Clear();
            _listProviders = Providers.GetDeepCopy(true);
            for (int i = 0; i < _listProviders.Count; i++)
            {
                comboProvNumOrdering.Items.Add(_listProviders[i].GetLongDesc());                //Only visible provs added to combobox.
                if (_listProviders[i].ProvNum == VaccinePatCur.ProvNumOrdering)
                {
                    comboProvNumOrdering.SelectedIndex = i;                  //Sets combo text too.
                }
            }
            if (comboProvNumOrdering.SelectedIndex == -1)                                    //The provider exists but is hidden
            {
                comboProvNumOrdering.Text = Providers.GetLongDesc(_provNumSelectedOrdering); //Appends "(hidden)" to the end of the long description.
            }
            _provNumSelectedAdministering = VaccinePatCur.ProvNumAdminister;
            comboProvNumAdministering.Items.Clear();
            for (int i = 0; i < _listProviders.Count; i++)
            {
                comboProvNumAdministering.Items.Add(_listProviders[i].GetLongDesc());                //Only visible provs added to combobox.
                if (_listProviders[i].ProvNum == VaccinePatCur.ProvNumAdminister)
                {
                    comboProvNumAdministering.SelectedIndex = i;                  //Sets combo text too.
                }
            }
            if (comboProvNumAdministering.SelectedIndex == -1)                                         //The provider exists but is hidden
            {
                comboProvNumAdministering.Text = Providers.GetLongDesc(_provNumSelectedAdministering); //Appends "(hidden)" to the end of the long description.
            }
            comboAdministrationRoute.Items.Clear();
            string[] arrayVaccineAdministrationRoutes = Enum.GetNames(typeof(VaccineAdministrationRoute));
            for (int i = 0; i < arrayVaccineAdministrationRoutes.Length; i++)
            {
                comboAdministrationRoute.Items.Add(arrayVaccineAdministrationRoutes[i]);
                VaccineAdministrationRoute administrationRoute = (VaccineAdministrationRoute)i;
                if (administrationRoute == VaccinePatCur.AdministrationRoute)
                {
                    comboAdministrationRoute.SelectedIndex = i;
                }
            }
            comboAdministrationSite.Items.Clear();
            string[] arrayVaccineAdministrationSites = Enum.GetNames(typeof(VaccineAdministrationSite));
            for (int i = 0; i < arrayVaccineAdministrationSites.Length; i++)
            {
                comboAdministrationSite.Items.Add(arrayVaccineAdministrationSites[i]);
                VaccineAdministrationSite administrationSite = (VaccineAdministrationSite)i;
                if (administrationSite == VaccinePatCur.AdministrationSite)
                {
                    comboAdministrationSite.SelectedIndex = i;
                }
            }
            listAdministrationNote.Items.Clear();
            string[] arrayAdministrationNotes = Enum.GetNames(typeof(VaccineAdministrationNote));
            for (int i = 0; i < arrayAdministrationNotes.Length; i++)
            {
                listAdministrationNote.Items.Add(arrayAdministrationNotes[i]);
                VaccineAdministrationNote administrationNote = (VaccineAdministrationNote)i;
                if (administrationNote == VaccinePatCur.AdministrationNoteCode)
                {
                    listAdministrationNote.SelectedIndex = i;
                }
            }
            listAction.Items.Clear();
            string[] arrayVaccineActions = Enum.GetNames(typeof(VaccineAction));
            for (int i = 0; i < arrayVaccineActions.Length; i++)
            {
                listAction.Items.Add(arrayVaccineActions[i]);
                VaccineAction action = (VaccineAction)i;
                if (action == VaccinePatCur.ActionCode)
                {
                    listAction.SelectedIndex = i;
                }
            }
            _listVaccineObservations = VaccineObses.GetForVaccine(VaccinePatCur.VaccinePatNum);
            FillObservations();
        }
Exemplo n.º 16
0
 ///<summary>Inserts one VaccineDef into the database.  Returns the new priKey.</summary>
 public static long Insert(VaccineDef vaccineDef)
 {
     return(Insert(vaccineDef, false));
 }
Exemplo n.º 17
0
 ///<summary>Updates one VaccineDef in the database.</summary>
 internal static void Update(VaccineDef vaccineDef)
 {
     string command="UPDATE vaccinedef SET "
         +"CVXCode            = '"+POut.String(vaccineDef.CVXCode)+"', "
         +"VaccineName        = '"+POut.String(vaccineDef.VaccineName)+"', "
         +"DrugManufacturerNum=  "+POut.Long  (vaccineDef.DrugManufacturerNum)+" "
         +"WHERE VaccineDefNum = "+POut.Long(vaccineDef.VaccineDefNum);
     Db.NonQ(command);
 }