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

            if (!useExistingPK && isRandomKeys)
            {
                medicalOrder.MedicalOrderNum = ReplicationServers.GetKeyNoCache("medicalorder", "MedicalOrderNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "MedicalOrderNum,";
            }
            command += "MedOrderType,PatNum,DateTimeOrder,Description,IsDiscontinued,ProvNum) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(medicalOrder.MedicalOrderNum) + ",";
            }
            command +=
                POut.Int((int)medicalOrder.MedOrderType) + ","
                + POut.Long(medicalOrder.PatNum) + ","
                + POut.DateT(medicalOrder.DateTimeOrder) + ","
                + "'" + POut.String(medicalOrder.Description) + "',"
                + POut.Bool(medicalOrder.IsDiscontinued) + ","
                + POut.Long(medicalOrder.ProvNum) + ")";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                medicalOrder.MedicalOrderNum = Db.NonQ(command, true, "MedicalOrderNum", "medicalOrder");
            }
            return(medicalOrder.MedicalOrderNum);
        }
Пример #3
0
 ///<summary>Inserts one MedicalOrder into the database.  Returns the new priKey.</summary>
 internal static long Insert(MedicalOrder medicalOrder)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         medicalOrder.MedicalOrderNum = DbHelper.GetNextOracleKey("medicalorder", "MedicalOrderNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(medicalOrder, true));
             }
             catch (Oracle.DataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     medicalOrder.MedicalOrderNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(medicalOrder, false));
     }
 }
Пример #4
0
 ///<summary>Inserts one MedicalOrder into the database.  Provides option to use the existing priKey.</summary>
 internal static long Insert(MedicalOrder medicalOrder,bool useExistingPK)
 {
     if(!useExistingPK && PrefC.RandomKeys) {
         medicalOrder.MedicalOrderNum=ReplicationServers.GetKey("medicalorder","MedicalOrderNum");
     }
     string command="INSERT INTO medicalorder (";
     if(useExistingPK || PrefC.RandomKeys) {
         command+="MedicalOrderNum,";
     }
     command+="MedOrderType,PatNum,DateTimeOrder,Description,IsDiscontinued,ProvNum) VALUES(";
     if(useExistingPK || PrefC.RandomKeys) {
         command+=POut.Long(medicalOrder.MedicalOrderNum)+",";
     }
     command+=
              POut.Int   ((int)medicalOrder.MedOrderType)+","
         +    POut.Long  (medicalOrder.PatNum)+","
         +    POut.DateT (medicalOrder.DateTimeOrder)+","
         +"'"+POut.String(medicalOrder.Description)+"',"
         +    POut.Bool  (medicalOrder.IsDiscontinued)+","
         +    POut.Long  (medicalOrder.ProvNum)+")";
     if(useExistingPK || PrefC.RandomKeys) {
         Db.NonQ(command);
     }
     else {
         medicalOrder.MedicalOrderNum=Db.NonQ(command,true);
     }
     return medicalOrder.MedicalOrderNum;
 }
Пример #5
0
        ///<summary>Updates one MedicalOrder 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(MedicalOrder medicalOrder, MedicalOrder oldMedicalOrder)
        {
            string command = "";

            if (medicalOrder.MedOrderType != oldMedicalOrder.MedOrderType)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "MedOrderType = " + POut.Int((int)medicalOrder.MedOrderType) + "";
            }
            if (medicalOrder.PatNum != oldMedicalOrder.PatNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PatNum = " + POut.Long(medicalOrder.PatNum) + "";
            }
            if (medicalOrder.DateTimeOrder != oldMedicalOrder.DateTimeOrder)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DateTimeOrder = " + POut.DateT(medicalOrder.DateTimeOrder) + "";
            }
            if (medicalOrder.Description != oldMedicalOrder.Description)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Description = '" + POut.String(medicalOrder.Description) + "'";
            }
            if (medicalOrder.IsDiscontinued != oldMedicalOrder.IsDiscontinued)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "IsDiscontinued = " + POut.Bool(medicalOrder.IsDiscontinued) + "";
            }
            if (medicalOrder.ProvNum != oldMedicalOrder.ProvNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ProvNum = " + POut.Long(medicalOrder.ProvNum) + "";
            }
            if (command == "")
            {
                return;
            }
            command = "UPDATE medicalorder SET " + command
                      + " WHERE MedicalOrderNum = " + POut.Long(medicalOrder.MedicalOrderNum);
            Db.NonQ(command);
        }
Пример #6
0
        ///<summary>Inserts one MedicalOrder into the database.  Provides option to use the existing priKey.</summary>
        internal static long Insert(MedicalOrder medicalOrder, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                medicalOrder.MedicalOrderNum = ReplicationServers.GetKey("medicalorder", "MedicalOrderNum");
            }
            string command = "INSERT INTO medicalorder (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "MedicalOrderNum,";
            }
            command += "MedOrderType,PatNum,DateTimeOrder,Description,IsDiscontinued,ProvNum) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(medicalOrder.MedicalOrderNum) + ",";
            }
            command +=
                POut.Int((int)medicalOrder.MedOrderType) + ","
                + POut.Long(medicalOrder.PatNum) + ","
                + POut.DateT(medicalOrder.DateTimeOrder) + ","
                + "'" + POut.String(medicalOrder.Description) + "',"
                + POut.Bool(medicalOrder.IsDiscontinued) + ","
                + POut.Long(medicalOrder.ProvNum) + ")";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                medicalOrder.MedicalOrderNum = Db.NonQ(command, true);
            }
            return(medicalOrder.MedicalOrderNum);
        }
Пример #7
0
 ///<summary>Returns true if Update(MedicalOrder,MedicalOrder) 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(MedicalOrder medicalOrder, MedicalOrder oldMedicalOrder)
 {
     if (medicalOrder.MedOrderType != oldMedicalOrder.MedOrderType)
     {
         return(true);
     }
     if (medicalOrder.PatNum != oldMedicalOrder.PatNum)
     {
         return(true);
     }
     if (medicalOrder.DateTimeOrder != oldMedicalOrder.DateTimeOrder)
     {
         return(true);
     }
     if (medicalOrder.Description != oldMedicalOrder.Description)
     {
         return(true);
     }
     if (medicalOrder.IsDiscontinued != oldMedicalOrder.IsDiscontinued)
     {
         return(true);
     }
     if (medicalOrder.ProvNum != oldMedicalOrder.ProvNum)
     {
         return(true);
     }
     return(false);
 }
Пример #8
0
        private void InitMedicalOrderData(int patientId)
        {
            using (MedicalOrderDao medicalOrderDao = new MedicalOrderDao())
            {
                int          lastInsertId = -1;
                MedicalOrder medicalOrder = new MedicalOrder();

                medicalOrder.PatientId   = patientId;
                medicalOrder.Activated   = true;
                medicalOrder.Plan        = "方法";
                medicalOrder.Seq         = "5";
                medicalOrder.MethodId    = 4;
                medicalOrder.Interval    = 1;
                medicalOrder.Times       = 0;
                medicalOrder.Description = "";
                medicalOrderDao.InsertMedicalOrder(medicalOrder, ref lastInsertId);

                medicalOrder.PatientId   = patientId;
                medicalOrder.Activated   = true;
                medicalOrder.Plan        = "方法";
                medicalOrder.Seq         = "4";
                medicalOrder.MethodId    = 3;
                medicalOrder.Interval    = 1;
                medicalOrder.Times       = 0;
                medicalOrder.Description = "";
                medicalOrderDao.InsertMedicalOrder(medicalOrder, ref lastInsertId);

                medicalOrder.PatientId   = patientId;
                medicalOrder.Activated   = true;
                medicalOrder.Plan        = "方法";
                medicalOrder.Seq         = "3";
                medicalOrder.MethodId    = 2;
                medicalOrder.Interval    = 1;
                medicalOrder.Times       = 0;
                medicalOrder.Description = "";
                medicalOrderDao.InsertMedicalOrder(medicalOrder, ref lastInsertId);

                medicalOrder.PatientId   = patientId;
                medicalOrder.Activated   = true;
                medicalOrder.Plan        = "方法";
                medicalOrder.Seq         = "2";
                medicalOrder.MethodId    = 1;
                medicalOrder.Interval    = 1;
                medicalOrder.Times       = 0;
                medicalOrder.Description = "";
                medicalOrderDao.InsertMedicalOrder(medicalOrder, ref lastInsertId);

                medicalOrder.PatientId   = patientId;
                medicalOrder.Activated   = true;
                medicalOrder.Plan        = "频次";
                medicalOrder.Seq         = "1";
                medicalOrder.MethodId    = -1;
                medicalOrder.Interval    = 1;
                medicalOrder.Times       = 0;
                medicalOrder.Description = "";
                medicalOrderDao.InsertMedicalOrder(medicalOrder, ref lastInsertId);
            }
        }
Пример #9
0
        ///<summary>Updates one MedicalOrder in the database.</summary>
        public static void Update(MedicalOrder medicalOrder)
        {
            string command = "UPDATE medicalorder SET "
                             + "MedOrderType   =  " + POut.Int((int)medicalOrder.MedOrderType) + ", "
                             + "PatNum         =  " + POut.Long(medicalOrder.PatNum) + ", "
                             + "DateTimeOrder  =  " + POut.DateT(medicalOrder.DateTimeOrder) + ", "
                             + "Description    = '" + POut.String(medicalOrder.Description) + "', "
                             + "IsDiscontinued =  " + POut.Bool(medicalOrder.IsDiscontinued) + ", "
                             + "ProvNum        =  " + POut.Long(medicalOrder.ProvNum) + " "
                             + "WHERE MedicalOrderNum = " + POut.Long(medicalOrder.MedicalOrderNum);

            Db.NonQ(command);
        }
Пример #10
0
 ///<summary>Inserts one MedicalOrder into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(MedicalOrder medicalOrder)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(medicalOrder, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             medicalOrder.MedicalOrderNum = DbHelper.GetNextOracleKey("medicalorder", "MedicalOrderNum");                  //Cacheless method
         }
         return(InsertNoCache(medicalOrder, true));
     }
 }
Пример #11
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<MedicalOrder> TableToList(DataTable table){
			List<MedicalOrder> retVal=new List<MedicalOrder>();
			MedicalOrder medicalOrder;
			for(int i=0;i<table.Rows.Count;i++) {
				medicalOrder=new MedicalOrder();
				medicalOrder.MedicalOrderNum= PIn.Long  (table.Rows[i]["MedicalOrderNum"].ToString());
				medicalOrder.MedOrderType   = (OpenDentBusiness.MedicalOrderType)PIn.Int(table.Rows[i]["MedOrderType"].ToString());
				medicalOrder.PatNum         = PIn.Long  (table.Rows[i]["PatNum"].ToString());
				medicalOrder.DateTimeOrder  = PIn.DateT (table.Rows[i]["DateTimeOrder"].ToString());
				medicalOrder.Description    = PIn.String(table.Rows[i]["Description"].ToString());
				medicalOrder.IsDiscontinued = PIn.Bool  (table.Rows[i]["IsDiscontinued"].ToString());
				medicalOrder.ProvNum        = PIn.Long  (table.Rows[i]["ProvNum"].ToString());
				retVal.Add(medicalOrder);
			}
			return retVal;
		}
Пример #12
0
        private void CreateLabPanel()
        {
            MedicalOrder order = listLabOrders[gridMain.GetSelectedIndex()];
            MessageHL7   msg   = new MessageHL7(textHL7Raw.Text);
            //SegmentHL7 segOBR=null;
            //SegmentHL7 segOBX=null;
            //int idxPanel=0;
            //int idxResult=0;
            LabPanel  panel  = null;
            LabResult result = null;

            //loop through all message segments.
            for (int i = 0; i < msg.Segments.Count; i++)
            {
                if (msg.Segments[i].Name == SegmentNameHL7.OBR)              //if this is the start of a new panel
                {
                    panel                   = new LabPanel();
                    panel.PatNum            = order.PatNum;
                    panel.MedicalOrderNum   = order.MedicalOrderNum;
                    panel.RawMessage        = textHL7Raw.Text;
                    panel.LabNameAddress    = msg.Segments[i].GetFieldFullText(20);
                    panel.SpecimenSource    = msg.Segments[i].GetFieldFullText(15);
                    panel.SpecimenCondition = msg.Segments[i].GetFieldFullText(13);
                    panel.ServiceId         = msg.Segments[i].GetFieldComponent(4, 0);
                    panel.ServiceName       = msg.Segments[i].GetFieldComponent(4, 1);
                    LabPanels.Insert(panel);
                }
                if (msg.Segments[i].Name == SegmentNameHL7.OBX)              //if this is a result within a panel
                {
                    result              = new LabResult();
                    result.LabPanelNum  = panel.LabPanelNum;
                    result.DateTimeTest = msg.Segments[i].GetDateTime(14);
                    result.TestID       = msg.Segments[i].GetFieldComponent(3, 0);
                    result.TestName     = msg.Segments[i].GetFieldComponent(3, 1);
                    result.ObsValue     = msg.Segments[i].GetFieldFullText(5);
                    result.ObsUnits     = msg.Segments[i].GetFieldFullText(6);
                    result.ObsRange     = msg.Segments[i].GetFieldFullText(7);
                    LabResults.Insert(result);
                }
                //any other kind of segment, continue.
            }
            //order.IsLabPending=false;
            //MedicalOrders.Update(order);
            //return true;//I guess it's always true?
        }
Пример #13
0
        private void gridMedOrders_CellDoubleClick(object sender, ODGridClickEventArgs e)
        {
            long         medicalOrderNum = PIn.Long(table.Rows[e.Row]["MedicalOrderNum"].ToString());
            MedicalOrder ord             = MedicalOrders.GetOne(medicalOrderNum);

            if (ord.MedOrderType == MedicalOrderType.Laboratory)
            {
                FormEhrMedicalOrderLabEdit FormMlab = new FormEhrMedicalOrderLabEdit();
                FormMlab.MedOrderCur = ord;
                FormMlab.ShowDialog();
            }
            else              //Rad
            {
                FormEhrMedicalOrderRadEdit FormMrad = new FormEhrMedicalOrderRadEdit();
                FormMrad.MedOrderCur = ord;
                FormMrad.ShowDialog();
            }
            FillGridMedOrders();
        }
Пример #14
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        internal static List <MedicalOrder> TableToList(DataTable table)
        {
            List <MedicalOrder> retVal = new List <MedicalOrder>();
            MedicalOrder        medicalOrder;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                medicalOrder = new MedicalOrder();
                medicalOrder.MedicalOrderNum = PIn.Long(table.Rows[i]["MedicalOrderNum"].ToString());
                medicalOrder.MedOrderType    = (MedicalOrderType)PIn.Int(table.Rows[i]["MedOrderType"].ToString());
                medicalOrder.PatNum          = PIn.Long(table.Rows[i]["PatNum"].ToString());
                medicalOrder.DateTimeOrder   = PIn.DateT(table.Rows[i]["DateTimeOrder"].ToString());
                medicalOrder.Description     = PIn.String(table.Rows[i]["Description"].ToString());
                medicalOrder.IsDiscontinued  = PIn.Bool(table.Rows[i]["IsDiscontinued"].ToString());
                medicalOrder.ProvNum         = PIn.Long(table.Rows[i]["ProvNum"].ToString());
                retVal.Add(medicalOrder);
            }
            return(retVal);
        }
Пример #15
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <MedicalOrder> TableToList(DataTable table)
        {
            List <MedicalOrder> retVal = new List <MedicalOrder>();
            MedicalOrder        medicalOrder;

            foreach (DataRow row in table.Rows)
            {
                medicalOrder = new MedicalOrder();
                medicalOrder.MedicalOrderNum = PIn.Long(row["MedicalOrderNum"].ToString());
                medicalOrder.MedOrderType    = (OpenDentBusiness.MedicalOrderType)PIn.Int(row["MedOrderType"].ToString());
                medicalOrder.PatNum          = PIn.Long(row["PatNum"].ToString());
                medicalOrder.DateTimeOrder   = PIn.DateT(row["DateTimeOrder"].ToString());
                medicalOrder.Description     = PIn.String(row["Description"].ToString());
                medicalOrder.IsDiscontinued  = PIn.Bool(row["IsDiscontinued"].ToString());
                medicalOrder.ProvNum         = PIn.Long(row["ProvNum"].ToString());
                retVal.Add(medicalOrder);
            }
            return(retVal);
        }
Пример #16
0
 ///<summary>Inserts one MedicalOrder into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(MedicalOrder medicalOrder)
 {
     return(InsertNoCache(medicalOrder, false));
 }
Пример #17
0
 ///<summary>Updates one MedicalOrder 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(MedicalOrder medicalOrder,MedicalOrder oldMedicalOrder)
 {
     string command="";
     if(medicalOrder.MedOrderType != oldMedicalOrder.MedOrderType) {
         if(command!=""){ command+=",";}
         command+="MedOrderType = "+POut.Int   ((int)medicalOrder.MedOrderType)+"";
     }
     if(medicalOrder.PatNum != oldMedicalOrder.PatNum) {
         if(command!=""){ command+=",";}
         command+="PatNum = "+POut.Long(medicalOrder.PatNum)+"";
     }
     if(medicalOrder.DateTimeOrder != oldMedicalOrder.DateTimeOrder) {
         if(command!=""){ command+=",";}
         command+="DateTimeOrder = "+POut.DateT(medicalOrder.DateTimeOrder)+"";
     }
     if(medicalOrder.Description != oldMedicalOrder.Description) {
         if(command!=""){ command+=",";}
         command+="Description = '"+POut.String(medicalOrder.Description)+"'";
     }
     if(medicalOrder.IsDiscontinued != oldMedicalOrder.IsDiscontinued) {
         if(command!=""){ command+=",";}
         command+="IsDiscontinued = "+POut.Bool(medicalOrder.IsDiscontinued)+"";
     }
     if(medicalOrder.ProvNum != oldMedicalOrder.ProvNum) {
         if(command!=""){ command+=",";}
         command+="ProvNum = "+POut.Long(medicalOrder.ProvNum)+"";
     }
     if(command==""){
         return;
     }
     command="UPDATE medicalorder SET "+command
         +" WHERE MedicalOrderNum = "+POut.Long(medicalOrder.MedicalOrderNum);
     Db.NonQ(command);
 }
Пример #18
0
 ///<summary>Updates one MedicalOrder in the database.</summary>
 internal static void Update(MedicalOrder medicalOrder)
 {
     string command="UPDATE medicalorder SET "
         +"MedOrderType   =  "+POut.Int   ((int)medicalOrder.MedOrderType)+", "
         +"PatNum         =  "+POut.Long  (medicalOrder.PatNum)+", "
         +"DateTimeOrder  =  "+POut.DateT (medicalOrder.DateTimeOrder)+", "
         +"Description    = '"+POut.String(medicalOrder.Description)+"', "
         +"IsDiscontinued =  "+POut.Bool  (medicalOrder.IsDiscontinued)+", "
         +"ProvNum        =  "+POut.Long  (medicalOrder.ProvNum)+" "
         +"WHERE MedicalOrderNum = "+POut.Long(medicalOrder.MedicalOrderNum);
     Db.NonQ(command);
 }