예제 #1
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();
            }
        }
예제 #2
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);
            }
        }
예제 #3
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();
        }