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

            if (!useExistingPK && isRandomKeys)
            {
                ehrCarePlan.EhrCarePlanNum = ReplicationServers.GetKeyNoCache("ehrcareplan", "EhrCarePlanNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "EhrCarePlanNum,";
            }
            command += "PatNum,SnomedEducation,Instructions,DatePlanned) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(ehrCarePlan.EhrCarePlanNum) + ",";
            }
            command +=
                POut.Long(ehrCarePlan.PatNum) + ","
                + "'" + POut.String(ehrCarePlan.SnomedEducation) + "',"
                + "'" + POut.String(ehrCarePlan.Instructions) + "',"
                + POut.Date(ehrCarePlan.DatePlanned) + ")";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                ehrCarePlan.EhrCarePlanNum = Db.NonQ(command, true, "EhrCarePlanNum", "ehrCarePlan");
            }
            return(ehrCarePlan.EhrCarePlanNum);
        }
		///<summary>Inserts one EhrCarePlan into the database.  Provides option to use the existing priKey.</summary>
		public static long Insert(EhrCarePlan ehrCarePlan,bool useExistingPK){
			if(!useExistingPK && PrefC.RandomKeys) {
				ehrCarePlan.EhrCarePlanNum=ReplicationServers.GetKey("ehrcareplan","EhrCarePlanNum");
			}
			string command="INSERT INTO ehrcareplan (";
			if(useExistingPK || PrefC.RandomKeys) {
				command+="EhrCarePlanNum,";
			}
			command+="PatNum,SnomedEducation,Instructions,DatePlanned) VALUES(";
			if(useExistingPK || PrefC.RandomKeys) {
				command+=POut.Long(ehrCarePlan.EhrCarePlanNum)+",";
			}
			command+=
				     POut.Long  (ehrCarePlan.PatNum)+","
				+"'"+POut.String(ehrCarePlan.SnomedEducation)+"',"
				+"'"+POut.String(ehrCarePlan.Instructions)+"',"
				+    POut.Date  (ehrCarePlan.DatePlanned)+")";
			if(useExistingPK || PrefC.RandomKeys) {
				Db.NonQ(command);
			}
			else {
				ehrCarePlan.EhrCarePlanNum=Db.NonQ(command,true);
			}
			return ehrCarePlan.EhrCarePlanNum;
		}
Exemple #4
0
		///<summary></summary>
		public static long Insert(EhrCarePlan ehrCarePlan) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				ehrCarePlan.EhrCarePlanNum=Meth.GetLong(MethodBase.GetCurrentMethod(),ehrCarePlan);
				return ehrCarePlan.EhrCarePlanNum;
			}
			return Crud.EhrCarePlanCrud.Insert(ehrCarePlan);
		}
Exemple #5
0
		///<summary></summary>
		public static void Update(EhrCarePlan ehrCarePlan) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				Meth.GetVoid(MethodBase.GetCurrentMethod(),ehrCarePlan);
				return;
			}
			Crud.EhrCarePlanCrud.Update(ehrCarePlan);
		}
        ///<summary>Inserts one EhrCarePlan into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(EhrCarePlan ehrCarePlan, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                ehrCarePlan.EhrCarePlanNum = ReplicationServers.GetKey("ehrcareplan", "EhrCarePlanNum");
            }
            string command = "INSERT INTO ehrcareplan (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "EhrCarePlanNum,";
            }
            command += "PatNum,SnomedEducation,Instructions,DatePlanned) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(ehrCarePlan.EhrCarePlanNum) + ",";
            }
            command +=
                POut.Long(ehrCarePlan.PatNum) + ","
                + "'" + POut.String(ehrCarePlan.SnomedEducation) + "',"
                + "'" + POut.String(ehrCarePlan.Instructions) + "',"
                + POut.Date(ehrCarePlan.DatePlanned) + ")";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                ehrCarePlan.EhrCarePlanNum = Db.NonQ(command, true, "EhrCarePlanNum", "ehrCarePlan");
            }
            return(ehrCarePlan.EhrCarePlanNum);
        }
Exemple #7
0
		private void butAdd_Click(object sender,EventArgs e) {
			EhrCarePlan ehrCarePlan=new EhrCarePlan();
			ehrCarePlan.IsNew=true;
			ehrCarePlan.PatNum=_patCur.PatNum;
			ehrCarePlan.DatePlanned=DateTime.Today;
			FormEhrCarePlanEdit formEdit=new FormEhrCarePlanEdit(ehrCarePlan);
			if(formEdit.ShowDialog()==DialogResult.OK) {
				FillCarePlans();
			}
		}
        ///<summary>Updates one EhrCarePlan in the database.</summary>
        public static void Update(EhrCarePlan ehrCarePlan)
        {
            string command = "UPDATE ehrcareplan SET "
                             + "PatNum         =  " + POut.Long(ehrCarePlan.PatNum) + ", "
                             + "SnomedEducation= '" + POut.String(ehrCarePlan.SnomedEducation) + "', "
                             + "Instructions   = '" + POut.String(ehrCarePlan.Instructions) + "', "
                             + "DatePlanned    =  " + POut.Date(ehrCarePlan.DatePlanned) + " "
                             + "WHERE EhrCarePlanNum = " + POut.Long(ehrCarePlan.EhrCarePlanNum);

            Db.NonQ(command);
        }
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<EhrCarePlan> TableToList(DataTable table){
			List<EhrCarePlan> retVal=new List<EhrCarePlan>();
			EhrCarePlan ehrCarePlan;
			for(int i=0;i<table.Rows.Count;i++) {
				ehrCarePlan=new EhrCarePlan();
				ehrCarePlan.EhrCarePlanNum = PIn.Long  (table.Rows[i]["EhrCarePlanNum"].ToString());
				ehrCarePlan.PatNum         = PIn.Long  (table.Rows[i]["PatNum"].ToString());
				ehrCarePlan.SnomedEducation= PIn.String(table.Rows[i]["SnomedEducation"].ToString());
				ehrCarePlan.Instructions   = PIn.String(table.Rows[i]["Instructions"].ToString());
				ehrCarePlan.DatePlanned    = PIn.Date  (table.Rows[i]["DatePlanned"].ToString());
				retVal.Add(ehrCarePlan);
			}
			return retVal;
		}
Exemple #10
0
        private void butAdd_Click(object sender, EventArgs e)
        {
            EhrCarePlan ehrCarePlan = new EhrCarePlan();

            ehrCarePlan.IsNew       = true;
            ehrCarePlan.PatNum      = _patCur.PatNum;
            ehrCarePlan.DatePlanned = DateTime.Today;
            FormEhrCarePlanEdit formEdit = new FormEhrCarePlanEdit(ehrCarePlan);

            if (formEdit.ShowDialog() == DialogResult.OK)
            {
                FillCarePlans();
            }
        }
Exemple #11
0
 ///<summary>Inserts one EhrCarePlan into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(EhrCarePlan ehrCarePlan)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(ehrCarePlan, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             ehrCarePlan.EhrCarePlanNum = DbHelper.GetNextOracleKey("ehrcareplan", "EhrCarePlanNum");                  //Cacheless method
         }
         return(InsertNoCache(ehrCarePlan, true));
     }
 }
Exemple #12
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <EhrCarePlan> TableToList(DataTable table)
        {
            List <EhrCarePlan> retVal = new List <EhrCarePlan>();
            EhrCarePlan        ehrCarePlan;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                ehrCarePlan = new EhrCarePlan();
                ehrCarePlan.EhrCarePlanNum  = PIn.Long(table.Rows[i]["EhrCarePlanNum"].ToString());
                ehrCarePlan.PatNum          = PIn.Long(table.Rows[i]["PatNum"].ToString());
                ehrCarePlan.SnomedEducation = PIn.String(table.Rows[i]["SnomedEducation"].ToString());
                ehrCarePlan.Instructions    = PIn.String(table.Rows[i]["Instructions"].ToString());
                ehrCarePlan.DatePlanned     = PIn.Date(table.Rows[i]["DatePlanned"].ToString());
                retVal.Add(ehrCarePlan);
            }
            return(retVal);
        }
Exemple #13
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <EhrCarePlan> TableToList(DataTable table)
        {
            List <EhrCarePlan> retVal = new List <EhrCarePlan>();
            EhrCarePlan        ehrCarePlan;

            foreach (DataRow row in table.Rows)
            {
                ehrCarePlan = new EhrCarePlan();
                ehrCarePlan.EhrCarePlanNum  = PIn.Long(row["EhrCarePlanNum"].ToString());
                ehrCarePlan.PatNum          = PIn.Long(row["PatNum"].ToString());
                ehrCarePlan.SnomedEducation = PIn.String(row["SnomedEducation"].ToString());
                ehrCarePlan.Instructions    = PIn.String(row["Instructions"].ToString());
                ehrCarePlan.DatePlanned     = PIn.Date(row["DatePlanned"].ToString());
                retVal.Add(ehrCarePlan);
            }
            return(retVal);
        }
Exemple #14
0
        ///<summary>Updates one EhrCarePlan 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(EhrCarePlan ehrCarePlan, EhrCarePlan oldEhrCarePlan)
        {
            string command = "";

            if (ehrCarePlan.PatNum != oldEhrCarePlan.PatNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PatNum = " + POut.Long(ehrCarePlan.PatNum) + "";
            }
            if (ehrCarePlan.SnomedEducation != oldEhrCarePlan.SnomedEducation)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "SnomedEducation = '" + POut.String(ehrCarePlan.SnomedEducation) + "'";
            }
            if (ehrCarePlan.Instructions != oldEhrCarePlan.Instructions)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Instructions = '" + POut.String(ehrCarePlan.Instructions) + "'";
            }
            if (ehrCarePlan.DatePlanned.Date != oldEhrCarePlan.DatePlanned.Date)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "DatePlanned = " + POut.Date(ehrCarePlan.DatePlanned) + "";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE ehrcareplan SET " + command
                      + " WHERE EhrCarePlanNum = " + POut.Long(ehrCarePlan.EhrCarePlanNum);
            Db.NonQ(command);
            return(true);
        }
Exemple #15
0
 ///<summary>Returns true if Update(EhrCarePlan,EhrCarePlan) 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(EhrCarePlan ehrCarePlan, EhrCarePlan oldEhrCarePlan)
 {
     if (ehrCarePlan.PatNum != oldEhrCarePlan.PatNum)
     {
         return(true);
     }
     if (ehrCarePlan.SnomedEducation != oldEhrCarePlan.SnomedEducation)
     {
         return(true);
     }
     if (ehrCarePlan.Instructions != oldEhrCarePlan.Instructions)
     {
         return(true);
     }
     if (ehrCarePlan.DatePlanned.Date != oldEhrCarePlan.DatePlanned.Date)
     {
         return(true);
     }
     return(false);
 }
		///<summary>Inserts one EhrCarePlan into the database.  Returns the new priKey.</summary>
		public static long Insert(EhrCarePlan ehrCarePlan){
			if(DataConnection.DBtype==DatabaseType.Oracle) {
				ehrCarePlan.EhrCarePlanNum=DbHelper.GetNextOracleKey("ehrcareplan","EhrCarePlanNum");
				int loopcount=0;
				while(loopcount<100){
					try {
						return Insert(ehrCarePlan,true);
					}
					catch(Oracle.DataAccess.Client.OracleException ex){
						if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
							ehrCarePlan.EhrCarePlanNum++;
							loopcount++;
						}
						else{
							throw ex;
						}
					}
				}
				throw new ApplicationException("Insert failed.  Could not generate primary key.");
			}
			else {
				return Insert(ehrCarePlan,false);
			}
		}
		///<summary>Updates one EhrCarePlan in the database.</summary>
		public static void Update(EhrCarePlan ehrCarePlan){
			string command="UPDATE ehrcareplan SET "
				+"PatNum         =  "+POut.Long  (ehrCarePlan.PatNum)+", "
				+"SnomedEducation= '"+POut.String(ehrCarePlan.SnomedEducation)+"', "
				+"Instructions   = '"+POut.String(ehrCarePlan.Instructions)+"', "
				+"DatePlanned    =  "+POut.Date  (ehrCarePlan.DatePlanned)+" "
				+"WHERE EhrCarePlanNum = "+POut.Long(ehrCarePlan.EhrCarePlanNum);
			Db.NonQ(command);
		}
		///<summary>Updates one EhrCarePlan 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(EhrCarePlan ehrCarePlan,EhrCarePlan oldEhrCarePlan){
			string command="";
			if(ehrCarePlan.PatNum != oldEhrCarePlan.PatNum) {
				if(command!=""){ command+=",";}
				command+="PatNum = "+POut.Long(ehrCarePlan.PatNum)+"";
			}
			if(ehrCarePlan.SnomedEducation != oldEhrCarePlan.SnomedEducation) {
				if(command!=""){ command+=",";}
				command+="SnomedEducation = '"+POut.String(ehrCarePlan.SnomedEducation)+"'";
			}
			if(ehrCarePlan.Instructions != oldEhrCarePlan.Instructions) {
				if(command!=""){ command+=",";}
				command+="Instructions = '"+POut.String(ehrCarePlan.Instructions)+"'";
			}
			if(ehrCarePlan.DatePlanned != oldEhrCarePlan.DatePlanned) {
				if(command!=""){ command+=",";}
				command+="DatePlanned = "+POut.Date(ehrCarePlan.DatePlanned)+"";
			}
			if(command==""){
				return;
			}
			command="UPDATE ehrcareplan SET "+command
				+" WHERE EhrCarePlanNum = "+POut.Long(ehrCarePlan.EhrCarePlanNum);
			Db.NonQ(command);
		}
 public FormEhrCarePlanEdit(EhrCarePlan ehrCarePlan)
 {
     InitializeComponent();
     Lan.F(this);
     _ehrCarePlan = ehrCarePlan;
 }
 ///<summary>Inserts one EhrCarePlan into the database.  Returns the new priKey.</summary>
 public static long Insert(EhrCarePlan ehrCarePlan)
 {
     return(Insert(ehrCarePlan, false));
 }
Exemple #21
0
		public FormEhrCarePlanEdit(EhrCarePlan ehrCarePlan) {
			InitializeComponent();
			Lan.F(this);
			_ehrCarePlan=ehrCarePlan;
		}
Exemple #22
0
		///<summary>Helper for GenerateCCD().</summary>
		private void GenerateCcdSectionPlanOfCare(bool hasPlanOfCare) {
			_w.WriteComment(@"
=====================================================================================================
Care Plan
=====================================================================================================");
			List<EhrCarePlan> listEhrCarePlansAll=EhrCarePlans.Refresh(_patOutCcd.PatNum);
			List<EhrCarePlan> listEhrCarePlansFiltered;
			if(!hasPlanOfCare) {
				listEhrCarePlansFiltered=new List<EhrCarePlan>();
			}
			else {
				listEhrCarePlansFiltered=_listEhrCarePlansFiltered;
			}
			Start("component");
			Start("section");
			TemplateId("2.16.840.1.113883.10.20.22.2.10");//Only one template id allowed (unlike other sections).
			_w.WriteComment("Plan of Care section template");
			StartAndEnd("code","code","18776-5","codeSystem",strCodeSystemLoinc,"codeSystemName",strCodeSystemNameLoinc,"displayName","Treatment plan");
			_w.WriteElementString("title","Care Plan");
			Start("text");//The following text will be parsed as html with a style sheet to be human readable.
			if(listEhrCarePlansFiltered.Count>0 && hasPlanOfCare) {
				Start("table","width","100%","border","1");
				Start("thead");
				Start("tr");
				_w.WriteElementString("th","Planned Activity");
				_w.WriteElementString("th","Planned Date");
				End("tr");
				End("thead");
				Start("tbody");
				for(int i=0;i<listEhrCarePlansFiltered.Count;i++) {
					Start("tr");
					Snomed snomedEducation;
					snomedEducation=Snomeds.GetByCode(listEhrCarePlansFiltered[i].SnomedEducation);
					if(snomedEducation==null) {
						snomedEducation=new Snomed();
					}
					if(String.IsNullOrEmpty(snomedEducation.Description)) {
						if(String.IsNullOrEmpty(listEhrCarePlansFiltered[i].Instructions)) {
							_w.WriteElementString("td","");//Planned Activity
						}
						else {
							_w.WriteElementString("td","Goal: ; Instructions: "+listEhrCarePlansFiltered[i].Instructions);//Planned Activity
						}
					}
					else {
						_w.WriteElementString("td","Goal: "+snomedEducation.SnomedCode+" - "+snomedEducation.Description+"; Instructions: "+listEhrCarePlansFiltered[i].Instructions);//Planned Activity
					}
					if(listEhrCarePlansFiltered[i].DatePlanned.Year<1880) {
						_w.WriteElementString("td","");
					}
					else {
						DateText("td",listEhrCarePlansFiltered[i].DatePlanned);//Planned Date
					}
					End("tr");
				}
				End("tbody");
				End("table");
			}
			else {
				_w.WriteString("None");
			}
			End("text");
			if(listEhrCarePlansFiltered.Count==0) {//If there are no entries in the filtered list, then we want to add a dummy entry since at least one is required.
				EhrCarePlan eCP=new EhrCarePlan();
				listEhrCarePlansFiltered.Add(eCP);
			}
			for(int i=0;i<listEhrCarePlansFiltered.Count;i++) {
				Start("entry","typeCode","DRIV");
				Start("act","classCode","ACT","moodCode","INT");
				TemplateId("2.16.840.1.113883.10.20.22.4.20");
				_w.WriteComment("Instructions template");
				Start("code");
				_w.WriteAttributeString("xsi","type",null,"CE");
				Snomed snomedEducation=Snomeds.GetByCode(listEhrCarePlansFiltered[i].SnomedEducation);
				if(snomedEducation==null) {
					Attribs("nullFlavor","UNK");
				}
				else {
					Attribs("code",snomedEducation.SnomedCode,"codeSystem",strCodeSystemSnomed,"displayName",snomedEducation.Description);
				}
				End("code");
				if(listEhrCarePlansFiltered[i].Instructions=="") {
					StartAndEnd("text","nullFlavor","UNK");
				}
				else {
					_w.WriteElementString("text",listEhrCarePlansFiltered[i].Instructions);
				}
				StartAndEnd("statusCode","code","completed");
				End("act");
				End("entry");
			}
			End("section");
			End("component");
		}