private void AddPatientRace(LookupValueDto raceDto, Patient patient)
        {
            var race        = _mappingHelper.MapLookupField <Race> (raceDto);
            var patientRace = new PatientRace(race);

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

            if (!useExistingPK && isRandomKeys)
            {
                patientRace.PatientRaceNum = ReplicationServers.GetKeyNoCache("patientrace", "PatientRaceNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "PatientRaceNum,";
            }
            command += "PatNum,Race,CdcrecCode) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(patientRace.PatientRaceNum) + ",";
            }
            command +=
                POut.Long(patientRace.PatNum) + ","
                + POut.Int((int)patientRace.Race) + ","
                + "'" + POut.String(patientRace.CdcrecCode) + "')";
            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                patientRace.PatientRaceNum = Db.NonQ(command, true, "PatientRaceNum", "patientRace");
            }
            return(patientRace.PatientRaceNum);
        }
Example #3
0
        ///<summary>Inserts one PatientRace into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(PatientRace patientRace, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                patientRace.PatientRaceNum = ReplicationServers.GetKey("patientrace", "PatientRaceNum");
            }
            string command = "INSERT INTO patientrace (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "PatientRaceNum,";
            }
            command += "PatNum,Race,CdcrecCode) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(patientRace.PatientRaceNum) + ",";
            }
            command +=
                POut.Long(patientRace.PatNum) + ","
                + POut.Int((int)patientRace.Race) + ","
                + "'" + POut.String(patientRace.CdcrecCode) + "')";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                patientRace.PatientRaceNum = Db.NonQ(command, true, "PatientRaceNum", "patientRace");
            }
            return(patientRace.PatientRaceNum);
        }
Example #4
0
 ///<summary>Inserts one PatientRace into the database.  Returns the new priKey.</summary>
 public static long Insert(PatientRace patientRace)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         patientRace.PatientRaceNum = DbHelper.GetNextOracleKey("patientrace", "PatientRaceNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(patientRace, true));
             }
             catch (Oracle.ManagedDataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     patientRace.PatientRaceNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(patientRace, false));
     }
 }
Example #5
0
        private void BuildTaddYoungPatient()
        {
            PersonName name = new PersonNameBuilder()
                              .WithFirst("Tadd")
                              .WithLast("Young")
                              .Build();
            PatientProfile profile = new PatientProfileBuilder()
                                     .WithBirthDate(DateTime.Parse("5/10/2000"))
                                     .WithPatientGender(MaleGender)
                                     .Build();

            TaddYoungPatient = new Patient(SafeHarborAgency, name, profile);
            TaddYoungPatient.UpdateUniqueIdentifier("taddyoung");

            TaddYoungPatient.AddPhoneNumber(new PatientPhone(HomePatientPhoneType, "555-255-5454"));

            var patientRace = new PatientRace(WhiteRace);

            TaddYoungPatient.AddPatientRace(patientRace);
            TaddYoungPatient.SetPrimaryRace(WhiteRace);

            TaddYoungPatient.AddAlias(new PatientAlias(NicknamePatientAliasType, "Tadd"));

            TaddYoungPatient.AddPatientDisability(new PatientDisability(DeafDisability));

            Session.SaveOrUpdate(TaddYoungPatient);
        }
Example #6
0
        private string ConvertRace(PatientRace race)
        {
            switch (race)
            {
            case PatientRace.AmericanIndian:
                return("1002-5^American Indian Or Alaska Native^HL70005");

            case PatientRace.Asian:
                return("2028-9^Asian^HL70005");

            case PatientRace.AfricanAmerican:
                return("2054-5^Black or African American^HL70005");

            case PatientRace.HawaiiOrPacIsland:
                return("2076-8^Native Hawaiian or Other Pacific Islander^HL70005");

            case PatientRace.White:
                return("2106-3^White^HL70005");

            case PatientRace.Other:
                return("2131-1^Other Race^HL70005");

            default:                    //including hispanic
                return("2131-1^Other Race^HL70005");
            }
        }
Example #7
0
        public List <PatientRace> GetCancerTypeByRace()
        {
            if (!IsConnectionAlive())
            {
                OpenConnection();
            }

            var result = new List <PatientRace>();

            using (OracleDataAdapter adapter = new OracleDataAdapter(Queries.CancerTypeByRaceQuery, connection))
            {
                DataTable dt = new DataTable();
                adapter.Fill(dt);

                foreach (DataRow dr in dt.Rows)
                {
                    var patientRace = new PatientRace
                    {
                        Race         = dr["Race"].ToString(),
                        CancerType   = dr["Site_name"].ToString(),
                        Num_Patients = long.Parse(dr["Count"].ToString())
                    };

                    result.Add(patientRace);
                }
            }

            return(result);
        }
Example #8
0
        public List <PatientRace> GetPatientRace()
        {
            if (!IsConnectionAlive())
            {
                OpenConnection();
            }

            var result = new List <PatientRace>();

            using (OracleDataAdapter adapter = new OracleDataAdapter(Queries.patientByRace, connection))
            {
                DataTable dt = new DataTable();
                adapter.Fill(dt);
                foreach (DataRow dr in dt.Rows)
                {
                    PatientRace patientrace = new PatientRace
                    {
                        Race         = dr["Race"].ToString(),
                        Num_Patients = long.Parse(dr["NoOfPatients"].ToString())
                    };

                    result.Add(patientrace);
                }
            }

            return(result);
        }
Example #9
0
File: DFT.cs Project: nampn/ODental
        //=======================================================================================================================================
        //DO NOT ALTER any of these Convert... methods for use with any other HL7 bridge.
        //Each bridge tends to have slightly different implementation.
        //No bridge can share any of these.
        //Instead, copy them into other classes.
        //This set of methods is ONLY for ECW, and will have to be renamed and grouped if any other DFT bridge is built.
        //=======================================================================================================================================

        private string ConvertRace(PatientRace race)
        {
            switch (race)
            {
            case PatientRace.AmericanIndian:
                return("American Indian Or Alaska Native");

            case PatientRace.Asian:
                return("Asian");

            case PatientRace.HawaiiOrPacIsland:
                return("Native Hawaiian or Other Pacific");

            case PatientRace.AfricanAmerican:
                return("Black or African American");

            case PatientRace.White:
                return("White");

            case PatientRace.HispanicLatino:
                return("Hispanic");

            case PatientRace.Other:
                return("Other Race");

            default:
                return("Other Race");
            }
        }
Example #10
0
        ///<summary>Updates one PatientRace in the database.</summary>
        public static void Update(PatientRace patientRace)
        {
            string command = "UPDATE patientrace SET "
                             + "PatNum        =  " + POut.Long(patientRace.PatNum) + ", "
                             + "Race          =  " + POut.Int((int)patientRace.Race) + ", "
                             + "CdcrecCode    = '" + POut.String(patientRace.CdcrecCode) + "' "
                             + "WHERE PatientRaceNum = " + POut.Long(patientRace.PatientRaceNum);

            Db.NonQ(command);
        }
Example #11
0
        private string ConvertEthnicGroup(PatientRace race)
        {
            switch (race)
            {
            case PatientRace.HispanicLatino:
                return("H^Hispanic or Latino^HL70189");

            default:
                return("N^Not Hispanic or Latino^HL70189");
            }
        }
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<PatientRace> TableToList(DataTable table){
			List<PatientRace> retVal=new List<PatientRace>();
			PatientRace patientRace;
			for(int i=0;i<table.Rows.Count;i++) {
				patientRace=new PatientRace();
				patientRace.PatientRaceNum= PIn.Long  (table.Rows[i]["PatientRaceNum"].ToString());
				patientRace.PatNum        = PIn.Long  (table.Rows[i]["PatNum"].ToString());
				patientRace.Race          = (PatRace)PIn.Int(table.Rows[i]["Race"].ToString());
				patientRace.CdcrecCode    = PIn.String(table.Rows[i]["CdcrecCode"].ToString());
				retVal.Add(patientRace);
			}
			return retVal;
		}
Example #13
0
 ///<summary>Inserts one PatientRace into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(PatientRace patientRace)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(patientRace, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             patientRace.PatientRaceNum = DbHelper.GetNextOracleKey("patientrace", "PatientRaceNum");                  //Cacheless method
         }
         return(InsertNoCache(patientRace, true));
     }
 }
Example #14
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <PatientRace> TableToList(DataTable table)
        {
            List <PatientRace> retVal = new List <PatientRace>();
            PatientRace        patientRace;

            foreach (DataRow row in table.Rows)
            {
                patientRace = new PatientRace();
                patientRace.PatientRaceNum = PIn.Long(row["PatientRaceNum"].ToString());
                patientRace.PatNum         = PIn.Long(row["PatNum"].ToString());
                patientRace.Race           = (OpenDentBusiness.PatRace)PIn.Int(row["Race"].ToString());
                patientRace.CdcrecCode     = PIn.String(row["CdcrecCode"].ToString());
                retVal.Add(patientRace);
            }
            return(retVal);
        }
Example #15
0
 ///<summary>Returns true if Update(PatientRace,PatientRace) 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(PatientRace patientRace, PatientRace oldPatientRace)
 {
     if (patientRace.PatNum != oldPatientRace.PatNum)
     {
         return(true);
     }
     if (patientRace.Race != oldPatientRace.Race)
     {
         return(true);
     }
     if (patientRace.CdcrecCode != oldPatientRace.CdcrecCode)
     {
         return(true);
     }
     return(false);
 }
Example #16
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <PatientRace> TableToList(DataTable table)
        {
            List <PatientRace> retVal = new List <PatientRace>();
            PatientRace        patientRace;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                patientRace = new PatientRace();
                patientRace.PatientRaceNum = PIn.Long(table.Rows[i]["PatientRaceNum"].ToString());
                patientRace.PatNum         = PIn.Long(table.Rows[i]["PatNum"].ToString());
                patientRace.Race           = (PatRace)PIn.Int(table.Rows[i]["Race"].ToString());
                patientRace.CdcrecCode     = PIn.String(table.Rows[i]["CdcrecCode"].ToString());
                retVal.Add(patientRace);
            }
            return(retVal);
        }
Example #17
0
        private void BuildAlbertSmithPatient()
        {
            PersonName name = new PersonNameBuilder()
                              .WithFirst("Albert")
                              .WithLast("Smith")
                              .Build();
            PatientProfile profile = new PatientProfileBuilder()
                                     .WithBirthDate(DateTime.Parse("5/10/1971"))
                                     .WithPatientGender(MaleGender)
                                     .Build();

            AlbertSmithPatient = new Patient(SafeHarborAgency, name, profile);
            AlbertSmithPatient.UpdateUniqueIdentifier("albertsmith");

            var address = new AddressBuilder()
                          .WithFirstStreetAddress("14235 South St")
                          .WithCityName("Baltimore")
                          .WithPostalCode(new PostalCode("21075"))
                          .WithStateProvince(MarylandStateProvince)
                          .Build();

            PatientAddress albertSmithAddress = new PatientAddressBuilder()
                                                .WithPatientAddressType(HomePatientAddressType)
                                                .WithAddress(address)
                                                .Build();

            AlbertSmithPatient.AddAddress(albertSmithAddress);

            AlbertSmithPatient.AddPhoneNumber(new PatientPhone(HomePatientPhoneType, "555-255-5454"));

            var patientRace = new PatientRace(WhiteRace);

            AlbertSmithPatient.AddPatientRace(patientRace);
            AlbertSmithPatient.SetPrimaryRace(WhiteRace);

            AlbertSmithPatient.AddAlias(new PatientAlias(NicknamePatientAliasType, "Al-bear"));

            AlbertSmithPatient.AddPatientDisability(new PatientDisability(DeafDisability));

            Session.SaveOrUpdate(AlbertSmithPatient);
        }
Example #18
0
        ///<summary>Updates one PatientRace 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(PatientRace patientRace, PatientRace oldPatientRace)
        {
            string command = "";

            if (patientRace.PatNum != oldPatientRace.PatNum)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PatNum = " + POut.Long(patientRace.PatNum) + "";
            }
            if (patientRace.Race != oldPatientRace.Race)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Race = " + POut.Int((int)patientRace.Race) + "";
            }
            if (patientRace.CdcrecCode != oldPatientRace.CdcrecCode)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "CdcrecCode = '" + POut.String(patientRace.CdcrecCode) + "'";
            }
            if (command == "")
            {
                return(false);
            }
            command = "UPDATE patientrace SET " + command
                      + " WHERE PatientRaceNum = " + POut.Long(patientRace.PatientRaceNum);
            Db.NonQ(command);
            return(true);
        }
		///<summary>Inserts one PatientRace into the database.  Provides option to use the existing priKey.</summary>
		public static long Insert(PatientRace patientRace,bool useExistingPK){
			if(!useExistingPK && PrefC.RandomKeys) {
				patientRace.PatientRaceNum=ReplicationServers.GetKey("patientrace","PatientRaceNum");
			}
			string command="INSERT INTO patientrace (";
			if(useExistingPK || PrefC.RandomKeys) {
				command+="PatientRaceNum,";
			}
			command+="PatNum,Race,CdcrecCode) VALUES(";
			if(useExistingPK || PrefC.RandomKeys) {
				command+=POut.Long(patientRace.PatientRaceNum)+",";
			}
			command+=
				     POut.Long  (patientRace.PatNum)+","
				+    POut.Int   ((int)patientRace.Race)+","
				+"'"+POut.String(patientRace.CdcrecCode)+"')";
			if(useExistingPK || PrefC.RandomKeys) {
				Db.NonQ(command);
			}
			else {
				patientRace.PatientRaceNum=Db.NonQ(command,true);
			}
			return patientRace.PatientRaceNum;
		}
		///<summary>Inserts one PatientRace into the database.  Returns the new priKey.</summary>
		public static long Insert(PatientRace patientRace){
			if(DataConnection.DBtype==DatabaseType.Oracle) {
				patientRace.PatientRaceNum=DbHelper.GetNextOracleKey("patientrace","PatientRaceNum");
				int loopcount=0;
				while(loopcount<100){
					try {
						return Insert(patientRace,true);
					}
					catch(Oracle.DataAccess.Client.OracleException ex){
						if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
							patientRace.PatientRaceNum++;
							loopcount++;
						}
						else{
							throw ex;
						}
					}
				}
				throw new ApplicationException("Insert failed.  Could not generate primary key.");
			}
			else {
				return Insert(patientRace,false);
			}
		}
        private void BuildAlbertSmithPatient()
        {
            PersonName name = new PersonNameBuilder ()
                .WithFirst ( "Albert" )
                .WithLast ( "Smith" )
                .Build ();
            PatientProfile profile = new PatientProfileBuilder ()
                .WithBirthDate ( DateTime.Parse ( "5/10/1971" ) )
                .WithPatientGender ( MaleGender )
                .Build ();
            AlbertSmithPatient = new Patient ( SafeHarborAgency, name, profile );
            AlbertSmithPatient.UpdateUniqueIdentifier("albertsmith");

            var address = new AddressBuilder ()
                .WithFirstStreetAddress ( "14235 South St" )
                .WithCityName ( "Baltimore" )
                .WithPostalCode ( new PostalCode ( "21075" ) )
                .WithStateProvince ( MarylandStateProvince )
                .Build ();

            PatientAddress albertSmithAddress = new PatientAddressBuilder ()
                .WithPatientAddressType ( HomePatientAddressType )
                .WithAddress(address)
                .Build ();

            AlbertSmithPatient.AddAddress ( albertSmithAddress );

            AlbertSmithPatient.AddPhoneNumber ( new PatientPhone ( HomePatientPhoneType, "555-255-5454" ) );

            var patientRace = new PatientRace ( WhiteRace );
            AlbertSmithPatient.AddPatientRace ( patientRace );
            AlbertSmithPatient.SetPrimaryRace(WhiteRace);

            AlbertSmithPatient.AddAlias ( new PatientAlias ( NicknamePatientAliasType, "Al-bear" ) );

            AlbertSmithPatient.AddPatientDisability ( new PatientDisability ( DeafDisability ) );

            Session.SaveOrUpdate ( AlbertSmithPatient );
        }
        private void BuildTaddYoungPatient()
        {
            PersonName name = new PersonNameBuilder ()
                .WithFirst ( "Tadd" )
                .WithLast ( "Young" )
                .Build ();
            PatientProfile profile = new PatientProfileBuilder ()
                .WithBirthDate ( DateTime.Parse ( "5/10/2000" ) )
                .WithPatientGender ( MaleGender )
                .Build ();
            TaddYoungPatient = new Patient ( SafeHarborAgency, name, profile );
            TaddYoungPatient.UpdateUniqueIdentifier("taddyoung");

            TaddYoungPatient.AddPhoneNumber ( new PatientPhone ( HomePatientPhoneType, "555-255-5454" ) );

            var patientRace = new PatientRace ( WhiteRace );
            TaddYoungPatient.AddPatientRace ( patientRace );
            TaddYoungPatient.SetPrimaryRace ( WhiteRace );

            TaddYoungPatient.AddAlias ( new PatientAlias ( NicknamePatientAliasType, "Tadd" ) );

            TaddYoungPatient.AddPatientDisability ( new PatientDisability ( DeafDisability ) );

            Session.SaveOrUpdate ( TaddYoungPatient );
        }
Example #23
0
        /// <summary>
        /// Adds the patient race.
        /// </summary>
        /// <param name="patientRace">The patient race.</param>
        public virtual void AddPatientRace(PatientRace patientRace)
        {
            Check.IsNotNull(patientRace, "patient race is required.");

            DomainRuleEngine.CreateRuleEngine<Patient, PatientRace> ( this, () => AddPatientRace )
                .WithContext ( patientRace )
                .Execute (
                    () =>
                        {
                            patientRace.Patient = this;
                            _races.Add ( patientRace );
                            NotifyItemAdded ( () => Races, patientRace );
                        } );
        }
Example #24
0
        /// <summary>
        /// Removes the patient race.
        /// </summary>
        /// <param name="patientRace">The patient race.</param>
        public virtual void RemovePatientRace(PatientRace patientRace)
        {
            Check.IsNotNull(patientRace, "patient race is required.");

            if (PrimaryPatientRace == patientRace)
            {
                PrimaryPatientRace = null;
            }

            _races.Delete(patientRace);
            NotifyItemRemoved(() => Races, patientRace);
        }
		///<summary>Updates one PatientRace in the database.</summary>
		public static void Update(PatientRace patientRace){
			string command="UPDATE patientrace SET "
				+"PatNum        =  "+POut.Long  (patientRace.PatNum)+", "
				+"Race          =  "+POut.Int   ((int)patientRace.Race)+", "
				+"CdcrecCode    = '"+POut.String(patientRace.CdcrecCode)+"' "
				+"WHERE PatientRaceNum = "+POut.Long(patientRace.PatientRaceNum);
			Db.NonQ(command);
		}
 ///<summary>Inserts one PatientRace into the database.  Returns the new priKey.</summary>
 public static long Insert(PatientRace patientRace)
 {
     return(Insert(patientRace, false));
 }
		///<summary>Updates one PatientRace 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(PatientRace patientRace,PatientRace oldPatientRace){
			string command="";
			if(patientRace.PatNum != oldPatientRace.PatNum) {
				if(command!=""){ command+=",";}
				command+="PatNum = "+POut.Long(patientRace.PatNum)+"";
			}
			if(patientRace.Race != oldPatientRace.Race) {
				if(command!=""){ command+=",";}
				command+="Race = "+POut.Int   ((int)patientRace.Race)+"";
			}
			if(patientRace.CdcrecCode != oldPatientRace.CdcrecCode) {
				if(command!=""){ command+=",";}
				command+="CdcrecCode = '"+POut.String(patientRace.CdcrecCode)+"'";
			}
			if(command==""){
				return;
			}
			command="UPDATE patientrace SET "+command
				+" WHERE PatientRaceNum = "+POut.Long(patientRace.PatientRaceNum);
			Db.NonQ(command);
		}