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

AMHRPTP.m

Go to the documentation of this file.
AMHRPTP ; IHS/CMI/LAB - PRINT VISIT REPORT ;
 ;;4.0;IHS BEHAVIORAL HEALTH;;MAY 14, 2010
 ;
START ;EP
 ;Set up header line, dash line.
 S X=0,AMHHEAD="" F  S X=$O(^AMHTRPT(AMHRPT,12,X)) Q:X'=+X  S AMHHDR=$P(^AMHSORT($P(^AMHTRPT(AMHRPT,12,X,0),U),0),U,6),AMHLENG=$P(^AMHTRPT(AMHRPT,12,X,0),U,2),AMHHDR=$E(AMHHDR,1,AMHLENG) D
 .S J=$L(AMHHDR),AMHHEAD=AMHHEAD_AMHHDR,K=$P(^AMHTRPT(AMHRPT,12,X,0),U,2)+1 F I=J:1:K S AMHHEAD=AMHHEAD_" "
 .Q
 S AMHDASH="",$P(AMHDASH,"-",AMHTCW)="-"
 D COVPAGE^AMHRPTCP ;print cover page - note: if user ^'s out of cover page, processing continues
PROC ;process printing of report
 S AMHPG=0 I '$D(^XTMP("AMHRPT",AMHJOB,AMHBTH)) G DONE
 S (AMHSORT,AMHFRST)="" K AMHQUIT
 S AMHRCNT=0 F  S AMHSORT=$O(^XTMP("AMHRPT",AMHJOB,AMHBTH,"RECORDS",AMHSORT)) Q:AMHSORT=""!($D(AMHQUIT))  D V
 G:$D(AMHQUIT) DONE
 I $Y>(IOSL-3) D HEAD G:$D(AMHQUIT) DONE
 W:$D(AMHRCNT) !!!,"TOTAL Visits:  ",AMHRCNT
DONE ;
 D DONE^AMHLEIN,^AMHEKL
 K ^XTMP("AMHRPT",AMHJOB,AMHBT)
 D DEL^AMHRPT
 K AMHBD,AMHSD,AMHED,AMHEDD,AMHBDD,AMHRPT,AMHHEAD,AMHLINE,AMHL,AMHRCNT,AMHI,AMHCRIT,AMHR,AMHR0,AMHJOB,AMHBTH,AMHQUIT,AMHHDR,AMHDASH,AMHLENG,AMHPCNT,AMHTCW,AMHODAT,AMHPG,AUPNDAYS,AUPNPAT,AUPNDOD,AUPNDOB,AUPNSEX
 K AMHSORT,AMHSRT,AMHSORX,AMHFILE,AMHFIEL,AMHPRNT,AMHX,AMHTYPE,AMHFOUN,D0,J,K,L,AMHPRNM,AMHTEST,AMHSEAT,AMHLHDR,AMHFRST
 Q
V ;GETS RECORDS
 S AMHSCNT=0
 I $G(AMHSPAG)!($D(AMHFRST)) D HEAD Q:$D(AMHQUIT)
 K AMHFRST
 S AMHR=0 F  S AMHR=$O(^XTMP("AMHRPT",AMHJOB,AMHBTH,"RECORDS",AMHSORT,AMHR)) Q:AMHR'=+AMHR!($D(AMHQUIT))   S AMHR0=^AMHREC(AMHR,0) D PRINT
 Q:$D(AMHQUIT)
 I $Y>(IOSL-3) D HEAD Q:$D(AMHQUIT)
 W:$G(AMHSPAG) !!!,"SUB-TOTAL for ",AMHSORV," ",AMHSORT,":  ",AMHSCNT
 Q
PRINT ;
 S:$G(AMHSPAG) AMHSCNT=AMHSCNT+1
 K AMHLINE S AMHLINE(1)="",AMHL=1
 I $Y>(IOSL-5) D HEAD Q:$D(AMHQUIT)
 S AMHRCNT=AMHRCNT+1
 S AMHI=0 F  S AMHI=$O(^AMHTRPT(AMHRPT,12,AMHI)) Q:AMHI'=+AMHI!($D(AMHQUIT))  S AMHCRIT=$P(^AMHTRPT(AMHRPT,12,AMHI,0),U) D
 .I '$P(^AMHSORT(AMHCRIT,0),U,8) D SINGLE Q
 .D MULT
 .Q
 I $Y>(IOSL-(AMHL+3)) D HEAD Q:$D(AMHQUIT)
 S X=0 F  S X=$O(AMHLINE(X)) Q:X'=+X  W !,AMHLINE(X)
 Q
SINGLE ;process single valued item
 S AMHPRNT=""
 X:$D(^AMHSORT(AMHCRIT,3)) ^(3)
 S AMHLENG=$P(^AMHTRPT(AMHRPT,12,AMHI,0),U,2),AMHPRNT=$E(AMHPRNT,1,AMHLENG) D
 .S J=$L(AMHPRNT),AMHLINE(1)=AMHLINE(1)_AMHPRNT,K=$P(^AMHTRPT(AMHRPT,12,AMHI,0),U,2)+1 F I=J:1:K S AMHLINE(1)=AMHLINE(1)_" "
 .S X=1 F  S X=$O(AMHLINE(X)) Q:X'=+X  I $L(AMHLINE(X))<$L(AMHLINE(1)) S K=$L(AMHLINE(X))+1,J=$L(AMHLINE(1)) F I=K:1:J S AMHLINE(X)=AMHLINE(X)_" "
 Q
MULT ;
 K AMHPRNT,AMHPRNM S (AMHX,AMHPCNT)=0,AMHL=1
 X:$D(^AMHSORT(AMHCRIT,3)) ^(3)
 I '$D(AMHPRNM) S AMHPRNT="--" D
 .S AMHLENG=$P(^AMHTRPT(AMHRPT,12,AMHI,0),U,2),AMHPRNT=$E(AMHPRNT,1,AMHLENG) D
 ..S J=$L(AMHPRNT),AMHLINE(1)=AMHLINE(1)_AMHPRNT,K=$P(^AMHTRPT(AMHRPT,12,AMHI,0),U,2)+1 F I=J:1:K S AMHLINE(1)=AMHLINE(1)_" "
 S X=0 F  S X=$O(AMHPRNM(X)) Q:X'=+X  D
 .I X=1 D  Q
 ..S AMHLENG=$P(^AMHTRPT(AMHRPT,12,AMHI,0),U,2),AMHPRNT=$E(AMHPRNM(1),1,AMHLENG) D
 ...S J=$L(AMHPRNT),AMHLINE(1)=AMHLINE(1)_AMHPRNT,K=$P(^AMHTRPT(AMHRPT,12,AMHI,0),U,2)+1 F I=J:1:K S AMHLINE(1)=AMHLINE(1)_" "
 .S AMHLENG=$P(^AMHTRPT(AMHRPT,12,AMHI,0),U,2),AMHPRNT=$E(AMHPRNM(X),1,AMHLENG) D
 ..I '$D(AMHLINE(X)) S AMHLINE(X)="",K=$P(^AMHTRPT(AMHRPT,12,AMHI,0),U,2)+1,$P(AMHLINE(X)," ",($L(AMHLINE(1))-K))=""
 ..S J=$L(AMHPRNT),AMHLINE(X)=AMHLINE(X)_AMHPRNT,K=$P(^AMHTRPT(AMHRPT,12,AMHI,0),U,2)+1 F I=J:1:K S AMHLINE(X)=AMHLINE(X)_" "
 S X=1 F  S X=$O(AMHLINE(X)) Q:X'=+X  I $L(AMHLINE(X))<$L(AMHLINE(1)) S K=$L(AMHLINE(X))+1,J=$L(AMHLINE(1)) F I=K:1:J S AMHLINE(X)=AMHLINE(X)_" "
 Q
DIQ ;
 K AMHPRNT,AMHFILE,AMHFIEL
 S AMHFILE=$P($P(^AMHSORT(AMHCRIT,0),U,4),","),AMHFIEL=$P($P(^(0),U,4),",",2)
 S DIQ(0)="EN",DIQ="AMHPRNT(",DIC=AMHFILE,DR=AMHFIEL D EN^DIQ1 K DIC,DR,DIQ
 I '$D(AMHPRNT(AMHFILE,DA,AMHFIEL,"E")) S AMHPRNT(AMHFILE,DA,AMHFIEL,"E")="--"
 S AMHPRNT=AMHPRNT(AMHFILE,DA,AMHFIEL,"E")
 Q
 I 'AMHPG G HEAD1
 I $E(IOST)="C",IO=IO(0) W ! S DIR(0)="EO" D ^DIR K DIR I Y=0!(Y="^")!($D(DTOUT)) S AMHQUIT="" Q
HEAD1 ;
 W:$D(IOF) @IOF S AMHPG=AMHPG+1
 W !?13,"********** CONFIDENTIAL PATIENT INFORMATION **********"
 S AMHTEXT="BEHAVIORAL HEALTH RECORD LISTING",AMHLENG=$L(AMHTEXT) W !?((AMHTCW-AMHLENG)/2),AMHTEXT,?(AMHTCW-8)," Page ",AMHPG
 S AMHLENG=46 S:AMHTCW<AMHLENG AMHLENG=AMHTCW W !?((AMHTCW-AMHLENG)/2),"Visit Dates:  ",AMHBDD," and ",AMHEDD,!
 I $G(AMHSPAG) S AMHLENG=$L(AMHSORT)+$L(AMHSORV)+2 S:AMHTCW<AMHLENG AMHLENG=AMHTCW W !?((AMHTCW-AMHLENG)/2),AMHSORV,":  ",AMHSORT,!
 W !,AMHHEAD,!
 W AMHDASH,!
 Q