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

APCLCPTD.m

Go to the documentation of this file.
APCLCPTD ; IHS/CMI/LAB - PRINT VISIT REPORT ;
 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
 ;
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
PROC ;process printing of report
 I APCLDELT="F" D OPEN
 S APCLPG=0 K APCLQUIT
 I '$D(^XTMP("APCLCPT1",APCLJ,APCLH)) D HEADER W !!,"No data to report.",! G DONE
 S APCLPN="" F  S APCLPN=$O(^XTMP("APCLCPT1",APCLJ,APCLH,"CPTS",APCLPN)) Q:APCLPN=""!($D(APCLQUIT))  D
 .S APCLPIEN=0 F  S APCLPIEN=$O(^XTMP("APCLCPT1",APCLJ,APCLH,"CPTS",APCLPN,APCLPIEN)) Q:APCLPIEN'=+APCLPIEN!($D(APCLQUIT))  D
 ..D HEADER
 ..W !!,"Provider Name"_U_"Discipline"
 ..S APCLDISC=$O(^XTMP("APCLCPT1",APCLJ,APCLH,"CPTS",APCLPN,APCLPIEN,""))
 ..W !,APCLPN_U_APCLDISC
 ..I APCLOI="B"!(APCLOI="O") D
 ...D AMBHDR
 ...S APCLY="" F  S APCLY=$O(^XTMP("APCLCPT1",APCLJ,APCLH,"CPTS",APCLPN,APCLPIEN,APCLDISC,"OUTPATIENT",APCLY)) Q:APCLY=""!($D(APCLQUIT))  D
 ....S APCLN="" F  S APCLN=$O(^XTMP("APCLCPT1",APCLJ,APCLH,"CPTS",APCLPN,APCLPIEN,APCLDISC,"OUTPATIENT",APCLY,APCLN)) Q:APCLN=""!($D(APCLQUIT))  D PRNO
 ..;INPATIENT
 ..I APCLOI="B"!(APCLOI="I") D
 ...D INPHDR
 ...S APCLY="" F  S APCLY=$O(^XTMP("APCLCPT1",APCLJ,APCLH,"CPTS",APCLPN,APCLPIEN,APCLDISC,"INPATIENT",APCLY)) Q:APCLY=""!($D(APCLQUIT))  D
 ....S APCLN="" F  S APCLN=$O(^XTMP("APCLCPT1",APCLJ,APCLH,"CPTS",APCLPN,APCLPIEN,APCLDISC,"INPATIENT",APCLY,APCLN)) Q:APCLN=""!($D(APCLQUIT))  D PRNI
 ..;TOTALS
 ..I APCLOI="B"!(APCLOI="O") D
 ...S APCLCNT=$G(^XTMP("APCLCPT1",APCLJ,APCLH,"OUTPATIENT",APCLPN,APCLPIEN,APCLDISC))
 ...W !!,"Total Outpatient Visits: "_U_APCLCNT
 ..I APCLOI="B"!(APCLOI="I") D
 ...S APCLCNT=$G(^XTMP("APCLCPT1",APCLJ,APCLH,"INPATIENT",APCLPN,APCLPIEN,APCLDISC))
 ...W !!,"Total Inpatient Services: "_U_APCLCNT
 ..W !!,"Total Patients:  "_U_APCLCNT
 .Q
 Q
PRNO ;
 S APCLCNT=^XTMP("APCLCPT1",APCLJ,APCLH,"CPTS",APCLPN,APCLPIEN,APCLDISC,"OUTPATIENT",APCLY,APCLN)
 W !,APCLY_U_APCLN_U_APCLCNT
 Q
PRNI ;
 S APCLCNT=^XTMP("APCLCPT1",APCLJ,APCLH,"CPTS",APCLPN,APCLPIEN,APCLDISC,"INPATIENT",APCLY,APCLN)
 W !,APCLY_U_APCLN_U_APCLCNT
 Q
AMBHDR ;
 W !!,"Ambulatory/Outpatient Services:"
 W !!,"CPT Code"_U_"CPT Narrative"_U_"# Subtotaled by CPT"
 Q
INPHDR ;
 W !!,"Inpatient Services:"
 W !!,"CPT Code"_U_"CPT Narrative"_U_"# Subtotaled by CPT"
 Q
 G:'APCLPG HEADER1
HEADER1 ;
 S APCLPG=APCLPG+1
 W !,$P(^VA(200,DUZ,0),U,2)_U_$$FMTE^XLFDT(DT)_U_"Page ",APCLPG,!
 W !,"***  CPT Code by Provider Report  ***",!
 S X="Visit Dates: "_$$FMTE^XLFDT(APCLBD)_" to "_$$FMTE^XLFDT(APCLED) W X,!
 Q
DONE ;
 ;write out delimited file
 I APCLDELT="F" D ^%ZISC
 K ^XTMP("APCLFLAT",$J),^TMP($J,"APCLDELIMITED")
 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