public HealthBodyResponse GetPatientAndPreExamineData(HealthBodyRequest request) { var response = new HealthBodyResponse(); try { if (request.Data.ForPatient == 0) { request.Data.ForPatient = _unitOfWork.RegistrationRepository.Get(x => x.FormMedicalID == request.Data.FormMedicalID).FirstOrDefault().PatientID; } var _patientData = _unitOfWork.PatientRepository.GetById(request.Data.ForPatient); var _preExamineData = _unitOfWork.FormPreExamineRepository.Get(x => x.FormMedicalID == request.Data.FormMedicalID).FirstOrDefault(); var _letterData = _unitOfWork.LetterRepository.Get(x => x.FormMedicalID == request.Data.FormMedicalID).FirstOrDefault(); if (response.Entity == null) { response.Entity = new HealthBodyLetterModel(); } response.Entity.PatientData = new PatientModel(); response.Entity.PreExamineData = new PreExamineModel(); response.Entity.Keperluan = _letterData == null?"":_letterData.Keperluan; response.Entity.Pekerjaan = _letterData == null ? "" : _letterData.Pekerjaan; response.Entity.Decision = _letterData == null?"":_letterData.Decision; response.Entity.NoSurat = _letterData == null?"": $"{_letterData.AutoNumber}/SKKBS/{DateTime.Now.Month}/{DateTime.Now.Year}"; response.Entity.PatientData = Mapper.Map <Patient, PatientModel>(_patientData); response.Entity.PreExamineData = Mapper.Map <FormPreExamine, PreExamineModel>(_preExamineData); response.Status = true; } catch (Exception ex) { response.Status = false; response.Message = ex.Message; } return(response); }
public JsonResult CreateSuratBerbadanSehat() { var _model = new HealthBodyLetterModel { }; if (Request.Form["forPatient"] != null) { _model.ForPatient = long.Parse(Request.Form["forPatient"].ToString()); } if (Request.Form["FormMedicalID"] != null) { _model.FormMedicalID = long.Parse(Request.Form["FormMedicalID"].ToString()); } if (Request.Form["TglPeriksa"] != null) { _model.Cekdate = DateTime.Parse(Request.Form["TglPeriksa"].ToString()); } if (Session["UserLogon"] != null) { _model.Account = (AccountModel)Session["UserLogon"]; } _model.CreatedDate = DateTime.Now; var request = new HealthBodyRequest { Data = _model }; var response = new HealthBodyResponse { }; response = new HealthBodyValidator(_unitOfWork, _context).Validate(request); return(Json(new { Status = response.Status, Message = response.Message, Nama = response.Entity.PatientData == null ? "" : response.Entity.PatientData.Name, TTL = response.Entity.PatientData == null ? "" : response.Entity.PatientData.BirthDateStr, Alamat = response.Entity.PatientData == null ? "" : response.Entity.PatientData.Address, NoBPJS = response.Entity.PatientData == null ? "" : response.Entity.PatientData.BPJSNumber, TB = response.Entity.PreExamineData == null ? 0 : response.Entity.PreExamineData.Height, BB = response.Entity.PreExamineData == null ? 0 : response.Entity.PreExamineData.Weight, GolDarah = response.Entity.PatientData == null ? "" : response.Entity.PatientData.BloodType, TD = response.Entity.PreExamineData == null ? "" : $"{ response.Entity.PreExamineData.Systolic}/{ response.Entity.PreExamineData.Diastolic}", HR = response.Entity.PreExamineData == null ? 0 : response.Entity.PreExamineData.Pulse, RR = response.Entity.PreExamineData == null ? 0 : response.Entity.PreExamineData.Respitory, Visus = response.Entity.PreExamineData == null ? "" : $"{response.Entity.PreExamineData.RightEye}/{response.Entity.PreExamineData.LeftEye}" }, JsonRequestBehavior.AllowGet)); }
public JsonResult SaveAndPreviewHealthBody() { var _model = new HealthBodyLetterModel(); if (Request.Form["Keperluan"] != null) { _model.Keperluan = Request.Form["Keperluan"].ToString(); } if (Request.Form["Pekerjaan"] != null) { _model.Pekerjaan = Request.Form["Pekerjaan"] == null ? "" : Request.Form["Pekerjaan"].ToString(); } if (Request.Form["FormMedicalID"] != null) { _model.FormMedicalID = Convert.ToInt64(Request.Form["FormMedicalID"].ToString()); } if (Request.Form["ForPatient"] != null) { _model.ForPatient = Request.Form["ForPatient"] == null ? 0 : long.Parse(Request.Form["ForPatient"].ToString()); } if (Request.Form["Decision"] != null) { _model.Decision = Request.Form["Decision"] == null ? "" : Request.Form["Decision"].ToString(); } if (Session["UserLogon"] != null) { _model.Account = (AccountModel)Session["UserLogon"]; } var request = new HealthBodyRequest { Data = _model }; var response = new HealthBodyResponse { }; response = new HealthBodyValidator(_unitOfWork, _context).ValidateBeforePreview(request); return(Json(new { Status = response.Status, FormMedicalId = response.Entity.FormMedicalID }, JsonRequestBehavior.AllowGet)); }
public HealthBodyResponse SaveSuratBadanSehat(HealthBodyRequest request) { int _resultAffected = 0; request.Data.LetterType = LetterEnum.HealthBodyLetter.ToString(); request.Data.AutoNumber = GetLatestAutoNoSurat(LetterEnum.HealthBodyLetter.ToString()) + 1; request.Data.Year = DateTime.Now.Year; var response = new HealthBodyResponse { }; try { var cekExist = _unitOfWork.LetterRepository.Get(x => x.FormMedicalID == request.Data.FormMedicalID && x.LetterType == request.Data.LetterType && x.ForPatient == request.Data.ForPatient); if (!cekExist.Any()) { var _entity = Mapper.Map <HealthBodyLetterModel, Letter>(request.Data); _entity.CreatedBy = request.Data.Account.UserName; _entity.CreatedDate = DateTime.Now; _unitOfWork.LetterRepository.Insert(_entity); _resultAffected = _unitOfWork.Save(); } //get detail patient var _pasien = _unitOfWork.PatientRepository.GetById(request.Data.ForPatient); response.PatientData = Mapper.Map <Patient, PatientModel>(_pasien); if (response.Entity == null) { response.Entity = new HealthBodyLetterModel(); } response.Entity.FormMedicalID = request.Data.FormMedicalID; response.Status = true; } catch (Exception ex) { response.Status = false; response.Message = ex.Message.ToString(); } return(response); }
public ActionResult ExportSuratBerbadanSehat(string formMedId) { long _frmMedicalId = Convert.ToInt64(formMedId); var response = new HealthBodyResponse { }; var request = new HealthBodyRequest { Data = new HealthBodyLetterModel { FormMedicalID = _frmMedicalId } }; response = new HealthBodyHandler(_unitOfWork, _context).GetPatientAndPreExamineData(request); //return View(response.Entity); return(new PartialViewAsPdf(response.Entity) { PageOrientation = Orientation.Portrait, PageSize = Size.Folio, FileName = "PrintSuratBerbadanSehat.pdf" }); }