示例#1
0
        /// <summary>
        /// Writes the inserted date value to the client.
        /// </summary>
        private void UpdateStopDateAndReturn()
        {
            string newDate = string.Empty;

            // validate required mappings
            if (TABLE_MAPPINGS.ContainsKey(Table) && BusinessObjectFactory.CanBuildBusinessObject(Table) && PriKey.HasValue)
            {
                int patientId = int.Parse(Session[SessionKey.PatientId].ToString());

                // create instance
                IBusinessObject biz = BusinessObjectFactory.BuildBusinessObject(Table);
                // load record and validate
                biz.Get(PriKey.Value);
                if (!biz.IsEmpty)
                {
                    // turn on validation of patient
                    biz.EnableSaveValidation(patientId);

                    // the date field representing the stop date
                    string dateField = TABLE_MAPPINGS[Table];
                    // check for date text field
                    string dateTextField = dateField + "Text";
                    if (biz.HasField(dateField))
                    {
                        // determine if updating stop date of nullifying
                        bool doStop = Checked;
                        if (doStop)
                        {
                            // set date fields
                            DateTime date = QueryDate.HasValue ? QueryDate.Value : DateTime.Today; // ?? use DateTime.Today for normalization
                            biz[dateField] = date;
                            if (biz.HasField(dateTextField))
                            {
                                biz[dateTextField] = date.ToShortDateString();
                            }
                            // set short date
                            newDate = date.ToShortDateString();
                        }
                        // nullify stop date fields
                        else
                        {
                            biz[dateField] = null;
                            if (biz.HasField(dateTextField))
                            {
                                biz[dateTextField] = null;
                            }
                            newDate = string.Empty;
                        }
                    }
                    // update
                    biz.Save();
                }
            }
            else
            {
                newDate = string.Empty;
            }
            // write the new short stop date
            Response.Write(newDate);
        }
示例#2
0
        protected string RecordDetails(string tableName, string primaryKey)
        {
            string recordDetails = "";

            if (BOL.BusinessObjectFactory.CanBuildBusinessObject(tableName))
            {
                IBusinessObject biz = BusinessObjectFactory.BuildBusinessObject(tableName);
                biz.Get(int.Parse(primaryKey));

                string tableDisplayName = (biz.TableLabel.Length > 0) ? biz.TableLabel : tableName;

                Dictionary <string, string> HPIRecordDataEntryFields = new Dictionary <string, string>();
                HPIRecordDataEntryFields = CICHelper.GetCaisisInputControlsByTableName(tableName).ToDictionary(i => i.Field, i => pdec.GetFieldLabel(i.Table, i.Field));

                if (HPIRecordDataEntryFields.Keys.Count > 0)
                {
                    recordDetails = "<span id=\"HPIRecordDetailsBubbleContent_" + tableName + "_" + primaryKey + "\" class=\"HPIRecordDetailsBubbleContent\"><table><tr><td colspan=\"2\" class=\"HPIRecordDetailsBubbleTitle\" >" + tableDisplayName + "</td>";
                    foreach (string fieldName in HPIRecordDataEntryFields.Keys)
                    {
                        string fieldLabel = HPIRecordDataEntryFields[fieldName];
                        string fieldValue = biz[fieldName].ToString();

                        if (fieldValue.Length > 0)
                        {
                            recordDetails += "<tr><td>" + fieldLabel + "</td><td>" + fieldValue + "</td></tr>";
                        }
                    }
                    recordDetails += "</table></span>";
                }
            }

            return(recordDetails);
        }
示例#3
0
        protected void addGFRParams()
        {
            bool AgeOK    = false;
            bool GenderOK = false;
            bool RaceOK   = false;

            IBusinessObject biz = BusinessObjectFactory.BuildBusinessObject("Patients");

            biz.Get(this._patientId);
            string ptGender = biz[BOL.Patient.PtGender].ToString();
            string ptRace   = biz[BOL.Patient.PtRace].ToString();
            int    ptAge    = 0;

            DateTime ptBirthDate;

            if (DateTime.TryParse(biz[BOL.Patient.PtBirthDate].ToString(), out ptBirthDate))
            {
                ptAge = Convert.ToInt32(Math.Floor(((DateTime.Now - ptBirthDate).TotalDays) / (365.242222)));
                AgeOK = true;
            }

            double k = 0;
            double a = 0;


            if (ptGender.ToUpper() == "MALE")
            {
                k = 0.9; a = -0.411; GenderOK = true;
            }
            else if (ptGender.ToUpper() == "FEMALE")
            {
                k = 0.7; a = -0.329; GenderOK = true;
            }

            if (ptRace.Length > 0)
            {
                RaceOK = true;
            }

            if (GenderOK && RaceOK && AgeOK)
            {
                gfr_calcOK.Text    = "true";
                gfr_k.Text         = k.ToString();
                gfr_a.Text         = a.ToString();
                gfr_age.Text       = ptAge.ToString();
                gfr_genderMod.Text = ptGender.ToUpper() == "FEMALE" ? "1.018" : "1";
                gfr_raceMod.Text   = ptRace.ToUpper().Contains("BLACK") ? "1.159" : "1";
            }
            else
            {
                gfr_calcOK.Text    = "false";
                gfr_k.Text         = "0";
                gfr_a.Text         = "0";
                gfr_age.Text       = "0";
                gfr_genderMod.Text = "0";
                gfr_raceMod.Text   = "0";
            }
        }
示例#4
0
    /// <summary>
    /// Sets the Audit Grid for the clicked row in the CurrentRecord Grid.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void SetAuditGridViewOnViewClick(object sender, EventArgs e)
    {
        LinkButton  viewRecordButton = sender as LinkButton;
        GridViewRow row = viewRecordButton.NamingContainer as GridViewRow;

        row.CssClass = "CurrentGridRow";
        //string tableName = currentRecordBiz.Tablename;
        int priKey = int.Parse(viewRecordButton.CommandArgument);
        //BizObject biz = BOFactory.GetBO(tableName);
        //biz.Get(priKey);
        IBusinessObject biz = BusinessObjectFactory.BuildBusinessObject(bizObjects_tablename);

        biz.Get(priKey);
        SetAuditGrid(biz);
    }
示例#5
0
        protected DataView LabsWithGFR(int PatientID, DataView labDv)
        {
            DataTable labDt = labDv.ToTable();

            labDt.Columns.Add("GFR");
            labDt.Columns.Add("GFRError");

            // Calculate GFR
            // eGFR = 141 * min(SCr/k,1)^a * max(SCr/k,1)^-1.209 * 0.993^Age x [1.018 if female] * [1.159 if black]

            bool AgeOK    = false;
            bool GenderOK = false;
            bool RaceOK   = false;
            //           bool CreatOK = false;

            IBusinessObject biz = BusinessObjectFactory.BuildBusinessObject("Patients");

            biz.Get(PatientID);
            string ptGender = biz[BOL.Patient.PtGender].ToString();
            string ptRace   = biz[BOL.Patient.PtRace].ToString();
            int    ptAge    = 0;

            DateTime ptBirthDate;

            if (DateTime.TryParse(biz[BOL.Patient.PtBirthDate].ToString(), out ptBirthDate))
            {
                ptAge = Convert.ToInt32(Math.Floor(((DateTime.Now - ptBirthDate).TotalDays) / (365.242222)));
                AgeOK = true;
            }

            double k = 0;
            double a = 0;


            if (ptGender.ToUpper() == "MALE")
            {
                k = 0.9; a = -0.411; GenderOK = true;
            }
            else if (ptGender.ToUpper() == "FEMALE")
            {
                k = 0.7; a = -0.329; GenderOK = true;
            }

            if (ptRace.Length > 0)
            {
                RaceOK = true;
            }

            if (GenderOK && RaceOK && AgeOK)
            {
                foreach (DataRow dr in labDt.Rows)
                {
                    if (dr[BOL.LabTest.LabTest_Field].ToString().ToUpper().Equals("CREAT"))
                    {
                        double creatResult;
                        if (dr[BOL.LabTest.LabResult].ToString().Length > 0 && double.TryParse(dr[BOL.LabTest.LabResult].ToString(), out creatResult))
                        {
                            double gfrCalc = (141) * (Math.Pow((Math.Min((creatResult / k), 1)), a)) * (Math.Pow((Math.Max((creatResult / k), 1)), -1.209)) * (Math.Pow(0.993, ptAge));
                            if (ptGender.ToUpper() == "FEMALE")
                            {
                                gfrCalc = gfrCalc * 1.018;
                            }
                            if (ptRace.ToUpper().Contains("BLACK"))
                            {
                                gfrCalc = gfrCalc * 1.159;
                            }
                            dr["GFR"] = Math.Round(gfrCalc, 3);
                        }
                        else
                        {
                            dr["GFRError"] = "Invalid Creatinine Value";
                        }
                    }
                }
            }
            else
            {
                string errorMsg = "GFR cannot be calculated.<br/>(";
                if (!GenderOK)
                {
                    errorMsg += "No Gender. ";
                }
                if (!RaceOK)
                {
                    errorMsg += "No Race. ";
                }
                if (!AgeOK)
                {
                    errorMsg += "No Age.";
                }
                errorMsg += ")";
                foreach (DataRow dr in labDt.Rows)
                {
                    if (dr[BOL.LabTest.LabTest_Field].ToString().ToUpper().Equals("CREAT"))
                    {
                        dr["GFRError"] = errorMsg;
                    }
                }
            }


            return(labDt.DefaultView);
        }
示例#6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string tableList    = Request["tableNames"].ToString();
        string encryptedKey = Request["tablePriKey"].ToString();
        string decryptedKey = "";

        // End Response if key can't be decrypted or bogus key entered
        try
        {
            decryptedKey = Caisis.Security.CustomCryptoHelper.Decrypt(encryptedKey);
        }
        catch (Exception ex)
        {
            Response.End();
        }
        if (string.IsNullOrEmpty(decryptedKey))
        {
            Response.End();
        }
        int priKey = int.Parse(decryptedKey);

        string[] listOfTables = tableList.Split(',');
        string   parentTable  = listOfTables[0];
        string   showTable    = Request["showTable"] != null ? Request["showTable"].ToString() : "";

        DataTable linkTable = new DataTable();

        linkTable.Columns.Add("TableName");
        linkTable.Columns.Add("TableURL");
        foreach (string table in listOfTables)
        {
            string url = "?tableNames=" + tableList + "&tablePriKey=" + Caisis.Security.CustomCryptoHelper.Encrypt(priKey.ToString()) + "&showTable=" + table;
            if (table == parentTable)
            {
                ParentTableLink.Text        = table;
                ParentTableLink.NavigateUrl = url;
            }
            else
            {
                DataRow row = linkTable.NewRow();
                row["TableName"] = table;
                row["TableURL"]  = url;
                linkTable.Rows.Add(row);
            }
        }
        string boTable = string.IsNullOrEmpty(showTable) ? parentTable : showTable;

        //currentRecordBiz = BOFactory.GetBO(boTable);
        //if (boTable == parentTable)
        //{
        //    currentRecordBiz.Get(priKey);
        //}
        //else
        //{
        //    currentRecordBiz.GetByParent(priKey);
        //}
        //SetCurrentRecordGrid(currentRecordBiz, parentTable);
        //if (currentRecordBiz.RecordCount == 1)
        //{
        //    SetAuditGrid(currentRecordBiz);
        //}

        if (boTable == parentTable)
        {
            IBusinessObject b = BusinessObjectFactory.BuildBusinessObject(boTable);
            b.Get(priKey);
            bizObjects = new IBusinessObject[] { b };
        }
        else
        {
            bizObjects = BusinessObject.GetByParent(boTable, priKey);
        }

        bizObjects_tablename = boTable;

        DataTable dt = bizObjects.AsDataView(boTable).Table;

        SetCurrentRecordGrid(dt, boTable, parentTable);
        if (bizObjects.Count() == 1)
        {
            SetAuditGrid(bizObjects.First());
        }

        rptTableList.DataSource = linkTable;
        rptTableList.DataBind();
    }
示例#7
0
        /// <summary>
        /// Updates the metadta attibutes and attribute values
        /// </summary>
        protected virtual void Update()
        {
            GridView grid = GetMetadataGrid();

            if (grid == null)
            {
                return;
            }
            foreach (var dirtyRow in dirtyRows)
            {
                // the "dirty" grid row
                GridViewRow row      = dirtyRow.Key;
                int         rowIndex = row.RowIndex;
                // lookup of key fields in row
                var rowDataKeys = grid.DataKeys[rowIndex].Values;
                // a list of controls which are "dirty" in row
                var dirtyControls = dirtyRow.Value;
                // a list of "dirty" controls which represent an attribute value
                var dirtyAttributes = dirtyControls.Where(c => c.Table == attributeValueTableName);
                // a list of "dirty" contorls which represents a dirty metdata item
                var dirtyMetadataItemFields = dirtyControls.Where(c => c.Table == metadataItemTableName);

                IBusinessObject metadataItemBiz = BusinessObjectFactory.BuildBusinessObject(metadataItemTableName);
                int             metadataItemKey = (int)rowDataKeys[metadataItemBiz.PrimaryKeyName];

                // for each row, only updates values(attribuet values) which have changed, not all attribute values
                foreach (ICaisisInputControl dirtyAttributeValue in dirtyAttributes)
                {
                    string attributeName = dirtyAttributeValue.Field;
                    // only update if there is an attribute by this name
                    if (AttributeToHiddenField.ContainsKey(attributeName))
                    {
                        IBusinessObject attributeBiz     = BusinessObjectFactory.BuildBusinessObject(BIZ_ATTRIBUTE_TABLE.TableName);
                        int?            attributeId      = null;
                        int?            attributeValueId = null;

                        // get the table attribute id
                        ICaisisInputControl attributeIdField = AttributeToHiddenField[attributeName];

                        // CREATE/LOAD: Attribute (i.e., "FieldLabel" -> MetadataFieldAttribute)

                        // if attribute exists, set value
                        if (!string.IsNullOrEmpty(attributeIdField.Value))
                        {
                            attributeId = int.Parse(attributeIdField.Value);
                        }
                        // otherwise insert attribute
                        else
                        {
                            // set required attribute name
                            attributeBiz[attributeFieldName] = attributeName;
                            attributeBiz.Save();

                            // update hidden attribute id field
                            attributeId            = (int)attributeBiz[attributeBiz.PrimaryKeyName];
                            attributeIdField.Value = attributeId.Value.ToString();
                        }

                        // INSERT/UPDATE: Attribute Value (i.e., "FieldLabel" + "My Field" -> MetadataFieldAttributeValue)

                        // the field representing the AttributeValueId
                        ICaisisInputControl attributeValueIdField = GetTableAttributeValueIdControl(row, attributeName);
                        // the field representing the input control containing the AttributeValue
                        ICaisisInputControl attributeValueControl = GetTableAttributeValueControl(row, attributeName);
                        // the disease mapping to the attribute value
                        ICaisisInputControl diseaseAttributeValueId = GetDiseaseAttributeValueId(row, attributeName);

                        // validate fields exists
                        if (attributeValueIdField != null && attributeValueControl != null)
                        {
                            IBusinessObject attributeValueBiz = BusinessObjectFactory.BuildBusinessObject(attributeValueTableName);
                            bool            isDiseaseSpecific = QueryDiseaseId.HasValue && diseaseAttributeValueId != null;
                            // load attribute value, if isn't disease specific or disease specific has a value
                            if (!string.IsNullOrEmpty(attributeValueIdField.Value) && (!isDiseaseSpecific || !string.IsNullOrEmpty(diseaseAttributeValueId.Value)))
                            {
                                attributeValueId = int.Parse(attributeValueIdField.Value);
                                attributeValueBiz.Get(attributeValueId.Value);
                            }
                            // set required foreign keys for insert
                            else
                            {
                                // set required attribute id key (i.e., AttributeId)
                                attributeValueBiz[attributeBiz.PrimaryKeyName] = attributeId;
                                // set required metadata id (i.e., FieldId)
                                attributeValueBiz[metadataItemBiz.PrimaryKeyName] = metadataItemKey;
                            }

                            // get attribute value (i.e., "ControlType" = "CaisisTextBox")
                            string attributeValue = GetInputControlValue(attributeValueControl);

                            // update table attribute value

                            // validate (no empty values allowed)
                            if (string.IsNullOrEmpty(attributeValue))
                            {
                                // delete empty values
                                if (attributeValueId.HasValue)
                                {
                                    // delete atttibute value
                                    attributeValueBiz.Delete(attributeValueId.Value);
                                    attributeValueId            = null;
                                    attributeValueIdField.Value = string.Empty;
                                    // delete disease specific mapping
                                    if (isDiseaseSpecific && !string.IsNullOrEmpty(diseaseAttributeValueId.Value))
                                    {
                                        DiseaseAttributeValue dav = new DiseaseAttributeValue();
                                        dav.Delete(int.Parse(diseaseAttributeValueId.Value));
                                        diseaseAttributeValueId.Value = string.Empty;
                                    }
                                }
                                continue;
                            }
                            else
                            {
                                attributeValueBiz[attributeValueFieldName] = attributeValue;
                                attributeValueBiz.Save();
                                // update hidden field
                                attributeValueId            = (int)attributeValueBiz[attributeValueBiz.PrimaryKeyName];
                                attributeValueIdField.Value = attributeValueId.ToString();

                                // handle disease specific mapping
                                if (isDiseaseSpecific)
                                {
                                    var diseaseAttributeValue = new DiseaseAttributeValue();
                                    var diseaseAttributeId    = GetMetadataDiseaseAttributeId();
                                    // load existing mapping
                                    if (!string.IsNullOrEmpty(diseaseAttributeValueId.Value))
                                    {
                                        diseaseAttributeValue.Get(int.Parse(diseaseAttributeValueId.Value));
                                    }
                                    // new
                                    else
                                    {
                                        diseaseAttributeValue[DiseaseAttributeValue.DiseaseId]          = QueryDiseaseId.Value;
                                        diseaseAttributeValue[DiseaseAttributeValue.DiseaseAttributeId] = diseaseAttributeId.Value;
                                    }
                                    diseaseAttributeValue[DiseaseAttributeValue.DiseaseAttributeValue_Field] = attributeValueIdField.Value;

                                    diseaseAttributeValue.Save();
                                    diseaseAttributeValueId.Value = diseaseAttributeValue[diseaseAttributeValue.PrimaryKeyName].ToString();
                                }
                            }
                        }
                    }
                }
                // update metadata item (i.e., MetadataField)
                if (dirtyMetadataItemFields.Count() > 0)
                {
                    // load by pri key (i.e., FieldId)
                    metadataItemBiz.Get(metadataItemKey);
                    // update fields which have changed (i.e., FieldOrder, FieldSupress)
                    foreach (ICaisisInputControl input in dirtyMetadataItemFields)
                    {
                        metadataItemBiz[input.Field] = GetInputControlValue(input);
                    }
                    // save record
                    metadataItemBiz.Save();
                }
            }
            // after update rebuilds lists
            PopulateAttributeValues();
        }