/// <summary> /// Get data from source for given module /// </summary> /// <param name="connection">Source Database connection</param> /// <param name="parameters">number of parameters which are have version,modulename etc...</param> /// <returns>Return the datasetof 2 tables,one for module data and another is for errors or debug log or any validation message</returns> private DataTable GetPatientMedicalHistoryData(Hashtable parameters) { try { string strModuleName = string.Empty; strModuleName = "MedicalHistory"; DataTable dtModuleData = new DataTable(strModuleName); DataTable dtClinicaldata = new DataTable(); // Do data processing here. APIConnection api = (APIConnection)parameters["athenaapiobject"]; List <medicationdetail> objclinical1 = new List <medicationdetail>(); //ArrayList arydept = new ArrayList(); //arydept = (ArrayList)parameters["api_departmentid"]; //foreach (var value in arydept) //{ Dictionary <string, string> dirlst = new Dictionary <string, string>() { { "departmentid", parameters["api_departmentid"].ToString() }, { "showdeleted", "false" } }; JObject jobj = (JObject)api.GET("chart/" + parameters["patientid"].ToString() + "/medicalhistory", dirlst); JToken jtobj = jobj["MedicalHistory"]; if (jtobj != null) { if (jtobj.HasValues && jtobj.SelectToken("error") != null) { throw new Exception(jtobj["error"].ToString()); } List <JToken> jtobjlst = new List <JToken>(); foreach (var item in jtobj) { foreach (var item1 in item) { jtobjlst.Add(item1); } } medicationdetail objclinical = new medicationdetail(); objclinical1 = new List <medicationdetail>(); foreach (var subitem in jtobjlst) { objclinical = subitem.ToObject <medicationdetail>(); if (objclinical.Structuredsig != null) { objclinical.Dosagefrequencyvalue = objclinical.Structuredsig.Dosagefrequencyvalue; objclinical.Dosageroute = objclinical.Structuredsig.Dosageroute; objclinical.Dosageaction = objclinical.Structuredsig.Dosageaction; objclinical.Dosageadditionalinstructions = objclinical.Structuredsig.Dosageadditionalinstructions; objclinical.Dosagefrequencyunit = objclinical.Structuredsig.Dosagefrequencyunit; objclinical.Dosagequantityunit = objclinical.Structuredsig.Dosagequantityunit; objclinical.Dosagequantityvalue = objclinical.Structuredsig.Dosagequantityvalue; objclinical.Dosagefrequencydescription = objclinical.Structuredsig.Dosagefrequencydescription; objclinical.Dosagedurationunit = objclinical.Structuredsig.Dosagedurationunit; } if (objclinical.Events != null) { foreach (var item1 in objclinical.Events) { if (item1.Type.ToLower() == "start") { objclinical.Startdate = item1.Eventdate; } if (item1.Type.ToLower() == "end") { objclinical.Stopdate = item1.Eventdate; } if (item1.Type.ToLower() == "enter") { objclinical.Enterdate = item1.Eventdate; } if (item1.Type.ToLower() == "hide") { objclinical.Hidedate = item1.Eventdate; } objclinical.Type = item1.Type; } } if (objclinical.Rxnorm != null) { string rxlst = ""; foreach (var rx in objclinical.Rxnorm) { rxlst = string.Concat(rxlst, rx, ","); } if (rxlst.Length > 0) { objclinical.Rxnormstr = rxlst.TrimEnd(','); } } if (objclinical.Ndcoptions != null) { string Ndcoptionslst = ""; foreach (var rx in objclinical.Ndcoptions) { Ndcoptionslst = string.Concat(Ndcoptionslst, rx, ","); } if (Ndcoptionslst.Length > 0) { objclinical.Ndcoptionsstr = Ndcoptionslst.TrimEnd(','); } } objclinical1.Add(objclinical); } } //} dtClinicaldata = GetModuleDataBase.ConvertToDataTable(objclinical1); if (!dtClinicaldata.Columns.Contains("patientid")) { dtClinicaldata.Columns.Add("patientid"); } if (!dtClinicaldata.Columns.Contains("daterecorded")) { dtClinicaldata.Columns.Add("daterecorded"); } if (!dtClinicaldata.Columns.Contains("Active")) { dtClinicaldata.Columns.Add("Active"); } if (!dtClinicaldata.Columns.Contains("Active")) { dtClinicaldata.Columns.Add("Active"); } if (!dtClinicaldata.Columns.Contains("ndccode")) { dtClinicaldata.Columns.Add("ndccode"); } if (!dtClinicaldata.Columns.Contains("ndccode")) { dtClinicaldata.Columns.Add("ndccode"); } if (!dtClinicaldata.Columns.Contains("rxflag")) { dtClinicaldata.Columns.Add("rxflag"); } if (!dtClinicaldata.Columns.Contains("drugcode")) { dtClinicaldata.Columns.Add("drugcode"); } if (!dtClinicaldata.Columns.Contains("CodeSystemId")) { dtClinicaldata.Columns.Add("CodeSystemId"); } if (dtClinicaldata != null && dtClinicaldata.Rows.Count > 0) { dtClinicaldata.Columns["dosageroute"].ColumnName = "doseroute"; dtClinicaldata.Columns["dosageaction"].ColumnName = "doseaction"; dtClinicaldata.Columns["dosagequantityvalue"].ColumnName = "Dosequantity"; dtClinicaldata.Columns["dosagequantityunit"].ColumnName = "DoseUnit"; dtClinicaldata.Columns["unstructuredsig"].ColumnName = "Direction"; } foreach (DataRow dr in dtClinicaldata.Rows) { dr["startdate"] = dr["startdate"].ToString(); //objCommonCleanup.ParseDateFromString(dr["startdate"].ToString(), "yyyyMMdd"); dr["stopdate"] = dr["stopdate"].ToString(); //objCommonCleanup.ParseDateFromString(dr["stopdate"].ToString(), "yyyyMMdd"); dr["patientid"] = parameters["patientid"]; dr["daterecorded"] = dr["Enterdate"].ToString(); //objCommonCleanup.ParseDateFromString(dr["Enterdate"].ToString(), "yyyyMMdd"); if (dr["Rxnormstr"].ToString().Trim().Length > 0) { if (dr["Ndcoptionsstr"].ToString().Trim().Length > 0) { dr["drugcode"] = dr["Ndcoptionsstr"].ToString().Split(',').Last(); dr["ndccode"] = dr["drugcode"]; dr["CodeSystemId"] = "NDC"; } else { dr["drugcode"] = dr["Rxnormstr"].ToString().Split(',').Last(); dr["CodeSystemId"] = "RxNorm"; } } else { if (dr["Ndcoptionsstr"].ToString().Trim().Length > 0) { dr["drugcode"] = dr["Ndcoptionsstr"].ToString().Split(',').Last(); dr["ndccode"] = dr["drugcode"]; dr["CodeSystemId"] = "NDC"; } } string strStopDate = string.Empty; if (dr["stopdate"].ToString() != "") { strStopDate = dr["stopdate"].ToString(); } DateTime dtimeStopDate = DateTime.Now; if (strStopDate.Length > 0) { dtimeStopDate = DateTime.ParseExact(strStopDate, "yyyyMMdd", CultureInfo.InvariantCulture); if (dtimeStopDate >= DateTime.Now) { dr["stopdate"] = string.Empty; dr["Active"] = "1"; } else { dr["Active"] = "0"; } } else { dr["Active"] = "1"; } } dtClinicaldata = dtClinicaldata.DefaultView.ToTable(true); dtClinicaldata.TableName = strModuleName; return(dtClinicaldata); } catch (Exception) { throw; } }
private DataTable GetPatientDemographicsData(Hashtable parameters) { try { string strModuleName = "PatientDemographics"; //DataSet dsModuleData = new DataSet(strModuleName); DataTable dtClinicaldata = new DataTable(); APIConnection api = (APIConnection)parameters["athenaapiobject"]; JToken jtobj = (JToken)api.GET("patients" + "/" + parameters["patientid"]); if (jtobj != null) { if (jtobj.HasValues && jtobj.SelectToken("error") != null) { return(new DataTable()); //dtValidation.Rows.Add(new object[] { parameters["patientid"].ToString(), "", "", "", "", strModuleName, string.Empty, jtobj["error"].ToString() + parameters["patientid"].ToString() }); //{ throw new Exception(jtobj["error"].ToString()); } } List <Patients> Patientdata = jtobj.ToObject <List <Patients> >(); dtClinicaldata = GetModuleDataBase.ConvertToDataTable(Patientdata); if (dtClinicaldata != null && dtClinicaldata.Rows.Count > 0) { dtClinicaldata.Columns["status"].ColumnName = "pstatus"; dtClinicaldata.Columns["lastname"].ColumnName = "plname"; dtClinicaldata.Columns["firstname"].ColumnName = "pfname"; dtClinicaldata.Columns["middlename"].ColumnName = "pminit"; dtClinicaldata.Columns["email"].ColumnName = "pemail"; dtClinicaldata.Columns["address1"].ColumnName = "paddr1"; dtClinicaldata.Columns["address2"].ColumnName = "paddr2"; dtClinicaldata.Columns["city"].ColumnName = "pcity"; dtClinicaldata.Columns["state"].ColumnName = "pstate"; dtClinicaldata.Columns["zip"].ColumnName = "pzip"; dtClinicaldata.Columns["sex"].ColumnName = "psex"; dtClinicaldata.Columns["homephone"].ColumnName = "phomephn"; dtClinicaldata.Columns["mobilephone"].ColumnName = "pcellphone"; dtClinicaldata.Columns["ssn"].ColumnName = "pssn"; dtClinicaldata.Columns["dob"].ColumnName = "pdob"; dtClinicaldata.Columns["primaryproviderid"].ColumnName = "dcode"; dtClinicaldata.Columns["maritalstatus"].ColumnName = "pmarital"; dtClinicaldata.Columns["racename"].ColumnName = "prace"; dtClinicaldata.Columns["suffix"].ColumnName = "psuffix"; dtClinicaldata.Columns["prefix"].ColumnName = "pprefix"; dtClinicaldata.Columns["Lastappointment"].ColumnName = "lastvisit"; dtClinicaldata.Columns["firstappointment"].ColumnName = "firstvisit"; dtClinicaldata.Columns["language6392code"].ColumnName = "language"; dtClinicaldata.Columns["contactrelationship"].ColumnName = "emgcontactrelation"; dtClinicaldata.Columns["Contactname"].ColumnName = "emgname"; dtClinicaldata.Columns["contacthomephone"].ColumnName = "emgphone"; dtClinicaldata.Columns["Employername"].ColumnName = "ename"; dtClinicaldata.Columns["employeraddress"].ColumnName = "eaddr1"; dtClinicaldata.Columns["employeraddress2"].ColumnName = "eaddr2"; dtClinicaldata.Columns["employerphone"].ColumnName = "ephone"; dtClinicaldata.Columns["employercity"].ColumnName = "ecity"; dtClinicaldata.Columns["employerstate"].ColumnName = "estate"; dtClinicaldata.Columns["employerzip"].ColumnName = "ezip"; dtClinicaldata.Columns["employerfax"].ColumnName = "efax"; dtClinicaldata.Columns["guarantorlastname"].ColumnName = "glname"; dtClinicaldata.Columns["guarantorfirstname"].ColumnName = "gfname"; dtClinicaldata.Columns["guarantormiddlename"].ColumnName = "gminit"; dtClinicaldata.Columns["guarantoremail"].ColumnName = "gemail"; dtClinicaldata.Columns["guarantoraddress1"].ColumnName = "gaddr1"; dtClinicaldata.Columns["guarantoraddress2"].ColumnName = "gaddr2"; dtClinicaldata.Columns["guarantorcity"].ColumnName = "gcity"; dtClinicaldata.Columns["guarantorstate"].ColumnName = "gstate"; dtClinicaldata.Columns["guarantorzip"].ColumnName = "gzip"; dtClinicaldata.Columns["guarantorsex"].ColumnName = "gsex"; dtClinicaldata.Columns["guarantorphone"].ColumnName = "ghomephn"; dtClinicaldata.Columns["guarantorssn"].ColumnName = "gssn"; dtClinicaldata.Columns["guarantordob"].ColumnName = "gdob"; dtClinicaldata.Columns["guarantorracename"].ColumnName = "grace"; dtClinicaldata.Columns["guarantorsuffix"].ColumnName = "gsuffix"; dtClinicaldata.Columns["guarantorprefix"].ColumnName = "gprefix"; } string dobdate = string.Empty; if (!dtClinicaldata.Columns.Contains("original_pstatus")) { dtClinicaldata.Columns.Add("original_pstatus"); } if (!dtClinicaldata.Columns.Contains("pchartno")) { dtClinicaldata.Columns.Add("pchartno"); } if (!dtClinicaldata.Columns.Contains("pchartno")) { dtClinicaldata.Columns.Add("pchartno"); } if (!dtClinicaldata.Columns.Contains("original_prace")) { dtClinicaldata.Columns.Add("original_prace"); } if (!dtClinicaldata.Columns.Contains("original_ethnicity")) { dtClinicaldata.Columns.Add("original_ethnicity"); } if (!dtClinicaldata.Columns.Contains("original_pmarital")) { dtClinicaldata.Columns.Add("original_pmarital"); } if (!dtClinicaldata.Columns.Contains("original_prela2grn")) { dtClinicaldata.Columns.Add("original_prela2grn"); } if (!dtClinicaldata.Columns.Contains("daterecorded")) { dtClinicaldata.Columns.Add("daterecorded"); } if (!dtClinicaldata.Columns.Contains("custom3")) { dtClinicaldata.Columns.Add("custom3"); } if (!dtClinicaldata.Columns.Contains("custom2")) { dtClinicaldata.Columns.Add("custom2"); } if (!dtClinicaldata.Columns.Contains("custom1")) { dtClinicaldata.Columns.Add("custom1"); } if (!dtClinicaldata.Columns.Contains("prela2grn")) { dtClinicaldata.Columns.Add("prela2grn"); } if (!dtClinicaldata.Columns.Contains("ethnicity")) { dtClinicaldata.Columns.Add("ethnicity"); } string strprelatogrn = ""; foreach (DataRow dr in dtClinicaldata.Rows) { if (string.IsNullOrEmpty(dr["emgphone"].ToString())) { dr["emgphone"] = dr["contactmobilephone"].ToString(); } switch (dr["guarantorrelationshiptopatient"].ToString()) { case "1": strprelatogrn = "Self"; break; case "2": strprelatogrn = "Spouse"; break; case "3": strprelatogrn = "Child"; break; case "4": strprelatogrn = "Other"; break; case "5": strprelatogrn = "Grandparent"; break; case "6": strprelatogrn = "Grandchild"; break; case "7": strprelatogrn = "Nephew or Niece"; break; case "9": strprelatogrn = "Foster Child"; break; case "10": strprelatogrn = "Ward"; break; case "11": strprelatogrn = "Stepson or Stepdaughter"; break; case "12": strprelatogrn = "Employee"; break; case "13": strprelatogrn = "Unknown"; break; case "14": strprelatogrn = "Handicapped Dependent"; break; case "15": strprelatogrn = "Sponsored Dependent"; break; case "16": strprelatogrn = "Dependent of a Minor Dependent"; break; case "17": strprelatogrn = "Significant Other"; break; case "18": strprelatogrn = "Mother"; break; case "19": strprelatogrn = "Father"; break; case "21": strprelatogrn = "Emancipated Minor"; break; case "22": strprelatogrn = "Organ Donor"; break; case "23": strprelatogrn = "Cadaver Donor"; break; case "24": strprelatogrn = "Injured Plaintiff"; break; case "25": strprelatogrn = "Child(Ins.not Financially Respons.)"; break; case "26": strprelatogrn = "Life Partner"; break; case "27": strprelatogrn = "Child(Mother's Insurance)"; break; case "28": strprelatogrn = "Child(Father's Insurance)"; break; case "29": strprelatogrn = "Child(of Mother, Ins.not Financially Respons.)"; break; case "30": strprelatogrn = "Child(of Father, Ins.not Financially Respons.)"; break; case "31": strprelatogrn = "Stepson or Stepdaughter(Stepmother's Insurance)"; break; case "32": strprelatogrn = "Stepson or Stepdaughter(Stepfather's Insurance)"; break; } dr["prela2grn"] = strprelatogrn; dr["original_prela2grn"] = dr["prela2grn"]; dr["daterecorded"] = DateTime.Now.ToString(); // objCommonCleanup.ParseDateFromString(DateTime.Now.ToString(), "yyyyMMdd"); dr["lastvisit"] = dr["lastvisit"].ToString(); // objCommonCleanup.ParseDateFromString(dr["lastvisit"].ToString() , "yyyyMMdd"); dr["firstvisit"] = dr["firstvisit"].ToString(); // objCommonCleanup.ParseDateFromString(dr["firstvisit"].ToString(), "yyyyMMdd"); if (string.IsNullOrEmpty(dr["paddr1"].ToString()) && !string.IsNullOrEmpty(dr["paddr2"].ToString())) { dr["paddr1"] = dr["paddr2"]; dr["paddr2"] = string.Empty; } if (string.IsNullOrEmpty(dr["gaddr1"].ToString()) && !string.IsNullOrEmpty(dr["gaddr2"].ToString())) { dr["gaddr1"] = dr["gaddr2"]; dr["gaddr2"] = string.Empty; } dr["original_pstatus"] = dr["pstatus"]; dr["original_prace"] = dr["prace"]; dr["original_pmarital"] = dr["pmarital"]; dr["patientid"] = parameters["patientid"].ToString(); //need to discuss dr["pchartno"] = dr["patientid"]; if (dr["pstatus"].ToString().ToLower() == "active") { dr["pstatus"] = "A"; } else if (dr["pstatus"].ToString().ToLower() == "inactive") { dr["pstatus"] = "I"; } else if (dr["pstatus"].ToString().ToLower() == "prospective") { dr["pstatus"] = "A"; } string strethnicity = string.Empty; if (dr["ethnicitycode"].ToString() == "2135-2") { strethnicity = @"Hispanic or Latino\/Spanish"; } else if (dr["ethnicitycode"].ToString() == "2137-8") { strethnicity = "Spaniard"; } else if (dr["ethnicitycode"].ToString() == "2138-6") { strethnicity = "Andalusian"; } else if (dr["ethnicitycode"].ToString() == "2139-4") { strethnicity = "Asturian"; } else if (dr["ethnicitycode"].ToString() == "2140-2") { strethnicity = "Castillian"; } else if (dr["ethnicitycode"].ToString() == "2141-0") { strethnicity = "Catalonian"; } else if (dr["ethnicitycode"].ToString() == "2142-8") { strethnicity = "Belearic Islander"; } else if (dr["ethnicitycode"].ToString() == "2143-6") { strethnicity = "Gallego"; } else if (dr["ethnicitycode"].ToString() == "2144-4") { strethnicity = "Valencian"; } else if (dr["ethnicitycode"].ToString() == "2145-1") { strethnicity = "Canarian"; } else if (dr["ethnicitycode"].ToString() == "2146-9") { strethnicity = "Spanish Basque"; } else if (dr["ethnicitycode"].ToString() == "2148-5") { strethnicity = "Mexican"; } else if (dr["ethnicitycode"].ToString() == "2149-3") { strethnicity = "Mexican American"; } else if (dr["ethnicitycode"].ToString() == "2150-1") { strethnicity = "Mexicano"; } else if (dr["ethnicitycode"].ToString() == "2151-9") { strethnicity = "Chicano"; } else if (dr["ethnicitycode"].ToString() == "2152-7") { strethnicity = "La Raza"; } else if (dr["ethnicitycode"].ToString() == "2153-5") { strethnicity = "Mexican American Indian"; } else if (dr["ethnicitycode"].ToString() == "2155-0") { strethnicity = "Central American"; } else if (dr["ethnicitycode"].ToString() == "2156-8") { strethnicity = "Costa Rican"; } else if (dr["ethnicitycode"].ToString() == "2157-6") { strethnicity = "Guatemalan"; } else if (dr["ethnicitycode"].ToString() == "2158-4") { strethnicity = "Honduran"; } else if (dr["ethnicitycode"].ToString() == "2159-2") { strethnicity = "Nicaraguan"; } else if (dr["ethnicitycode"].ToString() == "2160-0") { strethnicity = "Panamanian"; } else if (dr["ethnicitycode"].ToString() == "2161-8") { strethnicity = "Salvadoran"; } else if (dr["ethnicitycode"].ToString() == "2162-6") { strethnicity = "Central American Indian"; } else if (dr["ethnicitycode"].ToString() == "2163-4") { strethnicity = "Canal Zone"; } else if (dr["ethnicitycode"].ToString() == "2165-9") { strethnicity = "South American"; } else if (dr["ethnicitycode"].ToString() == "2166-7") { strethnicity = "Argentinean"; } else if (dr["ethnicitycode"].ToString() == "2167-5") { strethnicity = "Bolivian"; } else if (dr["ethnicitycode"].ToString() == "2168-3") { strethnicity = "Chilean"; } else if (dr["ethnicitycode"].ToString() == "2169-1") { strethnicity = "Colombian"; } else if (dr["ethnicitycode"].ToString() == "2170-9") { strethnicity = "Ecuadorian"; } else if (dr["ethnicitycode"].ToString() == "2171-7") { strethnicity = "Paraguayan"; } else if (dr["ethnicitycode"].ToString() == "2172-5") { strethnicity = "Peruvian"; } else if (dr["ethnicitycode"].ToString() == "2173-3") { strethnicity = "Uruguayan"; } else if (dr["ethnicitycode"].ToString() == "2174-1") { strethnicity = "Venezuelan"; } else if (dr["ethnicitycode"].ToString() == "2175-8") { strethnicity = "South American Indian"; } else if (dr["ethnicitycode"].ToString() == "2176-6") { strethnicity = "Criollo"; } else if (dr["ethnicitycode"].ToString() == "2178-2") { strethnicity = @"Latin American\/Latin) Latino"; } else if (dr["ethnicitycode"].ToString() == "2180-8") { strethnicity = "Puerto Rican"; } else if (dr["ethnicitycode"].ToString() == "2182-4") { strethnicity = "Cuban"; } else if (dr["ethnicitycode"].ToString() == "2184-0") { strethnicity = "Dominican"; } else if (dr["ethnicitycode"].ToString() == "2186-5") { strethnicity = "Not Hispanic or Latino"; } else { strethnicity = dr["ethnicitycode"].ToString(); } if (strethnicity.Length > 0) { dr["original_ethnicity"] = strethnicity; } else { dr["original_ethnicity"] = dr["ethnicitycode"].ToString(); } dr["ethnicity"] = dr["ethnicitycode"].ToString(); } } dtClinicaldata.TableName = strModuleName; //dsModuleData.Tables.Add(dtValidation); //dsModuleData.Tables.Add(dtClinicaldata); return(dtClinicaldata); } catch (Exception) { throw; } }
/// <summary> /// Get data from source for given module /// </summary> /// <param name="connection">Source Database connection</param> /// <param name="parameters">number of parameters which are have version,modulename etc...</param> /// <returns>Return the datasetof 2 tables,one for module data and another is for errors or debug log or any validation message</returns> private DataTable GetAppointmentsData(Hashtable parameters) { try { string strModuleName = string.Empty; strModuleName = "Appointments"; //DataSet dsModuleData = new DataSet(strModuleName); DataTable dtClinicaldata = new DataTable(strModuleName); DataTable dtTempata = new DataTable(); // Do data processing here. APIConnection api = (APIConnection)parameters["athenaapiobject"]; Dictionary <string, string> appbook = null; JObject jobj = null; JToken jtobj = null; ArrayList arydept = new ArrayList(); arydept = (ArrayList)parameters["api_departmentid_patientmaster"]; foreach (var value in arydept) { string format = "MM/dd/yyyy"; DateTime StartDateTime = new DateTime(); //if (Convert.ToString(objConfiguration.GetDeltaIdentifier(parameters, connection.GetType().Name)) != string.Empty) //{ // StartDateTime = Convert.ToDateTime(objConfiguration.GetDeltaIdentifier(parameters, connection.GetType().Name)); //} DateTime EndDateTime = DateTime.Now; appbook = new Dictionary <string, string>() { { "patientid", parameters["patientid"].ToString() }, { "departmentid", value.ToString() }, { "startdate", "01/01/2001" }, { "enddate", EndDateTime.ToString(format).Replace("-", "/") }, { "limit", "10000" } }; jobj = (JObject)api.GET("appointments/booked", appbook); jtobj = jobj["appointments"]; if (jtobj != null) { if (jtobj.HasValues && jtobj.SelectToken("error") != null) { throw new Exception(jtobj["error"].ToString()); } List <appointments> objclinical = jtobj.ToObject <List <appointments> >(); dtTempata = GetModuleDataBase.ConvertToDataTable(objclinical); dtClinicaldata.Merge(dtTempata); } } if (dtClinicaldata != null && dtClinicaldata.Rows.Count > 0) { dtClinicaldata.Columns["date"].ColumnName = "adate"; dtClinicaldata.Columns["starttime"].ColumnName = "atime"; dtClinicaldata.Columns["appointmentstatus"].ColumnName = "astatus"; dtClinicaldata.Columns["providerid"].ColumnName = "dcode"; dtClinicaldata.Columns["appointmenttype"].ColumnName = "atype"; dtClinicaldata.Columns["duration"].ColumnName = "aduration"; dtClinicaldata.Columns["lastmodified"].ColumnName = "updateddate"; } if (!dtClinicaldata.Columns.Contains("daterecorded")) { dtClinicaldata.Columns.Add("daterecorded"); } if (!dtClinicaldata.Columns.Contains("anotes")) { dtClinicaldata.Columns.Add("anotes"); } if (!dtClinicaldata.Columns.Contains("comments")) { dtClinicaldata.Columns.Add("comments"); } foreach (DataRow dr in dtClinicaldata.Rows) { dr["patientid"] = parameters["patientid"]; dr["daterecorded"] = dr["adate"]; dr["atime"] = dr["atime"].ToString().Replace(":", ""); dr["adate"] = dr["adate"].ToString(); dr["startcheckin"] = dr["startcheckin"].ToString(); dr["daterecorded"] = dr["daterecorded"].ToString(); jobj = (JObject)api.GET("appointments/" + dr["appointmentid"].ToString() + "/notes"); if (jobj.SelectToken("totalcount").ToString() != "0") { jtobj = jobj["notes"]; string strnote = ""; if (jtobj.Count() > 0) { foreach (var item in jtobj) { if (item.SelectToken("notetext") != null) { strnote = string.Concat("Notes: ", strnote, item["notetext"].ToString()); strnote = string.Concat(strnote, "; Created: ", item["created"].ToString()); strnote = string.Concat(strnote, "; Created By: ", item["createdby"].ToString()); } } } if (strnote.Length > 2000) { dr["comments"] = strnote; } else { dr["anotes"] = strnote; } } } dtClinicaldata = dtClinicaldata.DefaultView.ToTable(true); dtClinicaldata.TableName = strModuleName; //dsModuleData.Tables.Add(dtValidation); //dsModuleData.Tables.Add(dtClinicaldata); return(dtClinicaldata); } catch (Exception) { throw; } }
/// <summary> /// Get data from source for given module /// </summary> /// <param name="connection">Source Database connection</param> /// <param name="parameters">number of parameters which are have version,modulename etc...</param> /// <returns>Return the datasetof 2 tables,one for module data and another is for errors or debug log or any validation message</returns> private DataTable GetCareTeamData(Hashtable parameters) { try { string strModuleName = string.Empty; strModuleName = "CareTeam"; //DataSet dsModuleData = new DataSet(strModuleName); DataTable dtClinicaldata = new DataTable(strModuleName); DataTable dtTempata = new DataTable(); // Do data processing here. APIConnection api = (APIConnection)parameters["athenaapiobject"]; Dictionary <string, string> dirlst = null; JObject jobj = null; JToken jtobj = null; ArrayList arydept = new ArrayList(); arydept = (ArrayList)parameters["api_departmentid_patientmaster"]; foreach (var value in arydept) { dirlst = new Dictionary <string, string>() { { "departmentid", value.ToString() } }; jobj = (JObject)api.GET("chart/" + parameters["patientid"].ToString() + "/careteam", dirlst); jtobj = jobj["members"]; if (jtobj != null) { if (jtobj.HasValues && jtobj.SelectToken("error") != null) { throw new Exception(jtobj["error"].ToString()); } List <appointments> objclinical = jtobj.ToObject <List <appointments> >(); dtTempata = GetModuleDataBase.ConvertToDataTable(objclinical); dtClinicaldata.Merge(dtTempata); } } if (dtClinicaldata != null && dtClinicaldata.Rows.Count > 0) { dtClinicaldata.Columns["date"].ColumnName = "adate"; dtClinicaldata.Columns["starttime"].ColumnName = "atime"; dtClinicaldata.Columns["appointmentstatus"].ColumnName = "astatus"; dtClinicaldata.Columns["providerid"].ColumnName = "dcode"; dtClinicaldata.Columns["appointmenttype"].ColumnName = "atype"; dtClinicaldata.Columns["duration"].ColumnName = "aduration"; dtClinicaldata.Columns["lastmodified"].ColumnName = "updateddate"; } if (!dtClinicaldata.Columns.Contains("daterecorded")) { dtClinicaldata.Columns.Add("daterecorded"); } if (!dtClinicaldata.Columns.Contains("anotes")) { dtClinicaldata.Columns.Add("anotes"); } if (!dtClinicaldata.Columns.Contains("comments")) { dtClinicaldata.Columns.Add("comments"); } foreach (DataRow dr in dtClinicaldata.Rows) { dr["patientid"] = parameters["patientid"]; dr["daterecorded"] = dr["adate"]; dr["atime"] = dr["atime"].ToString().Replace(":", ""); dr["adate"] = dr["adate"].ToString(); dr["startcheckin"] = dr["startcheckin"].ToString(); dr["daterecorded"] = dr["daterecorded"].ToString(); jobj = (JObject)api.GET("appointments/" + dr["appointmentid"].ToString() + "/notes"); if (jobj.SelectToken("totalcount").ToString() != "0") { jtobj = jobj["notes"]; string strnote = ""; if (jtobj.Count() > 0) { foreach (var item in jtobj) { if (item.SelectToken("notetext") != null) { strnote = string.Concat("Notes: ", strnote, item["notetext"].ToString()); strnote = string.Concat(strnote, "; Created: ", item["created"].ToString()); strnote = string.Concat(strnote, "; Created By: ", item["createdby"].ToString()); } } } if (strnote.Length > 2000) { dr["comments"] = strnote; } else { dr["anotes"] = strnote; } } } dtClinicaldata = dtClinicaldata.DefaultView.ToTable(true); dtClinicaldata.TableName = strModuleName; //dsModuleData.Tables.Add(dtValidation); //dsModuleData.Tables.Add(dtClinicaldata); return(dtClinicaldata); } catch (Exception) { throw; } }
/// <summary> /// Get data from source for given module /// </summary> /// <param name="connection">Source Database connection</param> /// <param name="parameters">number of parameters which are have version,modulename etc...</param> /// <returns>Return the datasetof 2 tables,one for module data and another is for errors or debug log or any validation message</returns> private DataTable GetLabResultsData(Hashtable parameters) { try { string strModuleName = string.Empty; strModuleName = "LabResults"; //DataSet dsModuleData = new DataSet(strModuleName); DataTable dtClinicaldata = new DataTable(); // Do data processing here. APIConnection api = (APIConnection)parameters["athenaapiobject"]; List <Analyte> objclinical = new List <Analyte>(); //ArrayList arydept = new ArrayList(); //arydept = (ArrayList)parameters["api_departmentid"]; //foreach (var value in arydept) //{ Dictionary <string, string> dirlst = new Dictionary <string, string>() { { "departmentid", parameters["api_departmentid"].ToString() } }; JObject jobj = (JObject)api.GET("chart/" + parameters["patientid"].ToString() + "/analytes", dirlst); JToken jtobj = jobj["analytes"]; if (jtobj != null) { if (jtobj.HasValues && jtobj.SelectToken("error") != null) { throw new Exception(jtobj["error"].ToString()); } objclinical = jtobj.ToObject <List <Analyte> >(); } //} dtClinicaldata = GetModuleDataBase.ConvertToDataTable(objclinical); if (!dtClinicaldata.Columns.Contains("patientid")) { dtClinicaldata.Columns.Add("patientid"); } if (!dtClinicaldata.Columns.Contains("daterecorded")) { dtClinicaldata.Columns.Add("daterecorded"); } if (!dtClinicaldata.Columns.Contains("ordernumber")) { dtClinicaldata.Columns.Add("ordernumber"); } if (!dtClinicaldata.Columns.Contains("ordertestcode")) { dtClinicaldata.Columns.Add("ordertestcode"); } if (!dtClinicaldata.Columns.Contains("ordertestname")) { dtClinicaldata.Columns.Add("ordertestname"); } if (!dtClinicaldata.Columns.Contains("resultcode")) { dtClinicaldata.Columns.Add("resultcode"); } if (dtClinicaldata != null && dtClinicaldata.Rows.Count > 0) { dtClinicaldata.Columns["analytename"].ColumnName = "resultname"; dtClinicaldata.Columns["analytedate"].ColumnName = "resultdatetime"; dtClinicaldata.Columns["Valuestatus"].ColumnName = "abnormalflag"; dtClinicaldata.Columns["Referencerange"].ColumnName = "range"; dtClinicaldata.Columns["description"].ColumnName = "reportcomments"; dtClinicaldata.Columns["Note"].ColumnName = "observationnotes"; dtClinicaldata.Columns["Loinc"].ColumnName = "loincresultcode"; dtClinicaldata.Columns["Units"].ColumnName = "units"; dtClinicaldata.Columns["Resultstatus"].ColumnName = "resultstatus"; } string strdate = string.Empty; foreach (DataRow dr in dtClinicaldata.Rows) { dr["patientid"] = parameters["patientid"].ToString(); dr["resultcode"] = dr["resultname"]; dr["ordertestname"] = dr["resultname"]; dr["ordertestcode"] = dr["resultcode"]; dr["resultdatetime"] = dr["resultdatetime"].ToString(); strdate = ""; if (!string.IsNullOrEmpty(dr["resultdatetime"].ToString())) { strdate = dr["resultdatetime"].ToString(); if (!string.IsNullOrEmpty(strdate)) { dr["ordernumber"] = strdate; dr["daterecorded"] = strdate; } else { dr["daterecorded"] = DateTime.Now.ToString(); } } else { dr["daterecorded"] = DateTime.Now.ToString(); } } if (dtClinicaldata.Rows.Count > 0) { DataTable dtfilter = dtClinicaldata.AsEnumerable() .Where(Filter => Filter.Field <string>("value") != null && Filter.Field <string>("value").Length > 0 && Filter.Field <string>("ResultName") != null && Filter.Field <string>("ResultName").Length > 0) .AsDataView().ToTable(); dtClinicaldata = dtfilter.Copy(); } dtClinicaldata = dtClinicaldata.DefaultView.ToTable(true); dtClinicaldata.TableName = strModuleName; //dsModuleData.Tables.Add(dtValidation); //dsModuleData.Tables.Add(dtClinicaldata); return(dtClinicaldata); } catch (Exception) { throw; } }
/// <summary> /// Get data from source for given module /// </summary> /// <param name="connection">Source Database connection</param> /// <param name="parameters">number of parameters which are have version,modulename etc...</param> /// <returns>Return the datasetof 2 tables,one for module data and another is for errors or debug log or any validation message</returns> private DataTable GetAllergyData(Hashtable parameters) { try { string strModuleName = string.Empty; strModuleName = "Allergy"; DataSet dsModuleData = new DataSet(strModuleName); DataTable dtClinicaldata = new DataTable(); // Do data processing here. APIConnection api = (APIConnection)parameters["athenaapiobject"]; List <allergy> objallergies = new List <allergy>(); //ArrayList arydept = new ArrayList(); //arydept = (ArrayList)parameters["api_departmentid"]; //foreach (var value in arydept) //{ Dictionary <string, string> dirlst = new Dictionary <string, string>() { { "departmentid", parameters["api_departmentid"].ToString() } }; JObject jobj = (JObject)api.GET("chart/" + parameters["patientid"].ToString() + "/allergies", dirlst); JToken jtobj = jobj["allergies"]; if (jtobj != null) { if (jtobj.HasValues && jtobj.SelectToken("error") != null) { throw new Exception(jtobj["error"].ToString()); } objallergies = jtobj.ToObject <List <allergy> >(); int count = 0; foreach (var item in objallergies) { if (item.Reactions.Count() > 0) { foreach (var subitem in item.Reactions) { if (subitem.Reactionname != "") { objallergies[count].Reaction = string.Concat(objallergies[count].Reaction, subitem.Reactionname, ","); } if (subitem.Snomedcode != "") { objallergies[count].Snomed = string.Concat(objallergies[count].Snomed, subitem.Snomedcode, ","); } if (subitem.Severity != "") { objallergies[count].Severity = string.Concat(objallergies[count].Severity, subitem.Severity, ","); } if (subitem.Severitysnomedcode != "") { objallergies[count].Severitysnomedcode = string.Concat(objallergies[count].Severitysnomedcode, subitem.Severitysnomedcode, ","); } } objallergies[count].Reaction = objallergies[count].Reaction.TrimEnd(','); objallergies[count].Snomed = objallergies[count].Snomed.TrimEnd(','); objallergies[count].Severity = objallergies[count].Severity.TrimEnd(','); objallergies[count].Severitysnomedcode = objallergies[count].Severitysnomedcode.TrimEnd(','); } count += 1; } } //} dtClinicaldata = GetModuleDataBase.ConvertToDataTable(objallergies); if (!dtClinicaldata.Columns.Contains("patientid")) { dtClinicaldata.Columns.Add("patientid"); } if (!dtClinicaldata.Columns.Contains("codesystemid")) { dtClinicaldata.Columns.Add("codesystemid"); } if (!dtClinicaldata.Columns.Contains("admitflag")) { dtClinicaldata.Columns.Add("admitflag"); } if (!dtClinicaldata.Columns.Contains("daterecorded")) { dtClinicaldata.Columns.Add("daterecorded"); } if (dtClinicaldata != null && dtClinicaldata.Rows.Count > 0) { dtClinicaldata.Columns["Allergenname"].ColumnName = "allergicto"; dtClinicaldata.Columns["Snomed"].ColumnName = "Reactionsnomedcode"; } foreach (DataRow dr in dtClinicaldata.Rows) { dr["patientid"] = parameters["patientid"]; dr["admitflag"] = "1"; dr["onsetdate"] = dr["onsetdate"].ToString(); dr["Deactivatedate"] = dr["Deactivatedate"].ToString(); dr["daterecorded"] = DateTime.Now.ToString(); } dtClinicaldata = dtClinicaldata.DefaultView.ToTable(true); //dsModuleData.Tables.Add(dtValidation); //dsModuleData.Tables.Add(dtClinicaldata); return(dtClinicaldata); } catch (Exception) { throw; } }
/// <summary> /// Get data from source for given module /// </summary> /// <param name="connection">Source Database connection</param> /// <param name="parameters">number of parameters which are have version,modulename etc...</param> /// <returns>Return the datasetof 2 tables,one for module data and another is for errors or debug log or any validation message</returns> private DataTable GetPatientPictureData(Hashtable parameters) { try { string strModuleName = string.Empty; strModuleName = "PatientPicture"; DataSet dsModuleData = new DataSet(strModuleName); DataTable dtClinicaldata = new DataTable(); // Do data processing here. APIConnection api = (APIConnection)parameters["athenaapiobject"]; List <patientpicture> objPatientPicture = new List <patientpicture>(); //ArrayList arydept = new ArrayList(); //arydept = (ArrayList)parameters["api_departmentid"]; //foreach (var value in arydept) //{ Dictionary <string, string> dirlst = new Dictionary <string, string>() { { "jpegoutput", "false" } }; JObject jobj = (JObject)api.GET("patients/" + parameters["patientid"].ToString() + "/photo", dirlst); JToken jtobj = jobj["image"]; if (jtobj != null) { if (jtobj.HasValues && jtobj.SelectToken("error") != null) { throw new Exception(jtobj["error"].ToString()); } //List<JToken> jtobjlst = new List<JToken>(); //foreach (var item in jtobj) //{ // jtobjlst.Add(item); //} patientpicture objclinical = new patientpicture(); objclinical.Image = jobj["image"].ToString(); objPatientPicture.Add(objclinical); } dtClinicaldata = GetModuleDataBase.ConvertToDataTable(objPatientPicture); if (!dtClinicaldata.Columns.Contains("patientid")) { dtClinicaldata.Columns.Add("patientid"); } dtClinicaldata = dtClinicaldata.DefaultView.ToTable(true); //dsModuleData.Tables.Add(dtValidation); //dsModuleData.Tables.Add(dtClinicaldata); foreach (DataRow dRow in dtClinicaldata.Rows) { dRow["patientid"] = parameters["patientid"]; } return(dtClinicaldata); } catch (Exception) { throw; } }
/// <summary> /// Get data from source for given module /// </summary> /// <param name="parameters">number of parameters which are have version,modulename etc...</param> /// <returns>Return the datatable with module data</returns> private DataTable GetPatientInsuranceData(Hashtable parameters) { try { string strModuleName = "PatientInsurance"; DataTable dtClinicaldata = new DataTable(); APIConnection api = (APIConnection)parameters["athenaapiobject"]; JObject jobj = (JObject)api.GET("patients" + "/" + parameters["patientid"].ToString() + "/" + "insurances"); JToken jtobj = jobj["insurances"]; if (jtobj != null) { if (jtobj.HasValues && jtobj.SelectToken("error") != null) { return(new DataTable()); //dtValidation.Rows.Add(new object[] { parameters["patientid"].ToString(), "", "", "", "", strModuleName, string.Empty, jtobj["error"].ToString() + parameters["patientid"].ToString() }); //{ throw new Exception(jtobj["error"].ToString()); } } // Do data processing here. List <patientinsurance> objclinical = jtobj.ToObject <List <patientinsurance> >(); dtClinicaldata = GetModuleDataBase.ConvertToDataTable(objclinical); if (dtClinicaldata != null && dtClinicaldata.Rows.Count > 0) { dtClinicaldata.Columns["sequencenumber"].ColumnName = "itype"; dtClinicaldata.Columns["insurancepackageid"].ColumnName = "icode"; dtClinicaldata.Columns["insuranceplanname"].ColumnName = "iname"; dtClinicaldata.Columns["insurancephone"].ColumnName = "iphone"; dtClinicaldata.Columns["insuranceidnumber"].ColumnName = "ipolicy"; dtClinicaldata.Columns["policynumber"].ColumnName = "igroup"; dtClinicaldata.Columns["relationshiptoinsured"].ColumnName = "irela2hld"; dtClinicaldata.Columns["insurancestate"].ColumnName = "istate"; dtClinicaldata.Columns["insurancezip"].ColumnName = "izip"; dtClinicaldata.Columns["insurancecity"].ColumnName = "icity"; dtClinicaldata.Columns["insuranceaddress"].ColumnName = "iaddra"; dtClinicaldata.Columns["insuranceaddress2"].ColumnName = "iaddrb"; dtClinicaldata.Columns["issuedate"].ColumnName = "ibegin"; dtClinicaldata.Columns["expirationdate"].ColumnName = "iend"; dtClinicaldata.Columns["insurancepolicyholder"].ColumnName = "ihname"; dtClinicaldata.Columns["insurancepolicyholderlastname"].ColumnName = "ihlname"; dtClinicaldata.Columns["insurancepolicyholderfirstname"].ColumnName = "ihfname"; dtClinicaldata.Columns["insurancepolicyholdermiddlename"].ColumnName = "ihminit"; dtClinicaldata.Columns["insurancepolicyholderssn"].ColumnName = "ihssn"; dtClinicaldata.Columns["insurancepolicyholdersex"].ColumnName = "ihsex"; dtClinicaldata.Columns["insurancepolicyholdercity"].ColumnName = "ihcity"; dtClinicaldata.Columns["insurancepolicyholderstate"].ColumnName = "ihstate"; dtClinicaldata.Columns["insurancepolicyholderzip"].ColumnName = "ihzip"; dtClinicaldata.Columns["insurancepolicyholderdob"].ColumnName = "ihdob"; dtClinicaldata.Columns["insurancepolicyholderaddress1"].ColumnName = "ihaddra"; dtClinicaldata.Columns["insurancepolicyholderaddress2"].ColumnName = "ihaddrb"; } DataTable dtPatientInsurance = new DataTable(); dtPatientInsurance = PreparePatientInsuranceTable(dtPatientInsurance); DataTable dtReturn = dtPatientInsurance.Clone(); if (dtClinicaldata != null && dtClinicaldata.Rows.Count > 0) { if (!dtClinicaldata.Columns.Contains("Patientid")) { dtClinicaldata.Columns.Add("Patientid"); } if (!dtClinicaldata.Columns.Contains("Original_irela2hld")) { dtClinicaldata.Columns.Add("Original_irela2hld"); } if (!dtClinicaldata.Columns.Contains("Original_iphone")) { dtClinicaldata.Columns.Add("Original_iphone"); } DataRow newRow = dtReturn.NewRow(); foreach (DataRow dr in dtClinicaldata.Rows) { dr["PatientID"] = parameters["patientid"]; newRow["patientid"] = dr["PatientID"]; if (dr["itype"].ToString() == "1") { if (dr["ipolicy"].ToString().Trim().Length > 0 || dr["igroup"].ToString().Trim().Length > 0) { newRow["ibegin1"] = dr["ibegin"].ToString(); newRow["iend1"] = dr["iend"].ToString(); newRow["itype1"] = dr["insurancetype"].ToString(); //'Insurance Holder Information //newRow["irela2hld1"] = RelationshipMapping(dr["irela2hld"].ToString()); newRow["irela2hld1"] = dr["irela2hld"].ToString(); newRow["Original_irela2hld1"] = dr["irela2hld"].ToString(); newRow["ihlname1"] = dr["ihlname"].ToString(); newRow["ihfname1"] = dr["ihfname"].ToString(); newRow["ihminit1"] = dr["ihminit"].ToString(); newRow["ihaddr1a"] = dr["IHADDRA"].ToString(); newRow["ihaddr1b"] = dr["IHADDRB"].ToString(); newRow["ihcity1"] = dr["ihcity"].ToString(); newRow["ihstate1"] = dr["ihstate"].ToString(); newRow["ihzip1"] = dr["ihzip"].ToString(); newRow["ihsex1"] = dr["ihsex"].ToString(); newRow["ihssn1"] = dr["ihssn"].ToString(); //string strDateOfBirthPrimary = string.Empty; //strDateOfBirthPrimary = dr["ihdob"].ToString(); //string strValidationDateOfBirth = objCommonCleanup.ParseDateFromString(strDateOfBirthPrimary, "yyyyMMdd"); newRow["ihdob1"] = dr["ihdob"].ToString(); //'Insurance Company Information newRow["icode1"] = dr["icode"].ToString(); newRow["ipolicy1"] = dr["ipolicy"].ToString(); newRow["igroup1"] = dr["igroup"].ToString(); newRow["iname1"] = dr["iname"].ToString(); newRow["iaddr1a"] = dr["IAddrA"].ToString(); newRow["iaddr1b"] = dr["IAddrB"].ToString(); newRow["icity1"] = dr["icity"].ToString(); newRow["istate1"] = dr["istate"].ToString(); newRow["izip1"] = dr["izip"].ToString(); newRow["iphone1"] = dr["iphone"].ToString(); dr["Original_iphone"] = dr["iphone"].ToString(); newRow["Original_iphone1"] = dr["Original_iphone"].ToString(); //newRow["icopay1"] = dr["icopay"].ToString(); StringBuilder strComments = new StringBuilder(); strComments.Append("Insurancetype: " + dr["Insurancetype"].ToString() + ", "); strComments.Append("Eligibilityreason: " + dr["Eligibilityreason"].ToString() + ", "); strComments.Append("Ircname: " + dr["Ircname"].ToString() + ", "); strComments.Append("Relationshiptoinsuredid: " + dr["Relationshiptoinsuredid"].ToString() + ", "); strComments.Append("Eligibilitymessage: " + dr["Eligibilitymessage"].ToString() + ", "); strComments.Append("Eligibilitystatus: " + dr["eligibilitystatus"].ToString()); newRow["icomments1"] = strComments.ToString(); } } if (dr["itype"].ToString() == "2") { if ((newRow["ipolicy1"].ToString().Trim().Length > 0 || newRow["igroup1"].ToString().Trim().Length > 0) && (dr["ipolicy"].ToString().Trim().Length > 0 || dr["igroup"].ToString().Trim().Length > 0)) { newRow["ibegin2"] = dr["ibegin"].ToString(); newRow["iend2"] = dr["iend"].ToString(); newRow["itype2"] = dr["insurancetype"].ToString(); //'Insurance Holder Information // newRow["irela2hld2"] = RelationshipMapping(dr["irela2hld"].ToString()); newRow["irela2hld2"] = dr["irela2hld"].ToString(); newRow["Original_irela2hld2"] = dr["irela2hld"].ToString(); newRow["ihlname2"] = dr["ihlname"].ToString(); newRow["ihfname2"] = dr["ihfname"].ToString(); newRow["ihminit2"] = dr["ihminit"].ToString(); newRow["ihaddr2a"] = dr["IHADDRA"].ToString(); newRow["ihaddr2b"] = dr["IHADDRB"].ToString(); newRow["ihcity2"] = dr["ihcity"].ToString(); newRow["ihstate2"] = dr["ihstate"].ToString(); newRow["ihzip2"] = dr["ihzip"].ToString(); newRow["ihsex2"] = dr["ihsex"].ToString(); newRow["ihssn2"] = dr["ihssn"].ToString(); //string strDateOfBirthSecondary = string.Empty; //strDateOfBirthSecondary = dr["ihdob"].ToString(); //string strValidationDateOfBirth = objCommonCleanup.ParseDateFromString(strDateOfBirthSecondary, "yyyyMMdd"); newRow["ihdob2"] = dr["ihdob"].ToString(); //'Insurance Company Information newRow["icode2"] = dr["icode"].ToString(); newRow["ipolicy2"] = dr["ipolicy"].ToString(); newRow["igroup2"] = dr["igroup"].ToString(); newRow["iname2"] = dr["iname"].ToString(); newRow["iaddr2a"] = dr["IAddrA"].ToString(); newRow["iaddr2b"] = dr["IAddrB"].ToString(); newRow["icity2"] = dr["icity"].ToString(); newRow["istate2"] = dr["istate"].ToString(); newRow["izip2"] = dr["izip"].ToString(); newRow["iphone2"] = dr["iphone"].ToString(); dr["Original_iphone"] = dr["iphone"].ToString(); newRow["Original_iphone2"] = dr["Original_iphone"].ToString(); //newRow["icopay2"] = dr["icopay"].ToString(); StringBuilder strComments = new StringBuilder(); strComments.Append("Insurancetype: " + dr["Insurancetype"].ToString() + ", "); strComments.Append("Eligibilityreason: " + dr["Eligibilityreason"].ToString() + ", "); strComments.Append("Ircname: " + dr["Ircname"].ToString() + ", "); strComments.Append("Relationshiptoinsuredid: " + dr["Relationshiptoinsuredid"].ToString() + ", "); strComments.Append("Eligibilitymessage: " + dr["Eligibilitymessage"].ToString() + ", "); strComments.Append("Eligibilitystatus: " + dr["eligibilitystatus"].ToString()); newRow["icomments2"] = strComments.ToString(); } } } dtReturn.Rows.Add(newRow); } dtClinicaldata = dtReturn; } dtClinicaldata = dtClinicaldata.DefaultView.ToTable(true); dtClinicaldata.TableName = strModuleName; return(dtClinicaldata); } catch (Exception) { throw; } }
/// <summary> /// Get data from source for given module /// </summary> /// <param name="connection">Source Database connection</param> /// <param name="parameters">number of parameters which are have version,modulename etc...</param> /// <returns>Return the datasetof 2 tables,one for module data and another is for errors or debug log or any validation message</returns> private DataTable GetProblemsData(Hashtable parameters) { try { string strModuleName = string.Empty; strModuleName = "Diagnosis"; DataSet dsModuleData = new DataSet(strModuleName); DataTable dtClinicaldata = new DataTable(); //DataTable dtValidation = new DataTable(); //dtValidation = CreateValidationDataTable("xclinicalvalidations"); // Do data processing here. APIConnection api = (APIConnection)parameters["athenaapiobject"]; List <problems> objclinical = new List <problems>(); //ArrayList arydept = new ArrayList(); //arydept = (ArrayList)parameters["api_departmentid"]; //foreach (var value in arydept) //{ Dictionary <string, string> dirlst = new Dictionary <string, string>() { { "departmentid", parameters["api_departmentid"].ToString() } }; JObject jobj = (JObject)api.GET("chart/" + parameters["patientid"].ToString() + "/problems", dirlst); JToken jtobj = jobj["problems"]; if (jtobj != null) { if (jtobj.HasValues && jtobj.SelectToken("error") != null) { throw new Exception(jtobj["error"].ToString()); } objclinical = jtobj.ToObject <List <problems> >(); List <problems> objclinical1 = new List <problems>(); problems objproblems = new problems(); foreach (var item in objclinical) { if (item.Events != null) { item.Source = item.Events[0].Source; item.Status = item.Events[0].Status; item.Eventtype = item.Events[0].Eventtype; item.Startdate = item.Events[0].Startdate; item.CreatedDate = item.Events[0].CreatedDate; item.OnSetDate = item.Events[0].OnSetDate; item.Laterality = item.Events[0].Laterality; item.Note = item.Events[0].Note; item.Eventcount = item.Events.Count().ToString(); } } // int count = 0; //Diagnoses records foreach (var item in objclinical) { if (item.Events != null && item.Events[0].Diagnoses != null && item.Events[0].Diagnoses.Count() > 0) { objproblems = new problems(); objproblems.Source = item.Events[0].Source; objproblems.Status = item.Events[0].Status; objproblems.Eventtype = item.Events[0].Eventtype; objproblems.Startdate = item.Events[0].Startdate; objproblems.CreatedDate = item.Events[0].CreatedDate; objproblems.OnSetDate = item.Events[0].OnSetDate; objproblems.Laterality = item.Events[0].Laterality; objproblems.Note = item.Events[0].Note; objproblems.Eventcount = item.Events.Count().ToString(); objproblems.Codeset = item.Events[0].Diagnoses[0].Codeset; objproblems.Code = item.Events[0].Diagnoses[0].Code; objproblems.Name = item.Events[0].Diagnoses[0].Name; objproblems.LastModifiedBy = item.LastModifiedBy; objproblems.LastModifiedDateTime = item.LastModifiedDateTime; objclinical1.Add(objproblems); } } if (objclinical1.Count() > 0) { objclinical.AddRange(objclinical1); } } //} dtClinicaldata = GetModuleDataBase.ConvertToDataTable(objclinical); if (!dtClinicaldata.Columns.Contains("patientid")) { dtClinicaldata.Columns.Add("patientid"); } if (dtClinicaldata != null && dtClinicaldata.Rows.Count > 0) { dtClinicaldata.Columns["codeset"].ColumnName = "codesystemid"; dtClinicaldata.Columns["name"].ColumnName = "problem"; } string strstartdate = string.Empty; foreach (DataRow dr in dtClinicaldata.Rows) { dr["patientid"] = parameters["patientid"].ToString(); //dr["lifecycle"] = "CHRONIC"; //set hard coded lifecycle as per api documention mentioned like:The status of this problem event: CHRONIC or ACUTE //strstartdate = ""; //if (!string.IsNullOrEmpty(dr["startdate"].ToString())) //{ // strstartdate = dr["startdate"].ToString(); // if (!string.IsNullOrEmpty(strstartdate)) // { // dr["daterecorded"] = strstartdate; // } // else // { // dr["daterecorded"] = DateTime.Now.ToString(); // } //} } dtClinicaldata = dtClinicaldata.DefaultView.ToTable(true); dtClinicaldata.TableName = strModuleName; //dsModuleData.Tables.Add(dtValidation); //dsModuleData.Tables.Add(dtClinicaldata); return(dtClinicaldata); } catch (Exception) { throw; } }
/// <summary> /// Get data from source for given module /// </summary> /// <param name="connection">Source Database connection</param> /// <param name="parameters">number of parameters which are have version,modulename etc...</param> /// <returns>Return the datasetof 2 tables,one for module data and another is for errors or debug log or any validation message</returns> private DataTable GetSurgicalHistoryData(Hashtable parameters) { try { string strModuleName = string.Empty; strModuleName = "SurgicalHistory"; DataSet dsModuleData = new DataSet(strModuleName); DataTable dtClinicaldata = new DataTable(); // Do data processing here. APIConnection api = (APIConnection)parameters["athenaapiobject"]; List <Procedure> objclinical = new List <Procedure>(); //ArrayList arydept = new ArrayList(); //arydept = (ArrayList)parameters["api_departmentid"]; //foreach (var value in arydept) //{ Dictionary <string, string> dirlst = new Dictionary <string, string>() { { "departmentid", parameters["api_departmentid"].ToString() } }; JObject jobj = (JObject)api.GET("chart/" + parameters["patientid"].ToString() + "/surgicalhistory", dirlst); JToken jtobj = jobj["procedures"]; if (jtobj != null) { if (jtobj.HasValues && jtobj.SelectToken("error") != null) { throw new Exception(jtobj["error"].ToString()); } objclinical = jtobj.ToObject <List <Procedure> >(); } dtClinicaldata = GetModuleDataBase.ConvertToDataTable(objclinical); if (!dtClinicaldata.Columns.Contains("patientid")) { dtClinicaldata.Columns.Add("patientid"); } string strsurgerydate = string.Empty; foreach (DataRow dr in dtClinicaldata.Rows) { dr["patientid"] = parameters["patientid"].ToString(); } if (dtClinicaldata.Rows.Count > 0) { DataTable dtfilter = dtClinicaldata.AsEnumerable() .Where(Filter => Filter.Field <string>("description") != null && Filter.Field <string>("description").Length > 0) .AsDataView().ToTable(); dtClinicaldata = dtfilter.Copy(); } //} dtClinicaldata = dtClinicaldata.DefaultView.ToTable(true); dtClinicaldata.TableName = strModuleName; return(dtClinicaldata); } catch (Exception) { throw; } }
/// <summary> /// Get data from source for given module /// </summary> /// <param name="connection">Source Database connection</param> /// <param name="parameters">number of parameters which are have version,modulename etc...</param> /// <returns>Return the datasetof 2 tables,one for module data and another is for errors or debug log or any validation message</returns> private DataTable GetOpenSlotsData(Hashtable parameters) { try { string strModuleName = string.Empty; strModuleName = "OpenSlots"; //DataSet dsModuleData = new DataSet(strModuleName); DataTable dtClinicaldata = new DataTable(strModuleName); DataTable dtTempata = new DataTable(); // Do data processing here. APIConnection api = (APIConnection)parameters["athenaapiobject"]; Dictionary <string, string> appbook = null; JObject jobj = null; JToken jtobj = null; ArrayList arydept = new ArrayList(); arydept = (ArrayList)parameters["api_departmentid_patientmaster"]; foreach (var value in arydept) { string format = "MM/dd/yyyy"; DateTime EndDateTime = DateTime.Now; appbook = new Dictionary <string, string>() { { "appointmenttypeid", "2" }, { "bypassscheduletimechecks", "1" }, { "departmentid", value.ToString() }, { "enddate", EndDateTime.ToString(format).Replace("-", "/") }, { "ignoreschedulablepermission", "0" }, { "reasonid", "-1" }, { "showfrozenslots", "1" }, { "startdate", "01/01/2001" } }; jobj = (JObject)api.GET("appointments/open", appbook); jtobj = jobj["appointments"]; if (jtobj != null) { if (jtobj.HasValues && jtobj.SelectToken("error") != null) { throw new Exception(jtobj["error"].ToString()); } List <appointments> objclinical = jtobj.ToObject <List <appointments> >(); dtTempata = GetModuleDataBase.ConvertToDataTable(objclinical); dtClinicaldata.Merge(dtTempata); } } //if (dtClinicaldata != null && dtClinicaldata.Rows.Count > 0) //{ // dtClinicaldata.Columns["date"].ColumnName = "adate"; // dtClinicaldata.Columns["starttime"].ColumnName = "atime"; // dtClinicaldata.Columns["appointmentstatus"].ColumnName = "astatus"; // dtClinicaldata.Columns["providerid"].ColumnName = "dcode"; // dtClinicaldata.Columns["appointmenttype"].ColumnName = "atype"; // dtClinicaldata.Columns["duration"].ColumnName = "aduration"; // dtClinicaldata.Columns["lastmodified"].ColumnName = "updateddate"; //} dtClinicaldata = dtClinicaldata.DefaultView.ToTable(true); dtClinicaldata.TableName = strModuleName; //dsModuleData.Tables.Add(dtValidation); //dsModuleData.Tables.Add(dtClinicaldata); return(dtClinicaldata); } catch (Exception) { throw; } }
/// <summary> /// Get data from source for given module /// </summary> /// <param name="connection">Source Database connection</param> /// <param name="parameters">number of parameters which are have version,modulename etc...</param> /// <returns>Return the datasetof 2 tables,one for module data and another is for errors or debug log or any validation message</returns> private DataTable GetVitalsData(Hashtable parameters) { try { string strModuleName = string.Empty; strModuleName = "Vitals"; DataTable dtModuleData = new DataTable(strModuleName); DataTable dtClinicaldata = new DataTable(); //DataTable dtValidation = new DataTable(); //dtValidation = CreateValidationDataTable("xclinicalvalidations"); DataTable dtvitalclinical = createvitaltable(); // Do data processing here. APIConnection api = (APIConnection)parameters["athenaapiobject"]; List <readings> objclinical1 = new List <readings>(); //ArrayList arydept = new ArrayList(); //arydept = (ArrayList)parameters["api_departmentid"]; //foreach (var value in arydept) //{ Dictionary <string, string> dirlst = new Dictionary <string, string>() { { "departmentid", parameters["api_departmentid"].ToString() } }; JObject jobj = (JObject)api.GET("chart/" + parameters["patientid"].ToString() + "/vitals", dirlst); JToken jtobj = jobj["vitals"]; if (jtobj != null) { if (jtobj.HasValues && jtobj.SelectToken("error") != null) { throw new Exception(jtobj["error"].ToString()); } List <vital> objclinical = jtobj.ToObject <List <vital> >(); objclinical1 = new List <readings>(); readings[][] obredreadingsary; List <readings[]> obredreadinglst; foreach (var item in objclinical) { obredreadingsary = item.readings; obredreadinglst = obredreadingsary.ToList <readings[]>(); foreach (var obredreadingsublist in obredreadinglst) { foreach (var subitem in obredreadingsublist) { objclinical1.Add(subitem); } } } dtClinicaldata = GetModuleDataBase.ConvertToDataTable(objclinical1); if (!dtClinicaldata.Columns.Contains("patientid")) { dtClinicaldata.Columns.Add("patientid"); } if (!dtClinicaldata.Columns.Contains("daterecorded")) { dtClinicaldata.Columns.Add("daterecorded"); } if (!dtClinicaldata.Columns.Contains("Active")) { dtClinicaldata.Columns.Add("Active"); } DataRow newrow; string strbpd = string.Empty; DataTable dtReading = dtClinicaldata.DefaultView.ToTable(true, "Readingid", "Readingtaken"); string strvitalname = string.Empty; string strvitalvalue = string.Empty; string strbpcolumn = string.Empty; string strbploccolumn = string.Empty; string strcode = string.Empty; foreach (DataRow item in dtReading.Rows) { //string strreadingdate = string.Empty; newrow = dtvitalclinical.NewRow(); newrow["patientid"] = parameters["patientid"].ToString(); newrow["readingid"] = item["readingid"].ToString(); newrow["daterecorded"] = item["Readingtaken"].ToString(); //objCommonCleanup.ParseDateFromString(item["Readingtaken"].ToString(), "yyyyMMdd"); strbpcolumn = "bp_sitting"; strbploccolumn = "bp_sitting_location"; DataTable dtfilter = dtClinicaldata.AsEnumerable() .Where(r => r.Field <string>("Readingtaken") == item["Readingtaken"].ToString() && r.Field <string>("Readingid") == item["Readingid"].ToString()) .AsDataView().ToTable(); foreach (DataRow item1 in dtfilter.Rows) { newrow["encounterid"] = item1["Sourceid"].ToString(); newrow["codeset"] = item1["codeset"].ToString(); if (item1["clinicalelementid"].ToString() == "VITALS.BLOODPRESSURE.TYPE") { if (item1["value"].ToString() == "sitting") { strbpcolumn = "bp_sitting"; strbploccolumn = "bp_sitting_location"; } else if (item1["value"].ToString() == "standing") { strbpcolumn = "bp_standing"; strbploccolumn = "bp_standing_location"; } else if (item1["value"].ToString() == "supine") { strbpcolumn = "bp_supine"; strbploccolumn = "bp_supine_location"; } else { strbpcolumn = "bp_sitting"; strbploccolumn = "bp_sitting_location"; } } else if (item1["clinicalelementid"].ToString() == "VITALS.BLOODPRESSURE.DIASTOLIC") { strbpd = item1["value"].ToString(); } else if (item1["clinicalelementid"].ToString() == "VITALS.BLOODPRESSURE.SYSTOLIC") { if (strbpd != "") { newrow[strbpcolumn] = item1["value"].ToString() + "/" + strbpd; strbpd = string.Empty; } else { newrow[strbpcolumn] = ""; newrow["original_" + strbpcolumn] = item1["value"].ToString(); } } else if (item1["clinicalelementid"].ToString() == "VITALS.BLOODPRESSURE.SITE") { newrow[strbploccolumn] = item1["value"].ToString(); } else if (item1["clinicalelementid"].ToString() == "VITALS.WEIGHT") { newrow["original_WEIGHT"] = item1["value"].ToString(); try { newrow["WEIGHT"] = item1["value"].ToString(); // objVitalCleanup.ConvertWeight(item1["value"].ToString(), WeightFormat.Gram, WeightFormat.BlackBox); } catch (Exception) { throw; // dtValidation.Rows.Add(new object[] { parameters["patientid"].ToString(), "", "", "", "", strModuleName, string.Empty, "Invalid WEIGHT: " + item1["value"].ToString() }); } } else if (item1["clinicalelementid"].ToString() == "VITALS.HEIGHT") { newrow["original_HEIGHT"] = item1["value"].ToString(); try { newrow["HEIGHT"] = item1["value"].ToString(); // objVitalCleanup.ConvertHeight(item1["value"].ToString(), HeightFormat.Centimeter, HeightFormat.BlackBox); } catch (Exception) { throw; //dtValidation.Rows.Add(new object[] { parameters["patientid"].ToString(), "", "", "", "", strModuleName, string.Empty, "Invalid HEIGHT: " + item1["value"].ToString() }); } } else if (item1["clinicalelementid"].ToString() == "VITALS.BMI") { newrow["BMI"] = item1["value"].ToString(); } else if (item1["clinicalelementid"].ToString() == "VITALS.PULSE.RATE") { newrow["PULSE"] = item1["value"].ToString(); } else if (item1["clinicalelementid"].ToString() == "VITALS.TEMPERATURE") { newrow["TEMPERATURE"] = item1["value"].ToString(); newrow["origianl_TEMPERATURE"] = item1["value"].ToString(); } else if (item1["clinicalelementid"].ToString() == "VITALS.HEADCIRCUMFERENCE") { newrow["headcm"] = item1["value"].ToString(); } else if (item1["clinicalelementid"].ToString() == "VITALS.WAISTCIRCUMFERENCE") { newrow["waistcircumference"] = item1["value"].ToString(); } else if (item1["clinicalelementid"].ToString() == "VITALS.NECKCIRCUMFERENCE") { newrow["neckcircumference"] = item1["value"].ToString(); } else if (item1["clinicalelementid"].ToString() == "VITALS.PAINSCALE") { newrow["painlevel"] = item1["value"].ToString(); } else { strvitalname = string.Concat(strvitalname, item1["clinicalelementid"].ToString(), ":", item1["value"].ToString()); } strcode = string.Concat(strcode, item1["code"].ToString(), ","); } if (dtfilter.Rows.Count > 0) { newrow["code"] = strcode != "" ? newrow["codeset"] + ":" + strcode.TrimEnd(',') : ""; newrow["comments"] = strvitalname; dtvitalclinical.Rows.Add(newrow); strvitalname = string.Empty; strcode = string.Empty; } } } //} dtvitalclinical = dtvitalclinical.DefaultView.ToTable(true); dtClinicaldata = dtvitalclinical.Copy(); dtClinicaldata.TableName = strModuleName; //dsModuleData.Tables.Add(dtValidation); //dtModuleData = dtCliicaldata; return(dtClinicaldata); } catch (Exception) { throw; } }