app/helpers/eqconditions_helper.rb
#auto-create condition if being cared or at risk
auto-create condition if being cared or at risk
auto - create condition if being cared or at risk
def auto_create_condition(patient, profile)
    begin
      @cons = {}
      if (profile.hbv_cared || at_risk_hbv(profile)) && !patient_has_condition(patient, C_HBV_CODE)
        @eqcondition = patient.eqconditions.create!(code: C_HBV_CODE, name: C_HBV_NAME)
        @eqcondition.create_hbv()
        @cons[@eqcondition.id] = C_HBV_NAME
        puts "created condition: "+C_HBV_CODE
      end
      if (profile.hcv_positive || at_risk_hcv(profile)) && !patient_has_condition(patient, C_HCV_CODE)
        @eqcondition = patient.eqconditions.create!(code: C_HCV_CODE, name: C_HCV_NAME)
        @eqcondition.create_hcv()
        @cons[@eqcondition.id] = C_HCV_NAME
        puts "created condition: "+C_HCV_CODE
      end
      return @cons
    rescue Exception => e
      puts "failed to auto-create condition: "+e.message
    end
  end
def auto_create_condition ( patient , profile ) begin @cons = { } if ( profile . hbv_cared || at_risk_hbv ( profile ) ) && ! patient_has_condition ( patient , C_HBV_CODE ) @eqcondition = patient . eqconditions . create! ( code : C_HBV_CODE , name : C_HBV_NAME ) @eqcondition . create_hbv ( ) @cons [ @eqcondition . id ] = C_HBV_NAME puts "created condition: " + C_HBV_CODE end if ( profile . hcv_positive || at_risk_hcv ( profile ) ) && ! patient_has_condition ( patient , C_HCV_CODE ) @eqcondition = patient . eqconditions . create! ( code : C_HCV_CODE , name : C_HCV_NAME ) @eqcondition . create_hcv ( ) @cons [ @eqcondition . id ] = C_HCV_NAME puts "created condition: " + C_HCV_CODE end return @cons rescue Exception => e puts "failed to auto-create condition: " + e . message end end
auto-create condition if being cared or at risk
auto - create condition if being cared or at risk
#if hbv tested or at risk and hbv condition not created # hcv positive or hcv rick
patient
<not_specific>
profile
<not_specific>