示例#1
0
        public ServiceMessage <bool> AddImage(CreateVM createVM)
        {
            var response = new ServiceMessage <bool>();
            int counter  = 1;

            try
            {
                foreach (var item in createVM.Images)
                {
                    byte[] imageByte = new byte[item.ContentLength];
                    item.InputStream.Read(imageByte, 0, item.ContentLength);
                    string consent = createVM.Consent.ToString();
                    string MRN     = createVM.PAT_MRN;
                    //create DOV for file name
                    string DOV = createVM.Appointment_Time.ToString().Replace('/', '.');
                    //adding name and DOV for the file extension
                    string     saveTo      = CreateFolders(createVM.LastName.ToString() + ", " + createVM.FirstName.ToString() + " DOV " + DOV + " (" + counter.ToString() + ")" + ".jpeg", createVM);
                    FileStream writeStream = new FileStream(saveTo, FileMode.Create, FileAccess.Write);
                    counter++;
                    writeStream.Write(imageByte, 0, item.ContentLength);
                    writeStream.Close();

                    var encounterImage = new EncounterImage();
                    encounterImage.Appointment_Time = DateTime.Parse(createVM.Appointment_Time);
                    encounterImage.Consent          = createVM.Consent.ToString();
                    encounterImage.PAT_MRN          = MRN;
                    encounterImage.Image_Data       = imageByte;
                    db.EImage.Add(encounterImage);
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                response.IsSuccessful = false;
                response.ErrorMessage = ex.ToString();
            }
            response.IsSuccessful = true;
            response.Data         = true;
            return(response);
        }
示例#2
0
        public ServiceMessage <IEnumerable <IndexVM> > getAll()
        {
            var response = new ServiceMessage <IEnumerable <IndexVM> >();

            try
            {
                var allEncounters      = db.Encounters.ToList();
                var allEncounterImages = db.EImage.ToList();
                var result1            = from imageTable in allEncounterImages
                                         join encounters in allEncounters on imageTable.PAT_MRN equals encounters.PAT_MRN_ID into joinedList
                                         from joined in joinedList.DefaultIfEmpty()
                                         select new IndexVM
                {
                    image_id        = imageTable.Image_Id,
                    PAT_MRN         = imageTable.PAT_MRN,
                    Providers       = joined?.Provider_1 + ", " + joined?.Provider_2 + ", " + joined?.Provider_3 + ", " + joined?.Provider_4,
                    Contact_Date    = imageTable.Appointment_Time.ToShortDateString(),
                    First_Name      = joined?.First_Name,
                    Last_Name       = joined?.Last_Name,
                    Date_Of_Birth   = joined?.Date_Of_Birth.ToShortDateString(),
                    Department_Name = joined?.Department_Name,
                    Visit_Type      = joined?.Visit_Type,
                    Consent         = imageTable.Consent,
                    ImageData       = imageTable.Image_Data,
                    Gender          = joined?.Gender
                };

                response.Data         = result1;
                response.IsSuccessful = true;
            }
            catch (Exception ex)
            {
                response.IsSuccessful = false;
                response.ErrorMessage = ex.ToString();
            }
            return(response);
        }