Beispiel #1
0
        /// <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 GetMedicationsData(Hashtable parameters)
        {
            try
            {
                string strModuleName = "Medications";

                //DataSet dsModuleData = new DataSet(strModuleName);
                DataTable dtClinicaldata = new DataTable();

                //RestSharp.Deserializers.JsonDeserializer deserial = new RestSharp.Deserializers.JsonDeserializer();
                var client  = new RestClient("" + parameters["api_baseurl"].ToString() + "api/medications?patient=" + parameters["patientid"].ToString() + "");
                var request = new RestRequest(Method.GET);
                request.AddHeader("cache-control", "no-cache");
                request.AddHeader("authorization", "bearer:" + parameters["access_token"].ToString() + "");

                IRestResponse response = client.Execute(request);

                var data = (JObject)JsonConvert.DeserializeObject(response.Content);

                JToken jtobj = (JToken)JsonConvert.DeserializeObject(data.SelectToken("results").ToString());

                List <medicationdetail> Medicationdata = jtobj.ToObject <List <medicationdetail> >();

                dtClinicaldata = GetModuleDataBase.ConvertToDataTable(Medicationdata);

                dtClinicaldata.TableName = strModuleName;

                return(dtClinicaldata);
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #2
0
        private DataTable GetPatientDemographicsData(Hashtable parameters)
        {
            try
            {
                string strModuleName = "PatientDemographics";

                //DataSet dsModuleData = new DataSet(strModuleName);
                DataTable dtClinicaldata = new DataTable();

                //RestSharp.Deserializers.JsonDeserializer deserial = new RestSharp.Deserializers.JsonDeserializer();
                var client  = new RestClient("" + parameters["api_baseurl"].ToString() + "api/patients/" + parameters["patientid"].ToString() + "");
                var request = new RestRequest(Method.GET);
                request.AddHeader("cache-control", "no-cache");
                request.AddHeader("authorization", "bearer:" + parameters["access_token"].ToString() + "");

                IRestResponse response = client.Execute(request);

                JToken jtobj = (JToken)JsonConvert.DeserializeObject("[" + response.Content.Replace("[", "\"[").Replace("]", "]\"") + "]");

                List <Patients> Patientdata = jtobj.ToObject <List <Patients> >();

                dtClinicaldata = GetModuleDataBase.ConvertToDataTable(Patientdata);

                if (dtClinicaldata.Rows[0][dtClinicaldata.Columns["Detail"]].ToString().Trim().ToLower() == "not found.")
                {
                    return(new DataTable());
                }

                dtClinicaldata.TableName = strModuleName;

                return(dtClinicaldata);
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #3
0
        /// <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;
            }
        }
Beispiel #4
0
        /// <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;
            }
        }