Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: AMHRAS4

AMHRAS4.m

Go to the documentation of this file.
  1. AMHRAS4 ; IHS/CMI/LAB - list ALCOHOL ;
  1. ;;4.0;IHS BEHAVIORAL HEALTH;**6**;JUN 02, 2010;Build 10
  1. ;
  1. ;
  1. INFORM ;
  1. W !,$$CTR($$USR)
  1. W !,$$CTR($$LOC())
  1. W !!,"*Please Note: This ALCOHOL report is intended for advanced RPMS users"
  1. W !,"who are experienced in building search templates and using Q-MAN."
  1. W !!,$$CTR("TALLY AND LISTING OF PATIENT'S RECEIVING ALCOHOL SCREENING, INCLUDING REFUSALS",80)
  1. W !,$$CTR("ONLY PATIENTS WHO ARE MEMBERS OF A USER DEFINED SEARCH TEMPLATE",80)
  1. W !,$$CTR("ARE INCLUDED IN THIS REPORT",80)
  1. W !!,"This report will tally and list all patients who are members of"
  1. W !,"a user defined search template. It will tally and list their latest"
  1. W !,"ALCOHOL screening or a refusal documented in the time frame specified by "
  1. W !,"the user. Alcohol Screening is defined as any of the following documented:"
  1. W !?5,"- Alcohol Screening Exam (Exam code 35)"
  1. W !?5,"- Measurements: AUDC, AUDT, CRFT"
  1. W !?5,"- Health Factor with Alcohol/Drug Category (CAGE)"
  1. W !?5,"- Diagnoses V79.1, 29.1"
  1. W !?5,"- Education Topics: AOD-SCR, CD-SCR"
  1. W !?5,"- CPT Codes: 99408, 99409, G0396, G0397, H0049"
  1. W !?5,"- refusal of exam code 35"
  1. D PAUSE^AMHLEA W !!
  1. W !,"This report will tally the patients by age, gender, screening exam result,"
  1. W !,"provider (either exam provider, if available, or primary provider on the "
  1. W !,"visit), clinic, date of screening, designated PCP, MH Provider, SS Provider"
  1. W !,"and A/SA Provider."
  1. W !," Notes: "
  1. W !?10,"- the last screening/refusal for each patient is used. If a patient"
  1. W !?10," was screened more than once in the time period, only the latest"
  1. W !?10," is used in this report."
  1. W !?10,"- this report will optionally, look at both PCC and the Behavioral"
  1. W !?10," Health databases for evidence of screening/refusal"
  1. W !?10,"- this is a tally of Patients, not visits or screenings"
  1. W !
  1. D PAUSE^AMHLEA,DBHUSR^AMHUTIL
  1. D XIT
  1. S AMHREXC=$O(^AUTTEXAM("C",35,0))
  1. I 'AMHREXC W !!,"Exam code 35 is missing from the EXAM table. Cannot run report.",! H 3 D XIT Q
  1. ;
  1. DATES K AMHRED,AMHRBD
  1. W !,"Please enter the date range during which the screening was done.",!,"To get all screenings ever put in a long date range like 01/01/1980 ",!,"to the present date.",!
  1. K DIR W ! S DIR(0)="DO^::EXP",DIR("A")="Enter Beginning Date for Screening"
  1. D ^DIR Q:Y<1 S AMHRBD=Y
  1. K DIR S DIR(0)="DO^:DT:EXP",DIR("A")="Enter Ending Date for Screening"
  1. D ^DIR Q:Y<1 S AMHRED=Y
  1. ;
  1. I AMHRED<AMHRBD D G DATES
  1. . W !!,$C(7),"Sorry, Ending Date MUST not be earlier than Beginning Date."
  1. ;
  1. STMP ;
  1. S AMHRSEAT=""
  1. W ! S DIC("S")="I $P(^(0),U,4)=9000001!($P(^(0),U,4)=2)" S DIC="^DIBT(",DIC("A")="Enter Patient SEARCH TEMPLATE name: ",DIC(0)="AEMQ" D ^DIC K DIC,DA,DR,DICR
  1. I Y=-1 G DATES
  1. S AMHRSEAT=+Y
  1. ;
  1. TALLY ;which items to tally
  1. K AMHRTALL
  1. W !!,"Please select which items you wish to tally on this report:",!
  1. W !?3,"0) Do not include any Tallies",?40,"6) Date of Screening"
  1. W !?3,"1) Type/Result of Screening",?40,"7) Primary Provider on Visit"
  1. W !?3,"2) Gender",?40,"8) Designated MH Provider"
  1. W !?3,"3) Age of Patient",?40,"9) Designated SS Provider"
  1. W !?3,"4) Provider who Screened",?40,"10) Designated ASA/CD Provider"
  1. W !?3,"5) Clinic",?40,"11) Designated Primary Care Provider"
  1. K DIR S DIR(0)="L^0:11",DIR("A")="Which items should be tallied",DIR("B")="" KILL DA D ^DIR KILL DIR
  1. I $D(DIRUT) G DATES
  1. I Y="" G DATES
  1. S AMHRTALL=Y
  1. S A=Y,C="" F I=1:1 S C=$P(A,",",I) Q:C="" S AMHRTALL(C)=""
  1. EXCL ;
  1. S AMHREXPC=""
  1. W !!,"Would you like to include ALCOHOL Screenings documented in the PCC clinical"
  1. S DIR(0)="Y",DIR("A")="database",DIR("B")="N" KILL DA D ^DIR KILL DIR
  1. I $D(DIRUT) G DATES
  1. S AMHREXPC=Y
  1. LIST ;
  1. S AMHRLIST=""
  1. W !
  1. S DIR(0)="Y",DIR("A")="Would you like to include a list of patients screened",DIR("B")="Y" KILL DA D ^DIR KILL DIR
  1. I $D(DIRUT) G DATES
  1. S AMHRLIST=Y
  1. I 'AMHRLIST G DEMO
  1. LIST1 ;
  1. S AMHRSORT=""
  1. W !
  1. S DIR(0)="S^H:Health Record Number;N:Patient Name;P:Provider who screened;C:Clinic;R:Result of Exam;D:Date Screened;A:Age of Patient at Screening;G:Gender of Patient;T:Terminal Digit HRN"
  1. S DIR("A")="How would you like the list to be sorted",DIR("B")="H"
  1. KILL DA D ^DIR KILL DIR
  1. I $D(DIRUT) G LIST
  1. S AMHRSORT=Y
  1. DP ;
  1. S AMHRDP=""
  1. W !
  1. S DIR(0)="Y",DIR("A")="Display the Patient's Designated Providers on the list",DIR("B")="N" KILL DA D ^DIR KILL DIR
  1. I $D(DIRUT) G LIST
  1. S AMHRDP=Y
  1. DEMO ;
  1. D DEMOCHK^AMHUTIL1(.AMHDEMO)
  1. I AMHDEMO=-1 G LIST
  1. ZIS ;
  1. S XBRP="PRINT^AMHRAS4P",XBRC="PROC^AMHRAS4",XBRX="XIT^AMHRAS4",XBNS="AMHR"
  1. D ^XBDBQUE
  1. D XIT
  1. Q
  1. XIT ;
  1. D EN^XBVK("AMHR")
  1. D ^XBFMK
  1. Q
  1. PROC ;
  1. S AMHRCNT=0
  1. S AMHRH=$H,AMHRJ=$J
  1. K ^XTMP("AMHRAS4",AMHRJ,AMHRH)
  1. D XTMP^AMHUTIL("AMHRAS4","ALCOHOL SCREENING REPORT")
  1. ;now go through BH
  1. S DFN=0 F S DFN=$O(^DIBT(AMHRSEAT,1,DFN)) Q:DFN'=+DFN D
  1. .Q:'$$ALLOWP^AMHUTIL(DUZ,DFN) ;allowed to see this patient?
  1. .Q:$$DEMO^AMHUTIL1(DFN,$G(AMHDEMO))
  1. .S AMHALSC=$$BHALCS^AMHRAS1(DFN,AMHRBD,AMHRED),AMHPFI="BH" ;include refusals
  1. .S AMHPCALS="" I AMHREXPC S AMHPCALS=$$PCCALCS^AMHRAS1(DFN,AMHRBD,AMHRED) ;include refusals
  1. .I $P(AMHPCALS,U,1)>$P(AMHALSC,U,1) S AMHALSC=AMHPCALS,AMHPFI="PCC"
  1. .S AMHREFS="" I AMHREXPC S AMHREFS=$$REFUSAL^AMHRAS1(DFN,9999999.15,$O(^AUTTEXAM("C",35,0)),AMHRBD,AMHRED)
  1. .I $P(AMHREFS,U,1)>$P(AMHALSC,U,1) S AMHALSC=AMHREFS,AMHPFI="PCC"
  1. .I AMHALSC="" Q ;no screenings
  1. .S ^XTMP("AMHRAS4",AMHRJ,AMHRH,"PTS",DFN)=AMHALSC,$P(^XTMP("AMHRAS4",AMHRJ,AMHRH,"PTS",DFN),U,20)=AMHPFI
  1. Q
  1. ;
  1. BHPPNAME(R) ;EP primary provider internal # from 200
  1. NEW %,%1
  1. S %=0,%1="" F S %=$O(^AMHRPROV("AD",R,%)) Q:%'=+% I $P(^AMHRPROV(%,0),U,4)="P" S %1=$P(^AMHRPROV(%,0),U),%1=$P($G(^VA(200,%1,0)),U)
  1. I %1]"" Q %1
  1. Q "UNKNOWN"
  1. SPRV(E) ;
  1. I $P($G(^AUPNVXAM(E,12)),U,4) Q $$VAL^XBDIQ1(9000010.13,E,1204)
  1. Q "UNKNOWN"
  1. PRVREF(R) ;
  1. I $P($G(^AUPNPREF(R,12)),U,4)]"" Q $$VAL^XBDIQ1(9000022,R,1204)
  1. Q "UNKNOWN"
  1. PPV(V) ;
  1. NEW %
  1. S %=$$PRIMPROV^APCLV(V)
  1. I %]"" Q %
  1. Q "UNKNOWN"
  1. CTR(X,Y) ;EP - Center X in a field Y wide.
  1. Q $J("",$S($D(Y):Y,1:IOM)-$L(X)\2)_X
  1. ;----------
  1. EOP ;EP - End of page.
  1. Q:$E(IOST)'="C"
  1. Q:IO'=IO(0)
  1. Q:$D(ZTQUEUED)!'(IOT="TRM")!$D(IO("S"))
  1. NEW DIR
  1. K DIRUT,DFOUT,DLOUT,DTOUT,DUOUT
  1. W !
  1. S DIR("A")="End of Report. Press Enter",DIR(0)="E" D ^DIR
  1. Q
  1. ;----------
  1. USR() ;EP - Return name of current user from ^VA(200.
  1. Q $S($G(DUZ):$S($D(^VA(200,DUZ,0)):$P(^(0),U),1:"UNKNOWN"),1:"DUZ UNDEFINED OR 0")
  1. ;----------
  1. LOC() ;EP - Return location name from file 4 based on DUZ(2).
  1. Q $S($G(DUZ(2)):$S($D(^DIC(4,DUZ(2),0)):$P(^(0),U),1:"UNKNOWN"),1:"DUZ(2) UNDEFINED OR 0")
  1. ;----------