public StudyPopulation GetStudyPopulationByID(int id, string lang = "en") { StudyPopulation studypopulation = databasePlaceholder.Get(id, lang); if (studypopulation == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } return(studypopulation); }
//END - 7 MedicalConditionByProtocol 20170209 //BEGIN - 8 GetAllStudyPopulationByProtocol 20170209 // This function is called by GetAllProtocol to populate the list (collection list) of associated study populaiton(s) to a particular Protocol. public List <StudyPopulation> GetAllStudyPopulationByProtocol(int protocolId) { var items = new List <StudyPopulation>(); string commandText = "SELECT MC.STUDY_POPULATION_ID, "; if (this.Lang != null && this.Lang.Equals("fr")) { commandText += " STUDY_POPULATION_FR AS STUDY_POPULATION"; } else { commandText += " STUDY_POPULATION_EN AS STUDY_POPULATION"; } commandText += " FROM CTA_OWNER.STUDY_POPULATION MC, CTA_OWNER.CTA_STUDY_POPULATION CMC"; commandText += " WHERE CMC.STUDY_POPULATION_ID = MC.STUDY_POPULATION_ID AND CMC.CTA_PROTOCOL_ID = :protocolId "; using (OracleConnection con = new OracleConnection(CtDBConnection)) { OracleCommand cmd = new OracleCommand(commandText, con); cmd.Parameters.Add(":protocolId", protocolId); try { con.Open(); using (OracleDataReader dr = cmd.ExecuteReader()) { if (dr.HasRows) { while (dr.Read()) { var item = new StudyPopulation(); item.study_population_id = dr["STUDY_POPULATION_ID"] == DBNull.Value ? 0 : Convert.ToInt32(dr["STUDY_POPULATION_ID"]); item.study_population = dr["STUDY_POPULATION"] == DBNull.Value ? string.Empty : dr["STUDY_POPULATION"].ToString().Trim(); items.Add(item); } } } } catch (Exception ex) { string errorMessages = string.Format("DbConnection.cs - GetAllStudyPopulationByProtocol()"); ExceptionHelper.LogException(ex, errorMessages); } finally { if (con.State == ConnectionState.Open) { con.Close(); } } } return(items); }
public StudyPopulation GetStudyPopulationById(int id) { var studypop = new StudyPopulation(); string commandText = "SELECT STUDY_POPULATION_ID, "; if (this.Lang != null && this.Lang.Equals("fr")) { commandText += " STUDY_POPULATION_FR AS STUDY_POPULATION"; } else { commandText += " STUDY_POPULATION_EN AS STUDY_POPULATION"; } commandText += " FROM CTA_OWNER.STUDY_POPULATION WHERE STUDY_POPULATION_ID = :id "; using (OracleConnection con = new OracleConnection(CtDBConnection)) { OracleCommand cmd = new OracleCommand(commandText, con); cmd.Parameters.Add(":id", id); try { con.Open(); using (OracleDataReader dr = cmd.ExecuteReader()) { if (dr.HasRows) { while (dr.Read()) { studypop.study_population_id = dr["STUDY_POPULATION_ID"] == DBNull.Value ? 0 : Convert.ToInt32(dr["STUDY_POPULATION_ID"]); studypop.study_population = dr["STUDY_POPULATION"] == DBNull.Value ? string.Empty : dr["STUDY_POPULATION"].ToString().Trim(); } } } } catch (Exception ex) { string errorMessages = string.Format("DbConnection.cs - GetStudyPopulationById()"); ExceptionHelper.LogException(ex, errorMessages); } finally { if (con.State == ConnectionState.Open) { con.Close(); } } } return(studypop); }//END - 6 Study Population 20170206