Exemplo n.º 1
0
 //Updates an existing patient visit
 public static void UpdatePatientVisit(PatientVisit visit)
 {
     string updateStatement =
         "UPDATE patient_visit SET " +
             "doctorID = @doctorID, nurseID = @nurseID, visit_date = @visit_date, " +
             "appt_date = @appt_date " +
         "WHERE visitID = @visitID";
     try
     {
         using (SqlConnection connection = NorthwindDbConnection.GetConnection())
         {
             connection.Open();
             using (SqlCommand updateCommand = new SqlCommand(updateStatement, connection))
             {
                 //parameters
                 updateCommand.Parameters.AddWithValue("@doctorID", visit.DoctorId);
                 updateCommand.Parameters.AddWithValue("@nurseID", visit.NurseId);
                 updateCommand.Parameters.AddWithValue("@visit_date", visit.VisitDate);
                 updateCommand.Parameters.AddWithValue("@appt_date", visit.ApptDate);
                 updateCommand.Parameters.AddWithValue("@visitID", visit.VisitId);
                 updateCommand.ExecuteNonQuery();
             }
         }
     }
     catch (SqlException ex)
     {
         throw ex;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 2
0
 protected void SaveVitalSigns(PatientVisit patientVisit)
 {
     if (patientVisit.VitalSigns != null) /// Add Or Update Vital Signs during patient visit.
     {
         var vitalSigns = _vitalSignsRepository.Table.Where(vs => vs.PatientVisitId == patientVisit.Id).FirstOrDefault();
         if (vitalSigns != null)
         {
             patientVisit.VitalSigns.ElementAtOrDefault(0).Id = vitalSigns.Id;
         }
         patientVisit.VitalSigns.ElementAtOrDefault(0).PatientVisitId = patientVisit.Id;
         if (patientVisit.VitalSigns.ElementAtOrDefault(0).Id <= 0)
         {
             patientVisit.VitalSigns.ElementAtOrDefault(0).CreatedDate = DateTime.Now;
             _vitalSignsRepository.Insert(patientVisit.VitalSigns);
         }
         else
         {
             vitalSigns.BloodPressure   = patientVisit.VitalSigns.ElementAtOrDefault(0).BloodPressure;
             vitalSigns.Glucose         = patientVisit.VitalSigns.ElementAtOrDefault(0).Glucose;
             vitalSigns.HeartRate       = patientVisit.VitalSigns.ElementAtOrDefault(0).HeartRate;
             vitalSigns.Height          = patientVisit.VitalSigns.ElementAtOrDefault(0).Height;
             vitalSigns.O2Saturation    = patientVisit.VitalSigns.ElementAtOrDefault(0).O2Saturation;
             vitalSigns.RespirationRate = patientVisit.VitalSigns.ElementAtOrDefault(0).RespirationRate;
             vitalSigns.Temprature      = patientVisit.VitalSigns.ElementAtOrDefault(0).Temprature;
             vitalSigns.Weight          = patientVisit.VitalSigns.ElementAtOrDefault(0).Weight;
             vitalSigns.UpdatedDate     = DateTime.Now;
             _vitalSignsRepository.Update(vitalSigns);
             patientVisit.VitalSigns.Clear();
             patientVisit.VitalSigns.Add(vitalSigns);
         }
     }
 }
Exemplo n.º 3
0
        public void CanInsertNewPatientRecord()
        {
            var name = new PersonName();

            name.FirstName  = "Thomas";
            name.LastName   = "Chapman";
            name.MiddleName = "C";

            var newDiagnosis1 = new Diagnosis();

            newDiagnosis1.SetId             = 9998;
            newDiagnosis1.DiagnosisDateTime = DateTime.Now;
            newDiagnosis1.Description       = "Test Diagnosis 1";
            newDiagnosis1.Clinician         = "Dr. Test";

            var newDiagnosis2 = new Diagnosis();

            newDiagnosis2.SetId             = 9998;
            newDiagnosis2.DiagnosisDateTime = DateTime.Now;
            newDiagnosis2.Description       = "Test Diagnosis 2";
            newDiagnosis2.Clinician         = "Dr. Assert";

            var newPatientVisit = new PatientVisit();

            newPatientVisit.SetId                        = 9998;
            newPatientVisit.Location.Bed                 = "1";
            newPatientVisit.Location.Building            = "5";
            newPatientVisit.Location.Facility            = "UMC";
            newPatientVisit.Location.Floor               = "2";
            newPatientVisit.Location.LocationDescription = "General";
            newPatientVisit.Location.LocationStatus      = "Active";
            newPatientVisit.Location.Room                = "2112";

            var newPatient = new Patient();

            newPatient.ExternalPatientId              = "123456789";
            newPatient.InternalPatientId              = "987654321";
            newPatient.Address.Address1               = "1917 Churchill Downs";
            newPatient.Address.Address2               = "";
            newPatient.Address.City                   = "Lebanon";
            newPatient.Address.State                  = "TN";
            newPatient.Address.PostalCode             = "37087";
            newPatient.Gender                         = "M";
            newPatient.DateOfBirth                    = Convert.ToDateTime("11/23/1976");
            newPatient.PrimaryPhoneNumber.AreaCode    = "615";
            newPatient.PrimaryPhoneNumber.CountryCode = "1";
            newPatient.PrimaryPhoneNumber.LineNumber  = "496-4071";
            newPatient.Names.Add(name);
            newPatient.Diagnosis.Add(newDiagnosis1);
            newPatient.Diagnosis.Add(newDiagnosis2);
            newPatient.PatientVisit.Add(newPatientVisit);

            IHL7UnitOfWork uow = new HL7UnitOfWork();

            uow.Patients.Add(newPatient);
            uow.Commit();

            Assert.IsTrue(true);
        }
Exemplo n.º 4
0
        public List <PatientVisit> GetPatientsByPhysicians(int physicianID)
        {
            int itemNum = 0;
            List <PatientVisit> retLst = new List <PatientVisit>();

            foreach (var item in Entites.sp_GetPatientStatusByPhysican(physicianID).ToList())
            {
                PatientVisit patVisit = new PatientVisit();

                patVisit.PatientID = item.ID.Value;
                patVisit.FirstName = Cholestabetes.Encryption.Encryptor.Decrypt(item.FirstName);
                patVisit.LastName  = Cholestabetes.Encryption.Encryptor.Decrypt(item.LastName);
                patVisit.Telephone = Cholestabetes.Encryption.Encryptor.Decrypt(item.Telephone);

                patVisit.PhysicianID = item.UserID.Value;

                patVisit.VisitStatus1 = item.VisitStatus1.Value;
                if (item.VisitDateTime1 != null)
                {
                    patVisit.VisitDateTime1 = item.VisitDateTime1.Value;
                }
                patVisit.Visit1ScreenID = item.Visit1ScreenID.Value;

                patVisit.VisitStatus2 = item.VisitStatus2.Value;
                if (item.VisitDateTime2 != null)
                {
                    patVisit.VisitDateTime2 = item.VisitDateTime2.Value;
                }
                patVisit.Visit2ScreenID = item.Visit2ScreenID.Value;

                patVisit.VisitStatus3 = item.VisitStatus3.Value;
                if (item.VisitDateTime3 != null)
                {
                    patVisit.VisitDateTime3 = item.VisitDateTime3.Value;
                }
                patVisit.Visit3ScreenID = item.Visit3ScreenID.Value;

                patVisit.Visit1StartDate = item.Visit1StartDate;
                patVisit.Visit1EndDate   = item.Visit1EndDate;

                patVisit.Visit2StartDate = item.Visit2StartDate;
                patVisit.Visit2EndDate   = item.Visit2EndDate;

                patVisit.Visit3StartDate = item.Visit3StartDate;
                patVisit.Visit3EndDate   = item.Visit3EndDate;

                patVisit.PatientName = item.PatientName;



                patVisit.AutoNumber = (++itemNum).ToString("D2");

                retLst.Add(patVisit);
            }

            return(retLst);
        }
Exemplo n.º 5
0
 public void SetupTest()
 {
     Reporting.documentName = "TestSetup";
     login = new Login("Login.csv");
     login.SetupAndLogin();
     patient = new PatientDocument("Patient", "PatientData1.csv");
     patient.CreateSimplePatient();
     visit = new PatientVisit("Patient", "PatientVisit1.csv");
     visit.ScheduleSimpleVisit();
 }         // end SetUp()
 private void GetPatientExaminationsWithVisitViewModel(int id,
                                                       PatientVisit patientVisit,
                                                       out NewPatientVisitViewModel patientVM,
                                                       out List <IGrouping <string, PatientExamination> > patientExaminations)
 {
     patientVM           = NewPatientVisitViewModel.BuildPatientVisitVM(_context, patientVisit.PatientId, patientVisit.VisitDate).Result;
     patientVM.Patient   = _context.Patients.Where(p => p.ID == patientVisit.PatientId).SingleOrDefault();
     patientExaminations = _patientVisitManager.GetPatientExaminationsForVisitWithRelatedData(patientVisit.ID);
     SelectObjectsForVisit(patientVM, patientExaminations);
 }
Exemplo n.º 7
0
 public static void DeleteVisit(PatientVisit visit)
 {
     Db.Transact(() =>
     {
         visit.Registry = null;
         visit.Patient  = null;
         visit.Issues?.ForEach(i => i.Delete());
         visit.Delete();
     });
 }
        public void Test_Patient_Succeed()
        {
            var expectPatient = new PatientVisit();

            var caseNo = "";

            var actualPatientVisit = hl7Parser.GetPatient(caseNo);

            Assert.AreEqual <PatientVisit>(expectPatient, actualPatientVisit);
        }
Exemplo n.º 9
0
 public int AddPatientVisit(PatientVisit patientVisit)
 {
     using (UnitOfWork _unitOfWork = new UnitOfWork(new RecordContext()))
     {
         _unitOfWork.PatientVisitRepository.Add(patientVisit);
         Result = _unitOfWork.Complete();
         _unitOfWork.Dispose();
         return(patientVisit.Visit_Id);
     }
 }
Exemplo n.º 10
0
        private void DeleteExaminationsByIds(String klassName, PatientVisit patientVisit, IEnumerable <int> toDeleteItems)
        {
            var items = _context.PatientExaminations.AsEnumerable().Where(pe =>
            {
                var propertyInfo    = pe.GetType().GetProperty(TABS_KLASSES_LIST[klassName]);
                var propertyValueId = Convert.ToInt32(propertyInfo.GetValue(pe, null));
                return(pe.PatientVisitId == patientVisit.ID && toDeleteItems.Contains(propertyValueId));
            });

            _context.RemoveRange(items.ToList());
        }
Exemplo n.º 11
0
        public List <PatientExamination> SavePatientExaminationsForVisit(PatientVisit patientVisit)
        {
            var allExaminations = new List <PatientExamination>();

            foreach (string klassName in TABS_KLASSES_LIST.Keys)
            {
                var savedItems = SaveExamination(klassName, TABS_KLASSES_LIST[klassName], patientVisit);
                allExaminations = allExaminations.Concat(savedItems).ToList();
            }
            return(allExaminations);
        }
Exemplo n.º 12
0
        public List <int> UpdateSelectedItemsForPatientVisit(PatientVisit patientVisit)
        {
            var allIds = new List <int>();

            foreach (var klassName in TABS_KLASSES_LIST.Keys)
            {
                var userSelectedIds = FormSelectedIds(klassName);
                allIds = allIds.Concat(userSelectedIds).ToList();
                UpdateSelectedItemsForPatientVisit(userSelectedIds, klassName, patientVisit);
            }
            return(allIds);
        }
Exemplo n.º 13
0
 public static void CheckVisitDate(this Controller controller, PatientVisit patientVisit)
 {
     if (!string.IsNullOrEmpty(controller.Request.Form["VisitDate"]))
     {
         var dateFromForm = DateTime.ParseExact(controller.Request.Form["VisitDate"],
                                                @"dd/MM/yyyy", CultureInfo.InvariantCulture);
         patientVisit.VisitDate = dateFromForm;
     }
     else
     {
         controller.ModelState.AddModelError("visitDate", "Visit date cannot be blank");
     }
 }
Exemplo n.º 14
0
        public static void DeleteIssueFromPatientVisit(Issue issue, PatientVisit visit)
        {
            Db.Transact(() =>
            {
                var visitissues = Db.SQL <VisitIssue>($"SELECT v FROM {typeof(VisitIssue).Name} v " +
                                                      $"WHERE v.{nameof(VisitIssue.Issue)} = ? AND v.{nameof(VisitIssue.Visit)} = ?", issue, visit);

                foreach (VisitIssue item in visitissues)
                {
                    item.Delete();
                }
            });
        }
Exemplo n.º 15
0
        private void InsertExaminationsByIds(string klassName, PatientVisit patientVisit, IEnumerable <int> toInsertIds)
        {
            PatientExamination examination;
            var igs = _context.PatientImmunoglobulins.Where(pe => toInsertIds.Contains(pe.ID)).ToList();
            var currentCollection = PatientExamination.EntityTypes(_context, klassName);
            var items             = currentCollection.Where(pe => toInsertIds.ToList().Contains(pe.ID));

            foreach (var item in items)
            {
                examination = PatientExamination.BuildPatientExamination(klassName, TABS_KLASSES_LIST[klassName],
                                                                         item.ID.ToString(), patientVisit);
                _context.Add(examination);
            }
        }
Exemplo n.º 16
0
        private List <int> ExaminationsIdsListFromDatabase(string klassName, PatientVisit patientVisit)
        {
            var items = _context.PatientExaminations.AsEnumerable().Where(pe =>
            {
                var propertyInfo   = pe.GetType().GetProperty(TABS_KLASSES_LIST[klassName]);
                var propertyInfoId = Convert.ToInt32(propertyInfo.GetValue(pe, null));
                return(propertyInfoId > 0 && pe.PatientVisitId == patientVisit.ID);
            }).Select(i =>
            {
                var propertyInfo   = i.GetType().GetProperty(TABS_KLASSES_LIST[klassName]);
                var propertyInfoId = Convert.ToInt32(propertyInfo.GetValue(i, null));
                return(propertyInfoId);
            }).ToList();

            return(items);
        }
Exemplo n.º 17
0
        public static void AddIssue(PatientVisit visit, Issue issue)
        {
            if (issue == null || visit == null)
            {
                return;
            }

            Db.Transact(() =>
            {
                new VisitIssue
                {
                    Visit = visit,
                    Issue = issue
                };
            });
        }
Exemplo n.º 18
0
        public static PatientVisit ToConvert(this PatientDemoEnquiry pr)
        {
            PatientVisit pv = new PatientVisit();
            PatientObj   p  = Mapper.Map <PatientDemoEnquiry, PatientObj>(pr);

            pv.Pateint = p;

            foreach (var item in pr.CaseList)
            {
                VisitObj v = Mapper.Map <Case, VisitObj>(item);
                v.PatientID = p.PatientId;

                pv.Vists.Add(v);
            }

            return(pv);
        }
Exemplo n.º 19
0
        //Adds a new patient visit
        public static int AddPatientVisit(PatientVisit patientVisit)
        {
            string insertStatement =
            "INSERT patient_visit " +
                 "(patientID, visit_date, appt_date, doctorID, nurseID) " +
            "VALUES (@patientID, @visit_date, @appt_date, @doctorID, @nurseID)";
              try
              {
              using (SqlConnection connection = NorthwindDbConnection.GetConnection())
              {
                  connection.Open();
                  using (SqlCommand insertCommand = new SqlCommand(insertStatement, connection))
                  {
                      //parameters
                      insertCommand.Parameters.AddWithValue("@patientID", patientVisit.PatientId);
                      insertCommand.Parameters.AddWithValue("@visit_date", patientVisit.VisitDate);
                      if (patientVisit.ApptDate == null)
                      {
                          insertCommand.Parameters.AddWithValue("@appt_date", DBNull.Value);
                      }
                      else
                      {
                          insertCommand.Parameters.AddWithValue("@appt_date", patientVisit.ApptDate);
                      }
                      insertCommand.Parameters.AddWithValue("@doctorID", patientVisit.DoctorId);
                      insertCommand.Parameters.AddWithValue("@nurseID", patientVisit.NurseId);
                      insertCommand.ExecuteNonQuery();

                      string selectStatement =
                          "SELECT IDENT_CURRENT('patient_visit') FROM patient_visit";
                      SqlCommand selectCommand =
                          new SqlCommand(selectStatement, connection);
                      int visitID = Convert.ToInt32(selectCommand.ExecuteScalar());
                      return visitID;
                  }
              }
              }
              catch (SqlException ex)
              {
              throw ex;
              }
              catch (Exception ex)
              {
              throw ex;
              }
        }
Exemplo n.º 20
0
        public static bool ValidatePatientDate(DateTime dateOfBirth, DateTime dateOfReg, int patientId)
        {
            IPatientService ps        = (IPatientService)ObjectFactory.CreateInstance("BusinessProcess.PatientCore.PatientCoreServices, BusinessProcess.PatientCore");
            PatientVisit    lastVisit = ps.GetPatientLastVisit(patientId);

            if (lastVisit == null)
            {
                return(true);
            }
            if (lastVisit.VisitDate < dateOfBirth)
            {
                return(false);
            }
            if (lastVisit.VisitDate < dateOfReg)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 21
0
        private void cmdSave_Click(object sender, EventArgs e)
        {
            PatientVisit visit = new PatientVisit();

            visit.DoctorId       = Int32.Parse(((ComboBoxItem)cmbDoctor.SelectedItem).Value.ToString());
            visit.PatientId      = Int32.Parse(((ComboBoxItem)cmbPatient.SelectedItem).Value.ToString());
            visit.Followup       = chkFollowup.Checked;
            visit.FollowupDate   = dateFollowup.Value;
            visit.FollowupReason = txtReason.Text;
            visit.VisitDate      = dateVisit.Value;
            visit.Notes          = txtVisitNotes.Text;
            visit.VisitCost      = Int32.Parse(visitCost.Value.ToString());
            if (this.txtVisitRefNumber.Text == null ||
                this.txtVisitRefNumber.Text.Length < 10)
            {
                visit.VisitRefNumber = Utils.RandomString(10);
            }
            else
            {
                visit.VisitRefNumber = txtVisitRefNumber.Text;
            }

            try
            {
                if (NpgsqlDatabaseImpl.GetInstance().AddObject(visit))
                {
                    this.txtVisitRefNumber.Text    = visit.VisitRefNumber;
                    this.txtVisitRefNumber.Enabled = false;
                    MessageBox.Show("Patient Visit Saved ...", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    cmdPrint.Enabled = true;
                }
                else
                {
                    MessageBox.Show("Failed to save Patient Visit", "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to save Patient Visit", "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 22
0
        public static PatientVisit CreateNewPatientVisit(ulong personalNumber, PatientRegistry registry)
        {
            var          patient      = DbHelper.GetIfExist <Patient>(nameof(Patient.PersonalNo), personalNumber);
            PatientVisit patientVisit = null;

            if (patient == null)
            {
                patient = PersonHelper.CreatePatientBase(personalNumber);
            }

            Db.Transact(() =>
            {
                patientVisit = new PatientVisit
                {
                    Created  = DateTime.Now,
                    Patient  = patient,
                    Registry = registry
                };
            });

            return(patientVisit);
        }
Exemplo n.º 23
0
        public void PatientVisitAdd()
        {
            PatientVisit visit = new PatientVisit();

            {
                visit.ExpectedDeliveryDate = new DateTime(2017, 02, 23);
                visit.ArriveDate           = DateTime.Now;
            };

            visit.Patient = new Patient();
            {
                visit.Patient.ContactNo = "0771013425";
                visit.Patient.Address   = "12/B,colombo09";
                visit.Patient.Name      = "navod perera";
                visit.Patient.Age       = 30;
                visit.Patient.Gender    = "M";
            };

            visit.Doctor = new Doctor();
            {
                visit.Doctor.DoctorName       = "Thilan perera";
                visit.Doctor.DoctorSpeciality = "ENT";
            };

            visit.User = new User();
            {
                visit.User.Username   = "******";
                visit.User.ModifiedBy = null;
            };

            TestTemplate template = new TestTemplate()
            {
                TemplateName = "Blood Report Template",
            };

            PatientVisitManager patientvisit = new PatientVisitManager();
            var Visit = patientvisit.AddNewPatientVisit(visit, template);
        }
Exemplo n.º 24
0
        public async Task <IActionResult> Create(PatientVisit patientVisit)
        {
            _patientVisitManager = new PatientVisitManager(_context, ViewBag, Request.Form);

            InitViewBags();

            var itemsToSave = _patientVisitManager.SavePatientExaminationsForVisit(patientVisit);

            this.CheckIfAtLeastOneIsSelected(itemsToSave.Count);

            if (ModelState.IsValid)
            {
                _context.Add(patientVisit);
                _context.PatientExaminations.AddRange(itemsToSave);
                await _context.SaveChangesAsync();
            }
            else
            {
                Hashtable errors = ModelStateHelper.Errors(ModelState);
                return(Json(new { success = false, errors }));
            }
            return(Json(new { result = "ok" }));
        }
Exemplo n.º 25
0
        private bool ValidateVisit(PatientVisit patientvisit)
        {
            if (patientvisit == null)
            {
                throw new ArgumentNullException("patien visit Details canno't be null");
            }
            if (string.IsNullOrEmpty(patientvisit.ExpectedDeliveryDate.ToString()))
            {
                throw new ArgumentNullException("Insert Expected deliver date Field!");
            }
            if (string.IsNullOrEmpty(patientvisit.ArriveDate.ToString()))
            {
                throw new ArgumentNullException("Insert Arrive Date ");
            }
            if (patientvisit.Patient == null)
            {
                throw new ArgumentNullException("Patient information canno't be null.");
            }

            if (patientvisit.Patient.ContactNo.Length > 10)
            {
                System.Diagnostics.Debug.WriteLine("Invalid Contact Number");

                throw new ArgumentNullException();
            }

            if (patientvisit.Doctor == null)
            {
                throw new ArgumentNullException("Doctor information canno't be null.");
            }
            if (patientvisit.User == null)
            {
                throw new ArgumentNullException("user information canno't be null.");
            }

            return(true);
        }
Exemplo n.º 26
0
 public void Register(PatientVisit patientVisit)
 {
     PatientVisitRepository.SavePatientVisit(patientVisit);
 }
Exemplo n.º 27
0
 public static void UpdatePatientVisit(PatientVisit visit)
 {
     PatientVisitDal.UpdatePatientVisit(visit);
 }
Exemplo n.º 28
0
        public async Task <int> SaveUpdatePharmacy(int ptn, int PatientMasterVisitID, int PatientId, int LocationID, int OrderedBy,
                                                   int UserID, string RegimenType, int DispensedBy, int RegimenLine, int ModuleID,
                                                   List <DrugPrescription> drugPrescription, string pmscmFlag, int TreatmentProgram,
                                                   int PeriodTaken, int TreatmentPlan, int TreatmentPlanReason, int Regimen, string prescriptionDate,
                                                   string dispensedDate, DateTime VisitDate)
        {
            try
            {
                var PatientPharmacy = await _unitOfWork.Repository <PatientPharmacyOrder>()
                                      .Get(x => x.PatientId == PatientId && x.PatientMasterVisitId == PatientMasterVisitID && x.ProgId == TreatmentProgram && x.DeleteFlag != 1).OrderByDescending(x => x.ptn_pharmacy_pk).FirstOrDefaultAsync();

                if (PatientPharmacy != null)
                {
                    PatientPharmacy.OrderedBy           = OrderedBy;
                    PatientPharmacy.OrderedbyDate       = (prescriptionDate == "") ? (DateTime?)null : Convert.ToDateTime(prescriptionDate);
                    PatientPharmacy.DispensedBy         = DispensedBy;
                    PatientPharmacy.DispensedByDate     = (dispensedDate == "") ? (DateTime?)null : Convert.ToDateTime(dispensedDate);
                    PatientPharmacy.ProgId              = TreatmentProgram;
                    PatientPharmacy.UserId              = UserID;
                    PatientPharmacy.RegimenLine         = RegimenLine;
                    PatientPharmacy.PharmacyPeriodTaken = PeriodTaken;

                    _unitOfWork.Repository <PatientPharmacyOrder>().Update(PatientPharmacy);
                    await _unitOfWork.SaveAsync();

                    PharmacyPk = PatientPharmacy.ptn_pharmacy_pk;
                    PatientPk  = PatientPharmacy.Ptn_pk;
                    VisitPk    = PatientPharmacy.VisitId;
                    var ArvTreatmentTracker = await _unitOfWork.Repository <ARVTreatmentTracker>().Get(x => x.PatientId == PatientId && x.PatientMasterVisitId == PatientMasterVisitID && x.DeleteFlag == false).OrderByDescending(x => x.Id).FirstOrDefaultAsync();

                    if (ArvTreatmentTracker != null)
                    {
                        if (RegimenLine > 0)
                        {
                            ArvTreatmentTracker.RegimenId               = Regimen;
                            ArvTreatmentTracker.RegimenLineId           = RegimenLine;
                            ArvTreatmentTracker.TreatmentStatusId       = TreatmentPlan;
                            ArvTreatmentTracker.TreatmentStatusReasonId = TreatmentPlanReason;

                            _unitOfWork.Repository <ARVTreatmentTracker>().Update(ArvTreatmentTracker);
                            await _unitOfWork.SaveAsync();
                        }
                    }
                    else
                    {
                        if (RegimenLine > 0)
                        {
                            ARVTreatmentTracker arv = new ARVTreatmentTracker();


                            arv.PatientId               = PatientId;
                            arv.PatientMasterVisitId    = PatientMasterVisitID;
                            arv.RegimenId               = Regimen;
                            arv.RegimenLineId           = RegimenLine;
                            arv.TreatmentStatusId       = TreatmentPlan;
                            arv.TreatmentStatusReasonId = TreatmentPlanReason;
                            arv.DeleteFlag              = false;
                            arv.CreateBy   = UserID;
                            arv.CreateDate = DateTime.Now;

                            await _unitOfWork.Repository <ARVTreatmentTracker>().AddAsync(arv);

                            await _unitOfWork.SaveAsync();
                        }
                    }

                    var regimenmap = await _unitOfWork.Repository <RegimenMap>().Get(x => x.Ptn_Pk == PatientPk && x.OrderId == PharmacyPk && x.DeleteFlag == 0).OrderByDescending(x => x.RegimenMap_Pk).FirstOrDefaultAsync();

                    if (regimenmap != null)
                    {
                        regimenmap.RegimenType = RegimenType;

                        _unitOfWork.Repository <RegimenMap>().Update(regimenmap);
                        await _unitOfWork.SaveAsync();
                    }
                    else
                    {
                        RegimenMap rm = new RegimenMap();
                        rm.Ptn_Pk      = PatientPk;
                        rm.LocationID  = LocationID;
                        rm.RegimenType = rm.RegimenType;
                        rm.Visit_pk    = VisitPk;
                        rm.UserId      = UserID;
                        rm.OrderId     = PharmacyPk;
                        rm.CreateDate  = DateTime.Now;
                        await _unitOfWork.Repository <RegimenMap>().AddAsync(rm);

                        await _unitOfWork.SaveAsync();
                    }
                    StringBuilder sqlartstartdate = new StringBuilder();
                    sqlartstartdate.Append("Select Top 1  a.DispensedByDate as DispensedDate From  ord_PatientPharmacyOrder a,dtl_RegimenMap b  " +
                                           "  Where a.ptn_pk = b.Ptn_Pk And a.ptn_pharmacy_pk = b.orderid And(a.DeleteFlag = 0 Or a.DeleteFlag Is Null) And(b.DeleteFlag = 0 Or b.DeleteFlag Is Null)" +
                                           "  And a.ptn_pk = @pk And a.ProgId In(222, 223)   And a.dispensedbydate Is Not Null And b.regimentype Is Not Null And b.regimentype <> ''''  " +
                                           "  Order By a.dispensedbydate Asc ");

                    var ptnPk = new SqlParameter();
                    ptnPk.SqlDbType     = SqlDbType.Int;
                    ptnPk.Size          = -1;
                    ptnPk.ParameterName = "@pk";
                    ptnPk.Value         = PatientPk;


                    var PatientARTStartDate = _unitOfWork.Context.Query <PatientARTStartDate>().FromSql(sqlartstartdate.ToString(),
                                                                                                        parameters: new[]
                    {
                        ptnPk
                    }).FirstOrDefault();

                    if (PatientARTStartDate != null)
                    {
                        var patient = await _unitOfWork.Repository <Patient>().Get(x => x.Ptn_Pk == PatientPk).FirstOrDefaultAsync();

                        if (patient != null)
                        {
                            patient.ARTStartDate = Convert.ToDateTime(PatientARTStartDate.DispensedDate);
                            _unitOfWork.Repository <Patient>().Update(patient);
                            await _unitOfWork.SaveAsync();
                        }
                    }
                }
                else
                {
                    var VisitType = _unitOfWork.Repository <VisitType>().Get(x => x.VisitName == "Pharmacy" && x.DeleteFlag != 1).FirstOrDefault();
                    if (VisitType != null)
                    {
                        VisitTypeId = VisitType.VisitTypeID;
                    }

                    PatientVisit pvv = new PatientVisit();
                    pvv.Ptn_pk      = ptn;
                    pvv.LocationID  = LocationID;
                    pvv.VisitDate   = Convert.ToDateTime(VisitDate);
                    pvv.VisitType   = VisitTypeId;
                    pvv.DataQuality = 1;
                    pvv.DeleteFlag  = 0;
                    pvv.UserID      = UserID;
                    pvv.CreateDate  = DateTime.Now;
                    pvv.CreatedBy   = UserID;



                    await _unitOfWork.Repository <PatientVisit>().AddAsync(pvv);

                    await _unitOfWork.SaveAsync();

                    VisitPk = pvv.Visit_Id;

                    PatientPharmacyOrder pho = new PatientPharmacyOrder();
                    pho.Ptn_pk               = pvv.Ptn_pk;
                    pho.PatientId            = PatientId;
                    pho.PatientMasterVisitId = PatientMasterVisitID;
                    pho.LocationID           = LocationID;
                    pho.OrderedBy            = OrderedBy;
                    pho.OrderedbyDate        = (prescriptionDate == "") ? (DateTime?)null : Convert.ToDateTime(prescriptionDate);
                    pho.DispensedBy          = DispensedBy;
                    pho.DispensedByDate      = (dispensedDate == "") ? (DateTime?)null : Convert.ToDateTime(dispensedDate);
                    pho.ProgId               = TreatmentProgram;
                    pho.UserId               = UserID;
                    pho.RegimenLine          = RegimenLine;
                    pho.PharmacyPeriodTaken  = PeriodTaken;
                    pho.VisitId              = pvv.Visit_Id;
                    pho.ProviderId           = TreatmentProgram;
                    pho.CreateDate           = DateTime.Now;


                    await _unitOfWork.Repository <PatientPharmacyOrder>().AddAsync(pho);

                    await _unitOfWork.SaveAsync();

                    PharmacyPk = pho.ptn_pharmacy_pk;
                    PatientPk  = pho.Ptn_pk;
                    VisitPk    = pho.VisitId;
                    var ArvTreatmentTracker = await _unitOfWork.Repository <ARVTreatmentTracker>().Get(x => x.PatientId == PatientId && x.PatientMasterVisitId == PatientMasterVisitID && x.DeleteFlag == false).OrderByDescending(x => x.Id).FirstOrDefaultAsync();

                    if (ArvTreatmentTracker != null)
                    {
                        ArvTreatmentTracker.RegimenId               = Regimen;
                        ArvTreatmentTracker.RegimenLineId           = RegimenLine;
                        ArvTreatmentTracker.TreatmentStatusId       = TreatmentPlan;
                        ArvTreatmentTracker.TreatmentStatusReasonId = TreatmentPlanReason;

                        _unitOfWork.Repository <ARVTreatmentTracker>().Update(ArvTreatmentTracker);
                        await _unitOfWork.SaveAsync();
                    }
                    else
                    {
                        ARVTreatmentTracker arv = new ARVTreatmentTracker();


                        arv.PatientId               = PatientId;
                        arv.PatientMasterVisitId    = PatientMasterVisitID;
                        arv.RegimenId               = Regimen;
                        arv.RegimenLineId           = RegimenLine;
                        arv.TreatmentStatusId       = TreatmentPlan;
                        arv.TreatmentStatusReasonId = TreatmentPlanReason;
                        arv.DeleteFlag              = false;
                        arv.CreateBy   = UserID;
                        arv.CreateDate = DateTime.Now;

                        await _unitOfWork.Repository <ARVTreatmentTracker>().AddAsync(arv);

                        await _unitOfWork.SaveAsync();
                    }

                    var regimenmap = await _unitOfWork.Repository <RegimenMap>().Get(x => x.Ptn_Pk == PatientPk && x.OrderId == PharmacyPk && x.DeleteFlag == 0).OrderByDescending(x => x.RegimenMap_Pk).FirstOrDefaultAsync();

                    if (regimenmap != null)
                    {
                        regimenmap.RegimenType = RegimenType;

                        _unitOfWork.Repository <RegimenMap>().Update(regimenmap);
                        await _unitOfWork.SaveAsync();
                    }
                    else
                    {
                        RegimenMap rm = new RegimenMap();
                        rm.Ptn_Pk      = PatientPk;
                        rm.LocationID  = LocationID;
                        rm.RegimenType = rm.RegimenType;
                        rm.Visit_pk    = VisitPk;
                        rm.UserId      = UserID;
                        rm.OrderId     = PharmacyPk;
                        rm.CreateDate  = DateTime.Now;
                        await _unitOfWork.Repository <RegimenMap>().AddAsync(rm);

                        await _unitOfWork.SaveAsync();
                    }
                    StringBuilder sqlartstartdate = new StringBuilder();
                    sqlartstartdate.Append("Select Top 1  a.DispensedByDate as DispensedDate From  ord_PatientPharmacyOrder a,dtl_RegimenMap b  " +
                                           "  Where a.ptn_pk = b.Ptn_Pk And a.ptn_pharmacy_pk = b.orderid And(a.DeleteFlag = 0 Or a.DeleteFlag Is Null) And(b.DeleteFlag = 0 Or b.DeleteFlag Is Null)" +
                                           "  And a.ptn_pk = @pk And a.ProgId In(222, 223)   And a.dispensedbydate Is Not Null And b.regimentype Is Not Null And b.regimentype <> ''''  " +
                                           "  Order By a.dispensedbydate Asc ");

                    var ptnPk = new SqlParameter();
                    ptnPk.SqlDbType     = SqlDbType.Int;
                    ptnPk.ParameterName = "@pk";
                    ptnPk.Size          = -1;
                    ptnPk.Value         = Convert.ToInt32(PatientPk);

                    var PatientARTStartDate = _unitOfWork.Context.Query <PatientARTStartDate>().FromSql(sqlartstartdate.ToString(),
                                                                                                        parameters: new[]
                    {
                        ptnPk
                    }).FirstOrDefault();

                    if (PatientARTStartDate != null)
                    {
                        var patient = await _unitOfWork.Repository <Patient>().Get(x => x.Ptn_Pk == PatientPk).FirstOrDefaultAsync();

                        if (patient != null)
                        {
                            patient.ARTStartDate = Convert.ToDateTime(PatientARTStartDate.DispensedDate);
                            _unitOfWork.Repository <Patient>().Update(patient);
                            await _unitOfWork.SaveAsync();
                        }
                    }
                }


                string ptn_pharmacy_pk = PharmacyPk.ToString();

                StringBuilder sqldel = new StringBuilder();
                sqldel.Append("sp_DeletePharmacyPrescription_GreenCard @ptn_pharmacy_pk");
                var ptnpk = new SqlParameter("@ptn_pharmacy_pk", ptn_pharmacy_pk);
                var k     = await _unitOfWork.Context.Database.ExecuteSqlCommandAsync(sqldel.ToString(), parameters : new[] {
                    ptnpk
                });

                foreach (var drg in drugPrescription)
                {
                    if (drg.DrugId != "")
                    {
                        if (drg.qtyDisp == "")
                        {
                            drg.qtyDisp = "0";
                        }

                        StringBuilder sqlprescph = new StringBuilder();


                        // var ptnpharmacy = new SqlParameter("@ptn_pharmacy_pk", ptn_pharmacy_pk);



                        var ptnpharmacy = new SqlParameter();
                        ptnpharmacy.SqlDbType     = SqlDbType.Int;
                        ptnpharmacy.ParameterName = "@ptn_pharmacy_pk";
                        ptnpharmacy.Size          = -1;
                        ptnpharmacy.Value         = Convert.ToInt32(ptn_pharmacy_pk);


                        //  var drugid = new SqlParameter("@DrugId",  drg.DrugId);



                        var drugid = new SqlParameter();
                        drugid.SqlDbType     = SqlDbType.Int;
                        drugid.ParameterName = "@DrugId";
                        drugid.Size          = -1;
                        drugid.Value         = Convert.ToInt32(drg.DrugId);
                        // var batchid = new SqlParameter("@BatchId",  drg.BatchId);
                        var batchid = new SqlParameter();
                        batchid.SqlDbType     = SqlDbType.VarChar;
                        batchid.ParameterName = "@BatchId";
                        batchid.Size          = -1;
                        batchid.Value         = drg.BatchId;


                        // var freqid = new SqlParameter("@FreqId", drg.FreqId);

                        var freqid = new SqlParameter();
                        freqid.SqlDbType     = SqlDbType.Int;
                        freqid.ParameterName = "@FreqId";
                        freqid.Size          = -1;
                        freqid.Value         = Convert.ToInt32(drg.FreqId);


                        //  var dose = new SqlParameter("@Dose", drg.Dose);


                        var dose = new SqlParameter();
                        dose.SqlDbType     = SqlDbType.Int;
                        dose.ParameterName = "@Dose";
                        dose.Size          = -1;
                        dose.Value         = decimal.ToInt32(Convert.ToDecimal(drg.Dose.ToString()));


                        // var morning = new SqlParameter("@Morning",  drg.Morning == "" ? "0" : drg.Morning);

                        var morning = new SqlParameter();
                        morning.SqlDbType     = SqlDbType.Int;
                        morning.ParameterName = "@Morning";
                        morning.Size          = -1;
                        morning.Value         = decimal.ToInt32(Convert.ToDecimal(drg.Morning.ToString()));


                        //var  midday = new SqlParameter("@Midday",  drg.Midday == "" ? "0" : drg.Midday);

                        var midday = new SqlParameter();
                        midday.SqlDbType     = SqlDbType.Int;
                        midday.ParameterName = "@Midday";
                        midday.Size          = -1;
                        midday.Value         = decimal.ToInt32(Convert.ToDecimal(drg.Midday.ToString()));

                        // var  evening = new SqlParameter("@Evening",  drg.Evening == "" ? "0" : drg.Evening);


                        var evening = new SqlParameter();
                        evening.SqlDbType     = SqlDbType.Int;
                        evening.ParameterName = "@Evening";
                        evening.Size          = -1;
                        evening.Value         = decimal.ToInt32(Convert.ToDecimal(drg.Evening.ToString()));


                        // var   night=new SqlParameter("@Night",  drg.Night == "" ? "0" : drg.Night);



                        var night = new SqlParameter();
                        night.SqlDbType     = SqlDbType.Int;
                        night.ParameterName = "@Night";
                        night.Size          = -1;
                        night.Value         = decimal.ToInt32(Convert.ToDecimal(drg.Night.ToString()));


                        // var duration = new SqlParameter("@Duration", drg.Duration);
                        var duration = new SqlParameter();
                        duration.SqlDbType     = SqlDbType.Int;
                        duration.ParameterName = "@Duration";
                        duration.Size          = -1;
                        duration.Value         = decimal.ToInt32(Convert.ToDecimal(drg.Duration.ToString()));

                        // var qtypres = new SqlParameter("@qtyPres", drg.qtyPres);


                        var qtypres = new SqlParameter();
                        qtypres.SqlDbType     = SqlDbType.Int;
                        qtypres.ParameterName = "@qtyPres";
                        qtypres.Size          = -1;
                        qtypres.Value         = decimal.ToInt32(Convert.ToDecimal(drg.qtyPres.ToString()));


                        // var qtydisp = new SqlParameter("@qtyDisp",  drg.qtyDisp);

                        var qtydisp = new SqlParameter();
                        qtydisp.SqlDbType     = SqlDbType.Int;
                        qtydisp.ParameterName = "@qtyDisp";
                        qtydisp.Size          = -1;
                        qtydisp.Value         = decimal.ToInt32(Convert.ToDecimal(drg.qtyDisp.ToString()));
                        // var prophylaxis = new SqlParameter("@prophylaxis", drg.prophylaxis);

                        var prophylaxis = new SqlParameter();
                        prophylaxis.SqlDbType     = SqlDbType.Int;
                        prophylaxis.ParameterName = "@Prophylaxis";
                        prophylaxis.Size          = -1;
                        prophylaxis.Value         = (drg.prophylaxis == "")? 0: Convert.ToInt32(drg.prophylaxis.ToString());
                        //var pmscmflag= new SqlParameter("@pmscm",  pmscmFlag);
                        var pmscmflag = new SqlParameter();
                        pmscmflag.SqlDbType     = SqlDbType.Int;
                        pmscmflag.ParameterName = "@pmscm";
                        pmscmflag.Size          = -1;
                        pmscmflag.Value         = Convert.ToInt32(pmscmFlag.ToString());
                        //var userid =new SqlParameter("@UserID",UserID);

                        var userid = new SqlParameter();
                        userid.SqlDbType     = SqlDbType.Int;
                        userid.ParameterName = "@UserID";
                        userid.Size          = -1;
                        userid.Value         = Convert.ToInt32(UserID.ToString());

                        sqlprescph.Append($"exec sp_SaveUpdatePharmacyPrescription_GreenCard @ptn_pharmacy_pk={ptnpharmacy.Value},@DrugId={drugid.Value},@BatchId={batchid.Value},@FreqId={freqid.Value},@Dose={dose.Value},@Morning={morning.Value},@Midday={midday.Value},@Evening={evening.Value},@Night={night.Value},@Duration={duration.Value}" +
                                          $",@qtyPres={qtypres.Value},@qtyDisp={qtydisp.Value},@Prophylaxis={prophylaxis.Value},@pmscm={pmscmflag.Value},@UserID={userid.Value}");

                        var presc = _unitOfWork.Context.Database.ExecuteSqlCommand(sqlprescph.ToString());

                        /*   var presc = await _unitOfWork.Context.Database.ExecuteSqlCommand(sqlprescph.ToString(), parameters: new[] {
                         * ptnpharmacy,
                         * drugid,
                         * batchid,
                         * freqid,
                         * dose,
                         * morning,
                         * midday,
                         * evening,
                         * night,
                         * duration,
                         * qtypres,
                         * qtydisp,
                         * prophylaxis,
                         * pmscmflag,
                         * userid
                         *
                         * }); */
                    }
                }

                return(Convert.ToInt32(ptn_pharmacy_pk));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 29
0
        /// <summary>
        /// Saves the patient lab order.
        /// </summary>
        /// <param name="patientID">The patient identifier.</param>
        /// <param name="patient_Pk">The patient pk.</param>
        /// <param name="userId">The user identifier.</param>
        /// <param name="facilityID">The facility identifier.</param>
        /// <param name="moduleId">The module identifier.</param>
        /// <param name="patientMasterVisitId">The patient master visit identifier.</param>
        /// <param name="labOrderDate">The lab order date.</param>
        /// <param name="orderNotes">The order notes.</param>
        /// <param name="patientLabOrder">The patient lab order.</param>
        /// <param name="orderStatus">The order status.</param>
        /// <returns>order Id</returns>
        public int savePatientLabOrder(int patientID, int patient_Pk, int userId, int facilityID, int moduleId, int patientMasterVisitId, string labOrderDate, string orderNotes, string patientLabOrder, string orderStatus)
        {
            int visitId = 0;
            int orderId = 0;
            int testId  = 0;
            //int _paramId = 0;
            DateTime orderDate = Convert.ToDateTime(labOrderDate);
            // DateTime orderDate = DateTime.Now;
            //DateTime orderDate = DateTime.Parse(labOrderDate);
            var jss = new JavaScriptSerializer();
            IList <ListLabOrder> data = jss.Deserialize <IList <ListLabOrder> >(patientLabOrder);

            if (patientID > 0)
            {
                PatientVisit visit = new PatientVisit()
                {
                    Ptn_Pk      = patient_Pk,
                    LocationID  = facilityID,
                    UserID      = userId,
                    TypeofVisit = 70, //Self (70) 71 (Treatmentsupporter)
                    VisitDate   = orderDate,
                    ModuleId    = moduleId,
                    VisitType   = 6
                };
                visitId = _visitManager.AddPatientVisit(visit);

                LabOrderEntity labOrder = new LabOrderEntity()
                {
                    Ptn_pk               = patient_Pk,
                    PatientId            = patientID,
                    LocationId           = facilityID,
                    VisitId              = visitId,
                    ModuleId             = moduleId,
                    OrderedBy            = userId,
                    ClinicalOrderNotes   = orderNotes,
                    PatientMasterVisitId = patientMasterVisitId,
                    OrderStatus          = orderStatus,
                    OrderDate            = orderDate,
                    UserId               = userId
                };
                orderId = _mgr.AddPatientLabOrder(labOrder);
                // DateTime? nullDate = null;
                foreach (ListLabOrder t in data)
                {
                    LabDetailsEntity labDetails = new LabDetailsEntity()
                    {
                        LabOrderId = orderId,
                        LabTestId  = t.LabNameId,
                        TestNotes  = t.LabNotes,
                        UserId     = userId,
                        CreatedBy  = userId,
                        StatusDate = DateTime.Now,
                        ResultDate = t.ResultDate
                    };
                    testId = _mgr.AddLabOrderDetails(labDetails);

                    PatientLabTracker labTracker = new PatientLabTracker()
                    {
                        PatientId            = patientID,
                        PatientMasterVisitId = patientMasterVisitId,
                        LabName    = t.LabName,
                        SampleDate = orderDate,
                        Reasons    = t.OrderReason,

                        CreatedBy      = userId,
                        Results        = orderStatus,
                        LabOrderId     = orderId,
                        LabTestId      = t.LabNameId, //parameter
                        LabOrderTestId = testId,      //uniquely identifies a particular test
                        FacilityId     = facilityID,
                        ResultDate     = t.ResultDate
                    };

                    Result = _mgr.AddPatientLabTracker(labTracker);
                    if (Result > 0)
                    {
                        Id = _patientEncounterManager.AddpatientEncounter(patientID, patientMasterVisitId, _patientEncounterManager.GetPatientEncounterId("EncounterType", "lab-encounter".ToLower()), 205, userId);
                    }
                    //add to dtlresults

                    List <LookupTestParameter> _parameters = _lookupTest.GetTestParameter(t.LabNameId);
                    if (_parameters != null)
                    {
                        foreach (LookupTestParameter p in _parameters)
                        {
                            LabResultsEntity labresults = new LabResultsEntity()
                            {
                                LabOrderId     = orderId,
                                LabTestId      = t.LabNameId,
                                LabOrderTestId = testId,
                                ParameterId    = p.Id,
                                UserId         = userId,
                                CreatedBy      = userId,
                                StatusDate     = DateTime.Now
                            };
                            _mgr.AddPatientLabResults(labresults);
                        }
                    }
                }
            }
            return(orderId);
        }
Exemplo n.º 30
0
 //Updates the visit info
 private void editButton_Click(object sender, EventArgs e)
 {
     if (IsValidDataVisit())
     {
         PatientVisit updateVisit = new PatientVisit();
         this.PutPatientVisitData(updateVisit);
         updateVisit.VisitId = patientVisit.VisitId;
         try
         {
             NorthwindController.UpdatePatientVisit(updateVisit);
             editButton.Enabled = false;
         }
         catch (SqlException ex)
         {
             MessageBox.Show(ex.Message, ex.GetType().ToString());
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, ex.GetType().ToString());
         }
     }
 }
Exemplo n.º 31
0
 //Saves the visit data
 private void PutPatientVisitData(PatientVisit patientVisit)
 {
     patientVisit.PatientId = int.Parse(patientIDLabel.Text);
     patientVisit.VisitDate = visitDateBox.Value;
     patientVisit.ApptDate = appointmentDateBox.Value;
     patientVisit.DoctorId = (int)doctorsComboBox.SelectedValue;
     patientVisit.NurseId = NwLogin.employeeUser.EmployeeId;
 }
Exemplo n.º 32
0
 public static int AddPatientVisit(PatientVisit patientVisit)
 {
     return PatientVisitDal.AddPatientVisit(patientVisit);
 }
Exemplo n.º 33
0
 public static IEnumerable <Issue> SelectAllIssuesOf(PatientVisit visit)
 {
     return(DbHelper.SelectFrom <VisitIssue>(nameof(VisitIssue.Visit), visit).Select(pv => pv.Issue).ToList());
 }
Exemplo n.º 34
0
 public HttpResponseMessage Post([FromBody] PatientVisit data)
 {
     return(requestHandler.CreateGbObject(Request, data));
 }
Exemplo n.º 35
0
        //Saves patient visit info to database
        private void saveButton_Click(object sender, EventArgs e)
        {
            if (IsValidDataVisit())
            {
                patientVisit = new PatientVisit();
                this.PutPatientVisitData(patientVisit);
                try
                {
                    patientVisit.VisitId = NorthwindController.AddPatientVisit(patientVisit);
                    saveButton.Visible = false;
                    editButton.Visible = true;
                    editButton.Enabled = false;
                    saveButton2.Enabled = true;
                    saveButton3.Enabled = true;
                    saveButton5.Enabled = true;

                }
                catch (SqlException ex)
                {
                    MessageBox.Show(ex.Message, ex.GetType().ToString());
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, ex.GetType().ToString());
                }
            }
        }
Exemplo n.º 36
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="patientVisit"></param>
        /// <param name="Template"></param>

        /// <returns></returns>
        public PatientVisitDto AddNewPatientVisit(PatientVisit patientVisit, TestTemplate Template)
        {
            PatientVisitHelper visithelp = new PatientVisitHelper();

            MapperConfig.ConfigAutoMapper();

            if (this.ValidateVisit(patientVisit))
            {
                patientVisit.CreatedDate  = DateTime.Now;
                patientVisit.CreatedBy    = "EMP";
                patientVisit.ModifiedDate = new DateTime(2017, 12, 2);
                patientVisit.ModifiedBy   = string.Empty;

                // if (DoctorRepository.GetDoctor(patientVisit.Doctor.DoctorId) == null)
                if (DoctorHelp.GetDoctorByName(patientVisit.Doctor.DoctorName) == null ||
                    DoctorHelp.GetDoctorBySpeciality(patientVisit.Doctor.DoctorSpeciality) == null)
                {
                    this.AddNewDoctor(patientVisit.Doctor);

                    System.Diagnostics.Debug.WriteLine("Doctor Added");

                    patientVisit.Doctor = DoctorHelp.GetDoctorByName(patientVisit.Doctor.DoctorName);
                }
                else
                {
                    patientVisit.DoctorID = DoctorHelp.GetDoctorByName(patientVisit.Doctor.DoctorName).DoctorId;

                    patientVisit.Doctor = DoctorHelp.GetDoctorByName(patientVisit.Doctor.DoctorName);

                    System.Diagnostics.Debug.WriteLine("Doctor Exists");
                }


                if (PatientRepository.GetPatient(patientVisit.Patient.ContactNo) == null)
                {
                    this.AddNewPatient(patientVisit.Patient);

                    patientVisit.Patient = PatientRepository.GetPatient(patientVisit.Patient.ContactNo);

                    System.Diagnostics.Debug.WriteLine("Patient Added");
                }
                else
                {
                    patientVisit.PatientID = PatientRepository.GetPatient(patientVisit.Patient.ContactNo).PatientId;

                    patientVisit.Patient = PatientRepository.GetPatient(patientVisit.Patient.ContactNo);

                    System.Diagnostics.Debug.WriteLine("Patient Exists");
                }

                patientVisit.UserId = UserRepository.GetUser(patientVisit.User.Username).UserId;

                patientVisit.User.RoleId = 1;

                patientVisit.User = UserRepository.GetUser(patientVisit.User.Username);

                var NewVisit = PatientVisitRepo.Insert(Mapper.Map <PatientVisit>(patientVisit));
                Mapper.Map <PatientVisitDto>(NewVisit);

                System.Diagnostics.Debug.WriteLine("Visit Added");

                int VisitId = NewVisit.PatientVisitId;

                this.AddNewPatientTest(VisitId, Template);

                System.Diagnostics.Debug.WriteLine("Patient Test Added");

                int testTemplateID = TestTemplateRepository.GetTestTemplate(Template.TemplateName).TestTemplateId;

                IList <TestTemplateAttributeDto> TestAttribute = visithelp.GetTestTemplateAttributes(testTemplateID);

                TestResult results = new TestResult();

                foreach (var x in TestAttribute)
                {
                    results.AttrID  = x.AttrID;
                    results.VisitID = VisitId;
                    results.Status  = "NO STATUS YET";
                    results.Value   = "NO VALUE YET";
                    this.AddNewTestResult(results);
                }

                System.Diagnostics.Debug.WriteLine("Result Added");
            }

            else
            {
                throw new ArgumentNullException("Provided information is not valid.");
            }

            return(null);
        }
Exemplo n.º 37
0
        public static PatientVisitDetailsViewModel BuildPatientVisitDetailsVM(PatientVisitManager patientVisitManager, PatientVisit patientVisit)
        {
            var patientDetailsVM = new PatientVisitDetailsViewModel();

            patientVisit = patientVisitManager.GetPatientVisitById(patientVisit.ID);

            var patientExaminations = patientVisitManager.GetPatientExaminationsForVisitWithRelatedData(patientVisit.ID);
            var otherVisits         = patientVisitManager.GetVisitsWithRelatedDataExcluding(patientVisit);

            patientDetailsVM.Patient             = patientVisit.Patient;
            patientDetailsVM.VisitDate           = patientVisit.VisitDate;
            patientDetailsVM.PatientExaminations = patientExaminations;
            patientDetailsVM.OtherVisits         = otherVisits;
            patientDetailsVM.VisitId             = patientVisit.ID;
            return(patientDetailsVM);
        }