Exemplo n.º 1
0
        private void SetFlags()
        {
            VaccineObsType vaccineObsType = (VaccineObsType)listValueType.SelectedIndex;

            if (vaccineObsType == VaccineObsType.Coded)
            {
                listCodeSystem.Enabled = true;
            }
            else
            {
                listCodeSystem.Enabled = false;
            }
            if (vaccineObsType == VaccineObsType.Numeric)
            {
                comboUnits.Enabled = true;
            }
            else
            {
                comboUnits.Enabled = false;
            }
            VaccineObsIdentifier vaccineObsIdentifier = (VaccineObsIdentifier)comboObservationQuestion.SelectedIndex;

            if (vaccineObsIdentifier == VaccineObsIdentifier.FundPgmEligCat)
            {
                textMethodCode.ReadOnly = false;
            }
            else
            {
                textMethodCode.ReadOnly = true;
            }
        }
Exemplo n.º 2
0
        private void FormVaccineObsEdit_Load(object sender, EventArgs e)
        {
            comboObservationQuestion.Items.Clear();
            string[] arrayQuestionNames = Enum.GetNames(typeof(VaccineObsIdentifier));
            for (int i = 0; i < arrayQuestionNames.Length; i++)
            {
                comboObservationQuestion.Items.Add(arrayQuestionNames[i]);
                VaccineObsIdentifier vaccineObsIdentifier = (VaccineObsIdentifier)i;
                if (_vaccineObsCur.IdentifyingCode == vaccineObsIdentifier)
                {
                    comboObservationQuestion.SelectedIndex = i;
                }
            }
            listValueType.Items.Clear();
            string[] arrayValueTypeNames = Enum.GetNames(typeof(VaccineObsType));
            for (int i = 0; i < arrayValueTypeNames.Length; i++)
            {
                listValueType.Items.Add(arrayValueTypeNames[i]);
                VaccineObsType vaccineObsType = (VaccineObsType)i;
                if (_vaccineObsCur.ValType == vaccineObsType)
                {
                    listValueType.SelectedIndex = i;
                }
            }
            listCodeSystem.Items.Clear();
            string[] arrayCodeSystems = Enum.GetNames(typeof(VaccineObsValCodeSystem));
            for (int i = 0; i < arrayCodeSystems.Length; i++)
            {
                listCodeSystem.Items.Add(arrayCodeSystems[i].ToString());
                VaccineObsValCodeSystem valCodeSystem = (VaccineObsValCodeSystem)i;
                if (_vaccineObsCur.ValCodeSystem == valCodeSystem)
                {
                    listCodeSystem.SelectedIndex = i;
                }
            }
            textValue.Text = _vaccineObsCur.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 == _vaccineObsCur.UcumCode)
                {
                    comboUnits.SelectedIndex = i + 1;
                }
            }
            if (_vaccineObsCur.DateObs.Year > 1880)
            {
                textDateObserved.Text = _vaccineObsCur.DateObs.ToShortDateString();
            }
            textMethodCode.Text = _vaccineObsCur.MethodCode;
            SetFlags();
        }
Exemplo n.º 3
0
        private void butOK_Click(object sender, EventArgs e)
        {
            if (textValue.Text.Trim() == "")
            {
                MsgBox.Show(this, "Missing value.");
                return;
            }
            VaccineObsType vaccineObsType = (VaccineObsType)listValueType.SelectedIndex;

            if (vaccineObsType == VaccineObsType.Coded)
            {
                //Any value is allowed.
            }
            else if (vaccineObsType == VaccineObsType.Dated)
            {
                try {
                    DateTime.Parse(textValue.Text);
                }
                catch (Exception) {
                    MsgBox.Show(this, "Value must be a valid date.");
                    return;
                }
            }
            else if (vaccineObsType == VaccineObsType.Numeric)
            {
                try {
                    double.Parse(textValue.Text);
                }
                catch (Exception) {
                    MsgBox.Show(this, "Value must be a valid number.");
                    return;
                }
            }
            else if (vaccineObsType == VaccineObsType.Text)
            {
                //Any value is allowed.
            }
            else               //DateAndTime
            {
                try {
                    DateTime.Parse(textValue.Text);
                }
                catch (Exception) {
                    MsgBox.Show(this, "Value must be a valid date and time.");
                    return;
                }
            }
            if (comboUnits.Enabled && comboUnits.SelectedIndex == 0)
            {
                MsgBox.Show(this, "Missing units.");
                return;
            }
            if (textDateObserved.errorProvider1.GetError(textDateObserved) != "")
            {
                MessageBox.Show(Lan.g(this, "Please fix data entry errors first."));
                return;
            }
            if (!textMethodCode.ReadOnly && textMethodCode.Text.Trim() == "")
            {
                MsgBox.Show(this, "Missing method code.");
                return;
            }
            _vaccineObsCur.IdentifyingCode = (VaccineObsIdentifier)comboObservationQuestion.SelectedIndex;
            _vaccineObsCur.ValType         = (VaccineObsType)listValueType.SelectedIndex;
            _vaccineObsCur.ValCodeSystem   = (VaccineObsValCodeSystem)listCodeSystem.SelectedIndex;
            _vaccineObsCur.ValReported     = textValue.Text;
            _vaccineObsCur.UcumCode        = "";
            if (comboUnits.Enabled)
            {
                _vaccineObsCur.UcumCode = comboUnits.Items[comboUnits.SelectedIndex].ToString();
            }
            _vaccineObsCur.DateObs = DateTime.MinValue;
            if (textDateObserved.Text != "")
            {
                _vaccineObsCur.DateObs = PIn.Date(textDateObserved.Text);
            }
            _vaccineObsCur.MethodCode = textMethodCode.Text;
            DialogResult = DialogResult.OK;
        }