app/helpers/equity_helper.rb
#list hbv patients related to the given equity measure
list hbv patients related to the given equity measure
list hbv patients related to the given equity measure
def list_hbv_equity_patients(eq_id)
    @patients = []
    if(eq_id == 'hbv_test')
      @equity = Equity.new(:condition_code => C_HBV_CODE, :measure_code =>M_CODE_HBV_TEST, :measure_name => M_NAME_HBV_TEST)
      Patient.all.each do |patient|
        patient.eqconditions.each do |c|
          if(c.code == C_HBV_CODE)
            if(at_risk_hbv(patient.profile))
              @equity.expected_count += 1
              if c.test_status != TEST_STATUS_UNTESTED
                @equity.actual_count += 1
                patient.eqmeasure_meet_gl = true
              else
                patient.eqmeasure_meet_gl = false
              end
              @patients.push(patient)
            end
          end
        end
      end
    elsif(eq_id == 'hbv_vaccine')
      @equity = Equity.new(:condition_code => C_HBV_CODE, :measure_code =>M_CODE_HBV_VACCINE, :measure_name => M_NAME_HBV_VACCINE)
      Patient.all.each do |patient|
        patient.eqconditions.each do |c|
          if(c.code == C_HBV_CODE)
            if(c.test_status == TETS_STATUS_SUSCEPTIBLE )  
              @equity.expected_count += 1
              @patients.push(patient)
            else
              get_hbv_guidelines(patient.profile).each do |g|
                if g.vaccine_needed
                  @equity.expected_count += 1
                  @patients.push(patient)
                  break
                end
              end
            end
            c.eqvaccines.each do |v|
              if v.targetcon == "hbv"
                @equity.actual_count += 1
                patient.eqmeasure_meet_gl = true
                break
              end
            end
          end
        end
      end
    elsif(eq_id == 'hbv_monitor')
      @equity = Equity.new(:condition_code => C_HBV_CODE, :measure_code =>M_CODE_HBV_MONITOR, :measure_name => M_NAME_HBV_MONITOR)
      Patient.all.each do |patient|
        patient.eqconditions.each do |c|
          if(c.code == C_HBV_CODE)
            if(c.test_status == TEST_STATUS_INFECTED_CHRONIC )  
              @equity.expected_count += 1
              @patients.push(patient)
            end
            if(c.hbv.eqtests.length > 0)  
              @equity.actual_count += 1
              patient.eqmeasure_meet_gl = true
            end
          end
        end
      end
    elsif(eq_id == 'hbv_treatment')
      @equity = Equity.new(:condition_code => C_HBV_CODE, :measure_code =>M_CODE_HBV_TREAT, :measure_name => M_NAME_HBV_TREAT)
      Patient.all.each do |patient|
        patient.eqconditions.each do |c|
          if(c.code == C_HBV_CODE)
            if(c.test_status == TEST_STATUS_INFECTED_CHRONIC )  
              @equity.expected_count += 1
              @patients.push(patient)
            end
            if(c.eqtreatments.length > 0)  
              @equity.actual_count += 1
              patient.eqmeasure_meet_gl = true
            end
          end
        end
      end
    else
      @equity = Equity.new
    end
    cal_percentage(@equity)
  end
def list_hbv_equity_patients ( eq_id ) @patients = [ ] if ( eq_id == 'hbv_test' ) @equity = Equity . new ( :condition_code => C_HBV_CODE , :measure_code => M_CODE_HBV_TEST , :measure_name => M_NAME_HBV_TEST ) Patient . all . each do | patient | patient . eqconditions . each do | c | if ( c . code == C_HBV_CODE ) if ( at_risk_hbv ( patient . profile ) ) @equity . expected_count += 1 if c . test_status != TEST_STATUS_UNTESTED @equity . actual_count += 1 patient . eqmeasure_meet_gl = true else patient . eqmeasure_meet_gl = false end @patients . push ( patient ) end end end end elsif ( eq_id == 'hbv_vaccine' ) @equity = Equity . new ( :condition_code => C_HBV_CODE , :measure_code => M_CODE_HBV_VACCINE , :measure_name => M_NAME_HBV_VACCINE ) Patient . all . each do | patient | patient . eqconditions . each do | c | if ( c . code == C_HBV_CODE ) if ( c . test_status == TETS_STATUS_SUSCEPTIBLE ) @equity . expected_count += 1 @patients . push ( patient ) else get_hbv_guidelines ( patient . profile ) . each do | g | if g . vaccine_needed @equity . expected_count += 1 @patients . push ( patient ) break end end end c . eqvaccines . each do | v | if v . targetcon == "hbv" @equity . actual_count += 1 patient . eqmeasure_meet_gl = true break end end end end end elsif ( eq_id == 'hbv_monitor' ) @equity = Equity . new ( :condition_code => C_HBV_CODE , :measure_code => M_CODE_HBV_MONITOR , :measure_name => M_NAME_HBV_MONITOR ) Patient . all . each do | patient | patient . eqconditions . each do | c | if ( c . code == C_HBV_CODE ) if ( c . test_status == TEST_STATUS_INFECTED_CHRONIC ) @equity . expected_count += 1 @patients . push ( patient ) end if ( c . hbv . eqtests . length > 0 ) @equity . actual_count += 1 patient . eqmeasure_meet_gl = true end end end end elsif ( eq_id == 'hbv_treatment' ) @equity = Equity . new ( :condition_code => C_HBV_CODE , :measure_code => M_CODE_HBV_TREAT , :measure_name => M_NAME_HBV_TREAT ) Patient . all . each do | patient | patient . eqconditions . each do | c | if ( c . code == C_HBV_CODE ) if ( c . test_status == TEST_STATUS_INFECTED_CHRONIC ) @equity . expected_count += 1 @patients . push ( patient ) end if ( c . eqtreatments . length > 0 ) @equity . actual_count += 1 patient . eqmeasure_meet_gl = true end end end end else @equity = Equity . new end cal_percentage ( @equity ) end
list hbv patients related to the given equity measure
list hbv patients related to the given equity measure
#scan for now; should do search later #check risk #scan for now; should do search later #check vaccined/vaccine-needed #need vaccine #scan for now; should do search later #check monitoring #need monitoring # has test #scan for now; should do search later #check treatment #need monitoring # has treatment
eq_id
<not_specific>