public PatientForm() { InitializeComponent(); patienModel = PatientModel.patientModel; patienModel.patientform = this; DataHandler.IncomingErrorEvent += HandleError; //initialize event }
public ActionResult CreateFromRegistration() { ViewBag.ActionType = ClinicEnums.Action.Add; ViewBag.Response = new PatientResponse(); ViewBag.Relation = BindDropDownRelation(); ViewBag.PatientType = BindDropDownPatientType(); ViewBag.EmpReff = BindDropDownEmployeeReff(); ViewBag.Marital = BindDropDownMaritalStatus(); ViewBag.City = BindDropDownCity(); ViewBag.ReffRelation = BindDropDownReffRelation(); PatientModel model = new PatientModel { IsFromRegistration = true }; return(View("CreateOrEditPatient", model)); }
public PatientModel GETeditMethod(int?id) { PatientModel rm = new PatientModel(); using (var parepo = new PatientRepository()) { if (id.HasValue && id != 0) { Patient _patient = parepo.GetById(id.Value); rm.userId = _patient.PatientId; rm.Email = _patient.Email; rm.FullName = _patient.FullName; rm.Age = _patient.Age; rm.Surname = _patient.Surname; rm.Title = _patient.Title; rm.MaritalStatus = _patient.MaritalStatus; rm.DOB = _patient.DOB; rm.Sex = _patient.Sex; rm.Address1 = _patient.Address1; rm.Address2 = _patient.Address2; rm.Address3 = _patient.Address3; rm.PostalCode = _patient.PostalCode; rm.Telephone = _patient.Telephone; rm.Employer = _patient.Employer; rm.EmployerTelephone = _patient.EmployerTelephone; rm.Occupation = _patient.Occupation; rm.NationalId = _patient.NationalId; rm.Status = _patient.Status; rm.PatientAllergy = _patient.PatientAllergy; rm.MedicalAidName = _patient.MedicalAidName; rm.MedicalAidNo = _patient.MedicalAidNo; rm.resultFile = _patient.File; rm.FileName = _patient.FileName; rm.FileType = _patient.FileType; foreach (var item in _patient.PatientAddresses.ToList()) { PatientAddressModel padd = new PatientAddressModel(); padd.Address = item.Address; rm.PatientAddresses.Add(padd); } } return(rm); } }
public async System.Threading.Tasks.Task ShouldValidateAgeAsync() { string hdid = "1234567890123456789012345678901234567890123456789012"; Mock <IConfigurationService> configServiceMock = new Mock <IConfigurationService>(); configServiceMock.Setup(s => s.GetConfiguration()).Returns(new ExternalConfiguration() { WebClient = new WebClientConfiguration() { MinPatientAge = 19 } }); PatientModel patientModel = new PatientModel() { Birthdate = DateTime.Now.AddYears(-15) }; Mock <IPatientService> patientServiceMock = new Mock <IPatientService>(); patientServiceMock.Setup(s => s.GetPatient(hdid, PatientIdentifierType.HDID)).ReturnsAsync(new RequestResult <PatientModel> { ResultStatus = ResultType.Success, ResourcePayload = patientModel }); IUserProfileService service = new UserProfileService( new Mock <ILogger <UserProfileService> >().Object, new Mock <IUserProfileDelegate>().Object, new Mock <IUserPreferenceDelegate>().Object, new Mock <IEmailDelegate>().Object, new Mock <IMessagingVerificationDelegate>().Object, configServiceMock.Object, new Mock <IEmailQueueService>().Object, new Mock <ILegalAgreementDelegate>().Object, new Mock <ICryptoDelegate>().Object, new Mock <INotificationSettingsService>().Object, new Mock <IMessagingVerificationDelegate>().Object, patientServiceMock.Object ); PrimitiveRequestResult <bool> expected = new PrimitiveRequestResult <bool>() { ResultStatus = ResultType.Success, ResourcePayload = false }; PrimitiveRequestResult <bool> actualResult = await service.ValidateMinimumAge(hdid); Assert.Equal(ResultType.Success, actualResult.ResultStatus); Assert.Equal(expected.ResourcePayload, actualResult.ResourcePayload); }
public string SavePatientDetails(PatientModel model) { Int64 RecordID = 0; if (model.DOBStr != null) { model.DOB = new DateTime(Convert.ToInt32(model.DOBStr.Split('/')[2]), Convert.ToInt32(model.DOBStr.Split('/')[1]), Convert.ToInt32(model.DOBStr.Split('/')[0])); RecordID = model.SavePatientDetails(); } if (RecordID > 0) { } return(""); }
private static PatientModel createSinglePatientModel() { var testModel = new PatientModel() { Id = Guid.NewGuid(), FirstName = "John", LastName = "Hu", Gender = Gender.male, DateOfBirth = new DateTime(1992, 2, 14), Email = "*****@*****.**", Phone = "0425789632", CreateTime = DateTime.Now, UpdateTime = DateTime.Now, }; return(testModel); }
public void UpdatePatient(PatientModel patientModel) { var patient = context.Patients.FirstOrDefault(x => x.Id == patientModel.Id); if (patient == null) { return; } patient.FullName = patientModel.FullName; patient.MedData = patientModel.MedData; patient.PassData = patientModel.PassData; patient.Photo = patientModel.Photo == null && patient.Photo != null ? patient.Photo : patientModel.Photo; patient.Sex = patientModel.IsMan == true; context.Patients.Update(patient); context.SaveChanges(); }
public Task <string> Save(PatientModel aModel) { try { const string msg = ""; //Image string regNo = GetAutoIncrementNumberFromStoreProcedure(1); const string query = @"INSERT INTO tbl_PATIENT_REGISTRATION (PtRegNo, Name, MobileNo, DateOfBirth, GenderId, FatherName, MotherName, SpouseName, Address, ReligionId, Area, Occupation, BloodGroupId, NationalIdNo, PassportNo, IntroducerId, IntroducerName, BranchId, UserName) VALUES (@PtRegNo, @Name, @MobileNo, @DateOfBirth, @GenderId, @FatherName, @MotherName, @SpouseName, @Address, @ReligionId, @Area, @Occupation, @BloodGroupId, @NationalIdNo, @PassportNo, @IntroducerId, @IntroducerName, @BranchId, @UserName)"; Con.Open(); var cmd = new SqlCommand(query, Con); cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@PtRegNo", regNo); cmd.Parameters.AddWithValue("@Name", aModel.PtName); cmd.Parameters.AddWithValue("@MobileNo", aModel.PtMobileNo); cmd.Parameters.AddWithValue("@DateOfBirth", aModel.PtDob.ToString("yyyy-MM-dd")); cmd.Parameters.AddWithValue("@GenderId", aModel.PtGendeId); cmd.Parameters.AddWithValue("@FatherName", aModel.PtFatherName); cmd.Parameters.AddWithValue("@MotherName", aModel.PtMotherName); cmd.Parameters.AddWithValue("@SpouseName", aModel.PtSpooseName); cmd.Parameters.AddWithValue("@Address", aModel.PtAddress); cmd.Parameters.AddWithValue("@ReligionId", aModel.PtReligionId); cmd.Parameters.AddWithValue("@Occupation", aModel.PtOccupation); cmd.Parameters.AddWithValue("@BloodGroupId", aModel.PtBloodGroupId); cmd.Parameters.AddWithValue("@NationalIdNo", aModel.PtNationalIdNo); cmd.Parameters.AddWithValue("@PassportNo", aModel.PtPassportNo); cmd.Parameters.AddWithValue("@IntroducerId", aModel.PtIntroducerId); cmd.Parameters.AddWithValue("@IntroducerName", aModel.PtIntroducerName); cmd.Parameters.AddWithValue("@Area", aModel.PtArea); cmd.Parameters.AddWithValue("@UserName", aModel.UserName); cmd.Parameters.AddWithValue("@BranchId", ReturnFieldValueOpenCon("tbl_USER_BRANCH_INFO", "UserName='******'", "BranchId"));//System.Web.HttpContext.Current.Session["BranchId"]); cmd.ExecuteNonQuery(); Con.Close(); return(Task.FromResult <string>("Save uccess")); } catch (Exception exception) { if (Con.State == ConnectionState.Open) { Con.Close(); } return(Task.FromResult(exception.Message)); } }
/// <summary> /// 刷新界面数据 /// </summary> public void RefreshData() { // 在刷新数据时可能是定时器刷新也可能是消息指令刷新,为了防止数据冲突,使用对象锁 lock (this.locker) { try { // 每次刷新时从数据库中获取患者信息 MED_PAT_INFO patInfo = PatInfoService.ClientInstance.GetCurPatientInfo(ExtendAppContext.Current.OperDeptCode, ExtendAppContext.Current.OperRoomNo); this.CurPatientModel = PatientModel.CreateModel(patInfo); if (null != this.CurPatientModel) { this.IsSelectedBorderVisibility = Visibility.Visible; ExtendAppContext.Current.PatientInformationExtend = this.CurPatientModel.Med_Pat_Info; //设置状态灯亮 int lightIndex = OperationStatusHelper.GetOperStatusIndex(ExtendAppContext.Current.PatientInformationExtend.OPER_STATUS_CODE); KeyBoardStateCache.KeyBoard.OpenSecondKeyBoardAllLed(lightIndex); // 刷新患者的体征数据 this.RefreshVitalSignList(); // 刷新监护仪和麻醉机的图标显示 this.RefreshMonitor(); } else { this.IsSelectedBorderVisibility = Visibility.Collapsed; ExtendAppContext.Current.PatientInformationExtend = null; //关闭状态灯 if (KeyBoardStateCache.KeyBoard != null) { KeyBoardStateCache.KeyBoard.CloseSecondKeyBoardAllLed(); } } // 设置图片显示或隐藏 this.SetOperationVisibility(); // 刷新手术时长信息 this.RefreshOperationLength(); } catch (Exception ex) { Logger.Error("获取术中信息异常", ex); this.ShowMessageBox("获取术中信息发生异常。", MessageBoxButton.OK, MessageBoxImage.Error); } } }
public IActionResult Put(long id, [FromBody] PatientModel patientModel) { if (patientModel == null) { return(BadRequest("Employee is null.")); } var patient = new Patient(); Patient patientToUpdate = _dataRepository.Get(id); if (patientToUpdate == null) { return(NotFound("The Patient record couldn't be found.")); } _dataRepository.Update(patientToUpdate, patient); return(NoContent()); }
public void GetById_Test() { // Arrange TestKolgraphEntities context = new TestKolgraphEntities(); var repository = new PatientRepository(context); var phoneNumberService = new PatientPhoneNumberService(); var hitchayvutService = new HitchayvutService(); var service = new PatientService(repository, phoneNumberService, hitchayvutService); int id = 1; // Act PatientModel result = service.GetById(id); // Assert Assert.IsNotNull(result); Assert.AreEqual(id, result.Id); }
public async Task <PatientModel> RegisterPatient(PatientModel model) { try { var emailExists = await _userManager.FindByNameAsync(model.Username); if (emailExists != null) { throw new ValidationException("Email Already exists."); } var userDetails = new User() { UserName = model.Username, Email = model.Email, FirstName = model.FirstName, LastName = model.LastName, PhoneNumber = model.PhoneNumber, EmailConfirmed = true, IsDeleted = false, EmailNotification = true, SmsNotification = true }; var result = await _userManager.CreateAsync(userDetails, "PatientLogin123!"); if (!result.Succeeded) { throw new ValidationException("Registration failed."); } await _userManager.AddToRoleAsync(userDetails, "patient"); var patient = model.MapTo <Patient>(); patient.UserId = userDetails.Id; _dbContext.Patients.Add(patient); await _dbContext.SaveChangesAsync(); var jwt = await _jwtTokenGenerator.GenerateToken(userDetails); model.Token = jwt; return(model); } catch (Exception ex) { return(null); } }
public ActionResult CreateOrEditPatient() { PatientResponse _response = new PatientResponse(); if (Request.QueryString["id"] != null) { var request = new PatientRequest { Data = new PatientModel { Id = long.Parse(Request.QueryString["id"].ToString()), } }; if (Session["UserLogon"] != null) { request.Data.Account = (AccountModel)Session["UserLogon"]; } PatientResponse resp = new PatientHandler(_unitOfWork, _context).GetDetail(request); PatientModel _model = resp.Entity; ViewBag.Response = _response; ViewBag.Relation = BindDropDownRelation(); ViewBag.PatientType = BindDropDownPatientType(); ViewBag.City = BindDropDownCity(); ViewBag.EmpReff = BindDropDownEmployeeReff(); ViewBag.Marital = BindDropDownMaritalStatus(); ViewBag.ReffRelation = BindDropDownReffRelation(); ViewBag.ActionType = ClinicEnums.Action.Edit; return(View(_model)); } else { ViewBag.ActionType = ClinicEnums.Action.Add; ViewBag.Response = _response; ViewBag.Relation = BindDropDownRelation(); ViewBag.PatientType = BindDropDownPatientType(); ViewBag.EmpReff = BindDropDownEmployeeReff(); ViewBag.Marital = BindDropDownMaritalStatus(); ViewBag.City = BindDropDownCity(); ViewBag.ReffRelation = BindDropDownReffRelation(); return(View("CreateOrEditPatient", new PatientModel())); } }
public string Post([FromBody] PatientModel obj) { var context = new ValidationContext(obj, null, null); //fill the errors var result = new List <ValidationResult>(); var isValid = Validator.TryValidateObject(obj, context, result, true); if (result.Count == 0) { PatientDAL dal = new PatientDAL(ConStr); dal.Database.EnsureCreated(); // ensure table is created or not dal.Add(obj); //inmemory dal.SaveChanges(); // pysical commit save to database List <PatientModel> recs = dal.PatientModels.Include(pat => pat.problems). ToList <PatientModel>(); //List<DiseaseModel> dic = dal.Diseas.ToList<DiseaseModel>(); //dynamic dics = new ExpandoObject(); //dics.PatientModel = recs; //dics.DiseaseModel = dic; var json = JsonConvert.SerializeObject(recs, Formatting.None, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }); return(json); // return StatusCode(200, recs); } else { var json = JsonConvert.SerializeObject(result, Formatting.None, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }); // return StatusCode(500, result); return(json); } }
private PatientModel GetDemoItem(bool isNew) { PatientModel item = new PatientModel() { Id = 1, LastName = "רוזנשטרק", FirstName = "פנינה", Gender = new GenderModel { Id = 5 }, Street = "היסמין", HouseNumber = "11א ", ApartmentNumber = "", ZipCode = "99591 ", City = new CityModelConcise { Id = 1 }, EmailAddress = "", Zehut = "313663429", Kupah = new KupahModelConcise { Id = 1 }, Dob = null, OpenDate = new System.DateTime(), LastPureToneAppointment = new AppointmentModel { Id = 1 }, Branch = new BranchModelConcise { Id = 1 }, ReferredByType = new ReferredByTypeModelConcise { Id = 1 }, IsCurrent = true, Notes = "", NotesRtf = "" }; if (!isNew) { item.Id = 1; } return(item); }
public void Put_Test() { // Arrange var mockService = new Mock <IPatientService>(); var controller = new PatientController(mockService.Object); PatientModel model = GetDemoItem(false); int userId = 1; // Act IHttpActionResult actionResult = controller.Put(model, userId); var contentResult = actionResult as NegotiatedContentResult <PatientModel>; // Assert Assert.IsNotNull(contentResult); Assert.AreEqual(HttpStatusCode.Accepted, contentResult.StatusCode); Assert.IsNotNull(contentResult.Content); Assert.AreEqual(model.Id, contentResult.Content.Id); }
public void SavePatient(PatientModel patient) { if (patient.Id == 0) { adminContext.Patients.Add(patient); } else { PatientModel dbEntry = adminContext.Patients.FirstOrDefault(p => p.Id == patient.Id); if (dbEntry != null) { dbEntry.FirstName = patient.FirstName; dbEntry.LastName = patient.LastName; dbEntry.PESEL = patient.PESEL; } } adminContext.SaveChanges(); }
/// <summary> /// 构造方法 /// </summary> public OperationJumpViewModel(MED_PAT_INFO patModel, RichTextBox rtb) { if (patModel != null) { this.CurPatientModel = PatientModel.CreateModel(patModel); OperStatus = OperationStatusHelper.OperationStatusToString(OperationStatus.IsReady); this.MedOperatingRoomDict = DictService.ClientInstance.GetOperatingRoomList().Where(x => x.DEPT_CODE.Equals(ExtendAppContext.Current.OperDeptCode) && x.BED_TYPE.Equals(ExtendAppContext.Current.EventNo)).ToList(); this.CbOperatingRoomSourceList = this.MedOperatingRoomDict.Where(x => x.BED_TYPE == ExtendAppContext.Current.EventNo && (x.PATIENT_ID == null || string.IsNullOrEmpty(x.PATIENT_ID))).ToList(); this.rtbResaon = rtb; this.OperRoomNo = CurPatientModel.OperRoomNo; this.LoadOperStatusList(); // 注册按钮命令 this.RegisterCommand(); // 设置界面显示的警告消息 this.ResetWarningMessage(); } }
public ActionResult Save(PatientModel patientModel) { try { Patient patient = _document.SavePatient(Mappings.MapPatient(patientModel)); if (patient != null) { //PatientModel model = Mappings.MapPatient(patient); //return View("Patient", model); Session["PatientID"] = patient.PatientId; } return(RedirectToAction("Patient", "Patient", new { usertype = (int)Session["UserTypeID"] })); } catch (Exception ex) { return(View()); } }
public List <PatientModel> RetrievePatient(SQLiteDataReader rdr) { List <PatientModel> list = new List <PatientModel>(); while (rdr.Read()) { PatientModel patientObject = new PatientModel(); patientObject.Id = (int)Convert.ToInt64(rdr["Id"]); patientObject.Name = Convert.ToString(rdr["Name"]); patientObject.Age = (int)Convert.ToInt64(rdr["Age"]); patientObject.BloodGroup = Convert.ToString(rdr["BloodGroup"]); patientObject.Address = Convert.ToString(rdr["Address"]); patientObject.BedNumber = (int)Convert.ToInt64(rdr["BedNumber"]); patientObject.IcuId = (int)Convert.ToInt64(rdr["IcuId"]); list.Add(patientObject); } return(list); }
// GET: Patient/Details/5 public ActionResult Details(int id) { try { Patient patient = patientBusiness.GetById(id); if (patient == null) { return(HttpNotFound()); } return(View(PatientModel.ToModel(patient))); } catch (Exception ex) { Log.Error(ex.Message, ex); return(View()); } }
public void GeneratePatientRecipt(PatientModel model, Gender gender, List <TestSubcategory> tests, Branch branch, Contact branchcontact) { var path = Server.MapPath("/images/"); PatientRecipt recipt = new PatientRecipt(path, Session["loginusername"].ToString(), gender, model, tests, branch, branchcontact); string filename = "Recipt-" + model.Id + ".pdf"; if (!System.IO.File.Exists(Request.MapPath("/PatientsReport/") + filename)) { PdfDocument pdf = recipt.CreateDocument(); pdf.Save(Server.MapPath("/PatientsReport/") + filename); // System.IO.FileInfo fi=new System.IO.FileInfo(Request.MapPath("/PatientsReport/") + filename); // fi.Delete(); } Process.Start(Server.MapPath("/PatientsReport/") + filename); }
public void EditPatient(PatientModel patientForEdit) { List <PatientModel> allPatients = (List <PatientModel>)FindAll(); PatientModel patientForRemove = null; foreach (PatientModel patient in allPatients) { if (patient.Id == patientForEdit.Id) { patientForRemove = patient; allPatients.Add(patientForEdit); break; } } allPatients.Remove(patientForRemove); patientRepository.SaveAll(allPatients); }
public void UpdatePatient(string user, PatientModel oClass) { strSql = "UPDATE " + TABLE_PATIENT_DEPENDENT + " SET " + COLUMN_LASTNAME + " = '" + oClass.LastName.Replace("'", "''") + "', " + COLUMN_FIRSTNAME + " = '" + oClass.FirstName + "', " + COLUMN_MIDDLENAME + " = '" + oClass.MiddleName + "', " + COLUMN_DOB + " = '" + oClass.DOB.ToString("yyyy-MM-d HH:MM:ss") + "', " + COLUMN_GENDER + " = '" + oClass.Gender + "', " + COLUMN_PHONE + " = '" + oClass.ContactNo + "', " + COLUMN_EMAIL + " = '" + oClass.Email.Replace("'", "''") + "', " + COLUMN_ADDRESS + " = '" + oClass.Address.Replace("'", "''") + "', " + COLUMN_NATIONALITY + " = '" + oClass.Nationality.Replace("'", "''") + "', " + " updated_by = '" + user + "', " + " updated_date = '" + DateTime.Now.ToString("yyyy-MM-d HH:MM:ss") + "' " + " WHERE " + COLUMN_PATIENT_ID + " = '" + oClass.ID + "' "; SaveData(strSql); }
// GET: Prescription // GET: Prescription/Details/5 public ActionResult History(int?Id) { if (Id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } /*IBL bl=new bl() * bl.getpatient()*/ var patientModel = new PatientModel(); PatientViewModel patientViewModel = patientModel.GetPatient((int)Id); var prescription = prescriptionModel.GetPrescriptions(); PatientPrescriptionViewModel patientPrescription = new PatientPrescriptionViewModel(); patientPrescription.patientList = patientViewModel; patientPrescription.prescriptionList = prescription; return(View(patientPrescription)); }
private RequestDataStatus AssesPatientStatus (PatientModel patient, AnalysisRequestDataModel request) { var status = RequestDataStatus.New; if (patient != null) { if (!patient.AreEqual(request)) { status = RequestDataStatus.Dirty; } else { status = RequestDataStatus.Clean; } } return(status); }
public async Task <IActionResult> UpdatePatientInfo([FromBody] PatientModel model) { try { await _userRepository.UpdateUserData(model); return(Json( new { Success = true, Data = "ok" })); } catch (Exception exception) { return(Json(new { Success = false, exception.Message })); } }
public void updatePatient(int id, PatientModel patient) { if (Sqlcon.State == ConnectionState.Closed) { Sqlcon.Open(); SqlCommand Sqlcmd = new SqlCommand("SP_Update_Patient", Sqlcon); Sqlcmd.CommandType = CommandType.StoredProcedure; Sqlcmd.Parameters.AddWithValue("@PatientID", id); Sqlcmd.Parameters.AddWithValue("@PatientName", patient.PatientName); Sqlcmd.Parameters.AddWithValue("@PatientAddress", patient.PatientAddress); Sqlcmd.Parameters.AddWithValue("@PatientContact", patient.PatientContact); Sqlcmd.Parameters.AddWithValue("@PatientEmail", patient.PatientEmail); Sqlcmd.Parameters.AddWithValue("@ZIPCode", patient.ZIPCode); Sqlcmd.ExecuteNonQuery(); Sqlcon.Close(); } }
private void addButton_Click(object sender, RoutedEventArgs e) { PatientModel patient = new PatientModel() { PatientId = _patient.BedId + _patient.Name, IcuId = _patient.IcuId, BedId = _patient.BedId, Name = _patient.Name, Age = Int32.Parse(_patient.Age.ToString()), Address = _patient.Address, Gender = _patient.Gender, ContactNo = _patient.Contact }; var result = new PatientApiCalls().AddPatient(patient); MessageBox.Show(result); Application.Current.MainWindow.Content = new MainPage(); }
public async Task <PatientModel> Save(PatientModel newPatient) { Patient patient = await _patientRepository.GetById(newPatient.PatientId); if (patient != null) { return(null); } patient = _mapper.Map <Patient>(newPatient); Patient newPatientFromDbs = await _patientRepository.Save(patient); Log.Information("Patient Created {@newPatient}", newPatient); await PublishPatientCreated(newPatientFromDbs.PatientId); return(_mapper.Map <PatientModel>(newPatientFromDbs)); }
public ActionResult Edit(int id, PatientModel patient) { //This line was in params above // [Bind(Include = "ID,FirstName,LastName,Age,Email,PhoneNumber")] PatientModel patientModel /* if (ModelState.IsValid) * { * db.Entry(patientModel).State = EntityState.Modified; * db.SaveChanges(); * return RedirectToAction("Index"); * }*/ using (IDbConnection db = new SqlConnection(ConnectionHelper.CnnVal("DefaultConnection"))) { db.Execute("dbo.Patient_UpdateDetails @id, @firstName, @lastName, @age, @email, @phoneNumber", patient); } return(RedirectToAction("Details/" + id)); }
public ActionResult CreatePatient(PatientModel model) { if (ModelState.IsValid) { using (var db = new MainDbContext()) { var queryUser = db.Users.FirstOrDefault(u => u.Username == model.Users.Username); if (queryUser == null) { var encryptedPassword = CustomEnrypt.Encrypt(model.Users.Password); var patient = db.Patient.Create(); var address = db.Address.Create(); var contact = db.Contact.Create(); var user = db.Users.Create(); var role = db.Role.Create(); patient.FirstName = model.Patient.FirstName; patient.MiddleName = model.Patient.MiddleName; patient.LastName = model.Patient.LastName; patient.Email = model.Patient.Email; patient.DateBirth = model.Patient.DateBirth; patient.Sex = model.Patient.Sex; patient.MaritalStatus = model.Patient.MaritalStatus; patient.HoursWorked = model.Patient.HoursWorked; patient.CompanyName = model.Patient.CompanyName; patient.Occupation = model.Patient.Occupation; address.AddressType = model.Address.AddressType; address.City = model.Address.City; address.Province = model.Address.Province; address.Zipcode = model.Address.Zipcode; user.Username = model.Users.Username; user.Password = encryptedPassword; user.Password = encryptedPassword; contact.MobileNo = model.Contact.MobileNo; contact.PhoneNo = model.Contact.PhoneNo; db.Address.Add(address); db.Contact.Add(contact); db.Role.Add(role); db.SaveChanges(); user.Key_Role = role.Id; db.Users.Add(user); db.SaveChanges(); patient.Key_Address = address.Id; patient.Key_Contact = contact.Id; db.Patient.Add(patient); db.SaveChanges(); return RedirectToAction("CreatePatient", "FDR"); } else { return RedirectToAction("CreatePatient", "FDR"); } } } else { ModelState.AddModelError("", "One or more fields have been"); } return View(); }
public ActionResult PatientRegistration(Patient model, string command, HttpPostedFileBase Files) { ArogyaParivarEntities context = new ArogyaParivarEntities(); try { try { ObjectParameter outParm = new ObjectParameter("callid", typeof(string)); context.SP_TokenGenration(outParm); int tokennumber = Convert.ToInt32(outParm.Value); ObjectParameter outParm1 = new ObjectParameter("callid", typeof(string)); context.SP_GenarateArogyaID(outParm1); int intarogyaID = Convert.ToInt32(outParm1.Value); string arogyaID = "A" + intarogyaID; var webCamePath = ConfigurationSettings.AppSettings["WebCampath"]; if (command.Equals("Reset")) { return RedirectToAction("PatientRegistration"); } else { var fileName = ""; if (Request.Files.Count > 0 && Request.Files[0].ContentLength > 0) { var file = Request.Files[0]; if (file != null && file.ContentLength > 0) { fileName = Path.GetFileName(file.FileName); var path = Path.Combine(Server.MapPath(ConfigurationSettings.AppSettings["DocumentUploadPath"]), fileName); file.SaveAs(path); } T_RegUpload upload = new T_RegUpload() { Active = true, ArogyaID = arogyaID, CreateDate = DateTime.Now, FileName = fileName, UserID = Convert.ToInt32(Session["UserID"]) }; context.T_RegUpload.Add(upload); context.SaveChanges(); } PatientModel book = new PatientModel() { PatientName = model.PatientName, ArogyaID = arogyaID, Surname = model.Surname, Age = model.Age, AgeType = model.Cal, Gender = model.Gender, AadharID = model.AadharID, Address = model.Address, ContactNo = model.ContactNo, Village = Convert.ToInt64(Request.Form["Village"]), Town = Request.Form["Mandal"].ToString(), RefBy = Convert.ToInt32(Request.Form["RefBy"]), RefName = model.RefName, Consent = true, District = Convert.ToInt32(Request.Form["city"].ToString()), Sate = model.Sate, }; T_Token tokn = new T_Token() { ArogyaID = arogyaID, Token_Number = tokennumber, Tokem_Date = DateTime.Now }; context.T_Token.Add(tokn); context.SaveChanges(); patientBll.Save(book); return RedirectToAction("PrintCard", new { ArogyaID = arogyaID }); } } catch { return View(model); } } catch { return View(model); } }