AHIRM001        ;NC/RLP  Interface for Computed Field Reminders       16-Oct-00
        ;
        ; --- Note the routine AFJREM is for the VISN Computed Reminders
        ; --- Routine AHIRM001 is for North Chicago Computed Reminders
        ;
        ; --- Do not Modify routine AHIRM001.  Modify AHIRM002.  When
        ; --- everything is ok, then save as AHIRM001.
        ;
        ; --- Resolution Logic to Resolve Reminder(s)
        ; --- Page 163 in the Clinical Reminders Manager Manual
        ;=======================================================================
        ;
        ; --- has the patient been 'Educated' on 'Advanced Directives'?
        ; --- Check TIU(8925,"AA",dfn,nnnn,rev dt,ien)
        ; --- if nnnn=(8,27,136,245,246,247,248,250)
        ; --- --- then var TEST=1 for True
        ;
ADDIR(DFN,TEST,DATE,VALUE,TEXT) ;
        ;
        N HIT,LOOP,REVDT
        S DATE="",HIT=0,TEST=0
        ;
        F LOOP=8,27,136,243,245,246,247,248,250,2391 D  Q:HIT  ;
        . I $D(^TIU(8925,"AA",DFN,LOOP)) S REVDT=$O(^(LOOP,"")),HIT=1
        . I HIT S DATE=9999999-REVDT,TEST=1
        Q
        ;=======================================================================
        ; --- NCH/rlp 10-Jun-02   per: Rhonda P (CAC)
        ; --- Does the Patient have a 'Podiatry Pact Foot' note?
        ; --- File: TIU DOCUMENT DEFINITION LIST   ^TIU(8925.1,
        ; --- Entry: PODIATRY PACT FOOT SCREENING  IEN:2043
        ;
PODIATRY(DFN,TEST,DATE,VALUE,TEXT)      ;
        ;
        N HIT,REVDT,TIUDOC
        S DATE="",HIT=0,TEST=0
        ;
        S TIUDOC=2043
        ;
        I $D(^TIU(8925,"AA",DFN,TIUDOC)) S REVDT=$O(^(TIUDOC,"")),HIT=1
        I HIT S DATE=9999999-REVDT,TEST=1
        Q
        ;=======================================================================
        ; --- NCH/rlp ??-???-02   per: Rhonda P (CAC)
        ; --- Has the patient been 'Educated' on 'MH Treatment Plan'?
        ; --- File: TIU DOCUMENT DEFINITION LIST   ^TIU(8925.1,
        ; --- obsolete MH TREATMENT & EDUCATION PLAN - OUTPATIENT  IEN:2426
        ; --- MH TREATMENT PLAN - OUTPATIENT   IEN:1262
        ; --- Per Rhonda P, No longer use IEN:2426 instead use IEN:1262
        ; --- Modified on 18-Nov-02
        ;
MHEDU(DFN,TEST,DATE,VALUE,TEXT) ;
        ;
        N HIT,REVDT,TIUDOC
        S DATE="",HIT=0,TEST=0
        ;
        S TIUDOC=1262
        ;
        I $D(^TIU(8925,"AA",DFN,TIUDOC)) S REVDT=$O(^(TIUDOC,"")),HIT=1
        I HIT S DATE=9999999-REVDT,TEST=1
        Q
        ;=======================================================================
        ; --- NCH/rlp/ml 11-Oct-02   per: Rhonda P (CAC)
        ; --- Does the Patient have an Egg or Influenza Allergy?
        ; --- If so, do not administer the Flu shot.
        ; --- File: PATIENT ALLERGIES  ^GMR(120.8
        ; --- Field: REACTANT  .02   Contain the word EGGS
        ;
EGGS(DFN,TEST,DATE,VALUE,TEXT)   ;
        ;Uses AAR
        S TEST=0,TEXT="no"
        D AAR("EGGS")
        S:TEST TEXT="yes"
        Q
        ;=======================================================================
        ; --- NCH/rlp/ml 11-Oct-02   per: Rhonda P (CAC)
        ; --- Does the Patient have an Egg or Influenza Allergy?
        ; --- If so, do not administer the Flu shot.
        ; --- File: PATIENT ALLERGIES  ^GMR(120.8
        ; --- Field: REACTANT  .02   Contain the word INFLUENZA
        ;
INFLU(DFN,TEST,DATE,VALUE,TEXT)  ;
        ;Uses AAR
        S TEST=0,TEXT="no"
        D AAR("INFLUENZA")
        S:TEST TEXT="yes"
        Q
        ;=======================================================================
        ; --- NCH/rlp  25-Oct-02   per: Rhonda P (CAC)
        ; --- Does the patient have a TETANUS allergy?
        ; --- File:  PATIENT ALLERGIES  ^GMR(120.8
        ; --- Field: REACTANT  .02   Contain the word Tetanus
        ;
TETANUS(DFN,TEST,DATE,VALUE,TEXT)
        ;
        ;Uses AAR
        S TEST=0,TEXT="no"
        D AAR("TETANUS")
        S:TEST TEXT="yes"
        Q
        ;=======================================================================
AAR(ADN)        ;Patient Has ALLERGY/DISORDER NAME? ;2/16/01
        ;ADN = ALLERGY/DISORDER NAME
        N AA,O,X
        D LIST^ORQQAL(.AA,DFN)
        S O="" F  S O=$O(AA(O)) Q:O=""  D  Q:TEST=1
        .S X=AA(O)
        .I $P(X,"^",2)[ADN S TEST=1,DATE=DT
        Q
        ;=======================================================================
        ;
        ; --- NCH/rlp 19-Feb-02  per: Rhonda P (CAC)
        ; --- Is there a 'SGRC RESIDENT RIGHTS AND RESPONSIBILITIES'
        ; ---   note for the patient?
        ; --- File: TIU DOCUMENT DEFINITION LIST   ^TIU(8925.1,
        ; --- Entry: SGRC RESIDENT RIGHTS AND RESPONSIBILITIES  IEN:2411
        ; ---------------------------------------------------------------
        ;
SGRCRRR(DFN,TEST,DATE,VALUE,TEXT)       ;
        ;
        N HIT,REVDT,TIUDOC
        S DATE="",HIT=0,TEST=0
        ;
        S TIUDOC=2411
        ;
        I $D(^TIU(8925,"AA",DFN,TIUDOC)) S REVDT=$O(^(TIUDOC,"")),HIT=1
        I HIT S DATE=9999999-REVDT,TEST=1
        Q
        ;======================================================================
        ;
        ; --- NCH/rlp Apr-03  per: Rhonda Paulson (CAC)
        ; --- Does patient have at least 3 Smoking Cessation (1836,
        ; --- 1384, 1426, 1884, 1888, 2430) Titles within 365 days?
        ; --- File: The 6 entries in TIU DOCUMENT DEFINITION LIST ^TIU(8925.1
        ; -------------------------------------------------------------------
        ;
SMOKING(DFN,TEST,DATE,VALUE,TEXT)       ;
        ;
        N ANVRSYDT,COUNT,DOCIEN,ENTDATE,REVDATE,X1,X2
        ;
COUNT   S COUNT=0,DATE="",TEST=0,TEXT="Tobacco Cessation Note NEEDED"
        S X1=DT,X2=-365 D C^%DTC S ANVRSYDT=X
        ;
        F TIUDOC=1384,1426,1836,1884,1888,2430 D  ;
        . I $D(^TIU(8925,"AA",DFN,TIUDOC)) D  ;
        . . S REVDATE=0
        . . F  S REVDATE=$O(^TIU(8925,"AA",DFN,TIUDOC,REVDATE)) Q:'REVDATE  D  ;
RR      . . . S DOCIEN=0
        . . . F  S DOCIEN=$O(^TIU(8925,"AA",DFN,TIUDOC,REVDATE,DOCIEN)) Q:'DOCIE
N  D  ;
        . . . . I $D(^TIU(8925,DOCIEN,12)) D  ;
        . . . . . S ENTDATE=$P(^TIU(8925,DOCIEN,12),U,1)
        . . . . . I ENTDATE'<ANVRSYDT S COUNT=COUNT+1 I COUNT=1 S DATE=ENTDATE
        I COUNT>2 S TEST=1,VALUE=COUNT,TEXT="Tobacco Cessation notes have been c
ompleted  within the last 365 days"
        Q
        ;======================================================================
        ;
        ; --- NCH/rlp 30-Oct-03  per: Rhonda Paulson (CAC)
        ; --- Does the Patient have a 'OTC/HERBAL/NON-VA MEDS' note?
        ; --- File: TIU DOCUMENT DEFINITION LIST   ^TIU(8925.1,
        ; --- Entry: OTC/HERBAL/NON-VA MEDS   IEN:2575
        ;
OTCMEDS(DFN,TEST,DATE,VALUE,TEXT)       ;
        ;
        N HIT,REVDT,TIUDOC
        S DATE="",HIT=0,TEST=0
        ;
        S TIUDOC=2575
        ;
        I $D(^TIU(8925,"AA",DFN,TIUDOC)) S REVDT=$O(^(TIUDOC,"")),HIT=1
        I HIT S DATE=9999999-REVDT,TEST=1
        Q
        ;=====================================================================