private PatientDiseaseHistoryVM GetDiagnosisHistoryObject(int diagnosisID, PatientDiseaseHistoryVM patientDiagnosis) { StringBuilder stringJson = new StringBuilder(); using (SqlConnection dbConnection = new SqlConnection("Data Source=SQL5025.myASP.NET;Initial Catalog=DB_A0ADFA_HPCareDBContext;User Id=DB_A0ADFA_HPCareDBContext_admin;Password=hpcare2016;")) //using (SqlConnection dbConnection = new SqlConnection("Data Source= WANJIKU\\NEWSQLEXPRESS; Initial Catalog =HPCareDBContext; Integrated Security=SSPI")) { DbCommand dbCommand = dbConnection.CreateCommand(); dbCommand.CommandType = CommandType.Text; string query = " SELECT CID_Category.Description, CID_DiseaseCode.DiseaseCode, CIDCodes.Version, Diseases.Disease_start_date, Diseases.Disease_end_date, Diagnosis.ClinicRegistry_Manager_ClinicRegistryManagerId, Disease_id FROM CID_Category INNER JOIN CID_DiseaseCode ON CID_Category.CID_CategorID = CID_DiseaseCode.CIDCategory_CID_CategorID INNER JOIN CIDCodes ON CID_DiseaseCode.DiseaseCID_ID = CIDCodes.CID_DiseaseCode_DiseaseCID_ID INNER JOIN Diagnosis ON CIDCodes.CIDCOD_id = Diagnosis.Diagnosis_CID_code_CIDCOD_id INNER JOIN Diseases ON Diagnosis.Diagnosis_disease_Disease_id = Diseases.Disease_id AND Disease_is_active = '" + state + "' AND Diagnosis.Diagnosis_id = " + diagnosisID; dbCommand.CommandText = query; dbConnection.Open(); DbDataReader dbDataReader = dbCommand.ExecuteReader(); while (dbDataReader.Read()) { if (stringJson.Length != 0) { stringJson.Append(","); } patientDiagnosis.DiseaseCIDCategory = dbDataReader.GetString(0); patientDiagnosis.DiseaseCIDCode = dbDataReader.GetString(1); patientDiagnosis.Version = dbDataReader.GetString(2); patientDiagnosis.StartDate = dbDataReader.GetDateTime(3); patientDiagnosis.EndDate = GetDateSafely(dbDataReader, 4); patientDiagnosis.PhysicianName = setPhysicianName(dbDataReader.GetInt32(5)); patientDiagnosis.Disease_id = dbDataReader.GetInt32(6); } dbDataReader.Close(); } return(patientDiagnosis); }
/// <summary> /// This function return the diagnoisis history of the "current patient" /// </summary> /// <param name="patient"> /// patient is the patient being attended,the param retrives associated clinical registry /// </param> /// <returns> /// Rtuens a list of the past diseases /// </returns> public List <PatientDiseaseHistoryVM> GetDiagnosisHistory(Patient patient) { //List<PatientDiseaseHistoryaAUX> patientHistory = new List<PatientDiseaseHistoryaAUX>(); PatientDiseaseHistoryVM diseaseHistory = null; List <PatientDiseaseHistoryVM> listaBuilder = new List <PatientDiseaseHistoryVM>(); foreach (int diagnosisID in GetPatientDiagnoses(patient)) { diseaseHistory = new PatientDiseaseHistoryVM(); PatientDiseaseHistoryVM diagnosisHistory = GetDiagnosisHistoryObject(diagnosisID, diseaseHistory); if (diseaseHistory.Disease_id != 0) { listaBuilder.Add(diseaseHistory); } } return(listaBuilder); }