Example #1
0
        ///<summary>Inserts one MedLabSpecimen into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(MedLabSpecimen medLabSpecimen, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO medlabspecimen (";

            if (!useExistingPK && isRandomKeys)
            {
                medLabSpecimen.MedLabSpecimenNum = ReplicationServers.GetKeyNoCache("medlabspecimen", "MedLabSpecimenNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "MedLabSpecimenNum,";
            }
            command += "MedLabNum,SpecimenID,SpecimenDescript,DateTimeCollected) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(medLabSpecimen.MedLabSpecimenNum) + ",";
            }
            command +=
                POut.Long(medLabSpecimen.MedLabNum) + ","
                + "'" + POut.String(medLabSpecimen.SpecimenID) + "',"
                + "'" + POut.String(medLabSpecimen.SpecimenDescript) + "',"
                + POut.DateT(medLabSpecimen.DateTimeCollected) + ")";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                medLabSpecimen.MedLabSpecimenNum = Db.NonQ(command, true, "MedLabSpecimenNum", "medLabSpecimen");
            }
            return(medLabSpecimen.MedLabSpecimenNum);
        }
Example #2
0
		///<summary>Inserts one MedLabSpecimen into the database.  Provides option to use the existing priKey.</summary>
		public static long Insert(MedLabSpecimen medLabSpecimen,bool useExistingPK){
			if(!useExistingPK && PrefC.RandomKeys) {
				medLabSpecimen.MedLabSpecimenNum=ReplicationServers.GetKey("medlabspecimen","MedLabSpecimenNum");
			}
			string command="INSERT INTO medlabspecimen (";
			if(useExistingPK || PrefC.RandomKeys) {
				command+="MedLabSpecimenNum,";
			}
			command+="MedLabNum,SpecimenID,SpecimenDescript,DateTimeCollected) VALUES(";
			if(useExistingPK || PrefC.RandomKeys) {
				command+=POut.Long(medLabSpecimen.MedLabSpecimenNum)+",";
			}
			command+=
				     POut.Long  (medLabSpecimen.MedLabNum)+","
				+"'"+POut.String(medLabSpecimen.SpecimenID)+"',"
				+"'"+POut.String(medLabSpecimen.SpecimenDescript)+"',"
				+    POut.DateT (medLabSpecimen.DateTimeCollected)+")";
			if(useExistingPK || PrefC.RandomKeys) {
				Db.NonQ(command);
			}
			else {
				medLabSpecimen.MedLabSpecimenNum=Db.NonQ(command,true);
			}
			return medLabSpecimen.MedLabSpecimenNum;
		}
Example #3
0
        ///<summary>Inserts one MedLabSpecimen into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(MedLabSpecimen medLabSpecimen, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                medLabSpecimen.MedLabSpecimenNum = ReplicationServers.GetKey("medlabspecimen", "MedLabSpecimenNum");
            }
            string command = "INSERT INTO medlabspecimen (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "MedLabSpecimenNum,";
            }
            command += "MedLabNum,SpecimenID,SpecimenDescript,DateTimeCollected) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(medLabSpecimen.MedLabSpecimenNum) + ",";
            }
            command +=
                POut.Long(medLabSpecimen.MedLabNum) + ","
                + "'" + POut.String(medLabSpecimen.SpecimenID) + "',"
                + "'" + POut.String(medLabSpecimen.SpecimenDescript) + "',"
                + POut.DateT(medLabSpecimen.DateTimeCollected) + ")";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                medLabSpecimen.MedLabSpecimenNum = Db.NonQ(command, true, "MedLabSpecimenNum", "medLabSpecimen");
            }
            return(medLabSpecimen.MedLabSpecimenNum);
        }
Example #4
0
 ///<summary>Inserts one MedLabSpecimen into the database.  Returns the new priKey.</summary>
 public static long Insert(MedLabSpecimen medLabSpecimen)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         medLabSpecimen.MedLabSpecimenNum = DbHelper.GetNextOracleKey("medlabspecimen", "MedLabSpecimenNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(medLabSpecimen, true));
             }
             catch (Oracle.ManagedDataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     medLabSpecimen.MedLabSpecimenNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(medLabSpecimen, false));
     }
 }
Example #5
0
        ///<summary>Updates one MedLabSpecimen in the database.</summary>
        public static void Update(MedLabSpecimen medLabSpecimen)
        {
            string command = "UPDATE medlabspecimen SET "
                             + "MedLabNum        =  " + POut.Long(medLabSpecimen.MedLabNum) + ", "
                             + "SpecimenID       = '" + POut.String(medLabSpecimen.SpecimenID) + "', "
                             + "SpecimenDescript = '" + POut.String(medLabSpecimen.SpecimenDescript) + "', "
                             + "DateTimeCollected=  " + POut.DateT(medLabSpecimen.DateTimeCollected) + " "
                             + "WHERE MedLabSpecimenNum = " + POut.Long(medLabSpecimen.MedLabSpecimenNum);

            Db.NonQ(command);
        }
Example #6
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<MedLabSpecimen> TableToList(DataTable table){
			List<MedLabSpecimen> retVal=new List<MedLabSpecimen>();
			MedLabSpecimen medLabSpecimen;
			for(int i=0;i<table.Rows.Count;i++) {
				medLabSpecimen=new MedLabSpecimen();
				medLabSpecimen.MedLabSpecimenNum= PIn.Long  (table.Rows[i]["MedLabSpecimenNum"].ToString());
				medLabSpecimen.MedLabNum        = PIn.Long  (table.Rows[i]["MedLabNum"].ToString());
				medLabSpecimen.SpecimenID       = PIn.String(table.Rows[i]["SpecimenID"].ToString());
				medLabSpecimen.SpecimenDescript = PIn.String(table.Rows[i]["SpecimenDescript"].ToString());
				medLabSpecimen.DateTimeCollected= PIn.DateT (table.Rows[i]["DateTimeCollected"].ToString());
				retVal.Add(medLabSpecimen);
			}
			return retVal;
		}
Example #7
0
 ///<summary>Inserts one MedLabSpecimen into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(MedLabSpecimen medLabSpecimen)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(medLabSpecimen, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             medLabSpecimen.MedLabSpecimenNum = DbHelper.GetNextOracleKey("medlabspecimen", "MedLabSpecimenNum");                  //Cacheless method
         }
         return(InsertNoCache(medLabSpecimen, true));
     }
 }
Example #8
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <MedLabSpecimen> TableToList(DataTable table)
        {
            List <MedLabSpecimen> retVal = new List <MedLabSpecimen>();
            MedLabSpecimen        medLabSpecimen;

            foreach (DataRow row in table.Rows)
            {
                medLabSpecimen = new MedLabSpecimen();
                medLabSpecimen.MedLabSpecimenNum = PIn.Long(row["MedLabSpecimenNum"].ToString());
                medLabSpecimen.MedLabNum         = PIn.Long(row["MedLabNum"].ToString());
                medLabSpecimen.SpecimenID        = PIn.String(row["SpecimenID"].ToString());
                medLabSpecimen.SpecimenDescript  = PIn.String(row["SpecimenDescript"].ToString());
                medLabSpecimen.DateTimeCollected = PIn.DateT(row["DateTimeCollected"].ToString());
                retVal.Add(medLabSpecimen);
            }
            return(retVal);
        }
Example #9
0
        ///<summary>Updates one MedLabSpecimen 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(MedLabSpecimen medLabSpecimen, MedLabSpecimen oldMedLabSpecimen)
        {
            string command = "";

            if (medLabSpecimen.MedLabNum != oldMedLabSpecimen.MedLabNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "MedLabNum = " + POut.Long(medLabSpecimen.MedLabNum) + "";
            }
            if (medLabSpecimen.SpecimenID != oldMedLabSpecimen.SpecimenID)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "SpecimenID = '" + POut.String(medLabSpecimen.SpecimenID) + "'";
            }
            if (medLabSpecimen.SpecimenDescript != oldMedLabSpecimen.SpecimenDescript)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "SpecimenDescript = '" + POut.String(medLabSpecimen.SpecimenDescript) + "'";
            }
            if (medLabSpecimen.DateTimeCollected != oldMedLabSpecimen.DateTimeCollected)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DateTimeCollected = " + POut.DateT(medLabSpecimen.DateTimeCollected) + "";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE medlabspecimen SET " + command
                      + " WHERE MedLabSpecimenNum = " + POut.Long(medLabSpecimen.MedLabSpecimenNum);
            Db.NonQ(command);
            return(true);
        }
Example #10
0
 ///<summary>Returns true if Update(MedLabSpecimen,MedLabSpecimen) 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(MedLabSpecimen medLabSpecimen, MedLabSpecimen oldMedLabSpecimen)
 {
     if (medLabSpecimen.MedLabNum != oldMedLabSpecimen.MedLabNum)
     {
         return(true);
     }
     if (medLabSpecimen.SpecimenID != oldMedLabSpecimen.SpecimenID)
     {
         return(true);
     }
     if (medLabSpecimen.SpecimenDescript != oldMedLabSpecimen.SpecimenDescript)
     {
         return(true);
     }
     if (medLabSpecimen.DateTimeCollected != oldMedLabSpecimen.DateTimeCollected)
     {
         return(true);
     }
     return(false);
 }
Example #11
0
		///<summary>Inserts one MedLabSpecimen into the database.  Returns the new priKey.</summary>
		public static long Insert(MedLabSpecimen medLabSpecimen){
			if(DataConnection.DBtype==DatabaseType.Oracle) {
				medLabSpecimen.MedLabSpecimenNum=DbHelper.GetNextOracleKey("medlabspecimen","MedLabSpecimenNum");
				int loopcount=0;
				while(loopcount<100){
					try {
						return Insert(medLabSpecimen,true);
					}
					catch(Oracle.DataAccess.Client.OracleException ex){
						if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
							medLabSpecimen.MedLabSpecimenNum++;
							loopcount++;
						}
						else{
							throw ex;
						}
					}
				}
				throw new ApplicationException("Insert failed.  Could not generate primary key.");
			}
			else {
				return Insert(medLabSpecimen,false);
			}
		}
Example #12
0
		///<summary>Updates one MedLabSpecimen 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(MedLabSpecimen medLabSpecimen,MedLabSpecimen oldMedLabSpecimen){
			string command="";
			if(medLabSpecimen.MedLabNum != oldMedLabSpecimen.MedLabNum) {
				if(command!=""){ command+=",";}
				command+="MedLabNum = "+POut.Long(medLabSpecimen.MedLabNum)+"";
			}
			if(medLabSpecimen.SpecimenID != oldMedLabSpecimen.SpecimenID) {
				if(command!=""){ command+=",";}
				command+="SpecimenID = '"+POut.String(medLabSpecimen.SpecimenID)+"'";
			}
			if(medLabSpecimen.SpecimenDescript != oldMedLabSpecimen.SpecimenDescript) {
				if(command!=""){ command+=",";}
				command+="SpecimenDescript = '"+POut.String(medLabSpecimen.SpecimenDescript)+"'";
			}
			if(medLabSpecimen.DateTimeCollected != oldMedLabSpecimen.DateTimeCollected) {
				if(command!=""){ command+=",";}
				command+="DateTimeCollected = "+POut.DateT(medLabSpecimen.DateTimeCollected)+"";
			}
			if(command==""){
				return false;
			}
			command="UPDATE medlabspecimen SET "+command
				+" WHERE MedLabSpecimenNum = "+POut.Long(medLabSpecimen.MedLabSpecimenNum);
			Db.NonQ(command);
			return true;
		}
Example #13
0
		///<summary>Updates one MedLabSpecimen in the database.</summary>
		public static void Update(MedLabSpecimen medLabSpecimen){
			string command="UPDATE medlabspecimen SET "
				+"MedLabNum        =  "+POut.Long  (medLabSpecimen.MedLabNum)+", "
				+"SpecimenID       = '"+POut.String(medLabSpecimen.SpecimenID)+"', "
				+"SpecimenDescript = '"+POut.String(medLabSpecimen.SpecimenDescript)+"', "
				+"DateTimeCollected=  "+POut.DateT (medLabSpecimen.DateTimeCollected)+" "
				+"WHERE MedLabSpecimenNum = "+POut.Long(medLabSpecimen.MedLabSpecimenNum);
			Db.NonQ(command);
		}
Example #14
0
 ///<summary>Inserts one MedLabSpecimen into the database.  Returns the new priKey.</summary>
 public static long Insert(MedLabSpecimen medLabSpecimen)
 {
     return(Insert(medLabSpecimen, false));
 }
Example #15
0
		///<summary></summary>
		public static void ProcessSPM(HL7DefSegment segDef,List<SegmentHL7> listSegs) {
			int specIdIndex=-1;
			int specDescIndex=-1;
			int dateTSpecIndex=-1;
			for(int i=0;i<segDef.hl7DefFields.Count;i++) {//get indexes for fields from the segment def
				HL7DefField fieldDefCur=segDef.hl7DefFields[i];
				switch(fieldDefCur.FieldName) {
					case "specimenID":
						specIdIndex=fieldDefCur.OrdinalPos;
						continue;
					case "specimenDescript":
						specDescIndex=fieldDefCur.OrdinalPos;
						continue;
					case "dateTimeSpecimen":
						dateTSpecIndex=fieldDefCur.OrdinalPos;
						continue;
					default:
						continue;
				}
			}
			for(int i=0;i<listSegs.Count;i++) {
				MedLabSpecimen specimenCur=new MedLabSpecimen();
				specimenCur.MedLabNum=_medLabCur.MedLabNum;
				if(specIdIndex>=0) {
					specimenCur.SpecimenID=listSegs[i].GetFieldComponent(specIdIndex);
				}
				if(specDescIndex>=0) {
					specimenCur.SpecimenDescript=listSegs[i].GetFieldComponent(specDescIndex);
				}
				if(dateTSpecIndex>=0) {
					specimenCur.DateTimeCollected=FieldParserMedLab.DateTimeParse(listSegs[i].GetFieldComponent(dateTSpecIndex));
				}
				MedLabSpecimens.Insert(specimenCur);
			}
			return;
		}