/// <summary> /// /// </summary> /// <param name="toxicityId"></param> private void PopulateForm(int?toxicityId) { if (toxicityId.HasValue) { // populate toxicity Toxicity biz = new Toxicity(); biz.Get(toxicityId.Value); base.PopulateForm(ToxicityFields, biz); // Determine if SAE fields need to be displayed when records exits //SeriousAdverseEvent adverseEvents = new SeriousAdverseEvent(); //adverseEvents.GetByParent(toxicityId); //if (adverseEvents.RecordCount > 0) //{ // ShowSAEField.Value = bool.TrueString.ToLower(); // base.PopulateForm(SAEFields, adverseEvents); //} SeriousAdverseEvent adverseEvent = BusinessObject.GetByParent <SeriousAdverseEvent>(toxicityId.Value).FirstOrDefault(); if (adverseEvent != null) { base.PopulateForm(this, adverseEvent); } int patientItemId = int.Parse(base.DecrypyValue(PatientItemId.Value)); DataTable relatedRecords = RelatedRecordsDa.GetRecord("ProtocolMgr_PatientItems", patientItemId, "Toxicities", toxicityId.Value); if (relatedRecords.Rows.Count > 0) { RelatedRecordId.Value = relatedRecords.Rows[0][RelatedRecord.RelatedRecordId].ToString(); } } PopulateAttributions(toxicityId); }
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); } }