public void LoadMedicalData()
    {
        DeadMedicalInfo deadMedical = new DeadMedicalInfo();
        deadMedical.Where.DeadEventID.Value = ParmDeadEventID;
        deadMedical.Where.DeadEventID.Operator = MyGeneration.dOOdads.WhereParameter.Operand.Equal;
        deadMedical.Query.Load();

        //ICDCODE9000 objICD9000 = new ICDCODE9000();
        ICD10_DirectDeathReason objICD9000 = new ICD10_DirectDeathReason();
        ucItemControlDeathReasonA.setCode = objICD9000.getICD9000Description(deadMedical.CauseOfDeathA);
        //deadMedical.CauseOfDeathA = ucItemControlDeathReasonA.SelectedICD;
        ucItemControlDeathReasonA.Days = deadMedical.CauseOfDeathAPeriod.Substring(0, 2);
        ucItemControlDeathReasonA.Months = deadMedical.CauseOfDeathAPeriod.Substring(2, 2);
        ucItemControlDeathReasonA.Years = deadMedical.CauseOfDeathAPeriod.Substring(4, 2);

        //ucItemControlDeathReasonB.setCode = objICD9000.getICD9000Description(deadMedical.CauseOfDeathB);
        //ucItemControlDeathReasonC.setCode = objICD9000.getICD9000Description(deadMedical.CauseOfDeathC);
        ucItemControlDeathReasonD.setCode = objICD9000.getICD9000Description(deadMedical.CauseOfDeathD);

        /*
        //deadMedical.CauseOfDeathAPeriod = ucItemControlDeathReasonA.Days + ucItemControlDeathReasonA.Months + ucItemControlDeathReasonA.Years;
        if (deadMedical.CauseOfDeathB != null && deadMedical.CauseOfDeathB != 0)
            lblSelectedItem.Text = new ICD10ITEM().getItemDescription(deadMedical.CauseOfDeathB);
        //deadMedical.CauseOfDeathB = int.Parse(dropICDItem.SelectedValue);
        if (deadMedical.CauseOfDeathC != "")
            lblSelectedCode.Text = new ICD10CODE().getCodeDescription(deadMedical.CauseOfDeathC);
        //deadMedical.CauseOfDeathC = dropICDcode.SelectedValue;

        if (deadMedical.CauseOfDeathD != "")
            ucItemControlDeathReasonD.setCode = objICD9000.getICD9000Description(deadMedical.CauseOfDeathD);
        //deadMedical.CauseOfDeathD = ucItemControlDeathReasonD.SelectedICD;
        if (deadMedical.CauseOfDeathDPeriod != "000000")
        {
            //deadMedical.CauseOfDeathDPeriod = ucItemControlDeathReasonD.Days + ucItemControlDeathReasonD.Months + ucItemControlDeathReasonD.Years;
            ucItemControlDeathReasonD.Days = deadMedical.CauseOfDeathDPeriod.Substring(0, 2);
            ucItemControlDeathReasonD.Months = deadMedical.CauseOfDeathDPeriod.Substring(2, 2);
            ucItemControlDeathReasonD.Years = deadMedical.CauseOfDeathDPeriod.Substring(4, 2);
        }
        */
        if (deadMedical.CauseOfDeathNotRelatedA != "")
            ucItemCauseOfDeathNotRelatedA.setCode = objICD9000.getICD9000Description(deadMedical.CauseOfDeathNotRelatedA);
        //deadMedical.CauseOfDeathNotRelatedA = ucItemCauseOfDeathNotRelatedA.SelectedICD;
        if (deadMedical.CauseOfDeathNotRelatedAPeriod != "000000")
        {
            // deadMedical.CauseOfDeathNotRelatedAPeriod = ucItemCauseOfDeathNotRelatedA.Days + ucItemCauseOfDeathNotRelatedA.Months + ucItemCauseOfDeathNotRelatedA.Years;
            ucItemCauseOfDeathNotRelatedA.Days = deadMedical.CauseOfDeathNotRelatedAPeriod.Substring(0, 2);
            ucItemCauseOfDeathNotRelatedA.Months = deadMedical.CauseOfDeathNotRelatedAPeriod.Substring(2, 2);
            ucItemCauseOfDeathNotRelatedA.Years = deadMedical.CauseOfDeathNotRelatedAPeriod.Substring(4, 2);
        }

        if (deadMedical.CauseOfDeathNotRelatedB != "")
            ucItemCauseOfDeathNotRelatedB.setCode = objICD9000.getICD9000Description(deadMedical.CauseOfDeathNotRelatedB);
        // deadMedical.CauseOfDeathNotRelatedB = ucItemCauseOfDeathNotRelatedB.SelectedICD;
        if (deadMedical.CauseOfDeathNotRelatedBPeriod != "000000")
        {
            //deadMedical.CauseOfDeathNotRelatedBPeriod = ucItemCauseOfDeathNotRelatedB.Days + ucItemCauseOfDeathNotRelatedB.Months + ucItemCauseOfDeathNotRelatedB.Years;
            ucItemCauseOfDeathNotRelatedB.Days = deadMedical.CauseOfDeathNotRelatedBPeriod.Substring(0, 2);
            ucItemCauseOfDeathNotRelatedB.Months = deadMedical.CauseOfDeathNotRelatedBPeriod.Substring(2, 2);
            ucItemCauseOfDeathNotRelatedB.Years = deadMedical.CauseOfDeathNotRelatedBPeriod.Substring(4, 2);
        }

        if (deadMedical.IsSmoker)
            radioListISSmoker.SelectedIndex = 0;
        else
            radioListISSmoker.SelectedIndex = 1;
        //deadMedical.IsSmoker = radioListISSmoker.SelectedValue == "1" ? true : false;
        radioListSmokingType.SelectedIndex = radioListSmokingType.Items.IndexOf(radioListSmokingType.Items.FindByValue(deadMedical.SmokeType));
        //deadMedical.SmokeType = radioListSmokingType.SelectedValue;
        txtsmokingPeriod1.Text = deadMedical.SmokePeriod.Substring(0, 2);
        txtsmokingPeriod2.Text = deadMedical.SmokePeriod.Substring(2, 2);
        //  deadMedical.SmokePeriod = (txtsmokingPeriod1.Text.Length == 1 ? "0" + txtsmokingPeriod1.Text : txtsmokingPeriod1.Text) +
        //                           (txtsmokingPeriod2.Text.Length == 1 ? "0" + txtsmokingPeriod2.Text : txtsmokingPeriod2.Text);

        if (deadMedical.IsCausedByAccedent)
            rdCauseByAccedenc.SelectedIndex = 0;
        else
            rdCauseByAccedenc.SelectedIndex = 1;

        drpReason.SelectedIndex = drpReason.Items.IndexOf(drpReason.Items.FindByValue(deadMedical.AccedentCause.ToString()));
        //deadMedical.AccedentCause = int.Parse(drpReason.SelectedValue);
        txtAccidentLocation.Text = deadMedical.AccedentPlace;
        txtAnotherReason.Text = deadMedical.AccedentAnotherCause;
        //deadMedical.AccedentPlace = txtAccidentLocation.Text;
        dropCarType.SelectedIndex = dropCarType.Items.IndexOf(dropCarType.Items.FindByValue(deadMedical.VehicleType.ToString()));
        //deadMedical.VehicleType = int.Parse(dropCarType.SelectedValue);
        txtCarType.Text = deadMedical.VehicleTypeOther;
        //deadMedical.VehicleTypeOther = txtCarType.Text;
        RdDeadPersonType.SelectedIndex = RdDeadPersonType.Items.IndexOf(RdDeadPersonType.Items.FindByValue(deadMedical.DeadStatus.ToString()));
        //deadMedical.DeadStatus = int.Parse(RdDeadPersonType.SelectedValue);

        if (deadMedical.HasTumor)
            rdTumorFlag.SelectedIndex = 0;
        else
            rdTumorFlag.SelectedIndex = 1;
        txtTumorLocation.Text = deadMedical.PlaceOfTumor;
        dropTumorType.SelectedIndex = dropTumorType.Items.IndexOf(dropTumorType.Items.FindByValue(deadMedical.TypeOfTumor.ToString()));
        //deadMedical.TypeOfTumor = int.Parse(dropTumorType.SelectedValue);
        dropTumorPhases.SelectedIndex = dropTumorPhases.Items.IndexOf(dropTumorPhases.Items.FindByValue(deadMedical.PhaseOfTumor.ToString()));
        // deadMedical.PhaseOfTumor = int.Parse(dropTumorPhases.SelectedValue);

        if (deadMedical.DeadThroghCarry)
            rdDeathThroughCarry.SelectedIndex = 0;
        else
            rdDeathThroughCarry.SelectedIndex = 1;

        //deadMedical.DeadThroghCarry = rdDeathThroughCarry.SelectedValue == "1" ? true : false;
        if (deadMedical.DeadThroghBirth)
            rdDeadThroughBirth.SelectedIndex = 0;
        else
            rdDeadThroughBirth.SelectedIndex = 1;

        //deadMedical.DeadThroghBirth = rdAbortionPast6Weeks.SelectedValue == "1" ? true : false;
        if (deadMedical.AbortionPast6Weeks)
            rdAbortionPast6Weeks.SelectedIndex = 0;
        else
            rdAbortionPast6Weeks.SelectedIndex = 1;

        //deadMedical.AbortionPast6Weeks = rdAbortionPast6Weeks.SelectedValue == "1" ? true : false;
        if (deadMedical.BirthPast6Weeks)
            rdBirthPast6Weeks.SelectedIndex = 0;
        else
            rdBirthPast6Weeks.SelectedIndex = 1;
        // deadMedical.DeadThroghBirth = rdDeadThroughBirth.SelectedValue == "1" ? true : false;
        //deadMedical.BirthPast6Weeks = rdBirthPast6Weeks.SelectedValue == "1" ? true : false;

        try
        {
            txtDate.Text = deadMedical.BirthDate.ToString();
        }
        catch
        {
            //continue
        }
        //IFormatProvider culture = new CultureInfo("en-US", true);
        //deadMedical.BirthDate = DateTime.ParseExact(txtDate.Text, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture);
        dropBirthOuput.SelectedIndex = dropBirthOuput.Items.IndexOf(dropBirthOuput.Items.FindByValue(deadMedical.BirthResult.ToString()));
        //deadMedical.BirthResult = int.Parse(dropBirthOuput.SelectedValue);
        txtBirthLocation.Text = deadMedical.BirthPlace;
        txtBirthOperator.Text = deadMedical.BirthOperator;
    }
    public void AddNewHealthInfo()
    {
        DeadMedicalInfo deadMedical = new DeadMedicalInfo();

        deadMedical.AddNew();

        deadMedical.DeadEventID = ParmDeadEventID;

        deadMedical.CauseOfDeathA = ucItemControlDeathReasonA.SelectedICD;
        deadMedical.CauseOfDeathAPeriod = ucItemControlDeathReasonA.Days + ucItemControlDeathReasonA.Months + ucItemControlDeathReasonA.Years;

        deadMedical.CauseOfDeathD = ucItemControlDeathReasonD.SelectedICD;
        deadMedical.CauseOfDeathDPeriod = ucItemControlDeathReasonD.Days + ucItemControlDeathReasonD.Months + ucItemControlDeathReasonD.Years;

        deadMedical.CauseOfDeathNotRelatedA = ucItemCauseOfDeathNotRelatedA.SelectedICD;
        deadMedical.CauseOfDeathNotRelatedAPeriod = ucItemCauseOfDeathNotRelatedA.Days + ucItemCauseOfDeathNotRelatedA.Months + ucItemCauseOfDeathNotRelatedA.Years;

        deadMedical.CauseOfDeathNotRelatedB = ucItemCauseOfDeathNotRelatedB.SelectedICD;
        deadMedical.CauseOfDeathNotRelatedBPeriod = ucItemCauseOfDeathNotRelatedB.Days + ucItemCauseOfDeathNotRelatedB.Months + ucItemCauseOfDeathNotRelatedB.Years;

        deadMedical.IsSmoker = radioListISSmoker.SelectedValue == "1" ? true : false;
        deadMedical.SmokeType = radioListSmokingType.SelectedValue;
        deadMedical.SmokePeriod = (txtsmokingPeriod1.Text.Length == 1 ? "0" + txtsmokingPeriod1.Text : txtsmokingPeriod1.Text) +
                                  (txtsmokingPeriod2.Text.Length == 1 ? "0" + txtsmokingPeriod2.Text : txtsmokingPeriod2.Text);

        deadMedical.IsCausedByAccedent = rdCauseByAccedenc.SelectedValue == "1" ? true : false;
        deadMedical.AccedentCause = int.Parse(drpReason.SelectedValue);
        deadMedical.AccedentPlace = txtAccidentLocation.Text;
        deadMedical.AccedentAnotherCause = txtAnotherReason.Text;
        deadMedical.VehicleType = int.Parse(dropCarType.SelectedValue);
        deadMedical.VehicleTypeOther = txtCarType.Text;
        deadMedical.DeadStatus = int.Parse(RdDeadPersonType.SelectedValue);

        deadMedical.HasTumor = rdTumorFlag.SelectedValue == "1" ? true : false;
        deadMedical.PlaceOfTumor = txtTumorLocation.Text;
        deadMedical.TypeOfTumor = int.Parse(dropTumorType.SelectedValue);
        deadMedical.PhaseOfTumor = int.Parse(dropTumorPhases.SelectedValue);

        deadMedical.DeadThroghCarry = rdDeathThroughCarry.SelectedValue == "1" ? true : false;
        deadMedical.DeadThroghBirth = rdDeadThroughBirth.SelectedValue == "1" ? true : false;
        deadMedical.AbortionPast6Weeks = rdAbortionPast6Weeks.SelectedValue == "1" ? true : false;
        //   deadMedical.DeadThroghBirth = rdDeadThroughBirth.SelectedValue == "1" ? true : false;
        deadMedical.BirthPast6Weeks = rdBirthPast6Weeks.SelectedValue == "1" ? true : false;
        DateTime testInputDate;
        if (DateTime.TryParse(txtDate.Text, out testInputDate))
        {
            IFormatProvider culture = new CultureInfo("en-US", true);
            deadMedical.BirthDate = DateTime.ParseExact(txtDate.Text, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture);
        }
        deadMedical.BirthResult = int.Parse(dropBirthOuput.SelectedValue);
        deadMedical.BirthPlace = txtBirthLocation.Text;
        deadMedical.BirthOperator = txtBirthOperator.Text;

        deadMedical.Save();

        // update Dead record to indecate about medical info completion.
        Dead dead = new Dead();
        dead.LoadByPrimaryKey(ParmDeadEventID);
        dead.HasHealthData = true;
        dead.Save();
    }
    public void UpdateDeadMedicalInfo()
    {
        DeadMedicalInfo deadMedical = new DeadMedicalInfo();
        deadMedical.Where.DeadEventID.Value = ParmDeadEventID;
        deadMedical.Where.DeadEventID.Operator = MyGeneration.dOOdads.WhereParameter.Operand.Equal;
        deadMedical.Query.Load();
        if (!string.IsNullOrEmpty(ucItemControlDeathReasonA.SelectedICD))
        {
            deadMedical.CauseOfDeathA = ucItemControlDeathReasonA.SelectedICD;
        }
        deadMedical.CauseOfDeathAPeriod = ucItemControlDeathReasonA.Days + ucItemControlDeathReasonA.Months + ucItemControlDeathReasonA.Years + ucItemControlDeathReasonA.Hours + ucItemControlDeathReasonA.Mins;

        if (!string.IsNullOrEmpty(ucSubItemControlDeathReasonB.SelectedICD))
        {
            deadMedical.CauseOfDeathB = ucSubItemControlDeathReasonB.SelectedICD;
            deadMedical.CauseOfDeathBPeriod = ucSubItemControlDeathReasonB.Days + ucSubItemControlDeathReasonB.Months + ucSubItemControlDeathReasonB.Years + ucSubItemControlDeathReasonB.Hours + ucSubItemControlDeathReasonB.Mins;
        }
        if (!string.IsNullOrEmpty(ucSubItemControlDeathReasonC.SelectedICD))
        {
            deadMedical.CauseOfDeathC = ucSubItemControlDeathReasonC.SelectedICD;
            deadMedical.CauseOfDeathCPeriod = ucSubItemControlDeathReasonC.Days + ucSubItemControlDeathReasonC.Months + ucSubItemControlDeathReasonC.Years + ucSubItemControlDeathReasonC.Hours + ucSubItemControlDeathReasonC.Mins;
        }
        if (!string.IsNullOrEmpty(ucSubItemControlDeathReasonD.SelectedICD))
        {
            deadMedical.CauseOfDeathD = ucSubItemControlDeathReasonD.SelectedICD;
            deadMedical.CauseOfDeathDPeriod = ucSubItemControlDeathReasonD.Days + ucSubItemControlDeathReasonD.Months + ucSubItemControlDeathReasonD.Years + ucSubItemControlDeathReasonD.Hours + ucSubItemControlDeathReasonD.Mins;
        }

           /* if (dropICDItem.SelectedValue != "")
            deadMedical.CauseOfDeathB = int.Parse(dropICDItem.SelectedValue);
        deadMedical.CauseOfDeathC = dropICDcode.SelectedValue;

        deadMedical.CauseOfDeathD = ucItemControlDeathReasonD.SelectedICD;
        deadMedical.CauseOfDeathDPeriod = ucItemControlDeathReasonD.Days + ucItemControlDeathReasonD.Months + ucItemControlDeathReasonD.Years;
        */
        deadMedical.CauseOfDeathNotRelatedA = ucItemCauseOfDeathNotRelatedA.SelectedICD;
        deadMedical.CauseOfDeathNotRelatedAPeriod = ucItemCauseOfDeathNotRelatedA.Days + ucItemCauseOfDeathNotRelatedA.Months + ucItemCauseOfDeathNotRelatedA.Years + ucItemCauseOfDeathNotRelatedA.Hours + ucItemCauseOfDeathNotRelatedA.Mins;

        deadMedical.CauseOfDeathNotRelatedB = ucItemCauseOfDeathNotRelatedB.SelectedICD;
        deadMedical.CauseOfDeathNotRelatedBPeriod = ucItemCauseOfDeathNotRelatedB.Days + ucItemCauseOfDeathNotRelatedB.Months + ucItemCauseOfDeathNotRelatedB.Years + ucItemCauseOfDeathNotRelatedB.Hours + ucItemCauseOfDeathNotRelatedB.Mins;

        deadMedical.IsSmoker = radioListISSmoker.SelectedValue == "1" ? true : false;
        deadMedical.SmokeType = radioListSmokingType.SelectedValue;
        deadMedical.SmokePeriod = (txtsmokingPeriod1.Text.Length == 1 ? "0" + txtsmokingPeriod1.Text : txtsmokingPeriod1.Text) +
                                  (txtsmokingPeriod2.Text.Length == 1 ? "0" + txtsmokingPeriod2.Text : txtsmokingPeriod2.Text);

        deadMedical.IsCausedByAccedent = rdCauseByAccedenc.SelectedValue == "1" ? true : false;
        deadMedical.AccedentCause = int.Parse(drpReason.SelectedValue);
        deadMedical.AccedentPlace = txtAccidentLocation.Text;
        deadMedical.AccedentAnotherCause = txtAnotherReason.Text;
        deadMedical.VehicleType = int.Parse(dropCarType.SelectedValue);
        deadMedical.VehicleTypeOther = txtCarType.Text;
        deadMedical.DeadStatus = int.Parse(RdDeadPersonType.SelectedValue);

        deadMedical.HasTumor = rdTumorFlag.SelectedValue == "1" ? true : false;
        deadMedical.PlaceOfTumor = txtTumorLocation.Text;
        if(uiDropDownListTumorLocation.SelectedValue != "0")
            deadMedical.LocationOfTumor = Convert.ToInt32(uiDropDownListTumorLocation.SelectedValue);
        deadMedical.TypeOfTumor = int.Parse(dropTumorType.SelectedValue);
        deadMedical.PhaseOfTumor = int.Parse(dropTumorPhases.SelectedValue);

        deadMedical.DeadThroghCarry = rdDeathThroughCarry.SelectedValue == "1" ? true : false;
        //deadMedical.DeadThroghBirth = rdAbortionPast6Weeks.SelectedValue == "1" ? true : false;
        deadMedical.AbortionPast6Weeks = rdAbortionPast6Weeks.SelectedValue == "1" ? true : false;
        deadMedical.DeadThroghBirth = rdDeadThroughBirth.SelectedValue == "1" ? true : false;
        deadMedical.BirthPast6Weeks = rdBirthPast6Weeks.SelectedValue == "1" ? true : false;

        DateTime testInputDate;
        if (DateTime.TryParse(txtDate.Text, out testInputDate))
        {
            IFormatProvider culture = new CultureInfo("en-US", true);
            deadMedical.BirthDate = DateTime.ParseExact(txtDate.Text, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture);
        }
        deadMedical.BirthResult = int.Parse(dropBirthOuput.SelectedValue);
        deadMedical.BirthPlace = txtBirthLocation.Text;
        deadMedical.BirthOperator = txtBirthOperator.Text;

        if (DateTime.TryParse(uiTextBoxAbortionDate.Text, out testInputDate))
        {
            IFormatProvider culture = new CultureInfo("en-US", true);
            deadMedical.AbortionDate = DateTime.ParseExact(uiTextBoxAbortionDate.Text, "dd/MM/yyyy", null);
        }
        deadMedical.AbortionPlace = uiTextBoxAbortionPlace.Text;
        deadMedical.IsUnderInvestigation = uiCheckBoxUnderInvestigation.Checked;
        deadMedical.Save();
    }