private void butOK_Click(object sender, EventArgs e) { EhrAptObsIdentifier ehrAptObsId = (EhrAptObsIdentifier)comboObservationQuestion.SelectedIndex; if (listValueType.SelectedIndex == (int)EhrAptObsType.Address && ehrAptObsId != EhrAptObsIdentifier.TreatFacilityLocation || listValueType.SelectedIndex != (int)EhrAptObsType.Address && ehrAptObsId == EhrAptObsIdentifier.TreatFacilityLocation) { MsgBox.Show(this, "Value type Address must be used with question TreatFacilityLocation."); return; } if (listValueType.SelectedIndex == (int)EhrAptObsType.Coded && _loincValue == null && _snomedValue == null && _icd9Value == null && _icd10Value == null) { MsgBox.Show(this, "Missing value code."); return; } if (listValueType.SelectedIndex != (int)EhrAptObsType.Coded && textValue.Text == "") { MsgBox.Show(this, "Missing value."); return; } _ehrAptObsCur.IdentifyingCode = ehrAptObsId; _ehrAptObsCur.ValType = (EhrAptObsType)listValueType.SelectedIndex; if (_ehrAptObsCur.ValType == EhrAptObsType.Coded) { _ehrAptObsCur.ValCodeSystem = _strValCodeSystem; if (_strValCodeSystem == "LOINC") { _ehrAptObsCur.ValReported = _loincValue.LoincCode; } else if (_strValCodeSystem == "SNOMEDCT") { _ehrAptObsCur.ValReported = _snomedValue.SnomedCode; } else if (_strValCodeSystem == "ICD9") { _ehrAptObsCur.ValReported = _icd9Value.ICD9Code; } else if (_strValCodeSystem == "ICD10") { _ehrAptObsCur.ValReported = _icd10Value.Icd10Code; } } else if (_ehrAptObsCur.ValType == EhrAptObsType.Address) { _ehrAptObsCur.ValCodeSystem = ""; _ehrAptObsCur.ValReported = ""; } else { _ehrAptObsCur.ValCodeSystem = ""; _ehrAptObsCur.ValReported = textValue.Text; } _ehrAptObsCur.UcumCode = ""; if (comboUnits.Enabled) { _ehrAptObsCur.UcumCode = comboUnits.Items[comboUnits.SelectedIndex].ToString(); } DialogResult = DialogResult.OK; }
private void FormEhrAptObsEdit_Load(object sender, EventArgs e) { _appt = Appointments.GetOneApt(_ehrAptObsCur.AptNum); comboObservationQuestion.Items.Clear(); string[] arrayQuestionNames = Enum.GetNames(typeof(EhrAptObsIdentifier)); for (int i = 0; i < arrayQuestionNames.Length; i++) { comboObservationQuestion.Items.Add(arrayQuestionNames[i]); EhrAptObsIdentifier ehrAptObsIdentifier = (EhrAptObsIdentifier)i; if (_ehrAptObsCur.IdentifyingCode == ehrAptObsIdentifier) { comboObservationQuestion.SelectedIndex = i; } } listValueType.Items.Clear(); string[] arrayValueTypeNames = Enum.GetNames(typeof(EhrAptObsType)); for (int i = 0; i < arrayValueTypeNames.Length; i++) { listValueType.Items.Add(arrayValueTypeNames[i]); EhrAptObsType ehrAptObsType = (EhrAptObsType)i; if (_ehrAptObsCur.ValType == ehrAptObsType) { listValueType.SelectedIndex = i; } } if (_ehrAptObsCur.ValType == EhrAptObsType.Coded) { _strValCodeSystem = _ehrAptObsCur.ValCodeSystem; if (_ehrAptObsCur.ValCodeSystem == "LOINC") { _loincValue = Loincs.GetByCode(_ehrAptObsCur.ValReported); textValue.Text = _loincValue.NameShort; } else if (_ehrAptObsCur.ValCodeSystem == "SNOMEDCT") { _snomedValue = Snomeds.GetByCode(_ehrAptObsCur.ValReported); textValue.Text = _snomedValue.Description; } else if (_ehrAptObsCur.ValCodeSystem == "ICD9") { _icd9Value = ICD9s.GetByCode(_ehrAptObsCur.ValReported); textValue.Text = _icd9Value.Description; } else if (_ehrAptObsCur.ValCodeSystem == "ICD10") { _icd10Value = Icd10s.GetByCode(_ehrAptObsCur.ValReported); textValue.Text = _icd10Value.Description; } } else { textValue.Text = _ehrAptObsCur.ValReported; } comboUnits.Items.Clear(); comboUnits.Items.Add("none"); comboUnits.SelectedIndex = 0; List <string> listUcumCodes = Ucums.GetAllCodes(); for (int i = 0; i < listUcumCodes.Count; i++) { string ucumCode = listUcumCodes[i]; comboUnits.Items.Add(ucumCode); if (ucumCode == _ehrAptObsCur.UcumCode) { comboUnits.SelectedIndex = i + 1; } } SetFlags(); }