Exemplo n.º 1
0
 DataCheckerModel InitializeModel(DataCheckerModel m, IDnsRequestContext request)
 {
     m.RequestType  = DataCheckerRequestType.All.FirstOrDefault(rt => rt.ID == request.RequestType.ID);
     m.RequestId    = request.RequestID;
     m.DataPartners = (from o in DataContext.Organizations
                       where o.DataMarts.Any(dm => dm.Deleted == false && dm.Projects.Any(p => p.Project.Active && p.Project.Deleted == false && p.Project.Requests.Any(r => r.ID == m.RequestId))) && o.Deleted == false
                       orderby o.Name ascending
                       select new { o.Name, o.Acronym }).ToArray()
                      .Select(x => new KeyValuePair <string, string>(x.Name, x.Acronym)).ToArray();
     return(m);
 }
Exemplo n.º 2
0
        public DnsResult ValidateForSubmission(IDnsRequestContext context)
        {
            DataCheckerModel m = GetModel(context);
            IList <string>   errorMessages;

            if (Validate(m, out errorMessages))
            {
                return(DnsResult.Success);
            }
            else
            {
                return(DnsResult.Failed(errorMessages.ToArray <string>()));
            }
        }
Exemplo n.º 3
0
        private bool Validate(DataCheckerModel m, out IList <string> errorMessages)
        {
            errorMessages = new List <string>();

            var criteria  = RequestCriteriaHelper.ToServerModel(m.CriteriaGroupsJSON);
            var datamarts = (from c in criteria.Criterias
                             from t in c.Terms
                             where t.TermType == RequestCriteria.Models.TermTypes.DataPartnerTerm
                             select((DataPartnersData)t).DataPartners.Count()).Sum();

            if (datamarts < 1)
            {
                errorMessages.Add("Please select at least one Data Partner in the Data Partner Criteria selector.");
            }


            return(errorMessages.Count > 0 ? false : true);
        }
Exemplo n.º 4
0
        private string GetDisplayableRequest(DataCheckerModel model)

        {
            var terms = RequestCriteriaHelper.ToServerModel(model.CriteriaGroupsJSON).Criterias.First().Terms;
            var sb    = new StringBuilder("<html><body style='font-family: Sans-serif; font-size:9pt;'>");

            foreach (var term in terms)
            {
                switch (term.TermType)
                {
                case RequestCriteria.Models.TermTypes.CodesTerm:
                    string CodeTypeDescription = string.Empty;
                    switch ((term as CodesData).CodesTermType)
                    {
                    case CodesTermTypes.Diagnosis_ICD9Term:
                        switch ((term as CodesData).CodeType)
                        {
                        case "09": CodeTypeDescription = "ICD-9-CM"; break;

                        case "10": CodeTypeDescription = "ICD-10-CM"; break;

                        case "11": CodeTypeDescription = "ICD-11-CM"; break;

                        case "SM": CodeTypeDescription = "SNOMED CT"; break;

                        case "OT": CodeTypeDescription = "Other"; break;
                        }
                        break;

                    case CodesTermTypes.Procedure_ICD9Term:
                        switch ((term as CodesData).CodeType)
                        {
                        case "09": CodeTypeDescription = "ICD-9-CM"; break;

                        case "10": CodeTypeDescription = "ICD-10-CM"; break;

                        case "11": CodeTypeDescription = "ICD-11-CM"; break;

                        case "C2": CodeTypeDescription = "CPT Category II"; break;

                        case "C3": CodeTypeDescription = "CPT Category III"; break;

                        case "C4": CodeTypeDescription = "CPT-4 (i.e., HCPCS Level I)"; break;

                        case "HC": CodeTypeDescription = "HCPCS (i.e., HCPCS Level II)"; break;

                        case "H3": CodeTypeDescription = "HCPCS Level III"; break;

                        case "LC": CodeTypeDescription = "LOINC"; break;

                        case "LO": CodeTypeDescription = "Local Homegrown"; break;

                        case "ND": CodeTypeDescription = "NDC"; break;

                        case "RE": CodeTypeDescription = "Revenue"; break;

                        case "OT": CodeTypeDescription = "Other"; break;
                        }
                        break;
                    }
                    if (CodeTypeDescription != string.Empty)
                    {
                        sb.AppendFormat("<b>Code Type:</b> {0}<br />", CodeTypeDescription);
                    }

                    sb.AppendFormat("<b>Codes:</b> <i>{0}</i> {1}<br />",
                                    (term as CodesData).SearchMethodType == SearchMethodTypes.ExactMatch ? "Exact Match" : "Starts With",
                                    (term as CodesData).Codes);
                    break;

                case RequestCriteria.Models.TermTypes.DataPartnerTerm:
                    var partners      = (term as DataPartnersData).DataPartners;
                    var organizations = DataContext.Organizations.Where(o => partners.Contains(o.Acronym)).Select(o => new { o.Name, o.Acronym }).ToArray();
                    sb.AppendFormat("<b>Data Partners:</b> {0}<br />", String.Join(", ", organizations.Select(o => string.Format("{0} ({1})", o.Name, o.Acronym))));
                    break;

                case RequestCriteria.Models.TermTypes.EthnicityTerm:
                    var ethnicities = new List <string>();

                    foreach (var ethnicity in (term as EthnicityData).Ethnicities)
                    {
                        switch (ethnicity)
                        {
                        case EthnicityTypes.Unknown:
                            ethnicities.Add("Unknown");
                            break;

                        case EthnicityTypes.Hispanic:
                            ethnicities.Add("Hispanic");
                            break;

                        case EthnicityTypes.NotHispanic:
                            ethnicities.Add("Not Hispanic");
                            break;

                        case EthnicityTypes.Missing:
                            ethnicities.Add("Missing");
                            break;
                        }
                    }

                    sb.AppendFormat("<b>Ethnicities:</b> {0}<br />", String.Join(", ", ethnicities));
                    break;

                case RequestCriteria.Models.TermTypes.MetricTerm:
                    var metrics = new List <string>();

                    foreach (var metric in (term as MetricsData).Metrics)
                    {
                        switch (metric)
                        {
                        case MetricsTypes.DataPartnerCount:
                            metrics.Add("Count by Data Partner"); break;

                        case MetricsTypes.DataPartnerPercent:
                            metrics.Add("Percent within Data Partner"); break;

                        case MetricsTypes.DataPartnerPercentContribution:
                            metrics.Add("Percent of Data Partner Contribution"); break;

                        case MetricsTypes.DataPartnerPresence:
                            metrics.Add("Presence by Data Partner"); break;

                        case MetricsTypes.Overall:
                            metrics.Add("Overall"); break;

                        case MetricsTypes.OverallCount:
                            metrics.Add("Overall Count"); break;

                        case MetricsTypes.OverallPresence:
                            metrics.Add("Overall Presence"); break;
                        }
                    }

                    sb.AppendFormat("<b>Metrics:</b> {0}<br />", String.Join(", ", metrics));
                    break;

                case RequestCriteria.Models.TermTypes.RaceTerm:
                    var races = new List <string>();

                    foreach (var race in (term as RaceData).Races)
                    {
                        switch (race)
                        {
                        case RaceTypes.AmericanIndianOrAlaskaNative:
                            races.Add("American Indian/Alaska Native");
                            break;

                        case RaceTypes.Asian:
                            races.Add("Asian");
                            break;

                        case RaceTypes.BlackOrAfricanAmerican:
                            races.Add("Black/African American");
                            break;

                        case RaceTypes.NativeHawaiianOrOtherPacificIslander:
                            races.Add("Native Hawaiian/Pacific Islander");
                            break;

                        case RaceTypes.Unknown:
                            races.Add("Unknown");
                            break;

                        case RaceTypes.White:
                            races.Add("White");
                            break;

                        case RaceTypes.Missing:
                            races.Add("Missing");
                            break;
                        }
                    }

                    sb.AppendFormat("<b>Races:</b> {0}<br />", String.Join(", ", races));
                    break;

                case RequestCriteria.Models.TermTypes.PDXTerm:
                    var pdxes = new List <string>();
                    foreach (var pdx in (term as PDXData).PDXes)
                    {
                        switch (pdx)
                        {
                        case PDXTypes.Other:
                            pdxes.Add("Other PDX");
                            break;

                        default:
                            pdxes.Add(pdx.ToString());
                            break;
                        }
                    }
                    sb.AppendFormat("<b>PDX Codes:</b> {0}<br />", String.Join(", ", pdxes));
                    break;

                case RequestCriteria.Models.TermTypes.MetaDataTableTerm:
                    var tables = new List <string>();
                    foreach (var table in (term as MetaDataTableData).Tables)
                    {
                        tables.Add(table.ToString());
                    }
                    sb.AppendFormat("<b>Completeness Tables:</b> {0}<br />", String.Join(", ", tables));
                    break;

                case RequestCriteria.Models.TermTypes.EncounterTypeTerm:
                    var encounters = new List <string>();
                    foreach (var encounter in (term as EncounterData).Encounters)
                    {
                        switch (encounter)
                        {
                        case EncounterTypes.All:
                            encounters.Add("All Encounters");
                            break;

                        case EncounterTypes.AmbulatoryVisit:
                            encounters.Add("Ambulatory Visit (AV)");
                            break;

                        case EncounterTypes.EmergencyDepartment:
                            encounters.Add("Emergency Department (ED)");
                            break;

                        case EncounterTypes.InpatientHospitalStay:
                            encounters.Add("Inpatient Hospital Stay (IP)");
                            break;

                        case EncounterTypes.NonAcuteInstitutionalStay:
                            encounters.Add("Non-Acute Institutional Stay (IS)");
                            break;

                        case EncounterTypes.OtherAmbulatoryVisit:
                            encounters.Add("Other Ambulatory Visit (OA)");
                            break;

                        default:
                            encounters.Add("Missing");
                            break;
                        }
                    }
                    sb.AppendFormat("<b>Encounters:</b> {0}<br />", String.Join(", ", encounters));
                    break;

                case RequestCriteria.Models.TermTypes.RxAmtTerm:
                    var amtTerms = new List <string>();
                    foreach (var amt in (term as RxAmountData).RxAmounts)
                    {
                        switch (amt)
                        {
                        case RxAmountTypes.LessThanZero:
                            amtTerms.Add("< 0");
                            break;

                        case RxAmountTypes.Ninety:
                            amtTerms.Add("91-120");
                            break;

                        case RxAmountTypes.OneHundredTwenty:
                            amtTerms.Add("121-180");
                            break;

                        case RxAmountTypes.OneHundredEighty:
                            amtTerms.Add(">180");
                            break;

                        case RxAmountTypes.Other:
                            amtTerms.Add("Other RxAmt");
                            break;

                        case RxAmountTypes.Sixty:
                            amtTerms.Add("61-90");
                            break;

                        case RxAmountTypes.Thirty:
                            amtTerms.Add("31-60");
                            break;

                        case RxAmountTypes.TwoThroughThirty:
                            amtTerms.Add("2-30");
                            break;

                        case RxAmountTypes.Zero:
                            amtTerms.Add("0-1");
                            break;

                        case RxAmountTypes.Missing:
                            amtTerms.Add("Missing");
                            break;

                        default:
                            amtTerms.Add("Missing");
                            break;
                        }
                    }
                    sb.AppendFormat("<b>RxAmt Terms:</b> {0}<br />", String.Join(", ", amtTerms));
                    break;

                case RequestCriteria.Models.TermTypes.RxSupTerm:
                    var supTerms = new List <string>();
                    foreach (var sup in (term as RxSupData).RxSups)
                    {
                        switch (sup)
                        {
                        case RxSupTypes.LessThanZero:
                            supTerms.Add("<0");
                            break;

                        case RxSupTypes.Ninety:
                            supTerms.Add(">90");
                            break;

                        case RxSupTypes.TwoThroughThirty:
                            supTerms.Add("2-30");
                            break;

                        case RxSupTypes.Other:
                            supTerms.Add("Other RxSup");
                            break;

                        case RxSupTypes.Sixty:
                            supTerms.Add("61-90");
                            break;

                        case RxSupTypes.Thirty:
                            supTerms.Add("31-60");
                            break;

                        case RxSupTypes.Zero:
                            supTerms.Add("0-1");
                            break;

                        case RxSupTypes.Missing:
                            supTerms.Add("Missing");
                            break;

                        default:
                            supTerms.Add("Missing");
                            break;
                        }
                    }
                    sb.AppendFormat("<b>RxSup Terms:</b> {0}<br />", String.Join(", ", supTerms));
                    break;
                }
            }

            sb.Append("</body></html>");

            return(sb.ToString());
        }
Exemplo n.º 5
0
        DataCheckerModel GetModel(IDnsRequestContext request)
        {
            var m = new DataCheckerModel
            {
                RequestType = DataCheckerRequestType.All.FirstOrDefault(rt => rt.ID == request.RequestType.ID),
                RequestId   = request.RequestID
            };

            if ((request.Documents != null) && (request.Documents.Where(d => d.Name == REQUEST_ARGS_FILENAME).Count() > 0))
            {
                var doc = request.Documents.First(d => d.Name == REQUEST_ARGS_FILENAME);
                m.CriteriaGroupsJSON = FixDocumentContent(System.Text.UTF8Encoding.UTF8.GetString(doc.GetData(_dataContext.Value)));
            }
            else
            {
                // set up an initial model based on the request type
                var terms = new List <ITermData> {
                    new DataPartnersData()
                    {
                        TermType     = RequestCriteria.Models.TermTypes.DataPartnerTerm,
                        DataPartners = new string[] {}
                    }
                };

                var criteria = new CriteriaData()
                {
                    IsExclusion = false,
                    IsPrimary   = true,
                    Name        = "Primary",
                    Terms       = terms
                };

                var myRequest = new RequestCriteriaData()
                {
                    RequestType = m.RequestType.ID,
                    Criterias   = new List <CriteriaData> {
                        criteria
                    }
                };

                if (m.RequestType.ID == Guid.Parse(DataCheckerRequestType.DATA_CHECKER_DIAGNOSIS))
                {
                    terms.Add(new CodesData()
                    {
                        TermType      = RequestCriteria.Models.TermTypes.CodesTerm,
                        CodesTermType = CodesTermTypes.Diagnosis_ICD9Term,
                        Codes         = string.Empty
                    });
                }
                else if (m.RequestType.ID == Guid.Parse(DataCheckerRequestType.DATA_CHECKER_ETHNICITY))
                {
                    terms.Add(new EthnicityData()
                    {
                        TermType    = RequestCriteria.Models.TermTypes.EthnicityTerm,
                        Ethnicities = new EthnicityTypes[] { }
                    });
                }
                else if (m.RequestType.ID == Guid.Parse(DataCheckerRequestType.DATA_CHECKER_NDC))
                {
                    terms.Add(new CodesData()
                    {
                        TermType      = RequestCriteria.Models.TermTypes.CodesTerm,
                        CodesTermType = CodesTermTypes.NDCTerm,
                        Codes         = string.Empty
                    });
                }
                else if (m.RequestType.ID == Guid.Parse(DataCheckerRequestType.DATA_CHECKER_PROCEDURE))
                {
                    terms.Add(new CodesData()
                    {
                        TermType      = RequestCriteria.Models.TermTypes.CodesTerm,
                        CodesTermType = CodesTermTypes.Procedure_ICD9Term,
                        Codes         = string.Empty
                    });
                }
                else if (m.RequestType.ID == Guid.Parse(DataCheckerRequestType.DATA_CHECKER_RACE))
                {
                    terms.Add(new RaceData()
                    {
                        TermType = RequestCriteria.Models.TermTypes.RaceTerm,
                        Races    = new RaceTypes[] { }
                    });
                }
                else if (m.RequestType.ID == new Guid(DataCheckerRequestType.DATA_CHECKER_DIAGNOSIS_PDX))
                {
                    terms.Add(new PDXData
                    {
                        TermType = RequestCriteria.Models.TermTypes.PDXTerm,
                        PDXes    = new PDXTypes[] { }
                    });

                    terms.Add(new EncounterData
                    {
                        TermType   = RequestCriteria.Models.TermTypes.EncounterTypeTerm,
                        Encounters = new EncounterTypes[] { }
                    });
                }
                else if (m.RequestType.ID == new Guid(DataCheckerRequestType.DATA_CHECKER_METADATA_COMPLETENESS))
                {
                    terms.Add(new MetaDataTableData {
                        TermType = RequestCriteria.Models.TermTypes.MetaDataTableTerm,
                        Tables   = new MetaDataTableTypes[] {}
                    });
                }
                else if (m.RequestType.ID == new Guid(DataCheckerRequestType.DATA_CHECKER_DISPENSING_RXAMT))
                {
                    terms.Add(new RxAmountData
                    {
                        TermType  = RequestCriteria.Models.TermTypes.RxAmtTerm,
                        RxAmounts = new RxAmountTypes[] { }
                    });
                }
                else if (m.RequestType.ID == new Guid(DataCheckerRequestType.DATA_CHECKER_DISPENSING_RXSUP))
                {
                    terms.Add(new RxSupData
                    {
                        TermType = RequestCriteria.Models.TermTypes.RxSupTerm,
                        RxSups   = new RxSupTypes[] { }
                    });
                }

                m.CriteriaGroupsJSON = RequestCriteriaHelper.ToClientModel(myRequest);
            }

            return(m);
        }