using framework_business; using framework_library; using System; using System.Data; using System.Reflection; using System.Web.UI; using System.Web.UI.WebControls; public partial class controls_module_mediswitchMSV : System.Web.UI.UserControl { MediSwitch mediswitch = null; protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack || mediswitch == null) mediswitch = new MediSwitch(); BindMedicalAids(); if (mediswitch.isOnline()) { globe.ForeColor = System.Drawing.Color.Green; ddMedicalAids.Enabled = true; txtMemberNo.Disabled = false; btnSearch.Enabled = true; } else { globe.ForeColor = System.Drawing.Color.Red; ddMedicalAids.Enabled = false; txtMemberNo.Disabled = true; btnSearch.Enabled = false; } } catch (Exception ex) { exception.HandleException("mediswitch msv:", MethodBase.GetCurrentMethod().Name, ex, 0, false); } } private void BindMedicalAids() { try { DataTable medAids = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oMedicalAdministrator), "msMSVAllowed", "1", "medSchemeName"); ddMedicalAids.DataSource = medAids; ddMedicalAids.DataTextField = "medSchemeName"; ddMedicalAids.DataValueField = "msDestinationCode"; ddMedicalAids.DataBind(); ddMedicalAids.Items.Insert(0, new ListItem("select medical aid..", "")); } catch (Exception ex) { exception.HandleException("mediswitch msv:", MethodBase.GetCurrentMethod().Name, ex, 0); } } protected void btnSearch_Click(object sender, EventArgs e) { try { string sDestinationCode = ddMedicalAids.SelectedValue; string sMemberNo = txtMemberNo.Value; string sResponse = string.Empty; string pDependantCode = string.Empty, pPatientSurname = string.Empty, pPatientInitials = string.Empty, pPatientFullName = string.Empty, pPatientDOB = string.Empty, pPatientID = string.Empty, pPatientGender = string.Empty, pMedSchemeEffectiveDate = string.Empty, pMedSchemeTerminationDate = string.Empty, pMedSchemeStatusCode = string.Empty; bool isValid = false; if (mediswitch.isOnline()) { sResponse = mediswitch.MSVPatientDataSingle(sDestinationCode, sMemberNo); ddPatientDetails.Items.Clear(); ddPatientDetails.Items.Add(new ListItem("select patient..", "")); using (System.IO.StringReader reader = new System.IO.StringReader(sResponse.ToString())) { string line; while ((line = reader.ReadLine()) != null) { string[] splitLine = line.Split('|'); switch (splitLine[0]) { case "H": break; case "S": break; case "M": lblMainMedScheme.Text = splitLine[15].Length > 0 ? splitLine[15] : "N/A"; break; case "P": pDependantCode = splitLine[1]; pPatientSurname = splitLine[2]; pPatientInitials = splitLine[3]; pPatientFullName = splitLine[4]; pPatientDOB = splitLine[5]; pPatientID = splitLine[6]; pPatientGender = splitLine[7]; pMedSchemeEffectiveDate = splitLine[8]; pMedSchemeTerminationDate = splitLine[9]; pMedSchemeStatusCode = splitLine[10]; ddPatientDetails.Items.Add(new ListItem(pPatientSurname + " " + pPatientFullName + " - " + pPatientDOB, line)); break; case "RV": isValid = splitLine[1] == "02"; switch (splitLine[6]) { /* 01 = CDV - Check Digit Verification 02 = CHF - Card Holder File 03 = SO - Switch out to Medical Scheme*/ case "01": lblValidationMethod.Text = "CDV - Check Digit Verification"; break; case "02": lblValidationMethod.Text = "CHF - Card Holder File"; break; case "03": lblValidationMethod.Text = "SO - Switch out to Medical Scheme"; break; default: break; } lblDisclaimer.Text = splitLine[3]; break; case "E": break; default: break; } } } divImport.Visible = ddPatientDetails.Items.Count > 1; lblNotFound.Visible = !divImport.Visible; btnSearch.Enabled = !divImport.Visible; if (lblNotFound.Visible) { if (isValid) { lblNotFound.Text = "The member number is valid, however, no patients details are transferrable from the medical aid. Please manually complete all patient details as required"; } else lblNotFound.Text = "No Valid Patient Information Found."; } upMSV.Update(); } } catch (Exception ex) { exception.HandleException("mediswitch msv:", MethodBase.GetCurrentMethod().Name, ex, 0); } } protected void btnImport_Click(object sender, EventArgs e) { try { string[] splitLine = ddPatientDetails.SelectedValue.Split('|'); string pDependantCode = splitLine[1]; string pPatientSurname = splitLine[2]; string pPatientInitials = splitLine[3]; string pPatientFullName = splitLine[4]; string pPatientDOB = splitLine[5]; string pPatientID = splitLine[6]; string pPatientGender = splitLine[7]; string pMedSchemeEffectiveDate = splitLine[8]; string pMedSchemeTerminationDate = splitLine[9]; string pMedSchemeStatusCode = splitLine[10]; if (chkDependantCode.Checked && Parent.FindControl("PatientInformation_MedicalAidIfapplicable_DependantCode") != null) ((TextBox)(Parent.FindControl("PatientInformation_MedicalAidIfapplicable_DependantCode"))).Text = pDependantCode; if (chkMedAidNo.Checked && Parent.FindControl("PatientInformation_MedicalAidIfapplicable_MembershipNumber") != null) ((TextBox)(Parent.FindControl("PatientInformation_MedicalAidIfapplicable_MembershipNumber"))).Text = txtMemberNo.Value; if (chkSurname.Checked && Parent.FindControl("PatientInformation_PatientDetails_Surname") != null) ((TextBox)(Parent.FindControl("PatientInformation_PatientDetails_Surname"))).Text = pPatientSurname; if (chkFullName.Checked && Parent.FindControl("PatientInformation_PatientDetails_FirstNames") != null) ((TextBox)(Parent.FindControl("PatientInformation_PatientDetails_FirstNames"))).Text = pPatientFullName; if (chkInitials.Checked && Parent.FindControl("PatientInformation_PatientDetails_Initials") != null) ((TextBox)(Parent.FindControl("PatientInformation_PatientDetails_Initials"))).Text = pPatientInitials; if (chkDoB.Checked && Parent.FindControl("PatientInformation_PatientDetails_DateofBirth") != null) ((TextBox)(Parent.FindControl("PatientInformation_PatientDetails_DateofBirth"))).Text = DateTime.ParseExact(pPatientDOB, "yyyyMMdd", null).ToString("dd/MM/yyyy"); if (chkID.Checked && Parent.FindControl("PatientInformation_PatientDetails_IDPassportNumber") != null) ((TextBox)(Parent.FindControl("PatientInformation_PatientDetails_IDPassportNumber"))).Text = pPatientID; if (chkGender.Checked && Parent.FindControl("PatientInformation_PatientDetails_Gender") != null) { DropDownList ddlGender = ((DropDownList)(Parent.FindControl("PatientInformation_PatientDetails_Gender"))); if (pPatientGender == "M") ddlGender.SelectedIndex = ddlGender.Items.IndexOf(ddlGender.Items.FindByText("Male")); if (pPatientGender == "F") ddlGender.SelectedIndex = ddlGender.Items.IndexOf(ddlGender.Items.FindByText("Female")); } if (Parent.FindControl("PatientInformation_MedicalAidIfapplicable_MedicalAidSchemeName") != null) { DropDownList ddlMeds = ((DropDownList)(Parent.FindControl("PatientInformation_MedicalAidIfapplicable_MedicalAidSchemeName"))); DataTable dtMeds = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oMedicalScheme), "msDestinationCode", ddMedicalAids.SelectedValue.ToString(), "name"); ddlMeds.DataSource = dtMeds; ddlMeds.DataTextField = "name"; ddlMeds.DataValueField = "code"; ddlMeds.DataBind(); ddlMeds.Items.Insert(0, new ListItem("Select", "0")); ddlMeds.Items.Insert(1, new ListItem("Workmans Compensation Accident", "WCA")); } ((UpdatePanel)(Parent.FindControl("upSurface"))).Update(); ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "setPlaceholders", "setPlaceholders();", true); btnImport.Enabled = false; } catch (Exception ex) { exception.HandleException("mediswitch msv:", MethodBase.GetCurrentMethod().Name, ex, 0); } } protected void ddPatientDetails_SelectedIndexChanged(object sender, EventArgs e) { try { btnImport.Enabled = ddPatientDetails.SelectedIndex > 0; string[] splitLine = ddPatientDetails.SelectedValue.Split('|'); string pDependantCode = splitLine[1]; string pPatientSurname = splitLine[2]; string pPatientInitials = splitLine[3]; string pPatientFullName = splitLine[4]; string pPatientDOB = splitLine[5]; string pPatientID = splitLine[6]; string pPatientGender = splitLine[7]; string pMedSchemeEffectiveDate = splitLine[8]; string pMedSchemeTerminationDate = splitLine[9]; string pMedSchemeStatusCode = splitLine[10]; if (Parent.FindControl("PatientInformation_PatientDetails_Surname") != null) lblCurrentSurname.Text = ((TextBox)(Parent.FindControl("PatientInformation_PatientDetails_Surname"))).Text; if (Parent.FindControl("PatientInformation_PatientDetails_FirstNames") != null) lblCurrentFullName.Text = ((TextBox)(Parent.FindControl("PatientInformation_PatientDetails_FirstNames"))).Text; if (Parent.FindControl("PatientInformation_PatientDetails_Initials") != null) lblCurrentInitials.Text = ((TextBox)(Parent.FindControl("PatientInformation_PatientDetails_Initials"))).Text; if (Parent.FindControl("PatientInformation_PatientDetails_DateofBirth") != null) lblCurrentDoB.Text = ((TextBox)(Parent.FindControl("PatientInformation_PatientDetails_DateofBirth"))).Text; if (Parent.FindControl("PatientInformation_PatientDetails_IDPassportNumber") != null) lblCurrentID.Text = ((TextBox)(Parent.FindControl("PatientInformation_PatientDetails_IDPassportNumber"))).Text; if (Parent.FindControl("PatientInformation_PatientDetails_Gender") != null) lblCurrentGender.Text = ((DropDownList)(Parent.FindControl("PatientInformation_PatientDetails_Gender"))).SelectedItem.Text; if (Parent.FindControl("PatientInformation_MedicalAidIfapplicable_DependantCode") != null) lblCurrentDependantCode.Text = ((TextBox)(Parent.FindControl("PatientInformation_MedicalAidIfapplicable_DependantCode"))).Text; if (Parent.FindControl("PatientInformation_MedicalAidIfapplicable_MembershipNumber") != null) lblCurrentMedAidNo.Text = ((TextBox)(Parent.FindControl("PatientInformation_MedicalAidIfapplicable_MembershipNumber"))).Text; lblNewSurname.Text = pPatientSurname; lblNewFullName.Text = pPatientFullName; lblNewInitials.Text = pPatientInitials; lblNewDoB.Text = DateTime.ParseExact(pPatientDOB, "yyyyMMdd", null).ToString("dd/MM/yyyy"); lblNewID.Text = pPatientID; if (pPatientGender == "M") lblNewGender.Text = "Male"; if (pPatientGender == "F") lblNewGender.Text = "Female"; lblNewDependantCode.Text = pDependantCode; lblNewMedAidNo.Text = txtMemberNo.Value; lblEffectiveDate.Text = pMedSchemeEffectiveDate; lblTerminationDate.Text = pMedSchemeTerminationDate.Length > 0 ? "(" + pMedSchemeTerminationDate + ")" : ""; SetColors(pMedSchemeTerminationDate, pMedSchemeStatusCode); changeTable.Visible = true; } catch (Exception ex) { exception.HandleException("mediswitch msv:", MethodBase.GetCurrentMethod().Name, ex, 0); } } private void SetColors(string pMedSchemeTerminationDate, string pMedSchemeStatusCode) { try { DateTime thisDay = DateTime.Now; DateTime terminationDate = new DateTime(1900, 01, 01); DateTime.TryParse(pMedSchemeTerminationDate, out terminationDate); if (terminationDate < thisDay) lblTerminationDate.ForeColor = System.Drawing.Color.Red; else lblTerminationDate.ForeColor = System.Drawing.Color.Orange; lblStatus.Text = pMedSchemeStatusCode; if (lblCurrentSurname.Text != lblNewSurname.Text) lblNewSurname.ForeColor = System.Drawing.Color.Green; if (lblCurrentFullName.Text != lblNewFullName.Text) lblNewFullName.ForeColor = System.Drawing.Color.Green; if (lblCurrentInitials.Text != lblNewInitials.Text) lblNewInitials.ForeColor = System.Drawing.Color.Green; if (lblCurrentDoB.Text != lblNewDoB.Text) lblNewDoB.ForeColor = System.Drawing.Color.Green; if (lblCurrentID.Text != lblNewID.Text) lblNewID.ForeColor = System.Drawing.Color.Green; if (lblCurrentGender.Text != lblNewGender.Text) lblNewGender.ForeColor = System.Drawing.Color.Green; if (lblCurrentDependantCode.Text != lblNewDependantCode.Text) lblNewDependantCode.ForeColor = System.Drawing.Color.Green; if (lblCurrentMedAidNo.Text != lblNewMedAidNo.Text) lblNewMedAidNo.ForeColor = System.Drawing.Color.Orange; } catch (Exception ex) { exception.HandleException("mediswitch msv:", MethodBase.GetCurrentMethod().Name, ex, 0); } } }