private void FormOrthoChart_FormClosing(object sender, FormClosingEventArgs e) { if (!_hasChanged) { return; } else if (DialogResult != DialogResult.OK && _hasChanged && !MsgBox.Show(this, MsgBoxButtons.YesNo, "Unsaved changes will be lost. Would you like to save changes instead?")) { return; } if (_showSigBox && gridMain.SelectedCell.Y != -1) { SaveSignatureToDict(gridMain.SelectedCell.Y); } if (_showSigBox) { //Don't save the signature if the user tried to sign an empty ortho chart. for (int i = _dictOrthoCharts.Keys.Count - 1; i >= 0; i--) { if (_dictOrthoCharts[_dictOrthoCharts.Keys.ElementAt(i)].All(x => (_sigTableOrthoColIdx > -1 && x.FieldName == _listDisplayFieldNames[_sigTableOrthoColIdx]) || x.FieldValue == "")) { _dictOrthoCharts.Remove(_dictOrthoCharts.Keys.ElementAt(i)); } } } List <OrthoChart> listNewOrthoCharts = new List <OrthoChart>(); foreach (KeyValuePair <DateTime, List <OrthoChart> > kvPair in _dictOrthoCharts) { listNewOrthoCharts.AddRange(kvPair.Value); } OrthoCharts.Sync(_patCur, listNewOrthoCharts, _listOrthDisplayFields, _listOrthDisplayFields.Find(x => x.InternalName == "Signature")); }
private void butAudit_Click(object sender, EventArgs e) { FormAuditOrtho FormAO = new FormAuditOrtho(); SecurityLog[] orthoChartLogs = SecurityLogs.Refresh(_patCur.PatNum, new List <Permissions> { Permissions.OrthoChartEditFull }, null, checkIncludeArchived.Checked); SecurityLog[] patientFieldLogs = SecurityLogs.Refresh(new DateTime(1, 1, 1), DateTime.Today, Permissions.PatientFieldEdit, _patCur.PatNum, 0, DateTime.MinValue, DateTime.Today, checkIncludeArchived.Checked); SortedDictionary <DateTime, List <SecurityLog> > dictDatesOfServiceLogEntries = new SortedDictionary <DateTime, List <SecurityLog> >(); //Add all dates from grid first, some may not have audit trail entries, but should be selectable from FormAO for (int i = 0; i < gridMain.Rows.Count; i++) { DateTime dtCur = GetOrthoDate(i); if (dictDatesOfServiceLogEntries.ContainsKey(dtCur)) { continue; } dictDatesOfServiceLogEntries.Add(dtCur, new List <SecurityLog>()); } //Add Ortho Audit Trail Entries for (int i = 0; i < orthoChartLogs.Length; i++) { DateTime dtCur = OrthoCharts.GetOrthoDateFromLog(orthoChartLogs[i]); if (!dictDatesOfServiceLogEntries.ContainsKey(dtCur)) { dictDatesOfServiceLogEntries.Add(dtCur, new List <SecurityLog>()); } dictDatesOfServiceLogEntries[dtCur].Add(orthoChartLogs[i]); //add entry to existing list. } FormAO.DictDateOrthoLogs = dictDatesOfServiceLogEntries; FormAO.PatientFieldLogs.AddRange(patientFieldLogs); FormAO.ShowDialog(); }
private void FormOrthoChart_Load(object sender, EventArgs e) { signatureBoxWrapper.SetAllowDigitalSig(true); _listOrthoChartsInitial = OrthoCharts.GetAllForPatient(_patCur.PatNum); _listDatesAdded = new List <DateTime>() { DateTime.Today }; _listOrthoChartTabs = OrthoChartTabs.GetDeepCopy(true); FillTabs(); _dictOrthoCharts = new SortedDictionary <DateTime, List <OrthoChart> >(); FillDictionary(); //A specific tab is desired to be pre-selected. This has to happen after FillDataTable() because it causes FillGrid() to get called. if (_indexInitialTab != tabControl.SelectedIndex) { tabControl.SelectedIndex = _indexInitialTab; } else //Tab index hasn't changed, fill the grid. { FillGrid(); } FillGridPat(); if (PrefC.GetBool(PrefName.OrthoCaseInfoInOrthoChart)) { gridOrtho.Visible = true; FillOrtho(); } }
private void FillSignatureHelperTopaz(string keyData, string signature) { if (!CheckTopaz()) { return; } //According to Jeff Robertson from Topaz, the method SetKeyString() should be used to clear out the key string before loading a signature. //For that reason, it should only be called with 16 zeros as its arguments. The actual data that the signature will be bound to should be passed //to the method SetAutoKeyData(). sigBox.Visible = false; sigBoxTopaz.Visible = true; labelInvalidSig.Visible = false; TopazWrapper.ClearTopaz(sigBoxTopaz); TopazWrapper.SetTopazCompressionMode(sigBoxTopaz, 0); TopazWrapper.SetTopazEncryptionMode(sigBoxTopaz, 0); TopazWrapper.SetTopazKeyString(sigBoxTopaz, "0000000000000000"); //Clear out the key string TopazWrapper.SetTopazEncryptionMode(sigBoxTopaz, 2); //high encryption TopazWrapper.SetTopazCompressionMode(sigBoxTopaz, 2); //high compression string hashedKeyData; switch (_signatureMode) { case SigMode.TreatPlan: hashedKeyData = TreatPlans.GetHashStringForSignature(keyData); //Passed in key data has not been hashed yet. TopazWrapper.SetTopazAutoKeyData(sigBoxTopaz, hashedKeyData); break; case SigMode.OrthoChart: hashedKeyData = OrthoCharts.GetHashStringForSignature(keyData); //Passed in key data has not been hashed yet. TopazWrapper.SetTopazAutoKeyData(sigBoxTopaz, hashedKeyData); break; case SigMode.Document: case SigMode.Default: default: TopazWrapper.SetTopazAutoKeyData(sigBoxTopaz, keyData); break; } TopazWrapper.SetTopazSigString(sigBoxTopaz, signature); if (TopazWrapper.GetTopazNumberOfTabletPoints(sigBoxTopaz) == 0) { //Try reading in the signature using the old way that we used to handle signatures. FillSignatureTopazOld(keyData, signature); } //If sig still not showing it must be invalid. if (TopazWrapper.GetTopazNumberOfTabletPoints(sigBoxTopaz) == 0) { labelInvalidSig.Visible = true; } TopazWrapper.SetTopazState(sigBoxTopaz, 0); }
///<summary>Saves the signature to the dictionary. The signature is hashed using the patient name, the date of service, and all ortho chart fields ///(even the ones not showing).</summary> private void SaveSignatureToDict(int gridRow) { if (!_showSigBox || gridRow < 0) { return; } DateTime orthoDate = GetOrthoDate(gridRow); if (!CanEditRow(orthoDate)) { return; } if (!signatureBoxWrapper.GetSigChanged() || !signatureBoxWrapper.IsValid) { return; } string keyData; //Get the "translated" name for the signature column. string sigColumnName = _listOrthDisplayFields.FirstOrDefault(x => x.InternalName == "Signature").Description; List <OrthoChart> listCharts = _dictOrthoCharts[orthoDate].FindAll(x => x.DateService == orthoDate && x.FieldValue != "" && x.FieldName != sigColumnName); keyData = OrthoCharts.GetKeyDataForSignatureSaving(listCharts, orthoDate); OrthoSignature sig = new OrthoSignature(); sig.IsTopaz = signatureBoxWrapper.GetSigIsTopaz(); sig.SigString = signatureBoxWrapper.GetSignature(keyData); if (sig.IsTopaz && !_topazNeedsSaved) { return; } if (OrthoSignature.GetSigString(GetValueFromDict(orthoDate, sigColumnName)) != sig.SigString) { _hasChanged = true; SetValueInDict(sig.ToString(), orthoDate, sigColumnName); } }
private void FormOrthoChart_FormClosing(object sender, FormClosingEventArgs e) { //Save data from grid to table for (int i = 0; i < gridMain.Rows.Count; i++) { table.Rows[i]["Date"] = gridMain.Rows[i].Tag; //store date for (int j = 0; j < listOrthDisplayFields.Count; j++) { table.Rows[i][j + 1] = gridMain.Rows[i].Cells[j + 1].Text; } } List <OrthoChart> tempOrthoChartsFromDB = OrthoCharts.GetAllForPatient(PatCur.PatNum); List <OrthoChart> tempOrthoChartsFromTable = new List <OrthoChart>(); for (int r = 0; r < table.Rows.Count; r++) { for (int c = 1; c < table.Columns.Count; c++) //skip col 0 { OrthoChart tempChart = new OrthoChart(); tempChart.DateService = (DateTime)table.Rows[r]["Date"]; tempChart.FieldName = listOrthDisplayFields[c - 1].Description; tempChart.FieldValue = table.Rows[r][c].ToString(); tempChart.PatNum = PatCur.PatNum; tempOrthoChartsFromTable.Add(tempChart); } } //Check table list vs DB list for inserts, updates, and deletes. for (int i = 0; i < tempOrthoChartsFromTable.Count; i++) { //Either delete an existing record from the DB or ignore this non-entry. if (tempOrthoChartsFromTable[i].FieldValue == "") { for (int j = 0; j < tempOrthoChartsFromDB.Count; j++) { if (tempOrthoChartsFromDB[j].DateService == tempOrthoChartsFromTable[i].DateService && tempOrthoChartsFromDB[j].FieldName == tempOrthoChartsFromTable[i].FieldName) { OrthoCharts.Delete(tempOrthoChartsFromDB[j].OrthoChartNum); break; } } continue; //i loop } //Update the Record if it already exists or Insert if it's new. for (int j = 0; j <= tempOrthoChartsFromDB.Count; j++) { //Insert if you've made it through the whole list. if (j == tempOrthoChartsFromDB.Count) { OrthoCharts.Insert(tempOrthoChartsFromTable[i]); break; } //Update if type and date match if (tempOrthoChartsFromDB[j].DateService == tempOrthoChartsFromTable[i].DateService && tempOrthoChartsFromDB[j].FieldName == tempOrthoChartsFromTable[i].FieldName) { tempOrthoChartsFromTable[i].OrthoChartNum = tempOrthoChartsFromDB[j].OrthoChartNum; OrthoCharts.Update(tempOrthoChartsFromTable[i]); break; } } } }
private void FormOrthoChart_Load(object sender, EventArgs e) { //define the table---------------------------------------------------------------------------------------------------------- table = new DataTable("OrthoChartForPatient"); //define columns---------------------------------------------------------------------------------------------------------- table.Columns.Add("Date", typeof(DateTime)); listOrthDisplayFields = DisplayFields.GetForCategory(DisplayFieldCategory.OrthoChart); for (int i = 0; i < listOrthDisplayFields.Count; i++) { table.Columns.Add((i + 1).ToString()); //named by number, but probably refer to by index } //define rows------------------------------------------------------------------------------------------------------------ listOrthoCharts = OrthoCharts.GetAllForPatient(PatCur.PatNum); List <DateTime> datesShowing = new List <DateTime>(); List <string> listDisplayFieldNames = new List <string>(); for (int i = 0; i < listOrthDisplayFields.Count; i++) //fill listDisplayFieldNames to be used in comparison { listDisplayFieldNames.Add(listOrthDisplayFields[i].Description); } //start adding dates starting with today's date datesShowing.Add(DateTime.Today); for (int i = 0; i < listOrthoCharts.Count; i++) { if (!listDisplayFieldNames.Contains(listOrthoCharts[i].FieldName)) //skip rows not in display fields { continue; } if (!datesShowing.Contains(listOrthoCharts[i].DateService)) //add dates not already in date list { datesShowing.Add(listOrthoCharts[i].DateService); } } datesShowing.Sort(); //We now have a list of dates. //add all blank cells to each row except for the date. DataRow row; //create and add row for each date in date showing for (int i = 0; i < datesShowing.Count; i++) { row = table.NewRow(); row["Date"] = datesShowing[i]; for (int j = 0; j < listOrthDisplayFields.Count; j++) { row[j + 1] = ""; //j+1 because first row is date field. } table.Rows.Add(row); } //We now have a table with all empty strings in cells except dates. //Fill with data as necessary. for (int i = 0; i < listOrthoCharts.Count; i++) //loop { if (!datesShowing.Contains(listOrthoCharts[i].DateService)) { continue; } if (!listDisplayFieldNames.Contains(listOrthoCharts[i].FieldName)) { continue; } for (int j = 0; j < table.Rows.Count; j++) { if (listOrthoCharts[i].DateService == (DateTime)table.Rows[j]["Date"]) { table.Rows[j][listDisplayFieldNames.IndexOf(listOrthoCharts[i].FieldName) + 1] = listOrthoCharts[i].FieldValue; } } } FillGrid(); FillGridPat(); }
///<summary>Displays the signature that is saved in the dictionary in the signature box. Colors the grid row green if the signature is valid, ///red if invalid, or white if blank. Puts "Valid" or "Invalid" in the grid's signature column.</summary> private void DisplaySignature(int gridRow, bool hasRefresh = true) { if (!_showSigBox || gridRow < 0) { return; } DateTime orthoDate = GetOrthoDate(gridRow); List <OrthoChart> listOrthoCharts = _dictOrthoCharts[orthoDate]; //Get the "translated" name for the signature column. string sigColumnName = _listOrthDisplayFields.FirstOrDefault(x => x.InternalName == "Signature").Description; if (!listOrthoCharts.Exists(x => x.FieldName == sigColumnName)) { signatureBoxWrapper.ClearSignature(); return; } OrthoSignature sig = new OrthoSignature(listOrthoCharts.Find(x => x.FieldName == sigColumnName).FieldValue); if (sig.SigString == "") { signatureBoxWrapper.ClearSignature(); gridMain.Rows[gridRow].ColorBackG = SystemColors.Window; //Empty out the signature column displaying to the user. if (_sigColIdx > 0) //User might be vieweing a tab that does not have the signature column. Greater than 0 because index 0 is a Date column. { gridMain.Rows[gridRow].Cells[_sigColIdx].Text = ""; } if (hasRefresh) { gridMain.Refresh(); } return; } string keyData = OrthoCharts.GetKeyDataForSignatureHash(_patCur, listOrthoCharts .FindAll(x => x.DateService == orthoDate && x.FieldValue != "" && x.FieldName != sigColumnName), orthoDate); signatureBoxWrapper.FillSignature(sig.IsTopaz, keyData, sig.SigString); if (!signatureBoxWrapper.IsValid) { //This ortho chart may have been signed when we were using the patient name in the hash. Try hashing the signature with the patient name. keyData = OrthoCharts.GetKeyDataForSignatureHash(_patCur, listOrthoCharts .FindAll(x => x.DateService == orthoDate && x.FieldValue != "" && x.FieldName != sigColumnName), orthoDate, doUsePatName: true); signatureBoxWrapper.FillSignature(sig.IsTopaz, keyData, sig.SigString); } if (signatureBoxWrapper.IsValid) { gridMain.Rows[gridRow].ColorBackG = Color.FromArgb(0, 245, 165); //A lighter version of Color.MediumSpringGreen if (_sigColIdx > 0) //User might be vieweing a tab that does not have the signature column. Greater than 0 because index 0 is a Date column. { gridMain.Rows[gridRow].Cells[_sigColIdx].Text = Lan.g(this, "Valid"); } } else { gridMain.Rows[gridRow].ColorBackG = Color.FromArgb(255, 140, 143); //A darker version of Color.LightPink if (_sigColIdx > 0) //User might be vieweing a tab that does not have the signature column. Greater than 0 because index 0 is a Date column. { gridMain.Rows[gridRow].Cells[_sigColIdx].Text = Lan.g(this, "Invalid"); } } if (hasRefresh) { gridMain.Refresh(); } }