Beispiel #1
0
        public static List <TransferOrderHeader> GetPagedTransferOrderHeaderList(string OrderFacilityFrom, string orderStatus, ref int maximumRows, ref int startRowIndex)
        {
            try
            {
                int status = 999;
                if (!String.IsNullOrEmpty(orderStatus))
                {
                    switch (orderStatus)
                    {
                    case "Requested":
                        status = 0;
                        break;

                    case "Released":
                        status = 1;
                        break;

                    case "Packed":
                        status = 2;
                        break;

                    case "Shipped":
                        status = 3;
                        break;

                    case "Canceled":
                        status = -1;
                        break;
                    }
                }

                string query = @"SELECT ""ORDER_NUM"", ""ORDER_SCHED_REPLENISH_DATE"", ""ORDER_FACILITY_FROM"", 
       ""ORDER_FACILITY_TO"", ""ORDER_CARRIER"", case when ""ORDER_STATUS"" = 0 then 'Requested'
                                            when ""ORDER_STATUS"" = 1 then 'Released'
                                            when ""ORDER_STATUS"" = 2 then 'Packed'
                                            when ""ORDER_STATUS"" = 3 then 'Shipped'
                                            when ""ORDER_STATUS"" = -1 then 'Canceled'
                                            end ""ORDER_STATUS"", ""MODIFIED_ON"", 
       ""MODIFIED_BY"", ""REV_NUM"" FROM ""TRANSFER_ORDER_HEADER"" WHERE "
                               + @" ( ""ORDER_FACILITY_FROM"" = @OrderFacilityFrom ) "
                               + @" AND ( ""ORDER_STATUS"" = @OrderStatus OR @OrderStatus IS NULL OR @OrderStatus = 999)  ORDER BY ""ORDER_NUM"" OFFSET @StartRowIndex LIMIT @MaximumRows;";

                List <NpgsqlParameter> parameters = new List <NpgsqlParameter>()
                {
                    new NpgsqlParameter("@OrderFacilityFrom", DbType.String)
                    {
                        Value = OrderFacilityFrom
                    },
                    new NpgsqlParameter("@OrderStatus", DbType.Int32)
                    {
                        Value = status
                    },
                    new NpgsqlParameter("@MaximumRows", DbType.Int32)
                    {
                        Value = maximumRows
                    },
                    new NpgsqlParameter("@StartRowIndex", DbType.Int32)
                    {
                        Value = startRowIndex
                    }
                };

                DataTable dt = DBManager.ExecuteReaderCommand(query, CommandType.Text, parameters);
                return(GetTransferOrderHeaderAsListForStatus(dt));
            }
            catch (Exception ex)
            {
                Log.InsertEntity("TransferOrderHeader", "GetPagedTransferOrderHeaderList", 4, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", ""));
                throw ex;
            }
        }
        public static int GetCountChildList(int statusId, DateTime birthdateFrom, DateTime birthdateTo, string firstname1, string lastname1,
                                            string idFields, string healthFacilityId, int birthplaceId, int communityId, int domicileId,
                                            string motherFirstname, string motherLastname, string systemId, string barcodeId, string tempId)
        {
            try
            {
                string query = @"SELECT count(*) FROM ""CHILD"" WHERE 1 = 1 "
                               + @" AND ( ""BIRTHDATE"" >= @BirthdateFrom OR @BirthdateFrom is null or @BirthdateFrom = '0001-01-01')"
                               + @" AND ( ""BIRTHDATE"" <= @BirthdateTo OR @BirthdateTo is null or @BirthdateTo = '0001-01-01')"
                               + @" AND ( ""STATUS_ID"" = @StatusId OR @StatusId is null or @StatusId = -1)"
                               + @" AND ( ""BIRTHPLACE_ID"" = @BirthplaceId OR @BirthplaceId is null or @BirthplaceId = 0)"
                               + @" AND ( ""COMMUNITY_ID"" = @CommunityId OR @CommunityId is null or @CommunityId = 0)"
                               + @" AND ( ""DOMICILE_ID"" = @DomicileId OR @DomicileId is null or @DomicileId = 0)"
                               + @" AND (( ""HEALTHCENTER_ID"" = ANY( CAST( string_to_array(@HealthFacilityId, ',' ) AS INTEGER[] ))) or @HealthFacilityId = '')"

                               + @" AND ( UPPER(""FIRSTNAME1"") LIKE @Firstname1 or @Firstname1 is null or @Firstname1 = '%%' )"
                               + @" AND ( UPPER(""LASTNAME1"") LIKE @Lastname1 or @Lastname1 is null or @Lastname1 = '%%' )"

                               + @" AND ( UPPER(""SYSTEM_ID"") LIKE @SystemId or @SystemId is null or @SystemId = '%%' )"
                               + @" AND ( UPPER(""BARCODE_ID"") LIKE @BarcodeId or @BarcodeId is null or @BarcodeId = '%%') "
                               + @" AND ( UPPER(""TEMP_ID"") LIKE @TempId or @TempId is null or @TempId = '%%' )"

                               + @" AND ( UPPER(""MOTHER_FIRSTNAME"") LIKE @MotherFirstname or @MotherFirstname is null or @MotherFirstname = '%%' )"
                               + @" AND ( UPPER(""MOTHER_LASTNAME"") LIKE @MotherLastname or @MotherLastname is null or @MotherLastname = '%%' )"
                               + @" AND ( UPPER(""IDENTIFICATION_NO1"") LIKE @IdFields OR UPPER(""IDENTIFICATION_NO2"") LIKE @IdFields OR UPPER(""IDENTIFICATION_NO3"") LIKE @IdFields or (@IdFields is null ) or @IdFields = '%%' )"
                               + @" ;";

                if (healthFacilityId == null)
                {
                    healthFacilityId = "";
                }
                ;

                List <NpgsqlParameter> parameters = new List <NpgsqlParameter>()
                {
                    new NpgsqlParameter("@StatusId", DbType.Int32)
                    {
                        Value = statusId
                    },
                    new NpgsqlParameter("@BirthdateFrom", DbType.Date)
                    {
                        Value = birthdateFrom
                    },
                    new NpgsqlParameter("@BirthdateTo", DbType.Date)
                    {
                        Value = birthdateTo
                    },
                    new NpgsqlParameter("@Firstname1", DbType.String)
                    {
                        Value = "%" + firstname1 + "%"
                    },
                    new NpgsqlParameter("@Lastname1", DbType.String)
                    {
                        Value = "%" + lastname1 + "%"
                    },
                    new NpgsqlParameter("@MotherFirstname", DbType.String)
                    {
                        Value = "%" + motherFirstname + "%"
                    },
                    new NpgsqlParameter("@MotherLastname", DbType.String)
                    {
                        Value = "%" + motherLastname + "%"
                    },
                    new NpgsqlParameter("@IdFields", DbType.String)
                    {
                        Value = "%" + idFields + "%"
                    },
                    new NpgsqlParameter("@SystemId", DbType.String)
                    {
                        Value = "%" + systemId + "%"
                    },
                    new NpgsqlParameter("@BarcodeId", DbType.String)
                    {
                        Value = "%" + barcodeId + "%"
                    },
                    new NpgsqlParameter("@TempId", DbType.String)
                    {
                        Value = "%" + tempId + "%"
                    },
                    new NpgsqlParameter("@HealthFacilityId", DbType.String)
                    {
                        Value = healthFacilityId
                    },
                    new NpgsqlParameter("@BirthplaceId", DbType.Int32)
                    {
                        Value = birthplaceId
                    },
                    new NpgsqlParameter("@CommunityId", DbType.Int32)
                    {
                        Value = communityId
                    },
                    new NpgsqlParameter("@DomicileId", DbType.Int32)
                    {
                        Value = domicileId
                    }
                };

                object count = DBManager.ExecuteScalarCommand(query, CommandType.Text, parameters);
                return(int.Parse(count.ToString()));
            }
            catch (Exception ex)
            {
                Log.InsertEntity("Child", "GetCountChildList", 4, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", ""));
                throw ex;
            }
        }
Beispiel #3
0
        public static int Insert(Child o)
        {
            try
            {
                string query = @"INSERT INTO ""CHILD"" (""SYSTEM_ID"", ""FIRSTNAME1"", ""FIRSTNAME2"", ""LASTNAME1"", ""LASTNAME2"", ""BIRTHDATE"", ""GENDER"", ""HEALTHCENTER_ID"", ""BIRTHPLACE_ID"", ""COMMUNITY_ID"", ""DOMICILE_ID"", ""STATUS_ID"", ""ADDRESS"", ""PHONE"", ""MOBILE"", ""EMAIL"", ""MOTHER_FIRSTNAME"", ""MOTHER_LASTNAME"", ""FATHER_ID"", ""FATHER_FIRSTNAME"", ""FATHER_LASTNAME"", ""CARETAKER_ID"", ""CARETAKER_FIRSTNAME"", ""CARETAKER_LASTNAME"", ""NOTES"", ""IS_ACTIVE"", ""MODIFIED_ON"", ""MODIFIED_BY"", ""BARCODE_ID"", ""TEMP_ID"") VALUES (@SystemId, @Firstname1, @Firstname2, @Lastname1, @Lastname2, @Birthdate, @Gender, @HealthcenterId, @BirthplaceId, @CommunityId, @DomicileId, @StatusId, @Address, @Phone, @Mobile, @Email, @MotherFirstname, @MotherLastname, @FatherId, @FatherFirstname, @FatherLastname, @CaretakerId, @CaretakerFirstname, @CaretakerLastname, @Notes, @IsActive, @ModifiedOn, @ModifiedBy, @BarcodeId, @TempId) returning ""ID"" ";
                List <Npgsql.NpgsqlParameter> parameters = new List <NpgsqlParameter>()
                {
                    new NpgsqlParameter("@SystemId", DbType.String)
                    {
                        Value = o.SystemId
                    },
                    new NpgsqlParameter("@Firstname1", DbType.String)
                    {
                        Value = (object)o.Firstname1 ?? DBNull.Value
                    },
                    new NpgsqlParameter("@Firstname2", DbType.String)
                    {
                        Value = (object)o.Firstname2 ?? DBNull.Value
                    },
                    new NpgsqlParameter("@Lastname1", DbType.String)
                    {
                        Value = (object)o.Lastname1 ?? DBNull.Value
                    },
                    new NpgsqlParameter("@Lastname2", DbType.String)
                    {
                        Value = (object)o.Lastname2 ?? DBNull.Value
                    },
                    new NpgsqlParameter("@Birthdate", DbType.Date)
                    {
                        Value = o.Birthdate
                    },
                    new NpgsqlParameter("@Gender", DbType.Boolean)
                    {
                        Value = o.Gender
                    },
                    new NpgsqlParameter("@HealthcenterId", DbType.Int32)
                    {
                        Value = o.HealthcenterId
                    },
                    new NpgsqlParameter("@BirthplaceId", DbType.Int32)
                    {
                        Value = (object)o.BirthplaceId ?? DBNull.Value
                    },
                    new NpgsqlParameter("@CommunityId", DbType.Int32)
                    {
                        Value = (object)o.CommunityId ?? DBNull.Value
                    },
                    new NpgsqlParameter("@DomicileId", DbType.Int32)
                    {
                        Value = (object)o.DomicileId ?? DBNull.Value
                    },
                    new NpgsqlParameter("@StatusId", DbType.Int32)
                    {
                        Value = o.StatusId
                    },
                    new NpgsqlParameter("@Address", DbType.String)
                    {
                        Value = (object)o.Address ?? DBNull.Value
                    },
                    new NpgsqlParameter("@Phone", DbType.String)
                    {
                        Value = (object)o.Phone ?? DBNull.Value
                    },
                    new NpgsqlParameter("@Mobile", DbType.String)
                    {
                        Value = (object)o.Mobile ?? DBNull.Value
                    },
                    new NpgsqlParameter("@Email", DbType.String)
                    {
                        Value = (object)o.Email ?? DBNull.Value
                    },
                    new NpgsqlParameter("@MotherFirstname", DbType.String)
                    {
                        Value = (object)o.MotherFirstname ?? DBNull.Value
                    },
                    new NpgsqlParameter("@MotherLastname", DbType.String)
                    {
                        Value = (object)o.MotherLastname ?? DBNull.Value
                    },
                    new NpgsqlParameter("@FatherId", DbType.String)
                    {
                        Value = (object)o.FatherId ?? DBNull.Value
                    },
                    new NpgsqlParameter("@FatherFirstname", DbType.String)
                    {
                        Value = (object)o.FatherFirstname ?? DBNull.Value
                    },
                    new NpgsqlParameter("@FatherLastname", DbType.String)
                    {
                        Value = (object)o.FatherLastname ?? DBNull.Value
                    },
                    new NpgsqlParameter("@CaretakerId", DbType.String)
                    {
                        Value = (object)o.CaretakerId ?? DBNull.Value
                    },
                    new NpgsqlParameter("@CaretakerFirstname", DbType.String)
                    {
                        Value = (object)o.CaretakerFirstname ?? DBNull.Value
                    },
                    new NpgsqlParameter("@CaretakerLastname", DbType.String)
                    {
                        Value = (object)o.CaretakerLastname ?? DBNull.Value
                    },
                    new NpgsqlParameter("@Notes", DbType.String)
                    {
                        Value = (object)o.Notes ?? 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("@BarcodeId", DbType.String)
                    {
                        Value = (object)o.BarcodeId ?? DBNull.Value
                    },
                    new NpgsqlParameter("@TempId", DbType.String)
                    {
                        Value = (object)o.TempId ?? DBNull.Value
                    }
                };

                // TODO: Delete all of GIIS
                var debugString = query;
                foreach (var p in parameters)
                {
                    debugString = debugString.Replace(p.ParameterName, (p.Value == DBNull.Value) ? "NULL" : p.Value.ToString());
                }
                Trace.TraceInformation(debugString);
                object id = DBManager.ExecuteScalarCommand(query, CommandType.Text, parameters);
                AuditTable.InsertEntity("Child", id.ToString(), 1, DateTime.Now, o.ModifiedBy);
                return(int.Parse(id.ToString()));
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.ToString());
                Log.InsertEntity("Child", "Insert", 1, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", ""));
            }
            return(-1);
        }
Beispiel #4
0
 public static int Update(Child o)
 {
     try
     {
         string query = @"UPDATE ""CHILD"" SET ""ID"" = @Id, ""SYSTEM_ID"" = @SystemId, ""FIRSTNAME1"" = @Firstname1, ""FIRSTNAME2"" = @Firstname2, ""LASTNAME1"" = @Lastname1, ""LASTNAME2"" = @Lastname2, ""BIRTHDATE"" = @Birthdate, ""GENDER"" = @Gender, ""HEALTHCENTER_ID"" = @HealthcenterId, ""BIRTHPLACE_ID"" = @BirthplaceId, ""COMMUNITY_ID"" = @CommunityId, ""DOMICILE_ID"" = @DomicileId, ""STATUS_ID"" = @StatusId, ""ADDRESS"" = @Address, ""PHONE"" = @Phone, ""MOBILE"" = @Mobile, ""EMAIL"" = @Email, ""MOTHER_FIRSTNAME"" = @MotherFirstname, ""MOTHER_LASTNAME"" = @MotherLastname, ""FATHER_ID"" = @FatherId, ""FATHER_FIRSTNAME"" = @FatherFirstname, ""FATHER_LASTNAME"" = @FatherLastname, ""CARETAKER_ID"" = @CaretakerId, ""CARETAKER_FIRSTNAME"" = @CaretakerFirstname, ""CARETAKER_LASTNAME"" = @CaretakerLastname, ""NOTES"" = @Notes, ""IS_ACTIVE"" = @IsActive, ""MODIFIED_ON"" = @ModifiedOn, ""MODIFIED_BY"" = @ModifiedBy, ""BARCODE_ID"" = @BarcodeId, ""TEMP_ID"" = @TempId WHERE ""ID"" = @Id ";
         List <Npgsql.NpgsqlParameter> parameters = new List <NpgsqlParameter>()
         {
             new NpgsqlParameter("@SystemId", DbType.String)
             {
                 Value = o.SystemId
             },
             new NpgsqlParameter("@Firstname1", DbType.String)
             {
                 Value = (object)o.Firstname1 ?? DBNull.Value
             },
             new NpgsqlParameter("@Firstname2", DbType.String)
             {
                 Value = (object)o.Firstname2 ?? DBNull.Value
             },
             new NpgsqlParameter("@Lastname1", DbType.String)
             {
                 Value = (object)o.Lastname1 ?? DBNull.Value
             },
             new NpgsqlParameter("@Lastname2", DbType.String)
             {
                 Value = (object)o.Lastname2 ?? DBNull.Value
             },
             new NpgsqlParameter("@Birthdate", DbType.Date)
             {
                 Value = o.Birthdate
             },
             new NpgsqlParameter("@Gender", DbType.Boolean)
             {
                 Value = o.Gender
             },
             new NpgsqlParameter("@HealthcenterId", DbType.Int32)
             {
                 Value = o.HealthcenterId
             },
             new NpgsqlParameter("@BirthplaceId", DbType.Int32)
             {
                 Value = (object)o.BirthplaceId ?? DBNull.Value
             },
             new NpgsqlParameter("@CommunityId", DbType.Int32)
             {
                 Value = (object)o.CommunityId ?? DBNull.Value
             },
             new NpgsqlParameter("@DomicileId", DbType.Int32)
             {
                 Value = (object)o.DomicileId ?? DBNull.Value
             },
             new NpgsqlParameter("@StatusId", DbType.Int32)
             {
                 Value = o.StatusId
             },
             new NpgsqlParameter("@Address", DbType.String)
             {
                 Value = (object)o.Address ?? DBNull.Value
             },
             new NpgsqlParameter("@Phone", DbType.String)
             {
                 Value = (object)o.Phone ?? DBNull.Value
             },
             new NpgsqlParameter("@Mobile", DbType.String)
             {
                 Value = (object)o.Mobile ?? DBNull.Value
             },
             new NpgsqlParameter("@Email", DbType.String)
             {
                 Value = (object)o.Email ?? DBNull.Value
             },
             new NpgsqlParameter("@MotherId", DbType.String)
             {
                 Value = (object)o.MotherId ?? DBNull.Value
             },
             new NpgsqlParameter("@MotherFirstname", DbType.String)
             {
                 Value = (object)o.MotherFirstname ?? DBNull.Value
             },
             new NpgsqlParameter("@MotherLastname", DbType.String)
             {
                 Value = (object)o.MotherLastname ?? DBNull.Value
             },
             new NpgsqlParameter("@FatherId", DbType.String)
             {
                 Value = (object)o.FatherId ?? DBNull.Value
             },
             new NpgsqlParameter("@FatherFirstname", DbType.String)
             {
                 Value = (object)o.FatherFirstname ?? DBNull.Value
             },
             new NpgsqlParameter("@FatherLastname", DbType.String)
             {
                 Value = (object)o.FatherLastname ?? DBNull.Value
             },
             new NpgsqlParameter("@CaretakerId", DbType.String)
             {
                 Value = (object)o.CaretakerId ?? DBNull.Value
             },
             new NpgsqlParameter("@CaretakerFirstname", DbType.String)
             {
                 Value = (object)o.CaretakerFirstname ?? DBNull.Value
             },
             new NpgsqlParameter("@CaretakerLastname", DbType.String)
             {
                 Value = (object)o.CaretakerLastname ?? DBNull.Value
             },
             new NpgsqlParameter("@Notes", DbType.String)
             {
                 Value = (object)o.Notes ?? 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("@IdentificationNo1", DbType.String)
             {
                 Value = (object)o.IdentificationNo1 ?? DBNull.Value
             },
             new NpgsqlParameter("@IdentificationNo2", DbType.String)
             {
                 Value = (object)o.IdentificationNo2 ?? DBNull.Value
             },
             new NpgsqlParameter("@IdentificationNo3", DbType.String)
             {
                 Value = (object)o.IdentificationNo3 ?? DBNull.Value
             },
             new NpgsqlParameter("@BarcodeId", DbType.String)
             {
                 Value = (object)o.BarcodeId ?? DBNull.Value
             },
             new NpgsqlParameter("@TempId", DbType.String)
             {
                 Value = (object)o.TempId ?? DBNull.Value
             },
             new NpgsqlParameter("@Id", DbType.Int32)
             {
                 Value = o.Id
             }
         };
         int rowAffected = DBManager.ExecuteNonQueryCommand(query, CommandType.Text, parameters);
         AuditTable.InsertEntity("Child", o.Id.ToString(), 2, DateTime.Now, o.ModifiedBy);
         return(rowAffected);
     }
     catch (Exception ex)
     {
         Log.InsertEntity("Child", "Update", 2, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", ""));
     }
     return(-1);
 }
        public DataTable GetCoverageChart(int hfId)
        {
            try
            {
                string s = HealthFacility.GetAllChildsForOneHealthFacility(hfId);
                if (!string.IsNullOrEmpty(s))
                {
                    string query = @"with tmp as
(
SELECT SV.""NAME"" as ""Name"", date_part('month', ""SCHEDULED_DATE"") as ""Month"", date_part('year', ""SCHEDULED_DATE"")  ""Year"", COUNT(*) as ""Count"", 'Scheduled' as ""Type""

FROM ""VACCINATION_EVENT"" VE

INNER JOIN ""DOSE"" D ON VE.""DOSE_ID"" = D.""ID"" 
INNER JOIN ""SCHEDULED_VACCINATION"" SV ON SV.""ID"" = D.""SCHEDULED_VACCINATION_ID""

WHERE ""SCHEDULED_DATE"" BETWEEN (date_trunc('month', now()) - interval '3 month') AND (date_trunc('month', now())::date - 1)
AND ""HEALTH_FACILITY_ID"" IN (" + s + @")

GROUP BY SV.""NAME"", date_part('month', ""SCHEDULED_DATE""), date_part('year', ""SCHEDULED_DATE"")

union all

SELECT SV.""NAME"", date_part('month', ""VACCINATION_DATE""), date_part('year', ""VACCINATION_DATE""), COUNT(*), 'Done'

FROM ""VACCINATION_EVENT"" VE

INNER JOIN ""DOSE"" D ON VE.""DOSE_ID"" = D.""ID"" 
INNER JOIN ""SCHEDULED_VACCINATION"" SV ON SV.""ID"" = D.""SCHEDULED_VACCINATION_ID""

WHERE ""VACCINATION_DATE"" BETWEEN (date_trunc('month', now()) - interval '3 month') AND (date_trunc('month', now())::date - 1)
AND ""VACCINATION_STATUS"" = true
AND ""HEALTH_FACILITY_ID"" IN (" + s + @")

GROUP BY SV.""NAME"", date_part('month', ""VACCINATION_DATE""), date_part('year', ""VACCINATION_DATE"")
)

select t1.""Name"", t1.""Month"", t1.""Year"", trunc((t2.""Count"" / t1.""Count""::float * 100)::numeric, 2) as ""Percentage""
from tmp t1 left outer join tmp t2
on t1.""Name"" = t2.""Name"" and t1.""Month"" = t2.""Month"" and t1.""Year"" = t2.""Year"" and t1.""Type"" <> t2.""Type""
where t1.""Type"" = 'Scheduled'

order by t1.""Name"", t1.""Year"", t1.""Month""; ";


                    //List<NpgsqlParameter> parameters = new List<NpgsqlParameter>()
                    //{
                    //    new NpgsqlParameter("@hfid_1", DbType.String) { Value = s },
                    //     new NpgsqlParameter("@hfid_2", DbType.String) { Value = s }
                    //};

                    DataTable dt = DBManager.ExecuteReaderCommand(query, CommandType.Text, null);
                    return(dt);
                }
                return(null);
            }
            catch (Exception ex)
            {
                Log.InsertEntity("HealthFacilityBalance", "GetHealthFacilityBalanceForList", 4, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", ""));
                throw ex;
            }
        }
 public static int Update(ScheduledVaccination o)
 {
     try
     {
         string query = @"UPDATE ""SCHEDULED_VACCINATION"" SET ""ID"" = @Id, ""NAME"" = @Name, ""CODE"" = @Code, ""ITEM_ID"" = @ItemId, ""ENTRY_DATE"" = @EntryDate, ""EXIT_DATE"" = @ExitDate, ""STATUS"" = @Status, ""DESEASES"" = @Deseases, ""NOTES"" = @Notes, ""IS_ACTIVE"" = @IsActive, ""MODIFIED_ON"" = @ModifiedOn, ""MODIFIED_BY"" = @ModifiedBy WHERE ""ID"" = @Id ";
         List <Npgsql.NpgsqlParameter> parameters = new List <NpgsqlParameter>()
         {
             new NpgsqlParameter("@Name", DbType.String)
             {
                 Value = o.Name
             },
             new NpgsqlParameter("@Code", DbType.String)
             {
                 Value = o.Code
             },
             new NpgsqlParameter("@ItemId", DbType.Int32)
             {
                 Value = o.ItemId
             },
             new NpgsqlParameter("@EntryDate", DbType.Date)
             {
                 Value = o.EntryDate
             },
             new NpgsqlParameter("@ExitDate", DbType.Date)
             {
                 Value = (object)o.ExitDate ?? DBNull.Value
             },
             new NpgsqlParameter("@Status", DbType.Boolean)
             {
                 Value = o.Status
             },
             new NpgsqlParameter("@Deseases", DbType.String)
             {
                 Value = (object)o.Deseases ?? DBNull.Value
             },
             new NpgsqlParameter("@Notes", DbType.String)
             {
                 Value = (object)o.Notes ?? 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("ScheduledVaccination", o.Id.ToString(), 2, DateTime.Now, o.ModifiedBy);
         return(rowAffected);
     }
     catch (Exception ex)
     {
         Log.InsertEntity("ScheduledVaccination", "Update", 2, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", ""));
     }
     return(-1);
 }
 public static int Insert(ScheduledVaccination o)
 {
     try
     {
         string query = @"INSERT INTO ""SCHEDULED_VACCINATION"" (""NAME"", ""CODE"", ""ITEM_ID"", ""ENTRY_DATE"", ""EXIT_DATE"", ""STATUS"", ""DESEASES"", ""NOTES"", ""IS_ACTIVE"", ""MODIFIED_ON"", ""MODIFIED_BY"") VALUES (@Name, @Code, @ItemId, @EntryDate, @ExitDate, @Status, @Deseases, @Notes, @IsActive, @ModifiedOn, @ModifiedBy) returning ""ID"" ";
         List <Npgsql.NpgsqlParameter> parameters = new List <NpgsqlParameter>()
         {
             new NpgsqlParameter("@Name", DbType.String)
             {
                 Value = o.Name
             },
             new NpgsqlParameter("@Code", DbType.String)
             {
                 Value = o.Code
             },
             new NpgsqlParameter("@ItemId", DbType.Int32)
             {
                 Value = o.ItemId
             },
             new NpgsqlParameter("@EntryDate", DbType.Date)
             {
                 Value = o.EntryDate
             },
             new NpgsqlParameter("@ExitDate", DbType.Date)
             {
                 Value = (object)o.ExitDate ?? DBNull.Value
             },
             new NpgsqlParameter("@Status", DbType.Boolean)
             {
                 Value = o.Status
             },
             new NpgsqlParameter("@Deseases", DbType.String)
             {
                 Value = (object)o.Deseases ?? DBNull.Value
             },
             new NpgsqlParameter("@Notes", DbType.String)
             {
                 Value = (object)o.Notes ?? 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("ScheduledVaccination", id.ToString(), 1, DateTime.Now, o.ModifiedBy);
         return(int.Parse(id.ToString()));
     }
     catch (Exception ex)
     {
         Log.InsertEntity("ScheduledVaccination", "Insert", 1, ex.StackTrace.Replace("'", ""), ex.Message.Replace("'", ""));
     }
     return(-1);
 }
 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);
 }
 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);
 }