private void butOK_Click(object sender, EventArgs e) { //Validate if (textDate.Text != "") { try { DateTime.Parse(textDate.Text); } catch { MessageBox.Show("Please input a valid date."); return; } } //Save if (textDate.Text != "") { AllergyCur.DateAdverseReaction = DateTime.Parse(textDate.Text); } else { AllergyCur.DateAdverseReaction = DateTime.MinValue; } AllergyCur.AllergyDefNum = allergyDefList[comboAllergies.SelectedIndex].AllergyDefNum; AllergyCur.Reaction = textReaction.Text; AllergyCur.StatusIsActive = checkActive.Checked; if (AllergyCur.IsNew) { Allergies.Insert(AllergyCur); } else { Allergies.Update(AllergyCur); } DialogResult = DialogResult.OK; }
private void butOK_Click(object sender, EventArgs e) { //Validate if (textDate.Text != "") { try { DateTime.Parse(textDate.Text); } catch { MessageBox.Show("Please input a valid date."); return; } } //Save if (textDate.Text != "") { AllergyCur.DateAdverseReaction = DateTime.Parse(textDate.Text); } else { AllergyCur.DateAdverseReaction = DateTime.MinValue; } AllergyCur.AllergyDefNum = allergyDefList[comboAllergies.SelectedIndex].AllergyDefNum; AllergyCur.Reaction = textReaction.Text; AllergyCur.SnomedReaction = ""; if (snomedReaction != null) { AllergyCur.SnomedReaction = snomedReaction.SnomedCode; } AllergyCur.StatusIsActive = checkActive.Checked; if (AllergyCur.IsNew) { Allergies.Insert(AllergyCur); SecurityLogs.MakeLogEntry(Permissions.PatAllergyListEdit, AllergyCur.PatNum, AllergyDefs.GetDescription(AllergyCur.AllergyDefNum) + " added"); } else { Allergies.Update(AllergyCur); SecurityLogs.MakeLogEntry(Permissions.PatAllergyListEdit, AllergyCur.PatNum, AllergyDefs.GetDescription(AllergyCur.AllergyDefNum) + " edited"); } DialogResult = DialogResult.OK; }
private void butOK_Click(object sender, EventArgs e) { if (_listAllergyReconcile.Count == 0) { if (!MsgBox.Show(this, true, "The reconcile list is empty which will cause all existing allergies to be removed. Continue?")) { return; } } Allergy al; AllergyDef alD; bool isActive; //Discontinue any current medications that are not present in the reconcile list. for (int i = 0; i < _listAllergyCur.Count; i++) //Start looping through all current allergies { isActive = false; al = _listAllergyCur[i]; alD = AllergyDefs.GetOne(al.AllergyDefNum, _listAllergyDefCur); for (int j = 0; j < _listAllergyReconcile.Count; j++) //Compare each reconcile allergy to the current allergy { AllergyDef alDR = AllergyDefs.GetOne(_listAllergyReconcile[j].AllergyDefNum, _listAllergyDefCur); if (_listAllergyReconcile[j].AllergyDefNum == _listAllergyCur[i].AllergyDefNum) //Has identical AllergyDefNums { isActive = true; break; } if (alDR == null) { continue; } //if(alDR.SnomedAllergyTo!="" && alDR.SnomedAllergyTo==alD.SnomedAllergyTo) {//TODO: Change to UNII // isActive=true; // break; //} if (alDR.MedicationNum != 0 && alDR.MedicationNum == alD.MedicationNum) //Has a Snomed code and they are equal { isActive = true; break; } } if (!isActive) { _listAllergyCur[i].StatusIsActive = isActive; Allergies.Update(_listAllergyCur[i]); } } //Always update every current allergy for the patient so that DateTStamp reflects the last reconcile date. if (_listAllergyCur.Count > 0) { Allergies.ResetTimeStamps(_patCur.PatNum, true); } AllergyDef alDU; int index; for (int j = 0; j < _listAllergyReconcile.Count; j++) { if (!_listAllergyReconcile[j].IsNew) { continue; } index = ListAllergyNew.IndexOf(_listAllergyReconcile[j]); //Returns -1 if not found. if (index < 0) { continue; } //Insert the AllergyDef and Allergy if needed. if (ListAllergyDefNew[index].MedicationNum != 0) { alDU = AllergyDefs.GetAllergyDefFromMedication(ListAllergyDefNew[index].MedicationNum); } else { alDU = null; //remove once UNII is implemented //alDU=AllergyDefs.GetAllergyDefFromCode(ListAllergyDefNew[index].SnomedAllergyTo);//TODO: Change to UNII } if (alDU == null) //db is missing the def { ListAllergyNew[index].AllergyDefNum = AllergyDefs.Insert(ListAllergyDefNew[index]); } else { ListAllergyNew[index].AllergyDefNum = alDU.AllergyDefNum; //Set the allergydefnum on the allergy. } Allergies.Insert(ListAllergyNew[index]); } //TODO: Make an allergy measure event if one is needed for MU3. //EhrMeasureEvent newMeasureEvent = new EhrMeasureEvent(); //newMeasureEvent.DateTEvent=DateTime.Now; //newMeasureEvent.EventType=EhrMeasureEventType.AllergyReconcile; //newMeasureEvent.PatNum=PatCur.PatNum; //newMeasureEvent.MoreInfo=""; //EhrMeasureEvents.Insert(newMeasureEvent); for (int inter = 0; inter < _listAllergyReconcile.Count; inter++) { if (CDSPermissions.GetForUser(Security.CurUser.UserNum).ShowCDS&& CDSPermissions.GetForUser(Security.CurUser.UserNum).AllergyCDS) { AllergyDef alDInter = AllergyDefs.GetOne(_listAllergyReconcile[inter].AllergyDefNum); FormCDSIntervention FormCDSI = new FormCDSIntervention(); FormCDSI.ListCDSI = EhrTriggers.TriggerMatch(alDInter, _patCur); FormCDSI.ShowIfRequired(false); } } DialogResult = DialogResult.OK; }