/// <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(); }
/// <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(); } }
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); } }
/// <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(); }
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); } }
private void BuildPatientItem(int patientItemId) { PatientItem patientItem = new PatientItem(); patientItem.Get(patientItemId); var inputs = CICHelper.GetCaisisInputControls(PatientItemFields); foreach (var input in inputs) { input.Value = string.Format(input.Field.EndsWith("Date") ? "{0:d}" : "{0}", patientItem[input.Field]); } }
/// <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); }
/// <summary> /// Populates the PatienItem /// </summary> /// <param name="pItemId"></param> private void PopulatePatientItem(int pItemId) { PatientItem biz = new PatientItem(); biz.Get(pItemId); // ScheduledDate.Text = ((DateTime)biz[PatientItem.ScheduledDate]).ToShortDateString(); object dt = biz[PatientItem.ScheduledDate]; if (dt != null && !String.IsNullOrEmpty(dt.ToString())) { ScheduledDate.Text = ((DateTime)dt).ToShortDateString(); } StatusField.Value = biz[PatientItem.Status].ToString(); ItemStatus = GetItemStatus(biz); // register client buffer dates string clientDateFormatString = "new Date('{0}')"; object firstDate = biz[PatientItem.FirstAnticipatedDate]; object lastDate = biz[PatientItem.LastAnticipatedDate]; if (firstDate != null && !string.IsNullOrEmpty(firstDate.ToString())) { DateTime date = (DateTime)firstDate; string shortDate = date.ToShortDateString(); FirstAnticipatedClientDate = string.Format(clientDateFormatString, shortDate); FirstAnticipatedDateText.Text = shortDate; } else { FirstAnticipatedClientDate = "null"; FirstAnticipatedDateText.Text = string.Empty; } if (lastDate != null && !string.IsNullOrEmpty(lastDate.ToString())) { DateTime date = (DateTime)lastDate; string shortDate = date.ToShortDateString(); LastAnticipatedClientDate = string.Format(clientDateFormatString, shortDate); LastAnticipatedDateText.Text = shortDate; } else { LastAnticipatedClientDate = "null"; LastAnticipatedDateText.Text = string.Empty; } }
/// <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); } }
/// <summary> /// Populates the fiels on this form with a PatientDevaition record /// </summary> private void PopulateForm() { if (!string.IsNullOrEmpty(PatientItemId.Value)) { // Populate patient item scheduled field int patientItemId = int.Parse(base.DecrypyValue(PatientItemId.Value)); PatientItem item = new PatientItem(); item.Get(patientItemId); if (item[PatientItem.ScheduledDate] != null && item[PatientItem.ScheduledDate].ToString() != "") { string sDate = ((DateTime)item[PatientItem.ScheduledDate]).ToShortDateString(); ScheduledDate.Value = sDate; ScheduledDateText.Value = sDate; } // populate deviation if (!string.IsNullOrEmpty(PatientDeviationId.Value)) { int pdi = int.Parse(PatientDeviationId.Value); PatientDeviation deviation = new PatientDeviation(); deviation.Get(pdi); base.PopulateForm(deviation); // cleanup date field display var inputs = PageUtil.GetCaisisInputControlsInContainer(this); foreach (var input in inputs) { if (input.Table == "ProtocolMgr_PatientDeviations" && input.Field.Contains("DeviationDate")) { if (!deviation.IsNull(input.Field)) { input.Value = string.Format("{0:d}", deviation[input.Field]); } } } } } }