protected override void OnInit(EventArgs e) { base.OnInit(e); string eformName = Request["eformName"] ?? "Baseline"; string pidString = Request["pid"]; string paid = Request["paid"]; // no need for patient id in preview mode if (!IsPreview) { object sessionPtId = Session[Caisis.UI.Core.Classes.SessionKey.PatientId]; if (!string.IsNullOrEmpty(pidString)) { patientId = int.Parse(pidString); } else if (!string.IsNullOrEmpty(paid)) { patientId = int.Parse(Caisis.Security.CustomCryptoHelper.Decrypt(paid)); } // patient from session??? else if (sessionPtId != null && sessionPtId != "") { patientId = (int)sessionPtId; } } Action <string, int> addPage = AddEformPage; Action <string, bool, int, int> addDynamicSection = AddEformSection; Action <string, bool, string> addStaticSection = null; // initialize the form structure IEnumerable <XElement> metadataList = EformMetadata.GetMetadata(eformName, addPage, addDynamicSection, addStaticSection); // handle final title item if (currentTitleItem != null) { PageTitles.Controls.Add(currentTitleItem); } Action <BOL.BusinessObject, string, IDictionary <string, string> > addControl = AddControl; Action <Func <IEnumerable <IBusinessObject> >, Action <IBusinessObject>, IEnumerable <string>, XElement> addGrid = (f, a, c, x) => AddGrid(f, a, x); Action <string> doTransition = null; string identifier = null; int? identiferValue = null; bool isBaselineForm = eformName.Equals("Baseline", StringComparison.CurrentCultureIgnoreCase); // baseline eform will be a future subclass that handles this via GetIdentifier(), GetIdentifierValue() overrides if (isBaselineForm) { identifier = Patient.PatientId; identiferValue = patientId; } businessObjects = BusinessObject.Convert(metadataList, addControl, addGrid, doTransition, identifier, identiferValue); foreach (EformPage page in eformPages) { PagePanel.Controls.Add(page); } // SPECIAL CASE: for biz which are 1-1 or patient biz // get a list of biz where pri-key and foreign-key are patient id // NOTE: only process in special cases if (!isBaselineForm && patientId.HasValue) { IEnumerable <IBusinessObject> parentPriKeyIsPatient = from biz in businessObjects where biz.PrimaryKeyName == Patient.PatientId && biz.ParentKeyName == Patient.PatientId select biz; // during load, popuplate special biz objects objects if (parentPriKeyIsPatient.Count() > 0) { // load biz by patient id foreach (IBusinessObject biz in parentPriKeyIsPatient) { biz.Get(patientId.Value); } } } // supress navigation on preview mode if (IsPreview) { SaveButton.Visible = false; } }