Ejemplo n.º 1
0
        ///<summary>Takes a screening sheet that is associated to a patient and processes any corresponding ScreenCharts found.
        ///Processing will create treatment planned or completed procedures for the patient.
        ///Supply the sheet and then a bitwise enum of screen chart types to digest.
        ///listProcOrigVals, nulls are allowed, the first represents the fluoride field, second is assessment field, all others are other procs.</summary>
        public static void ProcessScreenChart(Sheet sheet, ScreenChartType chartTypes, long provNum, long sheetNum, List <SheetField> listChartOrigVals
                                              , List <SheetField> listProcOrigVals)
        {
            //No need to check RemotingRole; no call to db.
            if (sheet == null || sheet.PatNum == 0)
            {
                return;                //An invalid screening sheet was passed in.
            }
            List <string> listToothVals    = new List <string>();
            List <string> listToothValsOld = new List <string>();

            //Process treatment planned sealants.
            foreach (SheetField field in sheet.SheetFields)             //Go through the supplied sheet's fields and find the field.
            {
                if (chartTypes.HasFlag(ScreenChartType.TP) && field.FieldType == SheetFieldType.ScreenChart && field.FieldName == "ChartSealantTreatment")
                {
                    listToothVals = field.FieldValue.Split(';').ToList();
                    if (listToothVals[0] == "1")         //Primary tooth chart
                    {
                        continue;                        //Skip primary tooth charts because we do not need to create any TP procedures for them.
                    }
                    listToothVals.RemoveAt(0);           //Remove the toothchart type value
                    if (listChartOrigVals[0] != null)    //Shouldn't be null if ChartSealantTreatment exists
                    {
                        listToothValsOld = listChartOrigVals[0].FieldValue.Split(';').ToList();
                        listToothValsOld.RemoveAt(0);                        //Remove the toothchart type value
                    }
                    ScreenChartType chartType = ScreenChartType.TP;
                    ProcessScreenChartHelper(sheet.PatNum, listToothVals, chartType, provNum, sheetNum, listToothValsOld);
                    break;
                }
            }
            listToothVals = new List <string>();            //Clear out the tooth values for the next tooth chart.
            //Process completed sealants.
            foreach (SheetField field in sheet.SheetFields) //Go through the supplied sheet's fields and find the field.
            {
                if (chartTypes.HasFlag(ScreenChartType.C) && field.FieldType == SheetFieldType.ScreenChart && field.FieldName == "ChartSealantComplete")
                {
                    listToothVals = field.FieldValue.Split(';').ToList();
                    if (listToothVals[0] == "1")         //Primary tooth chart
                    {
                        continue;                        //Skip primary tooth charts because we do not need to create any TP procedures for them.
                    }
                    listToothVals.RemoveAt(0);           //Remove the toothchart type value
                    if (listChartOrigVals[1] != null)    //Shouldn't be null if ChartSealantTreatment exists
                    {
                        listToothValsOld = listChartOrigVals[1].FieldValue.Split(';').ToList();
                        listToothValsOld.RemoveAt(0);                        //Remove the toothchart type value
                    }
                    ScreenChartType chartType = ScreenChartType.C;
                    ProcessScreenChartHelper(sheet.PatNum, listToothVals, chartType, provNum, sheetNum, listToothValsOld);
                    break;
                }
            }
            //Process if the user wants to TP fluoride and/or assessment procedures and/or other procedures.
            foreach (SheetField field in sheet.SheetFields)
            {
                if (field.FieldType != SheetFieldType.CheckBox)
                {
                    continue;                    //Only care about check box types.
                }
                if (field.FieldName != "FluorideProc" && field.FieldName != "AssessmentProc" && !field.FieldName.StartsWith("Proc:"))
                {
                    continue;                    //Field name must be one of the two hard coded values, or a FieldName that starts with "Proc".
                }
                //Make other proc with provNum and patNum
                SheetField sheetFieldOrig = listProcOrigVals.FirstOrDefault(x => x.FieldName == field.FieldName && x.FieldType == SheetFieldType.CheckBox);
                if (sheetFieldOrig == null || sheetFieldOrig.FieldValue != "" || field.FieldValue != "X")
                {
                    //Either not found or field was previously checked (already charted proc) or field is not checked (do not chart).
                    continue;
                }
                string strProcCode = "";
                switch (field.FieldName)
                {
                case "FluorideProc":                        //Original value was blank, new value is "checked", make the D1206 (fluoride) proc.
                    strProcCode = "D1206";
                    break;

                case "AssessmentProc":                        //Original value was blank, new value is "checked", make the D0191 (assessment) proc.
                    strProcCode = "D0191";
                    break;

                default:                                        //Original value was blank, new value is "checked", make the proc.
                    strProcCode = field.FieldName.Substring(5); //Drop "Proc:" from FieldName.
                    break;
                }
                Procedure proc = Procedures.CreateProcForPatNum(sheet.PatNum, ProcedureCodes.GetCodeNum(strProcCode), "", "", ProcStat.C, provNum);
                if (proc != null)
                {
                    SecurityLogs.MakeLogEntry(Permissions.ProcEdit, sheet.PatNum, strProcCode + " " + Lans.g("Screens", "treatment planned during screening."));
                }
            }
        }
Ejemplo n.º 2
0
 ///<summary>Helper method so that we do not have to duplicate code.  The length of toothValues must match the length of chartOrigVals.</summary>
 private static void ProcessScreenChartHelper(long patNum, List <string> toothValues, ScreenChartType chartType, long provNum, long sheetNum
                                              , List <string> chartOrigVals)
 {
     //No need to check RemotingRole; no call to db.
     for (int i = 0; i < toothValues.Count; i++)       //toothValues is in the order from low to high tooth number in the chart
     {
         if (!toothValues[i].Contains("S"))            //No sealant, nothing to do.
         {
             continue;
         }
         //Logic to determine if the "S" changed surfaces or was erased between the time the toothchart was opened and when it was submitted.
         string[] newSurfaces  = toothValues[i].Split(',');
         string[] origSurfaces = chartOrigVals[i].Split(',');
         bool     isDiff       = false;
         for (int j = 0; j < origSurfaces.Length; j++)                                                                   //Both arrays have the same length unless the chart doesn't exist in the original.
         {
             if ((newSurfaces[j] == "S" && origSurfaces[j] != "S") || (newSurfaces[j] != "S" && origSurfaces[j] == "S")) //"S" changed surfaces or was removed.
             {
                 isDiff = true;
                 break;
             }
         }
         //If there is no difference don't make any duplicates.  We don't care if they changed a surface from N to PS for example, only S surfaces are important.
         if (!isDiff)
         {
             continue;                    //All the "S" surfaces are the same.
         }
         string surf     = "";
         int    toothNum = 0;
         bool   isMolar  = false;
         bool   isRight  = false;
         bool   isLing   = false;
         string tooth    = "";
         #region Parse ScreenChart FieldValues
         if (i <= 1)               //Top left quadrant of toothchart
         {
             toothNum = i + 2;
             isMolar  = true;
             isRight  = true;
             isLing   = true;
         }
         else if (i > 1 && i <= 3)             //Top middle-left quadrant of toothchart
         {
             toothNum = i + 2;
             isMolar  = false;
             isRight  = true;
             isLing   = true;
         }
         else if (i > 3 && i <= 5)             //Top middle-right quadrant of toothchart
         {
             toothNum = i + 8;
             isMolar  = false;
             isRight  = false;
             isLing   = true;
         }
         else if (i > 5 && i <= 7)             //Top right quadrant of toothchart
         {
             toothNum = i + 8;
             isMolar  = true;
             isRight  = false;
             isLing   = true;
         }
         else if (i > 7 && i <= 9)             //Lower right quadrant of toothchart
         {
             toothNum = i + 10;
             isMolar  = true;
             isRight  = false;
             isLing   = false;
         }
         else if (i > 9 && i <= 11)             //Lower middle-right quadrant of toothchart
         {
             toothNum = i + 10;
             isMolar  = false;
             isRight  = false;
             isLing   = false;
         }
         else if (i > 11 && i <= 13)             //Lower middle-left quadrant of toothchart
         {
             toothNum = i + 16;
             isMolar  = false;
             isRight  = true;
             isLing   = false;
         }
         else if (i > 13)               //Lower left quadrant of toothchart
         {
             toothNum = i + 16;
             isMolar  = true;
             isRight  = true;
             isLing   = false;
         }
         if (isMolar)
         {
             if (isRight)
             {
                 if (newSurfaces[0] == "S")
                 {
                     surf += "D";
                 }
                 if (newSurfaces[1] == "S")
                 {
                     surf += "M";
                 }
             }
             else                      //Is Left side
             {
                 if (newSurfaces[0] == "S")
                 {
                     surf += "M";
                 }
                 if (newSurfaces[1] == "S")
                 {
                     surf += "D";
                 }
             }
             if (isLing && newSurfaces[2] == "S")
             {
                 surf += "L";
             }
             if (!isLing && newSurfaces[2] == "S")
             {
                 surf += "B";
             }
         }
         else                  //Front teeth, only look at 3rd surface position in control as that's the only one the user can see.
         {
             if (newSurfaces[2] == "S")
             {
                 surf = "O";                      //NOTE: Not sure what surface to enter here... This is just a placeholder for now until we figure it out...
             }
         }
         if (toothNum != 0)
         {
             tooth = toothNum.ToString();
         }
         #endregion Parse Toothchart FieldValues
         surf = Tooth.SurfTidyForDisplay(surf, tooth);
         if (chartType == ScreenChartType.TP)               //Create TP'd sealant procs if they don't already exist for this patient.
         {
             if (Procedures.GetProcForPatByToothSurfStat(patNum, toothNum, surf, ProcStat.TP) != null)
             {
                 continue;
             }
             Procedure proc = Procedures.CreateProcForPatNum(patNum, ProcedureCodes.GetCodeNum("D1351"), surf, tooth, ProcStat.TP, provNum);
             if (proc != null)
             {
                 SecurityLogs.MakeLogEntry(Permissions.ProcEdit, patNum, "D1351 " + Lans.g("Screens", "treatment planned during screening with tooth")
                                           + " " + proc.ToothNum.ToString() + " " + Lans.g("Screens", "and surface") + " " + proc.Surf);
             }
         }
         else if (chartType == ScreenChartType.C)
         {
             Procedure proc = Procedures.GetProcForPatByToothSurfStat(patNum, toothNum, surf, ProcStat.TP);
             if (proc == null)                   //A TP procedure does not already exist.
             {
                 proc = Procedures.CreateProcForPatNum(patNum, ProcedureCodes.GetCodeNum("D1351"), surf, tooth, ProcStat.C, provNum);
             }
             else                      //TP proc already exists, set it complete.
             {
                 Procedure procOld = proc.Copy();
                 proc.ProcStatus = ProcStat.C;
                 proc.DateEntryC = DateTime.Now;
                 Procedures.Update(proc, procOld);
             }
             if (proc != null)
             {
                 SecurityLogs.MakeLogEntry(Permissions.ProcComplCreate, patNum, "D1351 " + Lans.g("Screens", "set complete during screening with tooth")
                                           + " " + proc.ToothNum.ToString() + " " + Lans.g("Screens", "and surface") + " " + proc.Surf);
             }
         }
     }
     if (chartType == ScreenChartType.C)
     {
         Recalls.Synch(patNum);
     }
 }
Ejemplo n.º 3
0
        ///<summary>Takes a screening sheet that is associated to a patient and processes any corresponding ScreenCharts found.
        ///Processing will create treatment planned or completed procedures for the patient.
        ///Supply the sheet and then a bitwise enum of screen chart types to digest.
        ///procOrigVals MUST be two items long, nulls are allowed, the first represents the fluoride field, second is assessment field.</summary>
        public static void ProcessScreenChart(Sheet sheet, ScreenChartType chartTypes, long provNum, long sheetNum, List <SheetField> listChartOrigVals
                                              , List <SheetField> listProcOrigVals)
        {
            //No need to check RemotingRole; no call to db.
            if (sheet == null || sheet.PatNum == 0)
            {
                return;                //An invalid screening sheet was passed in.
            }
            List <string> listToothVals    = new List <string>();
            List <string> listToothValsOld = new List <string>();

            //Process treatment planned sealants.
            foreach (SheetField field in sheet.SheetFields)             //Go through the supplied sheet's fields and find the field.
            {
                if (chartTypes.HasFlag(ScreenChartType.TP) && field.FieldType == SheetFieldType.ScreenChart && field.FieldName == "ChartSealantTreatment")
                {
                    listToothVals = field.FieldValue.Split(';').ToList();
                    if (listToothVals[0] == "1")         //Primary tooth chart
                    {
                        continue;                        //Skip primary tooth charts because we do not need to create any TP procedures for them.
                    }
                    listToothVals.RemoveAt(0);           //Remove the toothchart type value
                    if (listChartOrigVals[0] != null)    //Shouldn't be null if ChartSealantTreatment exists
                    {
                        listToothValsOld = listChartOrigVals[0].FieldValue.Split(';').ToList();
                        listToothValsOld.RemoveAt(0);                        //Remove the toothchart type value
                    }
                    ScreenChartType chartType = ScreenChartType.TP;
                    ProcessScreenChartHelper(sheet.PatNum, listToothVals, chartType, provNum, sheetNum, listToothValsOld);
                    break;
                }
            }
            listToothVals = new List <string>();            //Clear out the tooth values for the next tooth chart.
            //Process completed sealants.
            foreach (SheetField field in sheet.SheetFields) //Go through the supplied sheet's fields and find the field.
            {
                if (chartTypes.HasFlag(ScreenChartType.C) && field.FieldType == SheetFieldType.ScreenChart && field.FieldName == "ChartSealantComplete")
                {
                    listToothVals = field.FieldValue.Split(';').ToList();
                    if (listToothVals[0] == "1")         //Primary tooth chart
                    {
                        continue;                        //Skip primary tooth charts because we do not need to create any TP procedures for them.
                    }
                    listToothVals.RemoveAt(0);           //Remove the toothchart type value
                    if (listChartOrigVals[1] != null)    //Shouldn't be null if ChartSealantTreatment exists
                    {
                        listToothValsOld = listChartOrigVals[1].FieldValue.Split(';').ToList();
                        listToothValsOld.RemoveAt(0);                        //Remove the toothchart type value
                    }
                    ScreenChartType chartType = ScreenChartType.C;
                    ProcessScreenChartHelper(sheet.PatNum, listToothVals, chartType, provNum, sheetNum, listToothValsOld);
                    break;
                }
            }
            //Process if the user wants to TP fluoride and / or assessment procedures.
            foreach (SheetField field in sheet.SheetFields)
            {
                if (field.FieldType != SheetFieldType.CheckBox)
                {
                    continue;                    //Only care about check box types.
                }
                if (field.FieldName != "FluorideProc" && field.FieldName != "AssessmentProc")
                {
                    continue;                    //Field name must be one of the two hard coded values.
                }
                //Make D1206 proc with provNum and patNum
                if (field.FieldName == "FluorideProc" && listProcOrigVals[1] != null && listProcOrigVals[1].FieldValue == "" && field.FieldValue == "X")
                {
                    //Original value was blank, new value is "checked", make the D1206 (fluoride) proc.
                    Procedure proc = Procedures.CreateProcForPat(sheet.PatNum, ProcedureCodes.GetCodeNum("D1206"), "", "", ProcStat.C, provNum);
                    if (proc != null)
                    {
                        SecurityLogs.MakeLogEntry(Permissions.ProcEdit, sheet.PatNum, "D1206 " + Lans.g("Screens", "treatment planned during screening"));
                    }
                }
                //Make D0191 proc with provNum and patNum
                if (field.FieldName == "AssessmentProc" && listProcOrigVals[0] != null && listProcOrigVals[0].FieldValue == "" && field.FieldValue == "X")
                {
                    //Original value was blank, new value is "checked", make the D0191 (assessment) proc.
                    Procedure proc = Procedures.CreateProcForPat(sheet.PatNum, ProcedureCodes.GetCodeNum("D0191"), "", "", ProcStat.C, provNum);
                    if (proc != null)
                    {
                        SecurityLogs.MakeLogEntry(Permissions.ProcEdit, sheet.PatNum, "D0191 " + Lans.g("Screens", "treatment planned during screening."));
                    }
                }
            }
        }