public Patient GetInfoFromWebService(string voterId) { Patient aPatient = new Patient(); using ( XmlReader reader = XmlReader.Create(@"http://nerdcastlebd.com/web_service/voterdb/index.php/voters/voter/" + HttpUtility.UrlEncode(voterId))) { while (reader.Read()) { if (reader.IsStartElement()) { switch (reader.Name) { case "name": aPatient.Name = reader.ReadString(); break; case "address": aPatient.Address = reader.ReadString(); break; case "date_of_birth": DateTime birthDay = Convert.ToDateTime(reader.ReadString()); DateTime today = DateTime.Today; int age = (today - birthDay).Days/365; aPatient.Age = age; break; } } } return aPatient; } }
public Patient Find(long voterId) { string query = "SELECT * FROM tbl_patient WHERE voter_id='" + voterId + "'"; ASqlCommand = new SqlCommand(query, ASqlConnection); ASqlConnection.Open(); ASqlDataReader = ASqlCommand.ExecuteReader(); if (ASqlDataReader.HasRows) { Patient aPatient = new Patient(); ASqlDataReader.Read(); aPatient.Id = (int)ASqlDataReader["id"]; aPatient.VoterId = (long)ASqlDataReader["voter_id"]; ASqlDataReader.Close(); ASqlCommand.Dispose(); ASqlConnection.Close(); return aPatient; } else { ASqlDataReader.Close(); ASqlCommand.Dispose(); ASqlConnection.Close(); return null; } }
public List<Patient> GetTotalPatientList(DateTime startDateTime, DateTime endDateTime, int diseaseId) { string query = "SELECT district_id AS districtId,patient_id AS patientId from v_disease_report WHERE disease_id='" + diseaseId + "' and date between '" + startDateTime + "' and '" + endDateTime + "'"; ASqlConnection.Open(); ASqlCommand = new SqlCommand(query, ASqlConnection); ASqlDataReader = ASqlCommand.ExecuteReader(); List<Patient> patients = new List<Patient>(); while (ASqlDataReader.Read()) { Patient aPatient = new Patient(); aPatient.Id = Convert.ToInt16(ASqlDataReader["patientId"]); aPatient.DistrictId = Convert.ToInt16(ASqlDataReader["districtId"]); patients.Add(aPatient); } ASqlDataReader.Close(); ASqlConnection.Close(); return patients; }
public void SaveService(Patient aPatient) { aPatientDbGateway.SaveService(aPatient); }
public void SaveService(Patient aPatient) { int patientId; Patient patient = Find(aPatient.VoterId); if (patient == null) { Save(aPatient); patientId = Find(aPatient.VoterId).Id; } else { patientId = patient.Id; } string query = "INSERT INTO tbl_service_taken VALUES ('" + patientId + "')"; ASqlConnection.Open(); ASqlCommand = new SqlCommand(query, ASqlConnection); ASqlCommand.ExecuteNonQuery(); ASqlConnection.Close(); }
public int Save(Patient aPatient) { string query = "INSERT INTO tbl_patient VALUES ('" + aPatient.VoterId + "', '" + aPatient.DistrictId + "')"; ASqlConnection.Open(); ASqlCommand = new SqlCommand(query, ASqlConnection); int rowAffected = ASqlCommand.ExecuteNonQuery(); ASqlConnection.Close(); return rowAffected; }
protected void saveButton_Click(object sender, EventArgs e) { Patient aPatient = new Patient(); var diseaseList = diseaseName.Value; diseaseName.Value = ""; string[] disease = diseaseList.Split(','); var medicineList = medicineName.Value; medicineName.Value = ""; string[] medicine = medicineList.Split(','); var doseList = medicineDose.Value; medicineDose.Value = ""; string[] dose = doseList.Split(','); var doseRuleList = medicineDoseType.Value; medicineDoseType.Value = ""; string[] doseRule = doseRuleList.Split(','); var quantityList = medicineQuantityGiven.Value; medicineQuantityGiven.Value = ""; string[] quantity = quantityList.Split(','); var noteList = notes.Value; notes.Value = ""; string[] note = noteList.Split(','); string[] address = addressTextBox.Text.Split(' '); string districtName = address[address.Length - 1]; aPatient.VoterId = Convert.ToInt64(voterIdTextBox.Text); aPatient.DistrictId = aDistrictAndThanaManager.FindDistrict(districtName).Id; aPatientManager.SaveService(aPatient); Treatment aTreatment = new Treatment(); aTreatment.ServiceTakenId = aPatientManager.GetServiceTakenId(); aTreatment.Observation = observationTextBox.Text; aTreatment.ServiceDate = DateTime.Parse(dateTextBox.Value); aTreatment.DoctorId = Convert.ToInt32(doctorDropDownList.SelectedValue); aTreatment.CenterId = Convert.ToInt32(Session["CenterId"]); for (int i = 0; i < disease.Length - 1; i++) { Disease aDisease = aDiseaseManager.Find(disease[i]); aTreatment.DiseaseId = aDisease.Id; Medicine aMedicine = aMedicineManager.Find(medicine[i]); aTreatment.MedicineId = aMedicine.Id; aTreatment.Dose = dose[i]; aTreatment.DoseType = doseRule[i]; aTreatment.Quantity = Convert.ToInt32(quantity[i]); aTreatment.Note = note[i]; aTreatmentManager.SaveTreatment(aTreatment); MedicineStockInCenter aMedicineStockInCenter = new MedicineStockInCenter(); aMedicineStockInCenter.MedicineId = aTreatment.MedicineId; aMedicineStockInCenter.Quantity = aTreatment.Quantity; aMedicineStockInCenter.CenterId = aTreatment.CenterId; aMedicineManager.DeductMedicineFromCenter(aMedicineStockInCenter); } }