public static string GetPrimaryCarePhysicianName(string personId) { string today = DateTime.Today.ToString("yyyy-MM-dd"); StringBuilder sb = new StringBuilder(); sb.Append("SELECT Prsnl_Person_Id, Person_Prsnl_R_Cd "); sb.Append("FROM PERSON_PRSNL_RELTN "); sb.Append("WHERE Person_Id = '" + personId + "' "); sb.Append("AND Person_Prsnl_R_Cd = '1115.0000' "); sb.Append("AND active_ind = '1.0000' "); sb.Append("AND end_effective_dt_tm > '" + today + "' "); DataTable dt = new DataTable(); using (var conn = new SqlConnection(GlobalSettings.SqlConnectionString())) using (var cmd = new SqlCommand(sb.ToString(), conn)) using (var da = new SqlDataAdapter(cmd)) { cmd.CommandType = CommandType.Text; da.Fill(dt); } string result = string.Empty; if (dt.Rows.Count > 0) { //string physCode = EncntrPrsnlReltnDAL.GetAttendPhysician(dt.Rows[0]["Prsnl_Person_Id"].ToString()); Provider provider = ProviderDAL.GetProvider(dt.Rows[0]["Prsnl_Person_Id"].ToString()); result = provider.Name_Last + "," + provider.Name_First + " " + provider.Name_Middle; } return(result); }
public static string GetPrimaryCarePhysicianName(string personId) { DateTime todayDt = DateTime.Today; StringBuilder sb = new StringBuilder(); sb.Append("SELECT Prsnl_Person_Id, Person_Prsnl_R_Cd "); sb.Append("FROM BAR_PERSON_PRSNL_RELTN "); sb.Append("WHERE Person_Id = " + long.Parse(personId) + " "); sb.Append("AND Person_Prsnl_R_Cd = '1115' "); sb.Append("AND active_ind = '1' "); sb.Append("AND END_EFFECTIVE_DT_TM > '" + todayDt + "'"); DataTable dt = new DataTable(); using (var conn = new SqlConnection(GlobalSettings.SqlConnectionString())) using (var cmd = new SqlCommand(sb.ToString(), conn)) using (var da = new SqlDataAdapter(cmd)) { cmd.CommandType = CommandType.Text; da.Fill(dt); } string result = string.Empty; if (dt.Rows.Count > 0) { //string physCode = EncntrPrsnlReltnDAL.GetAttendPhysician(dt.Rows[0]["Prsnl_Person_Id"].ToString()); Provider provider = ProviderDAL.GetProvider(dt.Rows[0]["Prsnl_Person_Id"].ToString()); result = provider.Name_Last + "," + provider.Name_First + " " + provider.Name_Middle; } dt.Dispose(); return(result); }
private static Provider LoadPhysician(DataRow row) { Provider provider = ProviderDAL.GetProvider(row["prsnl_person_id"].ToString()); return(provider); }