public static void CreateClientsRequest( ref SqlDataReader reader, ref List <string> req_list, ref List <SyncEntities.SyncClient> listCli) { if (reader == null) { return; } List <string> exIds = null; try { string srv_clients = HttpHandler.Get(srvAPIURL + "/Client/List"); exIds = GetListOfIds(srv_clients); } catch (Exception e) { Logger.Write("Unable to retrieve list of Practices from server - " + e.ToString()); return; } if (exIds.Count == 0) { while (reader.Read()) { SyncEntities.SyncClient cl = new SyncEntities.SyncClient( (long)reader["Id"], reader["UpdateDate"].ToString().Trim(), reader["CreateDate"].ToString().Trim(), reader["Name"].ToString().Trim(), reader["Active"].ToString().Trim() ); req_list.Add(cl.GetNewHttpJson()); listCli.Add(cl); } } else { while (reader.Read()) { if (!exIds.Contains(reader["Id"].ToString().Trim())) { SyncEntities.SyncClient cl = new SyncEntities.SyncClient( (long)reader["Id"], reader["UpdateDate"].ToString(), reader["CreateDate"].ToString(), reader["Name"].ToString().Trim(), reader["Active"].ToString().Trim() ); req_list.Add(cl.GetNewHttpJson()); listCli.Add(cl); } } } }
public static string CreateCPTRequest(ref SqlDataReader reader, ref bool list, ref List <SyncEntities.SyncCPT> listCPT) { if (reader == null) { return(""); } List <string> exIds = null; try { string srv_trtypes = HttpHandler.Get(srvAPIURL + "/CPT/List"); exIds = GetListOfIds(srv_trtypes); } catch (Exception e) { Logger.Write("Unable to retrieve list of CPTs from server - " + e.ToString()); return(""); } List <string> cpts = new List <string>(); string result = ""; if (exIds.Count == 0) { while (reader.Read()) { SyncEntities.SyncCPT cpt = new SyncEntities.SyncCPT( (long)reader["Id"], reader["ClassId"].ToString().Trim(), reader["Name"].ToString().Trim(), reader["Description"].ToString().Trim(), reader["UpdateDate"].ToString().Trim(), reader["CreateDate"].ToString().Trim() ); cpts.Add(cpt.GetNewHttpJson()); listCPT.Add(cpt); } } else { while (reader.Read()) { if (!exIds.Contains(reader["Id"].ToString().Trim())) { SyncEntities.SyncCPT cpt = new SyncEntities.SyncCPT( (long)reader["Id"], reader["ClassId"].ToString().Trim(), reader["Name"].ToString().Trim(), reader["Description"].ToString().Trim(), reader["UpdateDate"].ToString().Trim(), reader["CreateDate"].ToString().Trim() ); cpts.Add(cpt.GetNewHttpJson()); listCPT.Add(cpt); } } } // code for testing /* string req = String.Format( * "{{\"ClassId\": {0}, \"Name\" : \"{1}\", \"Description\": \"{2}\", \"Id\": {3} }}", * 11, * "Name", * "Description", * 6502); * * cpts.Add(req); * * string req2 = String.Format( * "{{\"ClassId\": {0}, \"Name\" : \"{1}\", \"Description\": \"{2}\", \"Id\": {3} }}", * 11, * "Name", * "Description", * 6503); * * cpts.Add(req2);*/ if (cpts.Count <= 0) { return(""); } if (cpts.Count == 1) { return(cpts.ElementAt(0).Trim()); } else { list = true; result = CreateListParams(cpts); return(result); } }
public static string CreateTransactionTypesRequest(ref SqlDataReader reader, ref bool list, ref Dictionary <string, string> idsToUpdate) { if (reader == null) { return(""); } List <string> exIds = null; try { string srv_trtypes = HttpHandler.Get(srvAPIURL + "/TransactionType/List"); exIds = GetListOfIds(srv_trtypes); } catch (Exception e) { Logger.Write("Unable to retrieve list of Transaction Types from server - " + e.ToString()); return(""); } List <string> trtps = new List <string>(); string result = ""; if (exIds.Count == 0) { while (reader.Read()) { string req = String.Format( transactionTypesRequestFmt, reader["Name"].ToString().Trim(), reader["SourceFileId"].ToString().Trim(), reader["Id"].ToString().Trim()); trtps.Add(req); idsToUpdate.Add(reader["Id"].ToString().Trim(), ""); } } else { while (reader.Read()) { if (!exIds.Contains(reader["Id"].ToString().Trim())) { string req = String.Format( transactionTypesRequestFmt, reader["Name"].ToString().Trim(), reader["SourceFileId"].ToString().Trim(), reader["Id"].ToString().Trim()); trtps.Add(req); idsToUpdate.Add(reader["Id"].ToString().Trim(), ""); } } } if (trtps.Count <= 0) { return(""); } if (trtps.Count == 1) { return(trtps.ElementAt(0).Trim()); } else { list = true; result = CreateListParams(trtps); return(result); } }
/* public static string CreateClientPracticesRequest(ref SqlDataReader reader, ref bool list) * { * List<string> clprcts = new List<string>(); * string result = ""; * * while (reader.Read()) * { * string req = String.Format( * clientPracticeFmt, * reader["Name"].ToString().Trim(), * 805, * reader["Id"].ToString().Trim()); * * clprcts.Add(req); * } * * if (clprcts.Count <= 0) * return ""; * * if (clprcts.Count == 1) * { * return clprcts.ElementAt(0).Trim(); * } * else * { * list = true; * result = CreateListParams(clprcts); * return result; * } * } */ public static string CreateDoctorsRequest(ref SqlDataReader reader, ref bool list, ref List <SyncEntities.SyncDoc> listDoc) { if (reader == null) { return(""); } ArrayList objs = new ArrayList(); List <string> exIds = null; try { string srv_doctors = HttpHandler.Get(srvAPIURL + "/Physician/List"); exIds = GetListOfIds(srv_doctors); } catch (Exception e) { Logger.Write("Unable to retrieve list of Physicians from server - " + e.ToString()); return(""); } List <string> doctors = new List <string>(); string result = ""; if (exIds.Count == 0) { while (reader.Read()) { SyncEntities.SyncDoc doc = new SyncEntities.SyncDoc( (long)reader["Id"], reader["FirstName"].ToString().Trim().Replace("\"", "'"), reader["LastName"].ToString().Trim().Replace("\"", "'"), reader["ProviderId"].ToString().Trim().Replace("\"", "'"), reader["UpdateDate"].ToString().Trim().Replace("\"", "'"), reader["CreateDate"].ToString().Trim().Replace("\"", "'"), reader["MiddleName"].ToString().Trim().Replace("\"", "'") ); objs.Add(new { Id = (string)null, FirstName = reader["FirstName"].ToString().Trim(), LastName = reader["LastName"].ToString().Trim(), ProviderId = reader["ProviderId"].ToString().Trim(), MiddleName = reader["MiddleName"].ToString().Trim() }); doctors.Add(doc.GetNewHttpJson()); listDoc.Add(doc); } } else { while (reader.Read()) { if (!exIds.Contains(reader["Id"].ToString().Trim())) { SyncEntities.SyncDoc doc = new SyncEntities.SyncDoc( (long)reader["Id"], reader["FirstName"].ToString().Trim().Replace("\"", "'"), reader["LastName"].ToString().Trim().Replace("\"", "'"), reader["ProviderId"].ToString().Trim().Replace("\"", "'"), reader["UpdateDate"].ToString().Trim().Replace("\"", "'"), reader["CreateDate"].ToString().Trim().Replace("\"", "'"), reader["MiddleName"].ToString().Trim().Replace("\"", "'") ); objs.Add(new { Id = (string)null, FirstName = reader["FirstName"].ToString().Trim(), LastName = reader["LastName"].ToString().Trim(), ProviderId = reader["ProviderId"].ToString().Trim(), MiddleName = reader["MiddleName"].ToString().Trim() }); doctors.Add(doc.GetNewHttpJson()); listDoc.Add(doc); } } } if (doctors.Count <= 0) { return(""); } if (doctors.Count == 1) { return(doctors.ElementAt(0).Trim()); } else { list = true; result = CreateListParams(doctors); result = ""; result = result.Insert(0, "{ \"List\":"); string req1 = JsonConvert.SerializeObject(objs); result = result.Insert(result.Length, req1); result = result.Insert(result.Length, "}"); return(result); } }
public static string CreatePracticesRequest(ref SqlDataReader reader, ref bool list, ref List <SyncEntities.SyncPractice> listPrc) { if (reader == null) { return(""); } List <string> exIds = null; try { string srv_practices = HttpHandler.Get(srvAPIURL + "/Practice/List?clientId=805"); exIds = GetListOfIds(srv_practices); } catch (Exception e) { Logger.Write("Unable to retrieve list of Practices from server - " + e.ToString()); return(""); } List <string> prcts = new List <string>(); string result = ""; if (exIds.Count == 0) { while (reader.Read()) { SyncEntities.SyncPractice prc = new SyncEntities.SyncPractice( (long)reader["Id"], reader["Name"].ToString().Trim(), reader["UpdateDate"].ToString().Trim(), reader["CreateDate"].ToString().Trim() ); prcts.Add(prc.GetNewHttpJson()); listPrc.Add(prc); } } else { while (reader.Read()) { if (!exIds.Contains(reader["Id"].ToString().Trim())) { SyncEntities.SyncPractice prc = new SyncEntities.SyncPractice( (long)reader["Id"], reader["Name"].ToString().Trim(), reader["UpdateDate"].ToString().Trim(), reader["CreateDate"].ToString().Trim() ); prcts.Add(prc.GetNewHttpJson()); listPrc.Add(prc); } } } if (prcts.Count <= 0) { return(""); } if (prcts.Count == 1) { return(prcts.ElementAt(0).Trim()); } else { list = true; result = CreateListParams(prcts); return(result); } }
public static string CreateInsuranceCompaniesRequest(ref SqlDataReader reader, ref bool list, ref List <SyncEntities.SyncIC> listIC) { if (reader == null) { return(""); } ArrayList objs = new ArrayList(); List <string> exIds = null; try { string srv_ics = HttpHandler.Get(srvAPIURL + "/InsuranceCompany/List?clientId=805"); exIds = GetListOfInsuranceIds(srv_ics); } catch (Exception e) { Logger.Write("Unable to retrieve list of Insurance Companies from server - " + e.ToString()); return(""); } List <string> ics = new List <string>(); string result = ""; if (exIds.Count == 0) { while (reader.Read()) { SyncEntities.SyncIC ic = new SyncEntities.SyncIC( (long)reader["Id"], reader["InsuranceId"].ToString().Trim(), reader["Name"].ToString().Trim(), reader["UpdateDate"].ToString().Trim(), reader["CreateDate"].ToString().Trim(), 805, reader["DisplayName"].ToString().Trim() ); objs.Add(new { Id = (string)null, InsuranceID = reader["InsuranceId"].ToString().Trim(), Name = reader["Name"].ToString().Trim(), ClientID = 805, DisplayNAme = reader["DisplayName"].ToString().Trim() }); ics.Add(ic.GetNewHttpJson()); listIC.Add(ic); } } else { while (reader.Read()) { if (!exIds.Contains(reader["InsuranceId"].ToString().Trim())) { SyncEntities.SyncIC ic = new SyncEntities.SyncIC( (long)reader["Id"], reader["InsuranceId"].ToString().Trim(), reader["Name"].ToString().Trim(), reader["UpdateDate"].ToString().Trim(), reader["CreateDate"].ToString().Trim(), 805, reader["DisplayName"].ToString().Trim() ); objs.Add(new { Id = (string)null, InsuranceID = reader["InsuranceId"].ToString().Trim(), Name = reader["Name"].ToString().Trim(), ClientID = 805, DisplayNAme = reader["DisplayName"].ToString().Trim() }); ics.Add(ic.GetNewHttpJson()); listIC.Add(ic); } } } if (ics.Count <= 0) { return(""); } if (ics.Count == 1) { return(ics.ElementAt(0).Trim()); } else { list = true; result = CreateListParams(ics); return(result); } }
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); }
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); } }