Esempio n. 1
0
        public static Dictionary <string, List <SyncEntities.SyncPatient> > CreatePatientsRequestList(ref SqlDataReader reader)
        {
            if (reader == null)
            {
                return(null);
            }

            Dictionary <string, List <SyncEntities.SyncPatient> > requests_pat = new Dictionary <string, List <SyncEntities.SyncPatient> >();
            List <string> cpts = new List <string>();
            List <SyncEntities.SyncPatient> listPat = new List <SyncEntities.SyncPatient>();
            int count = 0;


            List <string> exIds = null;

            try
            {
                string srv_clients = HttpHandler.Get(srvAPIURL + "/Patient/List?clientId=805");
                exIds = GetListOfIds(srv_clients);
            }
            catch (Exception e)
            {
                Logger.Write("Unable to retrieve list of Patients from server - " + e.ToString());
                return(null);
            }

            if (exIds != null && exIds.Count > 0)
            {
                while (reader.Read())
                {
                    if (!exIds.Contains(reader["Id"].ToString().Trim()))
                    {
                        SyncEntities.SyncPatient pt = new SyncEntities.SyncPatient(
                            (long)reader["Id"],
                            805,
                            reader["PolicyNumber"].ToString().Trim(),
                            reader["AccountId"].ToString().Trim(),
                            reader["FirstName"].ToString().Trim(),
                            reader["MiddleName"].ToString().Trim(),
                            reader["LastName"].ToString().Trim(),
                            reader["DOB"].ToString().Trim(),
                            reader["UpdateDate"].ToString().Trim(),
                            reader["CreateDate"].ToString().Trim(),
                            reader["SSN"].ToString().Trim(),
                            reader["Policy"].ToString().Trim(),
                            reader["Access"].ToString().Trim());

                        cpts.Add(pt.GetNewHttpJson());
                        listPat.Add(pt);
                        ++count;

                        if (count >= 100)
                        {
                            string json = CreateListParams(cpts);
                            List <SyncEntities.SyncPatient> lc = new List <SyncEntities.SyncPatient>();
                            lc.AddRange(listPat);
                            requests_pat.Add(json, lc);
                            cpts.Clear();
                            listPat.Clear();
                            json  = "";
                            count = 0;
                        }
                    }
                }
            }
            else
            {
                while (reader.Read())
                {
                    SyncEntities.SyncPatient pt = new SyncEntities.SyncPatient(
                        (long)reader["Id"],
                        805,
                        reader["PolicyNumber"].ToString().Trim(),
                        reader["AccountId"].ToString().Trim(),
                        reader["FirstName"].ToString().Trim(),
                        reader["MiddleName"].ToString().Trim(),
                        reader["LastName"].ToString().Trim(),
                        reader["DOB"].ToString().Trim(),
                        reader["UpdateDate"].ToString().Trim(),
                        reader["CreateDate"].ToString().Trim(),
                        reader["SSN"].ToString().Trim(),
                        reader["Policy"].ToString().Trim(),
                        reader["Access"].ToString().Trim());

                    cpts.Add(pt.GetNewHttpJson());
                    listPat.Add(pt);
                    ++count;

                    if (count >= 100)
                    {
                        string json = CreateListParams(cpts);
                        List <SyncEntities.SyncPatient> lc = new List <SyncEntities.SyncPatient>();
                        lc.AddRange(listPat);
                        requests_pat.Add(json, lc);
                        cpts.Clear();
                        listPat.Clear();
                        json  = "";
                        count = 0;
                    }
                }

                if (cpts.Count > 0)
                {
                    string js = CreateListParams(cpts);
                    List <SyncEntities.SyncPatient> ll = new List <SyncEntities.SyncPatient>();
                    ll.AddRange(listPat);
                    requests_pat.Add(js, ll);
                }
            }

            if (requests_pat.Count <= 0)
            {
                return(null);
            }

            return(requests_pat);
        }
Esempio n. 2
0
        public static string CreatePatientsRequest(
            ref SqlDataReader reader,
            ref bool list,
            ref List <SyncEntities.SyncPatient> listPat)
        {
            if (reader == null)
            {
                return("");
            }

            List <string> exIds = null;

            try
            {
                string srv_clients = HttpHandler.Get(srvAPIURL + "/Patient/List?clientId=805");
                exIds = GetListOfAccountIds(srv_clients);
            }
            catch (Exception e)
            {
                Logger.Write("Unable to retrieve list of Patients from server - " + e.ToString());
                return("");
            }

            List <string> patients = new List <string>();
            string        result   = "";

            JArray jl = new JArray();

            if (exIds != null && exIds.Count > 0)
            {
                while (reader.Read())
                {
                    if (!exIds.Contains(reader["AccountId"].ToString().Trim()))
                    {
                        SyncEntities.SyncPatient pt = new SyncEntities.SyncPatient(
                            (long)reader["Id"],
                            805,
                            reader["PolicyNumber"].ToString().Trim(),
                            reader["AccountId"].ToString().Trim(),
                            reader["FirstName"].ToString().Trim(),
                            reader["MiddleName"].ToString().Trim(),
                            reader["LastName"].ToString().Trim(),
                            reader["DOB"].ToString().Trim(),
                            reader["UpdateDate"].ToString().Trim(),
                            reader["CreateDate"].ToString().Trim(),
                            reader["SSN"].ToString().Trim(),
                            reader["Policy"].ToString().Trim(),
                            reader["Access"].ToString().Trim());

                        patients.Add(pt.GetNewHttpJson());

                        listPat.Add(pt);
                    }
                }
            }
            else
            {
                while (reader.Read())
                {
                    SyncEntities.SyncPatient pt = new SyncEntities.SyncPatient(
                        (long)reader["Id"],
                        805,
                        reader["PolicyNumber"].ToString().Trim(),
                        reader["AccountId"].ToString().Trim(),
                        reader["FirstName"].ToString().Trim(),
                        reader["MiddleName"].ToString().Trim(),
                        reader["LastName"].ToString().Trim(),
                        reader["DOB"].ToString().Trim(),
                        reader["UpdateDate"].ToString().Trim(),
                        reader["CreateDate"].ToString().Trim(),
                        reader["SSN"].ToString().Trim(),
                        reader["Policy"].ToString().Trim(),
                        reader["Access"].ToString().Trim());

                    patients.Add(pt.GetNewHttpJson());

                    listPat.Add(pt);
                }
            }

            if (patients.Count <= 0)
            {
                return("");
            }

            if (patients.Count == 1)
            {
                return(patients.ElementAt(0).Trim());
            }
            else
            {
                list   = true;
                result = CreateListParams(patients);
                return(result);
            }
        }