示例#1
0
        ///<summary>After taking a screening using a sheet, this method will import the sheet as a screen and insert it into the db.
        ///Returns null if the sheet passed in is not a Screening sheet type or if the sheet is missing the required ScreenGroupNum param.
        ///Optionally supply a screen if you want to preset some values.  E.g. ScreenGroupOrder is often preset before calling this method.</summary>
        public static Screen CreateScreenFromSheet(Sheet sheet, Screen screen = null)
        {
            //No need to check RemotingRole; no call to db.
            //Make sure that the sheet passed in is a screening and contains the required ScreenGroupNum parameter.
            if (sheet.SheetType != SheetTypeEnum.Screening || SheetParameter.GetParamByName(sheet.Parameters, "ScreenGroupNum") == null)
            {
                return(null);
            }
            if (screen == null)
            {
                screen = new Screen();
                screen.ScreenGroupNum = (long)SheetParameter.GetParamByName(sheet.Parameters, "ScreenGroupNum").ParamValue;
            }
            screen.SheetNum = sheet.SheetNum;
            foreach (SheetField field in sheet.SheetFields)
            {
                switch (field.FieldName)
                {
                case "Gender":
                    if (field.FieldValue.Trim().ToLower().StartsWith("m"))
                    {
                        screen.Gender = PatientGender.Male;
                    }
                    else if (field.FieldValue.Trim().ToLower().StartsWith("f"))
                    {
                        screen.Gender = PatientGender.Female;
                    }
                    else
                    {
                        screen.Gender = PatientGender.Unknown;
                    }
                    break;

                case "Race/Ethnicity":
                    PatientRaceOld patientRace = PatientRaceOld.Unknown;
                    Enum.TryParse <PatientRaceOld>(field.FieldValue.Split(';')[0], out patientRace);
                    screen.RaceOld = patientRace;
                    break;

                case "GradeLevel":
                    PatientGrade patientGrade = PatientGrade.Unknown;
                    Enum.TryParse <PatientGrade>(field.FieldValue.Split(';')[0], out patientGrade);
                    screen.GradeLevel = patientGrade;
                    break;

                case "Age":
                    if (screen.Age != 0)
                    {
                        break;                                //Already calculated via Birthdate.
                    }
                    byte age = 0;
                    byte.TryParse(field.FieldValue, out age);
                    screen.Age = age;
                    break;

                case "Urgency":
                    TreatmentUrgency treatmentUrgency = TreatmentUrgency.Unknown;
                    Enum.TryParse <TreatmentUrgency>(field.FieldValue.Split(';')[0], out treatmentUrgency);
                    screen.Urgency = treatmentUrgency;
                    break;

                case "ChartSealantTreatment":
                    //Only mark "carious" if TP chart has C marked for any tooth surface.
                    if (field.FieldValue.Contains("C"))
                    {
                        screen.HasCaries = YN.Yes;                              //Caries is present in TP'd chart.  Compl chart doesn't matter, it's only for sealant placement.
                    }
                    else
                    {
                        screen.HasCaries = YN.No;
                    }
                    //Only mark "needs sealants" if TP chart has S marked for any tooth surface.
                    if (field.FieldValue.Contains("S"))
                    {
                        screen.NeedsSealants = YN.Yes;
                    }
                    else
                    {
                        screen.NeedsSealants = YN.No;
                    }
                    break;

                case "CariesExperience":
                    screen.CariesExperience = field.FieldValue == "X" ? YN.Yes : YN.No;
                    break;

                case "EarlyChildCaries":
                    screen.EarlyChildCaries = field.FieldValue == "X" ? YN.Yes : YN.No;
                    break;

                case "ExistingSealants":
                    screen.ExistingSealants = field.FieldValue == "X" ? YN.Yes : YN.No;
                    break;

                case "MissingAllTeeth":
                    screen.MissingAllTeeth = field.FieldValue == "X" ? YN.Yes : YN.No;
                    break;

                case "Birthdate":
                    DateTime birthdate = new DateTime(1, 1, 1);
                    DateTime.TryParse(field.FieldValue, out birthdate);
                    screen.Birthdate = birthdate;
                    //Check to see if the sheet has Age manually filled out.
                    //If Age was not manually set, automatically calculate the age based on the birthdate entered.
                    //This matches screening functionality.
                    SheetField sheetFieldAge = sheet.SheetFields.FirstOrDefault(x => x.FieldName == "Age");
                    if (sheetFieldAge != null && string.IsNullOrEmpty(sheetFieldAge.FieldValue))
                    {
                        screen.Age = PIn.Byte(Patients.DateToAge(birthdate).ToString());
                    }
                    break;

                case "Comments":
                    screen.Comments = field.FieldValue;
                    break;
                }
            }
            if (screen.ScreenNum == 0)
            {
                Insert(screen);
            }
            else
            {
                Update(screen);
            }
            return(screen);
        }
示例#2
0
 ///<summary>Gets a pref of type byte.  Used when the pref is a very small integer (0-255).</summary>
 public static byte GetByte(PrefName prefName)
 {
     return(PIn.Byte(Prefs.GetOne(prefName).ValueString));
 }
示例#3
0
        public EB271(X12Segment segment, bool isInNetwork, bool isCoinsuranceInverted, X12Segment segHsd = null)
        {
            if (eb01 == null)
            {
                FillDictionaries();
            }
            Segment = segment;
            SupplementalSegments = new List <X12Segment>();
            //start pattern matching to generate closest Benefit
            EB01          eb01val  = eb01.Find(EB01MatchesCode);
            EB02          eb02val  = eb02.Find(EB02MatchesCode);
            EB03          eb03val  = eb03.Find(EB03MatchesCode);
            EB06          eb06val  = eb06.Find(EB06MatchesCode);
            EB09          eb09val  = eb09.Find(EB09MatchesCode);
            ProcedureCode proccode = null;

            if (ProcedureCodes.IsValidCode(Segment.Get(13, 2)))
            {
                proccode = ProcedureCodes.GetProcCode(Segment.Get(13, 2));
            }
            if (!eb01val.IsSupported ||
                (eb02val != null && !eb02val.IsSupported) ||
                (eb03val != null && !eb03val.IsSupported) ||
                (eb06val != null && !eb06val.IsSupported) ||
                (eb09val != null && !eb09val.IsSupported))
            {
                Benefitt = null;
                return;
            }
            if (eb01val.BenefitType == InsBenefitType.ActiveCoverage && Segment.Get(3) == "30")
            {
                Benefitt = null;
                return;
            }
            if (eb01val.BenefitType == InsBenefitType.ActiveCoverage && proccode != null)
            {
                //A code is covered.  Informational only.
                Benefitt = null;
                return;
            }
            if (Segment.Get(8) != "")           //if percentage
            //must have either a category or a proc code
            {
                if (proccode == null)                                                                                                       //if no proc code is specified
                {
                    if (eb03val == null || eb03val.ServiceType == EbenefitCategory.None || eb03val.ServiceType == EbenefitCategory.General) //and no category specified
                    {
                        Benefitt = null;
                        return;
                    }
                }
            }
            //coinsurance amounts are handled with fee schedules rather than benefits
            if (eb01val.BenefitType == InsBenefitType.CoPayment || eb01val.BenefitType == InsBenefitType.CoInsurance)
            {
                if (Segment.Get(7) != "")               //and a monetary amount specified
                {
                    Benefitt = null;
                    return;
                }
            }
            //a limitation without an amount is meaningless
            if (eb01val.BenefitType == InsBenefitType.Limitations &&
                segHsd == null)                 //Some benefits do not have monetary value but limit service in a time period.  Originally done for customer 27936.
            {
                if (Segment.Get(7) == "")       //no monetary amount specified
                {
                    Benefitt = null;
                    return;
                }
            }
            if (isInNetwork && (Segment.Get(12) == "N" || Segment.Get(12) == "U"))
            {
                Benefitt = null;
                return;
            }
            if (!isInNetwork && Segment.Get(12) == "Y")
            {
                Benefitt = null;
                return;
            }
            //if only a quantity is specified with no qualifier, it's meaningless
            if (Segment.Get(10) != "" && eb09val == null)
            {
                Benefitt = null;
                return;
            }
            //if only a qualifier is specified with no quantity, it's meaningless
            if (eb09val != null && Segment.Get(10) == "")
            {
                Benefitt = null;
                return;
            }
            Benefitt = new Benefit();
            //1
            Benefitt.BenefitType = eb01val.BenefitType;
            //2
            if (eb02val != null)
            {
                Benefitt.CoverageLevel = eb02val.CoverageLevel;
            }
            //3
            if (eb03val != null)
            {
                Benefitt.CovCatNum = CovCats.GetForEbenCat(eb03val.ServiceType).CovCatNum;
            }
            //4-Insurance type - we ignore.
            //5-Plan description - we ignore.
            //6
            if (eb06val != null)
            {
                Benefitt.TimePeriod = eb06val.TimePeriod;
            }
            //7
            if (Segment.Get(7) != "")
            {
                Benefitt.MonetaryAmt = PIn.Double(Segment.Get(7));              //Monetary amount. Situational
            }
            //8
            if (Segment.Get(8) != "")
            {
                if (isCoinsuranceInverted && Benefitt.BenefitType == InsBenefitType.CoInsurance) //Some carriers incorrectly send insurance percentage.
                {
                    Benefitt.Percent = (int)(PIn.Double(Segment.Get(8)) * 100);                  //Percent. Came to us inverted, do Not Invert.
                }
                else
                {
                    //OD shows the percentage paid by Insurance by default.
                    //Some carriers submit 271s to us showing percentage paid by Patient, so we need to invert this case to match OD expectations.
                    Benefitt.Percent = 100 - (int)(PIn.Double(Segment.Get(8)) * 100);              //Percent. Invert.
                }
                Benefitt.CoverageLevel = BenefitCoverageLevel.None;
            }
            //9-Quantity qualifier
            if (eb09val != null)
            {
                Benefitt.QuantityQualifier = eb09val.QuantityQualifier;
            }
            //10-Quantity
            if (Segment.Get(10) != "")
            {
                Benefitt.Quantity = (byte)PIn.Double(Segment.Get(10));              //Example: "19.0" with Quantity qualifier "S7" (age).
            }
            //11-Authorization. Ignored.
            //12-In network. Ignored.
            //13-proc
            if (proccode != null)
            {
                Benefitt.CodeNum = proccode.CodeNum;              //element 13,2
            }
            if (Benefitt.BenefitType == InsBenefitType.Limitations &&
                proccode != null &&               //Valid ADA code.
                segHsd != null)
            {
                if (segHsd.Elements.Length < 6 || segHsd.Elements[2] == "" || segHsd.Elements[5] == "")
                {
                    Benefitt = null;
                    return;
                }
                Benefitt.Quantity   = PIn.Byte(segHsd.Elements[2]);                                      //HSD02: Quantity.
                Benefitt.TimePeriod = eb06.FirstOrDefault(x => x.Code == segHsd.Elements[5]).TimePeriod; //HSD05: Frequency.
            }
        }