Exemple #1
0
        public override void GetColumnsInfo(DBConnection connection, DBTableInfo tableInfo)
        {
            var query = string.Format("select * from all_tab_cols where table_name = '{0}'{1} order by column_id",
                                      tableInfo.Name,
                                      string.IsNullOrEmpty(tableInfo.Schema) ? null : $" and owner = '{tableInfo.Schema}'");
            QResult list     = connection.ExecuteQResult(query);
            int     iName    = list.GetIndex("column_name");
            int     iType    = list.GetIndex("data_type");
            int     iPrec    = list.GetIndex("data_precision");
            int     iScale   = list.GetIndex("data_scale");
            int     iLeng    = list.GetIndex("data_length");
            int     iNull    = list.GetIndex("nullable");
            int     iDefault = list.GetIndex("data_default");

            foreach (object[] item in list.Values)
            {
                tableInfo.Columns.Add(new DBColumnInfo()
                {
                    Name      = item[iName].ToString(),
                    DataType  = item[iType].ToString(),
                    Precision = item[iPrec].ToString(),
                    Scale     = item[iScale].ToString(),
                    Length    = item[iLeng].ToString(),
                    NotNull   = item[iNull].Equals("N"),
                    Default   = item[iDefault].ToString(),
                });
            }
        }
Exemple #2
0
            public void Parse(DBSchema schema, DBTable table)
            {
                QResult list = schema.Connection.ExecuteQResult(Filter);

                int iName      = list.GetIndex(Name);
                int iSchema    = list.GetIndex(Schema);
                int iTable     = list.GetIndex(Table);
                int iColumn    = list.GetIndex(Column);
                int iRefSchema = list.GetIndex(ReferenceSchema);
                int iRefTable  = list.GetIndex(ReferenceTable);
                int iRefColumn = list.GetIndex(ReferenceColumn);

                foreach (object[] item in list.Values)
                {
                    var name = item[iName].ToString();
                    var tab  = table ?? schema.ParseTable(item[iTable].ToString());
                    var col  = tab?.ParseColumn(item[iName].ToString());
                    var rtab = schema.ParseTable(item[iRefTable].ToString());
                    var rcol = rtab?.ParseColumn(item[iRefColumn].ToString());
                    if (col != null && rcol != null)
                    {
                        var reference = col.Table.Foreigns.GetByColumns(col, rcol);
                        if (reference == null)
                        {
                            reference = new DBForeignKey
                            {
                                Column    = col,
                                Reference = rcol
                            };
                            col.Table.Foreigns.Add(reference);
                        }
                        reference.Name = name;
                    }
                }
            }
Exemple #3
0
 public void ExecuteQResult(IDbCommand command, QResult list)
 {
     list.Values.Clear();
     list.Columns.Clear();
     using (var reader = ExecuteQuery(command, DBExecuteType.Reader) as IDataReader)
     {
         int fCount = reader.FieldCount;
         for (int i = 0; i < fCount; i++)
         {
             var name = reader.GetName(i);
             list.Columns.Add(name, new QField {
                 Index = i, Name = name, DataType = reader.GetFieldType(i)
             });
         }
         list.OnColumnsLoaded();
         while (reader.Read())
         {
             var objects = new object[fCount];
             reader.GetValues(objects);
             list.Values.Add(objects);
         }
         reader.Close();
         list.OnLoaded();
     }
 }
Exemple #4
0
        public virtual void GetColumnsInfo(DBConnection connection, DBTableInfo tableInfo)
        {
            var query = string.Format("select * from information_schema.columns where table_name='{0}'{1} order by ordinal_position",
                                      tableInfo.Name,
                                      string.IsNullOrEmpty(tableInfo.Schema) ? null : $" and table_schema = '{tableInfo.Schema}'");
            QResult list     = connection.ExecuteQResult(query);
            int     iName    = list.GetIndex("column_name");
            int     iType    = list.GetIndex("data_type");
            int     iPrec    = list.GetIndex("numeric_precision");
            int     iScale   = list.GetIndex("numeric_scale");
            int     iLeng    = list.GetIndex("character_maximum_length");
            int     iNull    = list.GetIndex("is_nullable");
            int     iDefault = list.GetIndex("column_default");

            foreach (object[] item in list.Values)
            {
                tableInfo.Columns.Add(new DBColumnInfo()
                {
                    Name      = item[iName].ToString(),
                    DataType  = item[iType].ToString(),
                    Precision = item[iPrec].ToString(),
                    Scale     = item[iScale].ToString(),
                    Length    = item[iLeng].ToString(),
                    NotNull   = iNull >= 0 && item[iNull].Equals("NO"),
                    Default   = item[iDefault].ToString(),
                });
            }
        }
Exemple #5
0
        public QResult ExecuteQResult(IDbCommand command)
        {
            var list = new QResult();

            ExecuteQResult(AddCommand(command), list);
            return(list);
        }
Exemple #6
0
        public QResult ExecuteQResult()
        {
            var list = new QResult();

            ExecuteQResult(Command, list);
            return(list);
        }
Exemple #7
0
        public void FillTable(OpenXmlElement element, QResult query)
        {
            var row    = FindParent <Word.TableRow>(element);
            var orow   = (Word.TableRow)row.Clone();
            var prg    = FindParent <Word.Paragraph>(element);
            var hCell  = FindParent <Word.TableCell>(element);
            var hList  = row.Descendants <Word.TableCell>().ToList();
            var hIndex = hList.IndexOf(hCell);

            //element.Remove();
            Word.TableRow prow = null;
            foreach (object[] data in query.Values)
            {
                var cell = row.GetFirstChild <Word.TableCell>();
                while (hList.IndexOf(cell) != hIndex)
                {
                    cell = cell.NextSibling <Word.TableCell>();
                }
                foreach (object value in data)
                {
                    if (cell != null)
                    {
                        var paragraph = cell.Descendants <Word.Paragraph>().FirstOrDefault();
                        if (paragraph == null)
                        {
                            paragraph = (Word.Paragraph)prg.Clone();
                            cell.Append(paragraph);
                        }
                        Word.Run run = paragraph.Descendants <Word.Run>().FirstOrDefault();
                        if (run != null)
                        {
                            ReplaceString(run, value.ToString());
                        }
                        else
                        {
                            ReplaceString(paragraph, value.ToString());
                        }

                        cell = cell.NextSibling <Word.TableCell>();
                    }
                }
                if (row.Parent == null)
                {
                    prow.InsertAfterSelf <Word.TableRow>(row);
                }
                prow  = row;
                row   = (Word.TableRow)orow.Clone();
                hList = row.Descendants <Word.TableCell>().ToList();
            }
        }
Exemple #8
0
 public void SetCommand(IDbCommand command, DBSchema schema, string name)
 {
     if (Query == null)
     {
         Query = new QResult()
         {
             Name = name
         }
     }
     ;
     Query.Name   = name;
     this.schema  = schema;
     this.command = command;
 }
Exemple #9
0
        public void FillTable(OpenXmlElement element, QResult query)
        {
            var row = FindParent <Word.TableRow>(element);
            var prg = row.Descendants <Word.Paragraph>().FirstOrDefault();

            //element.Remove();
            Word.TableRow prow = null;
            foreach (object[] data in query.Values)
            {
                Word.TableCell cell = row.GetFirstChild <Word.TableCell>();
                foreach (object value in data)
                {
                    if (cell != null)
                    {
                        var paragraph = cell.Descendants <Word.Paragraph>().FirstOrDefault();
                        if (paragraph == null)
                        {
                            paragraph = (Word.Paragraph)prg.Clone();
                            cell.Append(paragraph);
                        }
                        Word.Run run = paragraph.Descendants <Word.Run>().FirstOrDefault();
                        if (run != null)
                        {
                            ReplaceString(run, value.ToString());
                        }
                        else
                        {
                            Word.Text text = new Word.Text()
                            {
                                Text = value.ToString(), Space = SpaceProcessingModeValues.Preserve
                            };
                            run = new Word.Run();
                            run.Append(text);
                            paragraph.Append(run);
                        }

                        cell = cell.NextSibling <Word.TableCell>();
                    }
                }
                if (row.Parent == null)
                {
                    prow.InsertAfterSelf <Word.TableRow>(row);
                }
                prow = row;
                row  = (Word.TableRow)row.Clone();
            }
        }
Exemple #10
0
        public async Task <IEnumerable <Pos> > List(int CompanyId)
        {
            IEnumerable <Pos> list;
            IQueryable <Pos>  QList;
            IQueryable <Pos>  QResult;

            try
            {
                QList   = _dbContex.Pos.AsQueryable();
                QResult = QList.Where(x => x.CompanyId == CompanyId);
                return(await QResult.ToListAsync());
            }
            catch (Exception e)
            {
                throw;
            }
        }
Exemple #11
0
        public override IEnumerable <DBTableInfo> GetTablesInfo(DBConnection connection, string schemaName, string tableName = null)
        {
            var     filter  = schemaName != null ? $" where owner = '{schemaName.ToUpper()}'{(tableName != null ? $" and table_name = '{tableName.ToUpper()}'" : null)}" : null;
            QResult list    = connection.ExecuteQResult($"select * from all_tables{filter}");
            int     iSchema = list.GetIndex("owner");
            int     iName   = list.GetIndex("table_name");

            foreach (object[] item in list.Values)
            {
                var table = new DBTableInfo()
                {
                    Schema = item[iSchema].ToString(),
                    Name   = item[iName].ToString(),
                };
                GetColumnsInfo(connection, table);
                yield return(table);
            }
        }
Exemple #12
0
        public virtual IEnumerable <DBTableInfo> GetTablesInfo(DBConnection connection, string schemaName = null, string tableName = null)
        {
            var     tableFilter  = !string.IsNullOrEmpty(tableName) ? $" and table_name = '{tableName}'" : string.Empty;
            var     schemaFilter = !string.IsNullOrEmpty(schemaName) ? $" where table_schema = '{schemaName}'{tableFilter}" : string.Empty;
            QResult list         = connection.ExecuteQResult($"select * from information_schema.tables{schemaFilter} order by table_name");
            int     iSchema      = list.GetIndex("table_schema");
            int     iName        = list.GetIndex("table_name");
            int     iIndex       = list.GetIndex("table_type");

            foreach (object[] item in list.Values)
            {
                var table = new DBTableInfo()
                {
                    Schema = item[iSchema].ToString(),
                    Name   = item[iName].ToString(),
                    View   = item[iIndex].ToString().IndexOf("view", StringComparison.OrdinalIgnoreCase) >= 0,
                };
                GetColumnsInfo(connection, table);
                GetConstraintInfo(connection, table);
                yield return(table);
            }
        }
Exemple #13
0
        public IActionResult Index(ShellGameModel model)
        {
            Debug.WriteLine("Preparing to Compute Quantum Results using selected Shell #" + model.ShellSelected + "...");
            model.ComputedShell    = "0";
            model.QASM             = "";
            model.ExecutionResults = "";

            string token = "INSERTYOURTOKENHERE";


            //Build the processor
            QProcessor qp = new QProcessor(token);


            //login
            QResult result = qp.Login();

            Debug.WriteLine(string.Format("Login result.  Success={0} Message={1}", result.Success.ToString(), result.Message));

            if (result.Success)
            {
                int shell = 0;
                Int32.TryParse(model.ShellSelected, out shell);

                //build the QASM code
                QCode code = new QCode(shell);
                code.name = string.Format("ExperimentID {0} with Shell at {1} ", System.Guid.NewGuid().ToString(), shell.ToString());
                Debug.WriteLine("Code:" + Environment.NewLine + code.qasm);


                //execute the code
                result = qp.ExecuteCode(code);
                Debug.WriteLine(string.Format("Code Executed Success={0}, Data={1}", result.Success.ToString(), result.Message));

                //parse the result and output the location of the coin
                QExecutionOutput x = qp.GetOutputFromMessageData(result.Message);

                string labels = x.result.data.p.labels[0];
                switch (labels)
                {
                case "00000":
                    Debug.WriteLine("The coin was under Shell #1");
                    model.ComputedShell = "1";
                    break;

                case "00100":
                    Debug.WriteLine("The coin was under Shell #2");
                    model.ComputedShell = "2";
                    break;

                case "00010":
                    Debug.WriteLine("The coin was under Shell #3");
                    model.ComputedShell = "3";
                    break;

                case "00110":
                    Debug.WriteLine("The coin was under Shell #4");
                    model.ComputedShell = "4";
                    break;

                default:
                    Debug.WriteLine("Something broke!");
                    model.ComputedShell = "0";
                    break;
                }

                model.QASM             = JsonConvert.SerializeObject(x.code, Formatting.Indented);
                model.ExecutionResults = JsonConvert.SerializeObject(x.result, Formatting.Indented);

                //now cleanup and delete the results
                QResult deleteResult = qp.DeleteExperiment(x.code.idCode);
            }


            return(View(model));
        }
Exemple #14
0
        private void ParseWorksheetPart(ExecuteArgs param, Dictionary <string, DefinedName> cacheNames, StringKeyList sharedStrings, Stream worksheetPart, WorksheetPart newWorksheetPart)
        {
            var inserts = new List <CellRange>();

            using (var reader = OpenXmlReader.Create(worksheetPart))
                using (var writer = XmlWriter.Create(newWorksheetPart.GetStream(FileMode.Create)
                                                     , new XmlWriterSettings {
                    Encoding = Encoding.UTF8, CloseOutput = true
                }))
                {
                    int ind, dif = 0;
                    writer.WriteStartDocument(true);

                    while (reader.Read())
                    {
                        //remove protection
                        //if (reader.ElementType == typeof(Excel.SheetProtection))
                        //{
                        //    reader.LoadCurrentElement();
                        //    continue;
                        //}
                        if (reader.ElementType == typeof(Excel.Row))
                        {
                            var row      = (Excel.Row)reader.LoadCurrentElement();
                            var rowIndex = (int)row.RowIndex.Value;
                            ind = rowIndex + dif;
                            UpdateRowIndex(row, ind);
                            QResult query = null;
                            foreach (Excel.Cell ocell in row.Descendants <Excel.Cell>())
                            {
                                object rz = null;
                                if (cacheNames.TryGetValue(ocell.CellReference.Value, out var defName))
                                {
                                    rz = defName.CacheValue ?? param.GetValue(defName.Code);
                                }
                                else
                                {
                                    string value = ReadCell(ocell, sharedStrings);
                                    rz = ReplaceExcelString(param, value);
                                }

                                if (rz != null)
                                {
                                    query = rz as QResult;
                                    if (query != null)
                                    {
                                        var       sref     = CellReference.Parse(ocell.CellReference);
                                        var       insert   = new CellRange(sref, sref);
                                        Excel.Row tableRow = null;
                                        foreach (object[] dataRow in query.Values)
                                        {
                                            if (tableRow == null)
                                            {
                                                tableRow = row;
                                            }
                                            else if (defName != null && defName.Range.End.Row > sref.Row)
                                            {
                                                if (reader.Read() && reader.ElementType == typeof(Excel.Row))
                                                {
                                                    tableRow = (Excel.Row)reader.LoadCurrentElement();
                                                    UpdateRowIndex(tableRow, (int)tableRow.RowIndex.Value + dif);
                                                    insert.Start.Row++;
                                                    insert.End.Row++;
                                                }
                                                else
                                                {
                                                }
                                            }
                                            else
                                            {
                                                tableRow = CloneRow(tableRow, sref.Row);// GetRow(sd, srow, excelRow == null, cell.Parent as Excel.Row);
                                                insert.End.Row++;
                                            }

                                            int col = sref.Col;
                                            foreach (object itemValue in dataRow)
                                            {
                                                GetCell(tableRow, itemValue, col, sref.Row, 0, sharedStrings);
                                                col++;
                                            }
                                            sref.Row++;
                                            WriteElement(writer, tableRow);
                                        }

                                        if (insert.Rows > 0)
                                        {
                                            inserts.Add(insert);
                                            dif += insert.Rows;
                                        }
                                        break;
                                    }
                                    else
                                    {
                                        WriteCell(ocell, rz, sharedStrings);
                                    }
                                }
                            }
                            if (query == null)
                            {
                                WriteElement(writer, row);
                            }
                        }
                        else if (reader.ElementType == typeof(Excel.MergeCell))
                        {
                            var merge = reader.LoadCurrentElement() as Excel.MergeCell;
                            var range = CellRange.Parse(merge.Reference);

                            foreach (var insert in inserts)
                            {
                                if (insert.Start.Row < range.Start.Row)
                                {
                                    range.Start.Row += insert.Rows;
                                    range.End.Row   += insert.Rows;
                                }
                            }
                            merge.Reference = range.ToString();
                            WriteElement(writer, merge);
                        }
                        else if (reader.ElementType == typeof(Excel.DataValidation))
                        {
                            var validation = (Excel.DataValidation)reader.LoadCurrentElement();
                            if (validation.SequenceOfReferences.HasValue)
                            {
                                var newlist = new List <StringValue>();
                                foreach (var item in validation.SequenceOfReferences.Items)
                                {
                                    var range = CellRange.Parse(item);
                                    foreach (var insert in inserts)
                                    {
                                        if (insert.Start.Row <= range.End.Row && insert.End.Row > range.End.Row)
                                        {
                                            range.End.Row = insert.End.Row;
                                            newlist.Add(range.ToString());
                                            continue;
                                        }
                                    }
                                    newlist.Add(item);
                                }
                                validation.SequenceOfReferences = new ListValue <StringValue>(newlist);
                            }
                            WriteElement(writer, validation);
                        }
                        else if (reader.ElementType == typeof(Excel.OddFooter) ||
                                 reader.ElementType == typeof(Excel.EvenFooter) ||
                                 reader.ElementType == typeof(Excel.FirstFooter))
                        {
                            var footer = reader.LoadCurrentElement() as OpenXmlLeafTextElement;
                            var str    = ReplaceExcelString(param, footer.Text) as string;
                            if (str != null)
                            {
                                footer.Text = str;
                            }
                            WriteElement(writer, footer);
                        }
                        else if (reader.IsStartElement)
                        {
                            WriteStartElement(writer, reader);
                        }
                        else if (reader.IsEndElement)
                        {
                            writer.WriteEndElement();
                        }
                    }
                    writer.WriteEndDocument();
                    writer.Flush();
                    writer.Close();
                    //newWorksheetPart.FeedData(temp);
                }
        }
Exemple #15
0
        public static QResult GetPatientFullInfo(Guid _pkey)
        {
            GuruETCEntities _etc = new GuruETCEntities();
            long? ParentId = _etc.PatientProfiles.Where(d => d.UserGuid == _pkey).Select(d => d.Id).FirstOrDefault();
            long? DoctorId = _etc.PatientProfiles.Where(d => d.UserGuid == _pkey).Select(d => d.DoctorId).FirstOrDefault();
            QResult _result = new QResult();
            long? ExamId = _etc.PatientExams.Where(d => d.PatientId == ParentId && d.DoctorId == DoctorId).Max(d => d.ExamId);
            PatientResultQuestion _pResult = _etc.PatientResultQuestions.Where(d => d.ExamId == ExamId).FirstOrDefault();
            if (_pResult != null)
            {
                //Calculation for Periodental - HEALTH HX LINKED QUESTIONS

                DateTime? _pDOB = _etc.PatientProfiles.Where(d => d.Id == _pResult.PatientId).Select(d => d.DOB).FirstOrDefault();
                int Patient_age = (DateTime.Now.Year - _pDOB.Value.Year);
                string[] perioGeneralRAC = { "8.1" };
                string[] perioTobaccoRAC = { "2", "7" };
                string[] perioEndocrineRAC = { "4" };
                string[] perioDentalRAC = { "1.2", "12", "15", "21" };

                string[] hx_general = _pResult.hx_general.Split('|');
                string[] hx_tobacco = _pResult.hx_tobacco_alcohol.Split('|');
                string[] hx_endro = _pResult.hx_medical_endocrine_disorders.Split('|');
                string[] hx_dental = _pResult.hx_dental.Split('|');
                string[] hx_nutrition = _pResult.hx_nutrition_activity.Split('|');
                string[] hx_ent = _pResult.hx_medical_ent.Split('|');
                string[] hx_sleep = _pResult.hx_medical_sleep.Split('|');
                string[] hx_cancer = _pResult.hx_medical_cancer.Split('|');
                string[] hx_other = _pResult.hx_medical_other_diseases.Split('|');

                int perioRAC_Count = hx_general.Intersect(perioGeneralRAC).Count() + hx_tobacco.Intersect(perioTobaccoRAC).Count() + hx_endro.Intersect(perioEndocrineRAC).Count() + hx_dental.Intersect(perioDentalRAC).Count();
                _result.periodental = (27.2 + (27.2 * perioRAC_Count)) + "px";

                //Calculation for DIABETES - HEALTH HX LINKED QUESTIONS

                string[] diabetesGeneralRAC = { "8.3" };
                string[] diabetesVitalsRAC = { "2" };
                string[] diabetesNutritionRAC = { "7" };

                int diabetesRAC_Count = hx_general.Intersect(diabetesGeneralRAC).Count() + hx_tobacco.Intersect(diabetesVitalsRAC).Count() + hx_nutrition.Intersect(diabetesNutritionRAC).Count();

                if (Patient_age > 45)
                    diabetesRAC_Count++;

                _result.diabetic = (49 + (49 * diabetesRAC_Count)) + "px";

                //Calculation for SLEEP - HEALTH HX LINKED QUESTIONS

                string[] sleepEntRAC = { "6" };
                string[] sleepSleepRAC = { "1", "2", "3", "5", "6" };

                int sleepRAC_Count = hx_ent.Intersect(sleepEntRAC).Count() + hx_sleep.Intersect(sleepSleepRAC).Count();

                _result.sleepApnea = (35 + (35 * sleepRAC_Count)) + "px";

                //Calculation for TMD - HEALTH HX LINKED QUESTIONS

                string[] tmdEntRAC = { "1", "2", "3", "4", "5", "8" };
                string[] tmdDentalRAC = { "19" };

                int tmdRAC_Count = hx_ent.Intersect(tmdEntRAC).Count() + hx_dental.Intersect(tmdDentalRAC).Count();

                _result.tmd = (30.6 + (30.6 * tmdRAC_Count)) + "px";

                //Calculation for CARIES - HEALTH HX LINKED QUESTIONS

                string[] cariesGeneralRAC = { "9.1", "9.2" };
                string[] cariesNutritionRAC = { "4", "5", "13" };
                string[] cariesCancerRAC = { "2" };
                string[] cariesOtherDiseasesRAC = { "9", "10", "24" };
                string[] cariesDentalRAC = { "1.2", "2.2", "3", "7", "13", "19", "20" };

                int cariesRAC_Count = hx_general.Intersect(cariesGeneralRAC).Count() + hx_nutrition.Intersect(cariesNutritionRAC).Count() + hx_cancer.Intersect(cariesCancerRAC).Count() + hx_other.Intersect(cariesOtherDiseasesRAC).Count() + hx_dental.Intersect(cariesDentalRAC).Count();

                _result.caries = (15.3 + (15.3 * cariesRAC_Count)) + "px";

                //Calculation for ORAL CANCER - HEALTH HX LINKED QUESTIONS

                string[] oralCancerGeneralRAC = { "8.5" };
                string[] oralCancerNutritionRAC = { "1.2", "1.3" };
                string[] oralCancerTobaccoRAC = { "1.1", "1.2", "4.1", "4.2", "4.3", "4.4", "3" };
                string[] oralCancerCancerRAC = { "1", "3", "4", "5" };
                string[] oralCancerEntRAC = { "11", "12", "14", "15", "16", "17", "19", "20", "18" };

                int oralCancerRAC_Count = hx_general.Intersect(oralCancerGeneralRAC).Count() + hx_nutrition.Intersect(oralCancerNutritionRAC).Count() + hx_tobacco.Intersect(oralCancerTobaccoRAC).Count() + hx_cancer.Intersect(oralCancerCancerRAC).Count() + hx_ent.Intersect(oralCancerEntRAC).Count();

                if (Patient_age > 40)
                {
                    oralCancerRAC_Count++;
                }
                _result.oralCancer = oralCancerRAC_Count.ToString();
            }

            return _result;
        }
Exemple #16
0
        public static QResult GetPatientFullInfo(Guid _pkey)
        {
            GuruETCEntities       _etc     = new GuruETCEntities();
            long?                 ParentId = _etc.PatientProfiles.Where(d => d.UserGuid == _pkey).Select(d => d.Id).FirstOrDefault();
            long?                 DoctorId = _etc.PatientProfiles.Where(d => d.UserGuid == _pkey).Select(d => d.DoctorId).FirstOrDefault();
            QResult               _result  = new QResult();
            long?                 ExamId   = _etc.PatientExams.Where(d => d.PatientId == ParentId && d.DoctorId == DoctorId).Max(d => d.ExamId);
            PatientResultQuestion _pResult = _etc.PatientResultQuestions.Where(d => d.ExamId == ExamId).FirstOrDefault();

            if (_pResult != null)
            {
                //Calculation for Periodental - HEALTH HX LINKED QUESTIONS

                DateTime?_pDOB             = _etc.PatientProfiles.Where(d => d.Id == _pResult.PatientId).Select(d => d.DOB).FirstOrDefault();
                int      Patient_age       = (DateTime.Now.Year - _pDOB.Value.Year);
                string[] perioGeneralRAC   = { "8.1" };
                string[] perioTobaccoRAC   = { "2", "7" };
                string[] perioEndocrineRAC = { "4" };
                string[] perioDentalRAC    = { "1.2", "12", "15", "21" };


                string[] hx_general   = _pResult.hx_general.Split('|');
                string[] hx_tobacco   = _pResult.hx_tobacco_alcohol.Split('|');
                string[] hx_endro     = _pResult.hx_medical_endocrine_disorders.Split('|');
                string[] hx_dental    = _pResult.hx_dental.Split('|');
                string[] hx_nutrition = _pResult.hx_nutrition_activity.Split('|');
                string[] hx_ent       = _pResult.hx_medical_ent.Split('|');
                string[] hx_sleep     = _pResult.hx_medical_sleep.Split('|');
                string[] hx_cancer    = _pResult.hx_medical_cancer.Split('|');
                string[] hx_other     = _pResult.hx_medical_other_diseases.Split('|');

                int perioRAC_Count = hx_general.Intersect(perioGeneralRAC).Count() + hx_tobacco.Intersect(perioTobaccoRAC).Count() + hx_endro.Intersect(perioEndocrineRAC).Count() + hx_dental.Intersect(perioDentalRAC).Count();
                _result.periodental = (27.2 + (27.2 * perioRAC_Count)) + "px";

                //Calculation for DIABETES - HEALTH HX LINKED QUESTIONS

                string[] diabetesGeneralRAC   = { "8.3" };
                string[] diabetesVitalsRAC    = { "2" };
                string[] diabetesNutritionRAC = { "7" };

                int diabetesRAC_Count = hx_general.Intersect(diabetesGeneralRAC).Count() + hx_tobacco.Intersect(diabetesVitalsRAC).Count() + hx_nutrition.Intersect(diabetesNutritionRAC).Count();

                if (Patient_age > 45)
                {
                    diabetesRAC_Count++;
                }

                _result.diabetic = (49 + (49 * diabetesRAC_Count)) + "px";


                //Calculation for SLEEP - HEALTH HX LINKED QUESTIONS

                string[] sleepEntRAC   = { "6" };
                string[] sleepSleepRAC = { "1", "2", "3", "5", "6" };

                int sleepRAC_Count = hx_ent.Intersect(sleepEntRAC).Count() + hx_sleep.Intersect(sleepSleepRAC).Count();

                _result.sleepApnea = (35 + (35 * sleepRAC_Count)) + "px";


                //Calculation for TMD - HEALTH HX LINKED QUESTIONS

                string[] tmdEntRAC    = { "1", "2", "3", "4", "5", "8" };
                string[] tmdDentalRAC = { "19" };

                int tmdRAC_Count = hx_ent.Intersect(tmdEntRAC).Count() + hx_dental.Intersect(tmdDentalRAC).Count();

                _result.tmd = (30.6 + (30.6 * tmdRAC_Count)) + "px";


                //Calculation for CARIES - HEALTH HX LINKED QUESTIONS

                string[] cariesGeneralRAC       = { "9.1", "9.2" };
                string[] cariesNutritionRAC     = { "4", "5", "13" };
                string[] cariesCancerRAC        = { "2" };
                string[] cariesOtherDiseasesRAC = { "9", "10", "24" };
                string[] cariesDentalRAC        = { "1.2", "2.2", "3", "7", "13", "19", "20" };

                int cariesRAC_Count = hx_general.Intersect(cariesGeneralRAC).Count() + hx_nutrition.Intersect(cariesNutritionRAC).Count() + hx_cancer.Intersect(cariesCancerRAC).Count() + hx_other.Intersect(cariesOtherDiseasesRAC).Count() + hx_dental.Intersect(cariesDentalRAC).Count();

                _result.caries = (15.3 + (15.3 * cariesRAC_Count)) + "px";

                //Calculation for ORAL CANCER - HEALTH HX LINKED QUESTIONS

                string[] oralCancerGeneralRAC   = { "8.5" };
                string[] oralCancerNutritionRAC = { "1.2", "1.3" };
                string[] oralCancerTobaccoRAC   = { "1.1", "1.2", "4.1", "4.2", "4.3", "4.4", "3" };
                string[] oralCancerCancerRAC    = { "1", "3", "4", "5" };
                string[] oralCancerEntRAC       = { "11", "12", "14", "15", "16", "17", "19", "20", "18" };

                int oralCancerRAC_Count = hx_general.Intersect(oralCancerGeneralRAC).Count() + hx_nutrition.Intersect(oralCancerNutritionRAC).Count() + hx_tobacco.Intersect(oralCancerTobaccoRAC).Count() + hx_cancer.Intersect(oralCancerCancerRAC).Count() + hx_ent.Intersect(oralCancerEntRAC).Count();

                if (Patient_age > 40)
                {
                    oralCancerRAC_Count++;
                }
                _result.oralCancer = oralCancerRAC_Count.ToString();
            }


            return(_result);
        }