Example #1
0
        public static List <gSearchPatientViewModel> GetPatients(string connectionString, int OfficeId, string search, int PageIndex = 1, int PageSize = 10)
        {
            var db         = new LTCDataModel.PetaPoco.Database(connectionString, "MySql");
            var newResults = new List <gSearchPatientViewModel>();

            try
            {
                var q =
                    @"SELECT pt.Office_sequence,pt.Account,pt.PatientNumber,pt.Doctor,pt.LastName,pt.FirstName,pt.Sex,pt.Birthdate,pt.LastVisit,pt.BestPhone,
                    (Select phonenumber from patientphone ph where PatientNumber = pt.PatientNumber AND phoneType='P' AND Office_sequence=" +
                    OfficeId + @") AS PhoneNumber,
                    (Select phonenumber from patientphone ph where PatientNumber = pt.PatientNumber AND phoneType='W' AND Office_sequence=" +
                    OfficeId + @") As MobilePhone
                    FROM patient pt where  ( pt.PatientNumber like '%" + search + "%' OR pt.Doctor like '%" + search +
                    "%' or pt.LastName like '%" + search + "%' OR pt.FirstName like '%" + search +
                    "%' OR pt.Sex like '%" + search + "%' OR pt.Birthdate like '%" + search +
                    "%' OR pt.LastVisit like '%" + search + "%') AND pt.Office_sequence=" + OfficeId + "  LIMIT " +
                    PageSize +
                    " OFFSET " +
                    PageIndex;


                var results = db.Fetch <gSearchPatient>(q).ToList();

                foreach (var item in results)
                {
                    newResults.Add(new gSearchPatientViewModel
                    {
                        Account         = item.Account,
                        PatientNumber   = item.PatientNumber,
                        Doctor          = item.Doctor,
                        Name            = item.FirstName + " " + item.LastName,
                        Sex_Age         = item.Sex.ToUpper() + "" + CalculateAge(item.Birthdate),
                        Office_Sequence = item.Office_Sequence,
                        Birthdate       = item.Birthdate.ToString("MM/dd/yyyy"),
                        LastVisit       = item.LastVisit.ToString("MM/dd/yyyy"),
                        HomePhone       = item.PhoneNumber,
                        CellPhone       = item.MobilePhone
                    });
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                db.CloseSharedConnection();
            }

            return(newResults);
        }
Example #2
0
        public static List <gAddress> GetPatientAddress(string connectionString, int officeSequence, int patientNumber)
        {
            var db     = new LTCDataModel.PetaPoco.Database(connectionString, "MySql");
            var result = new List <gAddress>();

            try
            {
            }
            catch (Exception ex)
            {
            }
            finally
            {
                db.CloseSharedConnection();
            }
            return(db.Fetch <gAddress>($"select A.Office_sequence, A.title, A.lastname, A.firstname, A.initial, A.street, A.street2, A.street3, A.citycode, A.postalcode, A.note, A.AddrCounter, A.PostCounter, C.line1 from address A LEFT JOIN code C on A.citycode = C.code where  A.office_Sequence = {officeSequence} and A.PatientNumber = {patientNumber} AND A.type='-'"));
            //return db.Fetch<gAddress>($"select Office_sequence, title, lastname, firstname, initial, street, street2, street3, citycode, postalcode, note, AddrCounter, PostCounter from address where  office_Sequence = {officeSequence} and PatientNumber = {patientNumber}");
        }
Example #3
0
        public static List <gPatientPhone> GetPatientPhone(string connectionString, int officeSequence, int patientNumber)
        {
            var db     = new LTCDataModel.PetaPoco.Database(connectionString, "MySql");
            var result = new List <gPatientPhone>();

            try
            {
                result = db.Fetch <gPatientPhone>($"Select phonetype,areacode,phonenumber,extension,bestcalltimefrom,bestcalltimeto,PhoneCounter  from patientphone where office_Sequence = {officeSequence} and PatientNumber = {patientNumber}");
            }
            catch (Exception ex)
            {
            }
            finally
            {
                db.CloseSharedConnection();
            }
            return(result);
        }
Example #4
0
        public static List <gPatient> GetPatientDetail(string connectionString, int officeSequence, int patientNumber)
        {
            var db     = new LTCDataModel.PetaPoco.Database(connectionString, "MySql");
            var result = new List <gPatient>();

            try
            {
                result = db.Fetch <gPatient>($"Select patientnumber,account,title,title, lastname, firstname, initial,birthdate,sex,doctor from patient where office_Sequence = {officeSequence} and PatientNumber = {patientNumber}");
            }
            catch (Exception ex)
            {
            }
            finally
            {
                db.CloseSharedConnection();
            }
            return(result);
        }