Esempio n. 1
0
        public NotesViewModel GetNotes(string userName, int patientID, int? examID)
        {
            PatientModel patient = PatientRepository.PatientGet(patientID, false);

            bool defaultNotes = false;

            //get the last examid or the passed in exam id
            ExamModel exam = PatientRepository.ExamGet(patientID, examID);
            if (exam == null)
            {
                exam = new ExamModel();
                //getting the defaults if exists
                exam.ExamText = GetDefaultNotesText(userName, patient);
                defaultNotes = true;
            }

            PosConstants.NotesType notesType = GetNotesType(exam, examID);

            NotesViewModel notesVM = GetNotesFromXml(exam.ExamText, notesType, userName);
            NotesModel notes = notesVM.Notes;

            SetIdDates(exam, notes, patientID);

            if (defaultNotes)
                notes.DefaultInd = true;
            else
                notes.DefaultInd = false;
            if (notes.NotesType == PosConstants.NotesType.New)
            {
                SetPatientInfo(patient, notes);
                SetPriorValues(notes);
                //SetOverides(notes);
                notes.User.Value = userName;
            }

            //getting the history
            if (notes.NotesType != PosConstants.NotesType.Default)
            {
                notes.History = GetNotesHistory(patientID);
            }

            //In old code sometimes Patient Number & name is empty. This is causing problem. Setting that
            if (notes.PatientNumber.Value == "")
                notes.PatientNumber.Value = patient.PatientNumber;
            if (notes.PatientName.Value == "")
                notes.PatientName.Value = patient.FirstName + " " + patient.LastName;

            return notesVM;
        }
Esempio n. 2
0
 private void SetIdDates(ExamModel exam, NotesModel notes, int patientID)
 {
     if (notes.NotesType == PosConstants.NotesType.New)
         exam.ExamID = 0;
     notes.hdnPatientID = new Field() { Name = "hdnPatientID", Value = patientID.ToString() };
     if (exam.ExamID > 0)
     {
         notes.ExamDate = new Field() { Name = "ExamDate", Value = exam.ExamDate.ToShortDateString() };
         notes.hdnExamID = new Field() { Name = "hdnExamID", Value = exam.ExamID.ToString() };
     }
     else
     {
         notes.ExamDate = new Field() { Name = "ExamDate", Value = DateTime.Now.ToShortDateString() };
         notes.LastExam = new Field() { Name = "LastExam", Value = exam.ExamDate != DateTime.MinValue ? exam.ExamDate.ToShortDateString() : null };
         notes.hdnExamID = null;
     }
     //setting ExamDate & Correct Date
     if (notes.NotesType == PosConstants.NotesType.Correct && exam.CorrectExamID != null)
     {
         notes.ExamCorrectDate = new Field() { Name = "ExamCorrectDate", Value = exam.ExamCorrectDate.Value.ToShortDateString() };
     }
     else
     {
         notes.ExamCorrectDate = null;
     }
     if (notes.NotesType == PosConstants.NotesType.Saved)
     {
         notes.ExamSaveDate = new Field() { Name = "ExamSaveDate", Value = exam.LastUpdatedDate.ToString() };
     }
     else
     {
         notes.ExamSaveDate = null;
     }
 }
Esempio n. 3
0
        public string Save(PosConstants.NotesSaveType saveType, NotesModel model)
        {
            string message = String.Empty;

            ExamModel exam = new ExamModel()
            {
                ExamID = model.hdnExamID != null ? Convert.ToInt32(model.hdnExamID.Value) : 0,
                ExamDate = Convert.ToDateTime(model.ExamDate.Value),
                PatientID = Convert.ToInt32(model.hdnPatientID.Value),
                UserName = model.User.Value,
                SaveInd = 0,
                LastUpdatedDate = DateTime.Now,
                ExamCorrectDate = DateTime.Now,
                CorrectExamID = null,
            };
            switch (saveType)
            {
                case PosConstants.NotesSaveType.Save:
                    message = PosMessage.NotesSaveSuccessful;
                    exam.ExamText = WebUtil.GetXml(model, false, null);
                    exam.SaveInd = 1;
                    break;
                case PosConstants.NotesSaveType.SignOff:
                    message = PosMessage.NotesSignOffSuccessful;
                    exam.ExamText = WebUtil.GetXml(model, true, null);
                    break;
                case PosConstants.NotesSaveType.Correct:
                    message = PosMessage.NotesCorrectSuccessful;
                    exam.CorrectExamID = exam.ExamID;
                    exam.ExamID = 0;
                    //getting the original exam
                    ExamModel orginalExam = PatientRepository.ExamGet(exam.PatientID, exam.CorrectExamID);
                    Dictionary<string, string> dict = WebUtil.GetDictionary(orginalExam.ExamText, false);
                    exam.ExamText = WebUtil.GetXml(model, true, dict);
                    break;
                default:
                    message = String.Empty;
                    break;
            }

            PatientRepository.ExamSave(exam);

            //removing & creating print queue
            if (saveType == PosConstants.NotesSaveType.Correct)
            {
                PosRepository.PrintQueueRemove(exam.CorrectExamID.Value);
            }

            if(saveType == PosConstants.NotesSaveType.SignOff || saveType == PosConstants.NotesSaveType.Correct)
            {
                //saving additional data
                PatientRepository.ExamDataSave(exam.ExamID, exam.PatientID, model);

                if(model.cbPrintQueue.Value == true.ToString())
                    PosRepository.PrintQueueAdd(new PrintQueueItem() { ExamID = exam.ExamID, UserName = exam.UserName, PrintExamNote = null });
                if(model.ExamNoteTo.Value != "")
                    PosRepository.PrintQueueAdd(new PrintQueueItem() { ExamID = exam.ExamID, UserName = exam.UserName, PrintExamNote = true });
            }

            return message;
        }
Esempio n. 4
0
        private PosConstants.NotesType GetNotesType(ExamModel exam, int? examID)
        {
            //setting the notes type & examid
            PosConstants.NotesType notesType = PosConstants.NotesType.New;

            if (exam.SaveInd == 1)
            {
                notesType = PosConstants.NotesType.Saved;
            }
            else if (examID == null && exam.ExamID > 0 && exam.ExamDate.Date == DateTime.Today.Date)
            {
                notesType = PosConstants.NotesType.Correct;
            }
            else if (examID == null)
            {
                notesType = PosConstants.NotesType.New;
            }
            else
            {
                notesType = PosConstants.NotesType.Correct;
            }

            return notesType;
        }
Esempio n. 5
0
        public static void ExamSave(ExamModel exam)
        {
            using (var db = new PosEntities())
            {
                Exam dbExam;
                if (exam.ExamID > 0)
                {
                    dbExam = (from e in db.Exams where e.ExamID == exam.ExamID select e).First();
                }
                else
                {
                    dbExam = new Exam();
                    db.Exams.Add(dbExam);
                }

                dbExam.ExamText = exam.ExamText;
                dbExam.ExamDate = exam.ExamDate;
                dbExam.PatientID = exam.PatientID;
                dbExam.UserName = exam.UserName;
                dbExam.SavedInd = exam.SaveInd;
                dbExam.LastUpdatedDate = DateTime.Now;
                dbExam.ExamCorrectDate = exam.ExamCorrectDate;
                dbExam.CorrectExamID = exam.CorrectExamID;

                var patient = (from pat in db.Patients where pat.PatientID == exam.PatientID select pat).First();
                if (!patient.LastExamDate.HasValue || patient.LastExamDate < exam.ExamDate)
                {
                    patient.LastExamDate = exam.ExamDate;
                }

                db.SaveChanges();
                exam.ExamID = dbExam.ExamID;
            }
        }