protected HealthCardEPCRemaining[] GetEPCRemainingFromCache(Hashtable epcRemainingCache, HealthCard hc)
    {
        if (hc == null)
        {
            return new HealthCardEPCRemaining[] { }
        }
        ;

        HealthCardEPCRemaining[] epcsRemaining = null;
        if (epcRemainingCache == null)
        {
            epcsRemaining = HealthCardEPCRemainingDB.GetByHealthCardID(hc.HealthCardID, -1);
        }
        else
        {
            epcsRemaining = (HealthCardEPCRemaining[])epcRemainingCache[hc.HealthCardID];
        }

        return(epcsRemaining == null ? new HealthCardEPCRemaining[] { } : epcsRemaining);
    }
Пример #2
0
    protected void UpdateCard(HealthCard card, CardType cardType)  // can be null if no card and will set info for no card of that org
    {
        bool isGPsite = Session != null && Convert.ToBoolean(Session["SiteIsGP"]);

        if (card != null && card.Organisation.OrganisationID != -1 && card.Organisation.OrganisationID != -2 && card.Organisation.OrganisationType.OrganisationTypeGroup.ID != 7)
        {
            throw new Exception("Unknown health card type");
        }

        Label lblInfo = lblMedicareCard;

        if (cardType == CardType.Medicare)
        {
            lblInfo = lblMedicareCard;
        }
        if (cardType == CardType.DVA)
        {
            lblInfo = lblDVACard;
        }
        if (cardType == CardType.Insurance)
        {
            lblInfo = lblInsuranceCard;
        }


        lblInfo.Text = card == null ? "No card" : (card.CardNbr + (card.CardFamilyMemberNbr.Length > 0 ? " - " + card.CardFamilyMemberNbr : ""));

        if (card != null && card.Organisation != null && card.Organisation.OrganisationType != null && card.Organisation.OrganisationType.OrganisationTypeGroup.ID == 7)
        {
            lblInfo.Text = "[" + card.Organisation.Name + "]  " + lblInfo.Text;
        }


        bool cardHasEPC = card != null && card.HasEPC();

        (cardType == CardType.Medicare ? lblMedicareCardInfo         : (cardType == CardType.DVA ? lblDVACardInfo         : lblInsuranceCardInfo)).Visible         = card != null;
        (cardType == CardType.Medicare ? lnkMedicareCardEdit         : (cardType == CardType.DVA ? lnkDVACardEdit         : lnkInsuranceCardEdit)).Visible         = card != null;
        (cardType == CardType.Medicare ? lnkMedicareCardEdit         : (cardType == CardType.DVA ? lnkDVACardEdit         : lnkInsuranceCardEdit)).CommandArgument = card != null?card.HealthCardID.ToString() : "-1";

        (cardType == CardType.Medicare ? lblMedicareAddBtnSeperator  : (cardType == CardType.DVA ? lblDVAAddBtnSeperator  : lblInsuranceAddBtnSeperator)).Visible = card != null;
        (cardType == CardType.Medicare ? lnkMedicareCardAdd          : (cardType == CardType.DVA ? lnkDVACardAdd          : lnkInsuranceCardAdd)).Text            = card == null ? "Add Card" : "Replace Card";
        (cardType == CardType.Medicare ? lnkMedicareCardAdd          : (cardType == CardType.DVA ? lnkDVACardAdd          : lnkInsuranceCardAdd)).OnClientClick   = card == null ? null : "javascript:if (!confirm('Setting a new card will delete the current card and any associated referral'. Continue?')) return false;";

        (cardType == CardType.Medicare ? medicare_epc_info_row       : (cardType == CardType.DVA ? dva_epc_info_row       : insurance_epc_info_row)).Visible       = !isGPsite && card != null && cardHasEPC;
        (cardType == CardType.Medicare ? medicare_no_epc_message_row : (cardType == CardType.DVA ? dva_no_epc_message_row : insurance_no_epc_message_row)).Visible = !isGPsite && card != null && !cardHasEPC;
        if (cardType == CardType.Medicare)
        {
            medicare_epc_combined_remaining_row.Visible = !isGPsite && card != null && cardHasEPC;
        }


        if (card != null)
        {
            (cardType == CardType.Medicare ? chkMedicareIsActive  : (cardType == CardType.DVA ? chkDvaIsActive  : chkInsuranceIsActive)).Checked  = card.IsActive;
            (cardType == CardType.Medicare ? chkMedicareIsActive2 : (cardType == CardType.DVA ? chkDvaIsActive2 : chkInsuranceIsActive2)).Checked = card.IsActive;
            //if (card.IsActive)
            //{
            //    (cardType == CardType.Medicare ? chkMedicareIsActive  : (cardType == CardType.DVA ? chkDvaIsActive  : chkInsuranceIsActive )).Attributes["onclick"]  = "return false;";
            //    (cardType == CardType.Medicare ? chkMedicareIsActive2 : (cardType == CardType.DVA ? chkDvaIsActive2 : chkInsuranceIsActive2)).Attributes["onclick"] = "return false;";
            //}
            //else
            //{
            //    (cardType == CardType.Medicare ? chkMedicareIsActive  : (cardType == CardType.DVA ? chkDvaIsActive  : chkInsuranceIsActive )).Attributes.Remove("onclick");
            //    (cardType == CardType.Medicare ? chkMedicareIsActive2 : (cardType == CardType.DVA ? chkDvaIsActive2 : chkInsuranceIsActive2)).Attributes.Remove("onclick");
            //}
            (cardType == CardType.Medicare ? chkMedicareIsActive  : (cardType == CardType.DVA ? chkDvaIsActive  : chkInsuranceIsActive)).Attributes["CommandArgument"]  = string.Format("{0}", card.HealthCardID);
            (cardType == CardType.Medicare ? chkMedicareIsActive2 : (cardType == CardType.DVA ? chkDvaIsActive2 : chkInsuranceIsActive2)).Attributes["CommandArgument"] = string.Format("{0}", card.HealthCardID);

            // marcus said that can deactivate so that have all cards de-activated
            // insurance was not added to this yet

            /*
             * if (card.IsActive)
             * {
             *  (cardType == CardType.Medicare ? chkMedicareIsActive : chkDvaIsActive).Attributes.Add("onclick", "return false;");
             *  (cardType == CardType.Medicare ? chkMedicareIsActive2 : chkDvaIsActive2).Attributes.Add("onclick", "return false;");
             * }
             * else
             * {
             *  (cardType == CardType.Medicare ? chkMedicareIsActive : chkDvaIsActive).Attributes.Remove("onclick");
             *  (cardType == CardType.Medicare ? chkMedicareIsActive2 : chkDvaIsActive2).Attributes.Remove("onclick");
             * }
             */


            //
            // set add epc link
            //

            string allFeatures = "dialogWidth:550px;dialogHeight:550px;center:yes;resizable:no; scroll:no";
            string js          = "show_modal_updade_epc(" + card.HealthCardID.ToString() + ");" + (!Utilities.IsMobileDevice(Request) ? "window.location=window.location;" : "") + "return false;";

            (cardType == CardType.Medicare ? lnkNewMedicareEPC2 : (cardType == CardType.DVA ? lnkNewDVAEPC2 : lnkNewInsuranceEPC2)).Visible     = true;
            (cardType == CardType.Medicare ? lnkNewMedicareEPC2 : (cardType == CardType.DVA ? lnkNewDVAEPC2 : lnkNewInsuranceEPC2)).NavigateUrl = "  ";
            (cardType == CardType.Medicare ? lnkNewMedicareEPC2 : (cardType == CardType.DVA ? lnkNewDVAEPC2 : lnkNewInsuranceEPC2)).Text        = "Add Referral";
            (cardType == CardType.Medicare ? lnkNewMedicareEPC2 : (cardType == CardType.DVA ? lnkNewDVAEPC2 : lnkNewInsuranceEPC2)).Attributes.Add("onclick", js);


            if (cardType == CardType.Insurance)
            {
                lblInsuranceOrgName.Text = card.Organisation.Name + "  ";

                lblInsuranceExpireDate.Text = card.ExpiryDate == DateTime.MinValue ? "Not Entered" : card.ExpiryDate.ToString("d MMM yyyy");

                if (card.ExpiryDate != DateTime.MinValue && DateTime.Now.Date >= card.ExpiryDate)
                {
                    lblInsuranceExpireDate.ForeColor     = System.Drawing.Color.Red;
                    lblInsuranceExpireDateText.Text      = lblEPCExpireDateText.Text.Replace("Expires:", "*** Expired ***");
                    lblInsuranceExpireDateText.Font.Bold = true;
                    lblInsuranceExpireDateText.ForeColor = System.Drawing.Color.Red;
                }
                else
                {
                    lblInsuranceExpireDateText.Font.Bold = false;
                }
            }


            if (!isGPsite && cardHasEPC)
            {
                string refDate = card.DateReferralSigned == DateTime.MinValue ? "date not set" : card.DateReferralSigned.ToString("d MMM yyyy");
                string expDate = card.DateReferralSigned == DateTime.MinValue ? "date not set" : card.DateReferralSigned.AddYears(1).AddDays(-1).ToString("d MMM yyyy");
                (cardType == CardType.Medicare ? lblEPCSignedDate : (cardType == CardType.DVA ? lblDVAEPCSignedDate : lblInsuranceEPCSignedDate)).Text = refDate;
                (cardType == CardType.Medicare ? lblEPCExpireDate : (cardType == CardType.DVA ? lblDVAEPCExpireDate : lblInsuranceEPCExpireDate)).Text = expDate;



                //
                // set add/edit epc links
                //

                (cardType == CardType.Medicare ? lnkNewMedicareEPC : (cardType == CardType.DVA ? lnkNewDVAEPC : lnkNewInsuranceEPC)).Visible     = true;
                (cardType == CardType.Medicare ? lnkNewMedicareEPC : (cardType == CardType.DVA ? lnkNewDVAEPC : lnkNewInsuranceEPC)).NavigateUrl = "  ";
                (cardType == CardType.Medicare ? lnkNewMedicareEPC : (cardType == CardType.DVA ? lnkNewDVAEPC : lnkNewInsuranceEPC)).Text        = "Replace Referral";
                (cardType == CardType.Medicare ? lnkNewMedicareEPC : (cardType == CardType.DVA ? lnkNewDVAEPC : lnkNewInsuranceEPC)).Attributes.Add("onclick", js);


                if (!Utilities.IsMobileDevice(Request))
                {
                    allFeatures = "dialogWidth:550px;dialogHeight:520px;center:yes;resizable:no; scroll:no";
                    js          = "javascript:window.showModalDialog('EPCDetailV2.aspx?type=edit&id=" + card.HealthCardID.ToString() + "', '', '" + allFeatures + "');window.location=window.location;return false;";
                }
                else
                {
                    js = "open_new_tab('EPCDetailV2.aspx?type=edit&id=" + card.HealthCardID.ToString() + "');return false;";
                }

                (cardType == CardType.Medicare ? lnkEditMedicareEPC : (cardType == CardType.DVA ? lnkEditDVAEPC : lnkEditInsuranceEPC)).Visible     = true;
                (cardType == CardType.Medicare ? lnkEditMedicareEPC : (cardType == CardType.DVA ? lnkEditDVAEPC : lnkEditInsuranceEPC)).NavigateUrl = "  ";
                (cardType == CardType.Medicare ? lnkEditMedicareEPC : (cardType == CardType.DVA ? lnkEditDVAEPC : lnkEditInsuranceEPC)).Text        = "Edit Referral";
                (cardType == CardType.Medicare ? lnkEditMedicareEPC : (cardType == CardType.DVA ? lnkEditDVAEPC : lnkEditInsuranceEPC)).Attributes.Add("onclick", js);



                if (card.DateReferralSigned != DateTime.MinValue && DateTime.Now.Date >= card.DateReferralSigned.AddYears(1).Date)
                {
                    (cardType == CardType.Medicare ? lblEPCExpireDate     : (cardType == CardType.DVA ? lblDVAEPCExpireDate     : lblInsuranceEPCExpireDate)).ForeColor     = System.Drawing.Color.Red;
                    (cardType == CardType.Medicare ? lblEPCExpireDateText : (cardType == CardType.DVA ? lblDVAEPCExpireDateText : lblInsuranceEPCExpireDateText)).Text      = lblEPCExpireDateText.Text.Replace("Expires:", "*** Expired ***");
                    (cardType == CardType.Medicare ? lblEPCExpireDateText : (cardType == CardType.DVA ? lblDVAEPCExpireDateText : lblInsuranceEPCExpireDateText)).Font.Bold = true;
                    (cardType == CardType.Medicare ? lblEPCExpireDateText : (cardType == CardType.DVA ? lblDVAEPCExpireDateText : lblInsuranceEPCExpireDateText)).ForeColor = System.Drawing.Color.Red;
                }
                else
                {
                    (cardType == CardType.Medicare ? lblEPCExpireDateText : (cardType == CardType.DVA ? lblDVAEPCExpireDateText : lblInsuranceEPCExpireDateText)).Font.Bold = false;
                }



                if (cardType == CardType.Medicare)
                {
                    string lblEPCsRemainingTable = @"
                    <table border=""0"" cellspacing=""0"" cellpadding=""0"">";

                    int totalRemainingAllFields            = 0;
                    HealthCardEPCRemaining[] epcsRemaining = HealthCardEPCRemainingDB.GetByHealthCardID(card.HealthCardID, -1);
                    if (epcsRemaining.Length == 0)
                    {
                        lblEPCsRemainingTable += @"
                        <tr>
                            <td width=""18""></td>
                            <td>No service types added.</td>
                        </tr>";
                    }
                    else
                    {
                        for (int i = 0; i < epcsRemaining.Length; i++)
                        {
                            string colorStartTag = epcsRemaining[i].NumServicesRemaining > 0 ? "" : @"<font color=""red"">";
                            string colorEndTag   = epcsRemaining[i].NumServicesRemaining > 0 ? "" : @"</font>";

                            totalRemainingAllFields += epcsRemaining[i].NumServicesRemaining;
                            lblEPCsRemainingTable   += @"
                        <tr>
                            <td width=""18""></td>
                            <td>" + colorStartTag + epcsRemaining[i].Field.Descr + colorEndTag + @"</td>
                            <td width=""12""></td>
                            <td><b>" + colorStartTag + epcsRemaining[i].NumServicesRemaining + colorEndTag + @"</b></td>
                        </tr>";
                        }
                    }
                    lblEPCsRemainingTable += @"
                    </table>";

                    lblEPCsRemaining.Text = lblEPCsRemainingTable;

                    EPCInfo epcInfo = EPCInfoDB.GetEPCInfo(card.Patient.PatientID);
                    lblCombinedEPCRemainingThisYear.Text = (totalRemainingAllFields < epcInfo.RamainingThisYear) ? totalRemainingAllFields.ToString() : epcInfo.RamainingThisYear.ToString();
                    lblCombinedEPCUsedThisYear.Text      = epcInfo.NbrMedicareServicesUsedSoFarThisYear.ToString();
                    lblCombinedEPCRemainingNextYear.Text = (totalRemainingAllFields < epcInfo.RamainingThisYear) ? "0" : epcInfo.RemainingNextYear.ToString();
                    if (Convert.ToInt32(lblCombinedEPCRemainingThisYear.Text) <= 0)
                    {
                        lblCombinedEPCRemainingThisYear.ForeColor     = System.Drawing.Color.Red;
                        lblCombinedEPCRemainingThisYearText.Font.Bold = true;
                        lblCombinedEPCRemainingThisYearText.ForeColor = System.Drawing.Color.Red;
                    }
                    if (Convert.ToInt32(lblCombinedEPCRemainingNextYear.Text) <= 0)
                    {
                        spn_combined_epc_remaining_next_year.Visible = false;
                    }

                    bool expired = (card.DateReferralSigned != DateTime.MinValue && DateTime.Now.Date >= card.DateReferralSigned.AddYears(1).Date);
                    if (expired)
                    {
                        lblCombinedEPCRemainingThisYear.Text = "0";
                        lblCombinedEPCRemainingNextYear.Text = "0";
                    }
                }
            }
        }
    }