Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void UpdateStatusClick(object sender, EventArgs e)
        {
            foreach (int dirtyRow in dirtyVisits)
            {
                GridViewRow   row               = PatientVisitsGrid.Rows[dirtyRow];
                CaisisHidden  pItemStatus       = row.FindControl(PatientItem.Status) as CaisisHidden;
                CaisisTextBox pItemSDate        = row.FindControl(PatientItem.ScheduledDate) as CaisisTextBox;
                CaisisHidden  deviationId       = row.FindControl(PatientDeviation.PatientDeviationId) as CaisisHidden;
                int           patientItemId     = int.Parse(PatientVisitsGrid.DataKeys[dirtyRow][PatientItem.PatientItemId].ToString());
                string        patientItemStatus = pItemStatus.Value;
                string        scheduledDate     = pItemSDate.Value;

                PatientItem biz = new PatientItem();
                biz.Get(patientItemId);
                biz[PatientItem.Status]        = patientItemStatus;
                biz[PatientItem.ScheduledDate] = scheduledDate;
                // needs deviation ???


                if (patientItemStatus == "Missed")
                {
                    // do not create deviation

                    /*
                     * PatientDeviation deviation = new PatientDeviation();
                     * if (!string.IsNullOrEmpty(deviationId.Value))
                     * {
                     *  deviation.Get(int.Parse(deviationId.Value));
                     * }
                     * // otherwise set required foreign key
                     * else
                     * {
                     *  deviation[PatientDeviation.PatientItemId] = patientItemId.ToString();
                     * }
                     * deviation[PatientDeviation.DeviationType] = "Missed Visit";
                     * deviation.Save();
                     *
                     * // update hidden deviation field
                     * deviationId.Value = deviation[PatientDeviation.PatientDeviationId].ToString();
                     */
                }
                // if status isn't missed, remove deviation if exists
                else if (!string.IsNullOrEmpty(deviationId.Value))
                {
                    PatientDeviation deviation = new PatientDeviation();
                    deviation.Delete(int.Parse(deviationId.Value));
                    deviationId.Value = string.Empty;
                }
                biz.Save();

                // trigger scheduling for dependent items
                PatientProtocolController.ScheduleDependentItemsByItemStatus(patientItemId, patientItemStatus);
            }
            dirtyVisits.Clear();

            SetVisit(sender, e);

            RegisterReloadPatientLists();
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void SaveClick(object sender, EventArgs e)
        {
            // save survey
            Survey biz = new Survey();

            if (!string.IsNullOrEmpty(SurveyIdField.Value))
            {
                biz.Get(int.Parse(SurveyIdField.Value));
            }
            // if save was NOT triggerd from plugin, then save with form fields
            if (string.IsNullOrEmpty(SaveFromPlugin.Value))
            {
                CICHelper.SetBOValues(this.Controls, biz, int.Parse(BaseDecryptedPatientId));
                biz.Save();
                int surveyId = (int)biz[Survey.SurveyId];
                SurveyIdField.Value = surveyId.ToString();

                // save survey items
                SurveyItemsGrid.Save(surveyId);
            }

            SurveyPluginControl.SetSurveyIdField(SurveyIdField.Value);

            // create patient item if needed
            PatientItem item = new PatientItem();
            int         patientItemId;

            if (!string.IsNullOrEmpty(PatientItemId.Value))
            {
                item.Get(int.Parse(base.DecrypyValue(PatientItemId.Value)));
            }
            else
            {
                item[PatientItem.PatientSchemaId] = PatientSchemaId;
                item[PatientItem.Status]          = "Unplanned";
            }
            item[PatientItem.ScheduledDate] = FieldSurveyDate.Value;
            item.Save();
            patientItemId       = (int)item[item.PrimaryKeyName];
            PatientItemId.Value = base.EncryptValue(patientItemId.ToString());

            // now create association via related records
            int relatedRecordId = PatientProtocolController.CreateUnplannedVisitRelatedRecord(patientItemId, biz.TableName, int.Parse(SurveyIdField.Value));

            RelatedRecordId.Value = relatedRecordId.ToString();

            // don't register update script if triggered from add new row
            if (sender != AddNewRowBtn)
            {
                // register update script
                RegisterUpdateScript(false);
            }
            // otherwise repopulate form
            else
            {
                PopulateForm();
            }
        }
Ejemplo n.º 3
0
        private void SaveForm(bool registerUpdateScript)
        {
            // only update dirty record
            if (isToxicityRecordDirty)
            {
                int patientId = int.Parse(BaseDecryptedPatientId);
                // save toxicity
                Toxicity tox        = new Toxicity();
                int      toxicityId = SaveRecord(ToxicityFields, tox, ToxicityIdField, patientId);

                // PatientItem Record
                PatientItem item = new PatientItem();
                int         patientItemId;
                if (!string.IsNullOrEmpty(PatientItemId.Value))
                {
                    item.Get(int.Parse(base.DecrypyValue(PatientItemId.Value)));
                }
                else
                {
                    item[PatientItem.PatientSchemaId] = PatientSchemaId;
                    item[PatientItem.Status]          = "Unplanned";
                }
                item[PatientItem.ScheduledDate] = ToxDate.Value;
                item.Save();
                patientItemId       = (int)item[item.PrimaryKeyName];
                PatientItemId.Value = base.EncryptValue(patientItemId.ToString());

                // Related Record
                int relatedRecordId = PatientProtocolController.CreateUnplannedVisitRelatedRecord(patientItemId, tox.TableName, toxicityId);
                RelatedRecordId.Value = relatedRecordId.ToString();

                // if visible to user and record dirty
                if (isSAERecordDirty)
                {
                    // SAE Record
                    SeriousAdverseEvent sae = new SeriousAdverseEvent();
                    SaveRecord(SAEFields, sae, ToxicityIdField, toxicityId);
                }
            }
            // no need to update parent Toxicity, update child record if needed
            else if (isSAERecordDirty && !string.IsNullOrEmpty(ToxicityIdField.Value))
            {
                int toxicityId          = int.Parse(ToxicityIdField.Value);
                SeriousAdverseEvent sae = new SeriousAdverseEvent();
                SaveRecord(SAEFields, sae, ToxicityIdField, toxicityId);
            }
            // save attributions
            if (!string.IsNullOrEmpty(ToxicityIdField.Value) && ToxAttributionGrid.DirtyRows.Count > 0)
            {
                int toxicityId = int.Parse(ToxicityIdField.Value);
                ToxAttributionGrid.Save(toxicityId);
            }
            // register client update script (close form from popup)
            if (registerUpdateScript)
            {
                RegisterUpdateScript(false);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Save the data entry form and close
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void SaveClick(object sender, EventArgs e)
        {
            var biz = BusinessObjectFactory.BuildBusinessObject(QueryTableName);

            if (!string.IsNullOrEmpty(PriKeyField.Value))
            {
                biz.Get(int.Parse(PriKeyField.Value));
            }
            int patientId = (int)Session[Patient.PatientId];//int.Parse(BaseDecryptedPatientId)
            int parentKey = biz.HasField(Patient.PatientId) ? patientId : -1;

            CICHelper.SetBOValues(DataEntryLayout.Controls, biz, parentKey);
            biz.Save();
            // update hidden field
            int priKey = (int)biz[biz.PrimaryKeyName];

            PriKeyField.Value = priKey.ToString();

            // create patient item if needed
            PatientItem item = new PatientItem();
            int         patientItemId;

            if (!string.IsNullOrEmpty(PatientItemId.Value))
            {
                item.Get(int.Parse(base.DecrypyValue(PatientItemId.Value)));
            }
            else
            {
                item[PatientItem.PatientSchemaId] = PatientSchemaId;
                item[PatientItem.Status]          = "Unplanned";
            }
            // determine schedule date
            var dateFields = from field in biz.FieldNames
                             where field.EndsWith("Date")
                             select field;

            if (dateFields.Count() > 0)
            {
                item[PatientItem.ScheduledDate] = biz[dateFields.First()].ToString();
            }
            item.Save();
            patientItemId       = (int)item[item.PrimaryKeyName];
            PatientItemId.Value = base.EncryptValue(patientItemId.ToString());

            // now create association via related records
            if (string.IsNullOrEmpty(RelatedRecordId.Value))
            {
                int relatedRecordId = PatientProtocolController.CreateUnplannedVisitRelatedRecord(patientItemId, biz.TableName, priKey);
                RelatedRecordId.Value = relatedRecordId.ToString();
            }

            RegisterUpdateScript(false);

            // re populate
            BuildUnplannedEvent();
        }
Ejemplo n.º 5
0
 protected void UpdateItemClick(object sender, EventArgs e)
 {
     if (PatientItemId.HasValue)
     {
         PatientItem patientItem = new PatientItem();
         patientItem.Get(PatientItemId.Value);
         CICHelper.SetBOValues(PatientItemFields.Controls, patientItem, -1);
         patientItem.Save();
         RegisterUpdateScript(true);
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Saves/Updates the current PatientDeviation record
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void SaveClick(object sender, EventArgs e)
        {
            // Update/Insert PatientItem
            PatientItem patientItem = new PatientItem();

            // update
            if (!string.IsNullOrEmpty(PatientItemId.Value))
            {
                patientItem.Get(int.Parse(base.DecrypyValue(PatientItemId.Value)));
            }
            // inserting
            else
            {
                patientItem[PatientItem.PatientSchemaId] = PatientSchemaId;
            }
            patientItem[PatientItem.ScheduledDate] = ScheduledDate.Value;
            patientItem[PatientItem.Status]        = "Unplanned";
            patientItem.Save();
            int patientItemId = (int)patientItem[PatientItem.PatientItemId];

            PatientItemId.Value = base.EncryptValue(patientItemId.ToString());

            // Update/insert deviation
            PatientDeviation deviation = new PatientDeviation();

            // update
            if (!string.IsNullOrEmpty(PatientDeviationId.Value))
            {
                deviation.Get(int.Parse(PatientDeviationId.Value));
            }
            // insert
            else
            {
                deviation[PatientDeviation.PatientItemId] = patientItemId;
            }
            // set biz object values, update and reload form
            CICHelper.SetBOValues(this.Controls, deviation, patientItemId);
            deviation[PatientDeviation.PatientItemId] = patientItemId;
            deviation.Save();
            PatientDeviationId.Value = deviation[PatientDeviation.PatientDeviationId].ToString();

            // update fields
            PopulateForm();

            // notify client scripts
            RegisterUpdateScript(false);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Updates the PatientItem record including status and status date.
        /// Also triggers scheduling of dependent events on this item.
        /// </summary>
        private void UpdatePatientItem()
        {
            if (!string.IsNullOrEmpty(PatientItemId))
            {
                // Load Item record and update fields
                int         priKey = int.Parse(PatientItemId);
                PatientItem biz    = new PatientItem();
                biz.Get(priKey);
                biz[PatientItem.Status] = StatusField.Value;
                // ScheduledDate is read only, so values aren't persisted by rumtime, but in Form
                biz[PatientItem.ScheduledDate] = Request.Form[ScheduledDate.UniqueID];
                biz.Save();

                // trigger scheduling for dependent items
                PatientProtocolController.ScheduleDependentItemsByItemStatus(priKey, StatusField.Value);
            }
        }