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

APCLVLP8.m

Go to the documentation of this file.
APCLVLP8 ; IHS/CMI/LAB - PRINT VISIT REPORT ;
 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
 ;IHS/TUCSON/LAB - added killing of APCLPRNT to V subroutine 05/19/97
 ;IHS/TUCSON/LAB - modified subroutine FLAT - patch 1 - 05/27/97
DELIMIT ;EP - Set up header line, dash line
 S APCLFCNT=0
 K ^XTMP($J,"APCLFLAT") ;just in case
 K ^TMP($J,"APCLDELIMITED")
 S APCLDELC=0,APCLPIEC=0
 I APCLPTVS="V" S APCLHDR="PATIENT IEN"_U_"VISIT IEN",APCLPIEC=2
 I APCLPTVS="P" S APCLHDR="PATIENT IEN",APCLPIEC=1
 S X=0,APCLHEAD="" F  S X=$O(^APCLVRPT(APCLRPT,12,X)) Q:X'=+X  D
 .S APCLPIEC=APCLPIEC+1
 .S H=$P(^APCLVSTS($P(^APCLVRPT(APCLRPT,12,X,0),U),0),U,6)
 .S $P(APCLHDR,U,APCLPIEC)=H
 .Q
 D COVPAGE^APCLVLP1 ;print cover page - note: if user ^'s out of cover page, processing continues
PROC ;process printing of report
 I APCLDELT="F" D OPEN Q:Y=1
 W !,APCLHDR,!
 I '$D(^XTMP("APCLVL",APCLJOB,APCLBTH)) W !,"NO DATA TO REPORT" G DONE
 S (APCLSRTV,APCLFRST)="" K APCLQUIT
 F  S APCLSRTV=$O(^XTMP("APCLVL",APCLJOB,APCLBTH,"DATA HITS",APCLSRTV)) Q:APCLSRTV=""!($D(APCLQUIT))  D V
DONE ;
 ;write out delimited file
 I APCLDELT="F" D ^%ZISC
 K ^XTMP("APCLVL",APCLJOB,APCLBT),^XTMP("APCLFLAT",$J),^TMP($J,"APCLDELIMITED")
 D DEL^APCLVL
 K APCLBD,APCLSD,APCLED,APCLEDD,APCLBDD,APCLRPT,APCLHEAD,APCLLINE,APCLL,APCLRCNT,APCLI,APCLCRIT,APCLVIEN,APCLVREC,APCLJOB,APCLBT,APCLBTH,APCLQUIT,APCLHDR,APCLDASH,APCLLENG,APCLPCNT,APCLTCW,APCLODAT,APCLPG,AUPNDAYS,AUPNPAT,AUPNDOD,AUPNDOB,AUPNSEX
 K APCLSORT,APCLSRT,APCLSORX,APCLFILE,APCLFIEL,APCLPRNT,APCLX,APCLTYPE,APCLFOUN,D0,J,K,L,APCLPRNM,APCLTEST,APCLSEAT,APCLLHDR,APCLFRST
 D EN^XBVK("APCL")
 Q
V ;GETS DATA HITS
 S APCLCNT=0
 ;get readable sort value
 K APCLPRNT
 S APCLSRTR="",APCLVIEN=$O(^XTMP("APCLVL",APCLJOB,APCLBTH,"DATA HITS",APCLSRTV,0)) I APCLVIEN]"" S APCLCRIT=APCLSORT D
 .I APCLPTVS="V" S APCLVREC=^AUPNVSIT(APCLVIEN,0),DFN=$P(APCLVREC,U,5) X:$D(^APCLVSTS(APCLSORT,3)) ^(3) S APCLSRTR=APCLPRNT
 .I APCLPTVS="P" S DFN=APCLVIEN X:$D(^APCLVSTS(APCLSORT,3)) ^(3) S APCLSRTR=APCLPRNT
 K APCLFRST
 S APCLVIEN=0 F  S APCLVIEN=$O(^XTMP("APCLVL",APCLJOB,APCLBTH,"DATA HITS",APCLSRTV,APCLVIEN)) Q:APCLVIEN'=+APCLVIEN!($D(APCLQUIT))  D
 .I APCLPTVS="V" S APCLVREC=^AUPNVSIT(APCLVIEN,0),DFN=$P(APCLVREC,U,5) D PRINT Q
 .S DFN=APCLVIEN D PRINT
 .Q
 Q
PRINT ;
 K ^XTMP("APCLLINE",$J) S ^XTMP("APCLLINE",$J,1)=""
 K APCLDELD
 S APCLPIEC=0,APCLLINE=1,APCLCNT=APCLCNT+1
 I APCLPTVS="V" S APCLDELD(1,"S")=DFN,APCLDELD(2,"S")=APCLVIEN,APCLPIEC=2
 I APCLPTVS="P" S APCLDELD(1,"S")=DFN,APCLPIEC=1
 S APCLI=0 F  S APCLI=$O(^APCLVRPT(APCLRPT,12,APCLI)) Q:APCLI'=+APCLI!($D(APCLQUIT))  S APCLCRIT=$P(^APCLVRPT(APCLRPT,12,APCLI,0),U) D
 .S APCLPIEC=APCLPIEC+1
 .I '$P(^APCLVSTS(APCLCRIT,0),U,8) D SINGLE Q
 .D MULT
 .Q
 K APCLDELP
 F X=1:1:APCLLINE D
 .S APCLCNT=APCLCNT+1
 .F P=1:1:APCLPIEC D
 ..S V=$O(APCLDELD(P,""))
 ..I V="S" S D=APCLDELD(P,V),$P(APCLDELP(APCLCNT),U,P)=D
 ..I V="M" S D=$S($P(APCLDELD(P,V),"|",X)]"":$P(APCLDELD(P,V),"|",X),1:"--"),$P(APCLDELP(APCLCNT),U,P)=D
 S X=0 F  S X=$O(APCLDELP(X)) Q:X'=+X  W APCLDELP(X),!
 Q
SINGLE ;process single valued item
 K APCLPRNT
 S APCLX=0
 X:$D(^APCLVSTS(APCLCRIT,3)) ^(3)
 I APCLPRNT="" S APCLPRNT="--"
 S APCLDELD(APCLPIEC,"S")=APCLPRNT
 Q
MULT ;
 K APCLPRNT,APCLPRNM,APCLY S (APCLX,APCLPCNT)=0
 X:$D(^APCLVSTS(APCLCRIT,3)) ^(3)
 ;if 13th, then $o through delete bad ones and then reorder/number
 ;new logic here to screen if user wants to screen
 I $P(^APCLVRPT(APCLRPT,12,APCLI,0),U,3) D
 .;does this one match selected ones?
 .S X=0 F  S X=$O(APCLPRNM(X)) Q:X'=+X  D
 ..S Z=$G(APCLPRNM(X,"I")) I Z="" K APCLPRNM(X) Q
 ..I '$D(^APCLVRPT(APCLRPT,11,APCLCRIT,11,"B",Z)) K APCLPRNM(X)
 K Y S (X,C)=0 F  S X=$O(APCLPRNM(X)) Q:X'=+X  S C=C+1,Y(C)=APCLPRNM(X)
 I C>APCLLINE S APCLLINE=C
 K APCLPRNM S X=0 F  S X=$O(Y(X)) Q:X'=+X  S APCLPRNM(X)=Y(X)
 I '$D(APCLPRNM) S APCLPRNT="--" D
 .S APCLDELD(APCLPIEC,"M")=APCLPRNT
 S X=0 F  S X=$O(APCLPRNM(X)) Q:X'=+X  D
 .S $P(APCLDELD(APCLPIEC,"M"),"|",X)=APCLPRNM(X)
 Q
DIQ ;
 K APCLPRNT,APCLFILE,APCLFIEL
 S APCLFILE=$P($P(^APCLVSTS(APCLCRIT,0),U,4),","),APCLFIEL=$P($P(^(0),U,4),",",2)
 S DIQ(0)="EN",DIQ="APCLPRNT(",DIC=APCLFILE,DR=APCLFIEL D EN^DIQ1 K DIC,DR,DIQ
 I '$D(APCLPRNT(APCLFILE,DA,APCLFIEL,"E")) S APCLPRNT(APCLFILE,DA,APCLFIEL,"E")="--"
 S APCLPRNT=APCLPRNT(APCLFILE,DA,APCLFIEL,"E")
 Q
OPEN ;write flat file from global
 ;if screen selected do screen
 ;USE GS FROM GPRA TO OPEN AND WRITE FILE
 ;I APCLDELT="S" D SCREEN Q
 S Y=$$OPEN^%ZISH(APCLHDIR,APCLDELF,"W")
 I Y=1 W:'$D(ZTQUEUED) !!,"Cannot open host file to write out DELIMITED data.  Notify programmer." Q
 U IO
 Q