private static void InsertPatientRecord(Patient patient,string connection ) { }
private static void ImportDemographics() { string patientID = string.Empty; string firstName = string.Empty; string lastName = string.Empty; string Middle = string.Empty; string dateOfBirth = string.Empty; string age = string.Empty; string sex = string.Empty; string address1 = string.Empty; string address2 = string.Empty; string city = string.Empty; string state = string.Empty; string zip = string.Empty; string phone = string.Empty; StreamReader importFile = null; string line = string.Empty; importFile = File.OpenText("E:\\backups\\demographics.csv"); while ((line = importFile.ReadLine()) != null) { string[] demographics = line.Split(','); patientID = StripCharacters(demographics[0]); firstName = StripCharacters(demographics[1]); lastName = StripCharacters(demographics[2]); Middle = StripCharacters(demographics[3]); dateOfBirth = StripCharacters(demographics[6]); age = StripCharacters(demographics[7]); sex = StripCharacters(demographics[8]); address1 = StripCharacters(demographics[10]); address2 = StripCharacters(demographics[11]); city = StripCharacters(demographics[12]); state = StripCharacters(demographics[13]); zip = StripCharacters(demographics[14]); phone = StripCharacters(demographics[15]); Patient patient = new Patient(); patient.PatientID = patientID; patient.FirstName = firstName; patient.LastName = lastName; patient.Middle = Middle; patient.Address1 = address1; patient.Address2 = address2; patient.City = city; patient.State = state; patient.Zip = zip; patient.Phone = phone; patient.DateOfBirth = dateOfBirth; patient.Age = age; patient.Sex = sex; InsertPatient(patient,connection); } }
private static void InsertPatient(Patient patient, string connection) { try { using (SqlConnection db = new SqlConnection(connection)) { string query = "INSERT INTO [Patients](" + " [PatientID],[FirstName],[Middle],[LastName],[Address1],[Address2],[City]" + " ,[State],[Zip],[Phone],[Sex],[DateOfBirth],[Age]" + " )" + " VALUES(" + " @PatientID,@FirstName,@Middle,@LastName,@Address1,@Address2,@City" + " ,@State,@Zip,@Phone,@Sex,@DateOfBirth,@Age"; int rowsAffectd = db.Execute(query, new { @PatientID = patient.PatientID, @FirstName = patient.FirstName, @Middle = patient.Middle, @LastName = patient.LastName, @Address1 = patient.Address1, @Address2 = patient.Address2, @City = patient.City, @State = patient.State, @Zip = patient.Zip, @Phone = patient.Phone, @Sex = patient.Sex, @DateOfBirth = patient.DateOfBirth, @Age = patient.Age } ); int rr = rowsAffectd; } // File.Copy(file.FullName, "E:\\temp\\" + temp[2]); } catch (Exception er) { string s1 = er.ToString(); //Log.LogMessage(er.ToString()); //return patients; } }