コード例 #1
0
        public static List <VaccinationEvent> GetVaccinationEventAsList(DataTable dt)
        {
            List <VaccinationEvent> oList = new List <VaccinationEvent>();

            foreach (DataRow row in dt.Rows)
            {
                try
                {
                    VaccinationEvent o = new VaccinationEvent();
                    o.Id                     = Helper.ConvertToInt(row["ID"]);
                    o.AppointmentId          = Helper.ConvertToInt(row["APPOINTMENT_ID"]);
                    o.ChildId                = Helper.ConvertToInt(row["CHILD_ID"]);
                    o.DoseId                 = Helper.ConvertToInt(row["DOSE_ID"]);
                    o.VaccineLotId           = Helper.ConvertToInt(row["VACCINE_LOT_ID"]);
                    o.VaccineLotText         = row["VACCINE_LOT_TEXT"].ToString();
                    o.HealthFacilityId       = Helper.ConvertToInt(row["HEALTH_FACILITY_ID"]);
                    o.ScheduledDate          = Helper.ConvertToDate(row["SCHEDULED_DATE"]);
                    o.VaccinationDate        = Helper.ConvertToDate(row["VACCINATION_DATE"]);
                    o.Notes                  = row["NOTES"].ToString();
                    o.VaccinationStatus      = Helper.ConvertToBoolean(row["VACCINATION_STATUS"]);
                    o.NonvaccinationReasonId = Helper.ConvertToInt(row["NONVACCINATION_REASON_ID"]);
                    o.IsActive               = Helper.ConvertToBoolean(row["IS_ACTIVE"]);
                    o.ModifiedOn             = Helper.ConvertToDate(row["MODIFIED_ON"]);
                    o.ModifiedBy             = Helper.ConvertToInt(row["MODIFIED_BY"]);
                    //o.Timestamp = Helper.ConvertToDate(row["MODIFIEDON"]);
                    oList.Add(o);
                }
                catch (Exception ex)
                {
                    Log.InsertEntity("VaccinationEvent", "GetVaccinationEventAsList", 1, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", ""));
                    throw ex;
                }
            }
            return(oList);
        }
コード例 #2
0
        public static int InsertVaccinationsForChild(int childId, int userId)
        {
            try
            {
                Child child = Child.GetChildById(childId);

                List <Dose> vaccineDoseList = Dose.GetDosesByDates(child.Birthdate);

                foreach (Dose vaccineDose in vaccineDoseList)
                {
                    VaccinationAppointment o = new VaccinationAppointment();
                    o.ChildId             = childId;
                    o.ScheduledFacilityId = child.HealthcenterId;
                    o.ScheduledDate       = child.Birthdate.AddDays(vaccineDose.AgeDefinition.Days);
                    o.Notes      = String.Empty;
                    o.IsActive   = true;
                    o.ModifiedOn = DateTime.Now;
                    o.ModifiedBy = userId;

                    string where = string.Format(" \"CHILD_ID\" = {0} AND \"SCHEDULED_DATE\" = '{1}' ", child.Id, o.ScheduledDate.ToString("yyyy-MM-dd"));
                    List <VaccinationAppointment> list = GetVaccinationAppointmentForList(where);
                    int count = list.Count;

                    if (count == 0)
                    {
                        int lastApp = Insert(o);
                        if (lastApp > 0)
                        {
                            VaccinationEvent ve = new VaccinationEvent();

                            ve.AppointmentId     = lastApp;
                            ve.ChildId           = childId;
                            ve.DoseId            = vaccineDose.Id;
                            ve.HealthFacilityId  = child.HealthcenterId;
                            ve.ScheduledDate     = o.ScheduledDate;
                            ve.VaccinationDate   = o.ScheduledDate;
                            ve.Notes             = String.Empty;
                            ve.VaccinationStatus = false;
                            int dosenum = vaccineDose.DoseNumber - 1;

                            if (VaccinationEvent.OtherDose(vaccineDose.ScheduledVaccinationId, childId, dosenum) && dosenum > 0)
                            {
                                ve.IsActive = false;
                            }
                            else
                            {
                                ve.IsActive = true;
                            }
                            ve.ModifiedOn = DateTime.Now;
                            ve.ModifiedBy = userId;
                            int i = VaccinationEvent.Insert(ve);
                            if (!(i > 0))
                            {
                                VaccinationAppointment.DeleteByChild(childId);
                                Child.Delete(childId);
                                return(0);
                            }
                        }
                        else
                        {
                            Child.Delete(childId);
                            return(0);
                        }
                    }
                    else
                    {
                        VaccinationAppointment appointment = list[0];
                        VaccinationEvent       ve          = new VaccinationEvent();

                        ve.AppointmentId     = appointment.Id;
                        ve.ChildId           = childId;
                        ve.DoseId            = vaccineDose.Id;
                        ve.HealthFacilityId  = child.HealthcenterId;
                        ve.ScheduledDate     = o.ScheduledDate;
                        ve.VaccinationDate   = o.ScheduledDate;
                        ve.Notes             = String.Empty;
                        ve.VaccinationStatus = false;
                        int dosenum = vaccineDose.DoseNumber - 1;

                        if (VaccinationEvent.OtherDose(vaccineDose.ScheduledVaccinationId, childId, dosenum) && dosenum > 0)
                        {
                            ve.IsActive = false;
                        }
                        else
                        {
                            ve.IsActive = true;
                        }
                        ve.ModifiedOn = DateTime.Now;
                        ve.ModifiedBy = userId;
                        int i = VaccinationEvent.Insert(ve);
                        if (!(i > 0))
                        {
                            VaccinationAppointment.DeleteByChild(childId);
                            Child.Delete(childId);
                            return(0);
                        }
                    }
                }
                return(1);
            }
            catch (Exception ex)
            {
                Log.InsertEntity("VaccinationAppointment", "InsertVaccinationsForChild", 4, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", ""));
                throw ex;
            }

            // return 0;
        }
コード例 #3
0
 public static int Update(VaccinationEvent o)
 {
     try
     {
         string query = @"UPDATE ""VACCINATION_EVENT"" SET ""ID"" = @Id, ""APPOINTMENT_ID"" = @AppointmentId, ""CHILD_ID"" = @ChildId, ""DOSE_ID"" = @DoseId, ""VACCINE_LOT_ID"" = @VaccineLotId, ""VACCINE_LOT_TEXT"" = @VaccineLotText, ""HEALTH_FACILITY_ID"" = @HealthFacilityId, ""SCHEDULED_DATE"" = @ScheduledDate, ""VACCINATION_DATE"" = @VaccinationDate, ""NOTES"" = @Notes, ""VACCINATION_STATUS"" = @VaccinationStatus, ""NONVACCINATION_REASON_ID"" = @NonvaccinationReasonId, ""IS_ACTIVE"" = @IsActive, ""MODIFIED_ON"" = @ModifiedOn, ""MODIFIED_BY"" = @ModifiedBy, ""MODIFIEDON"" = @ModifiedOn WHERE ""ID"" = @Id ";
         List <Npgsql.NpgsqlParameter> parameters = new List <NpgsqlParameter>()
         {
             new NpgsqlParameter("@AppointmentId", DbType.Int32)
             {
                 Value = o.AppointmentId
             },
             new NpgsqlParameter("@ChildId", DbType.Int32)
             {
                 Value = o.ChildId
             },
             new NpgsqlParameter("@DoseId", DbType.Int32)
             {
                 Value = o.DoseId
             },
             new NpgsqlParameter("@VaccineLotId", DbType.Int32)
             {
                 Value = (object)o.VaccineLotId ?? DBNull.Value
             },
             new NpgsqlParameter("@VaccineLotText", DbType.String)
             {
                 Value = (object)o.VaccineLotText ?? DBNull.Value
             },
             new NpgsqlParameter("@HealthFacilityId", DbType.Int32)
             {
                 Value = o.HealthFacilityId
             },
             new NpgsqlParameter("@ScheduledDate", DbType.Date)
             {
                 Value = o.ScheduledDate
             },
             new NpgsqlParameter("@VaccinationDate", DbType.Date)
             {
                 Value = o.VaccinationDate
             },
             new NpgsqlParameter("@Notes", DbType.String)
             {
                 Value = (object)o.Notes ?? DBNull.Value
             },
             new NpgsqlParameter("@VaccinationStatus", DbType.Boolean)
             {
                 Value = o.VaccinationStatus
             },
             new NpgsqlParameter("@NonvaccinationReasonId", DbType.Int32)
             {
                 Value = (object)o.NonvaccinationReasonId ?? DBNull.Value
             },
             new NpgsqlParameter("@IsActive", DbType.Boolean)
             {
                 Value = o.IsActive
             },
             new NpgsqlParameter("@ModifiedOn", DbType.DateTime)
             {
                 Value = o.ModifiedOn
             },
             new NpgsqlParameter("@ModifiedBy", DbType.Int32)
             {
                 Value = o.ModifiedBy
             },
             new NpgsqlParameter("@Id", DbType.Int32)
             {
                 Value = o.Id
             }
         };
         int rowAffected = DBManager.ExecuteNonQueryCommand(query, CommandType.Text, parameters);
         AuditTable.InsertEntity("VaccinationEvent", o.Id.ToString(), 2, DateTime.Now, o.ModifiedBy);
         return(rowAffected);
     }
     catch (Exception ex)
     {
         Log.InsertEntity("VaccinationEvent", "Update", 2, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", ""));
     }
     return(-1);
 }
コード例 #4
0
 public static int Insert(VaccinationEvent o)
 {
     try
     {
         string query = @"INSERT INTO ""VACCINATION_EVENT"" (""APPOINTMENT_ID"", ""CHILD_ID"", ""DOSE_ID"", ""VACCINE_LOT_ID"", ""VACCINE_LOT_TEXT"", ""HEALTH_FACILITY_ID"", ""SCHEDULED_DATE"", ""VACCINATION_DATE"", ""NOTES"", ""VACCINATION_STATUS"", ""NONVACCINATION_REASON_ID"", ""IS_ACTIVE"", ""MODIFIED_ON"", ""MODIFIED_BY"", ""MODIFIEDON"") VALUES (@AppointmentId, @ChildId, @DoseId, @VaccineLotId, @VaccineLotText, @HealthFacilityId, @ScheduledDate, @VaccinationDate, @Notes, @VaccinationStatus, @NonvaccinationReasonId, @IsActive, @ModifiedOn, @ModifiedBy,@ModifiedOn) returning ""ID"" ";
         List <Npgsql.NpgsqlParameter> parameters = new List <NpgsqlParameter>()
         {
             new NpgsqlParameter("@AppointmentId", DbType.Int32)
             {
                 Value = o.AppointmentId
             },
             new NpgsqlParameter("@ChildId", DbType.Int32)
             {
                 Value = o.ChildId
             },
             new NpgsqlParameter("@DoseId", DbType.Int32)
             {
                 Value = o.DoseId
             },
             new NpgsqlParameter("@VaccineLotId", DbType.Int32)
             {
                 Value = (object)o.VaccineLotId ?? DBNull.Value
             },
             new NpgsqlParameter("@VaccineLotText", DbType.String)
             {
                 Value = (object)o.VaccineLotText ?? DBNull.Value
             },
             new NpgsqlParameter("@HealthFacilityId", DbType.Int32)
             {
                 Value = o.HealthFacilityId
             },
             new NpgsqlParameter("@ScheduledDate", DbType.Date)
             {
                 Value = o.ScheduledDate
             },
             new NpgsqlParameter("@VaccinationDate", DbType.Date)
             {
                 Value = o.VaccinationDate
             },
             new NpgsqlParameter("@Notes", DbType.String)
             {
                 Value = (object)o.Notes ?? DBNull.Value
             },
             new NpgsqlParameter("@VaccinationStatus", DbType.Boolean)
             {
                 Value = o.VaccinationStatus
             },
             new NpgsqlParameter("@NonvaccinationReasonId", DbType.Int32)
             {
                 Value = (object)o.NonvaccinationReasonId ?? DBNull.Value
             },
             new NpgsqlParameter("@IsActive", DbType.Boolean)
             {
                 Value = o.IsActive
             },
             new NpgsqlParameter("@ModifiedOn", DbType.DateTime)
             {
                 Value = o.ModifiedOn
             },
             new NpgsqlParameter("@ModifiedBy", DbType.Int32)
             {
                 Value = o.ModifiedBy
             }
         };
         object id = DBManager.ExecuteScalarCommand(query, CommandType.Text, parameters);
         AuditTable.InsertEntity("VaccinationEvent", id.ToString(), 1, DateTime.Now, o.ModifiedBy);
         return(int.Parse(id.ToString()));
     }
     catch (Exception ex)
     {
         Log.InsertEntity("VaccinationEvent", "Insert", 1, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", ""));
     }
     return(-1);
 }