Ejemplo n.º 1
0
        //private readonly ApplicationdbContect _db = new ApplicationdbContect();


        public async Task <PartialViewResult> LaboratoryResult(int patientId)
        {
            ViewBag.PatientId = patientId;
            var patientLaboratoryFiles = await _db.patient_Images.Where(x => x.PatientId == patientId).FirstOrDefaultAsync();

            if (patientLaboratoryFiles == null)
            {
                patientLaboratoryFiles           = new Patient_Images();
                patientLaboratoryFiles.PatientId = patientId;
            }
            var patientLaboratorylist = _db.patient_Images.Where(x => x.PatientId == patientId && x.IsDelete == false && x.ImgType == "Lab Report").ToList();

            if (patientLaboratorylist.Count > 0)
            {
                for (int i = 0; i < patientLaboratorylist.Count; i++)
                {
                    //string baseval = HelperExtensions.Decrypt(patientLaboratorylist[i].FilePath);
                    string baseval = patientLaboratorylist[i].FilePath;

                    string files = "data:image/png;base64," + HelperExtensions.convertbase64(baseval);
                    patientLaboratorylist[i].FilePath = files;
                }
            }
            ViewBag.MyList = patientLaboratorylist;


            var patient = await _db.Patients.FindAsync(patientId);


            return(PartialView(patient));
        }
Ejemplo n.º 2
0
        public async Task <string> LaboratoryResult([Bind(Exclude = "Photo,PhotoEmrRecords1,PhotoEmrRecords2,PhotoEmrRecords3,PhotoEmrRecords4,PhotoEmrRecords5,PhotoEmrRecords6,PhotoEmrRecords7,PhotoEmrRecords8,PhotoEmrRecords9,PhotoEmrRecords10,PhotoEmrRecords11,PhotoEmrRecords12,PhotoEmrRecords13,PhotoEmrRecords14,PhotoEmrRecords15,EnrollmentStatus,EnrollmentSubStatus,EnrollmentSubStatusReason")] Patient patient)
        {
            int patientId = patient.Id;

            Patient_Images laboratoryResult = new Patient_Images();

            if (HelperExtensions.isAllowedforEditingorAdd(patientId, CategoryCycleStatusHelper.GetPatientNewOrOldCycleByCategory(patientId, BillingCodeHelper.cmmBillingCatagoryid), User.Identity.GetUserId()) == false)
            {
                //return RedirectToAction("Index", "CcmStatus", new { status = HelperExtensions.GetStatusRedirectionbyUser(User.Identity.GetUserId()), Message = "Cycle is locked." });
                return("Cycle is locked.");
            }
            string [] arr = new string[14];
            for (int i = 1; i <= arr.Count(); i++)
            {
                string temp = "";

                temp       = "PhotoEmrRecords" + i;
                arr[i - 1] = temp;
            }

            var lastid = _db.patient_Images.Where(y => y.PatientId == patientId).Count();

            for (int i = 0; i <= arr.Count() - 1; i++)
            {
                string base64StringData = ""; // Your base 64 string data
                var    postedfile       = Request.Files[arr[i]];
                if (postedfile?.ContentLength != 0 && postedfile?.InputStream != null)
                {
                    using (var binaryEmr = new BinaryReader(postedfile.InputStream))
                    {
                        var emrImageData = binaryEmr.ReadBytes(postedfile.ContentLength);
                        if (emrImageData.Length > 0)
                        {
                            base64StringData = Convert.ToBase64String(emrImageData);
                        }
                    }


                    int    id       = lastid == null ? 1 + i : lastid + i == 0 ? 1 : lastid + i + 1;
                    string fileName = id + "_LR_" + DateTime.Now.ToString("MMddyyyy") + "_" + patientId;

                    string filepath = HelperExtensions.fileDirectory() + fileName;

                    string cleandata = "";
                    string mimtype   = "";
                    if (base64StringData.Contains("data:image/jpeg") || base64StringData.Contains("data:image/jpg"))
                    {
                        cleandata = base64StringData.Replace("data:image/jpeg;base64,", "");
                        mimtype   = "image/jpeg";
                    }
                    else if (base64StringData.Contains("data:image/png"))
                    {
                        cleandata = base64StringData.Replace("data:image/png;base64,", "");
                        mimtype   = "image/png";
                    }
                    else
                    {
                        cleandata = base64StringData;
                    }

                    Patient_Images patient_Laboratory = new Patient_Images();
                    patient_Laboratory.PatientId = patientId;
                    patient_Laboratory.FileName  = fileName;
                    //patient_Laboratory.FilePath =  HelperExtensions.Encrypt(filepath);
                    patient_Laboratory.FilePath = filepath;

                    patient_Laboratory.ImgType   = "Lab Report";
                    patient_Laboratory.MimeType  = mimtype;
                    patient_Laboratory.IsDelete  = false;
                    patient_Laboratory.CreatedOn = DateTime.Now;
                    patient_Laboratory.CreatedBy = User.Identity.GetUserId();
                    patient_Laboratory.UpdatedOn = DateTime.Now;

                    patient_Laboratory.UpdatedBy = User.Identity.GetUserId();

                    _db.patient_Images.Add(patient_Laboratory);
                    //After added into list
                    byte[] data = System.Convert.FromBase64String(cleandata);

                    System.IO.File.WriteAllBytes(filepath, data);
                }

                //********************Save image into folder ***********////
                //MemoryStream ms = new MemoryStream(data);
                //System.Drawing.Image img = System.Drawing.Image.FromStream(ms);
                //img.Save(imagePath, System.Drawing.Imaging.ImageFormat.Png);
                //********************Save image into folder ***********////
            }
            var SAVE = await _db.SaveChangesAsync();

            if (SAVE > 0)
            {
                return("True");
            }
            return("False");
            //else
            //{
            //    var errorList = ModelState.Values.SelectMany(m => m.Errors)
            //                     .Select(e => e.ErrorMessage)
            //                     .ToList();
            //    var errorstr = string.Join(",", errorList);
            //    return errorstr;
            //}
        }