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

APCLYV11.m

Go to the documentation of this file.
APCLYV11 ; IHS/CMI/LAB - PRINT APCLCO VIST REPORT (CALC) ;
 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
 ;
INIT ;initialize variables
 S APCLJOB=$J,APCLBT=$H
 D XTMP^APCLOSUT("APCLYV1","PCC COMM OFFS VISITS")
 S APCLCO=$O(^AUTTBEN("C","03",0)),APCLDEP=$O(^AUTTBEN("C","04",0))
 S APCLRET=$O(^AUTTBEN("C","30",0)),APCLRETD=$O(^AUTTBEN("C","31",0))
 I APCLCO="" W !!,"CODE 03 NOT IN BENEFICIARY FILE" G END
 I APCLDEP="" W !!,"CODE 04 NOT IN BENEFICIARY FILE" G END
 I APCLRET="" W !!,"CODE 30 NOT IN BENEFICIARY FILE" G END
 I APCLRETD="" W !!,"CODE 31 NOT IN BENEFICIARY FILE" G END
 S APCLDEN=$O(^DIC(40.7,"C",56,0)) ;dental clinic stop code
 S APCLSD=(9999999-APCLBD)_.2400
 ;
MAIN ;
 I APCLCO]"" S APCLII=APCLCO D CALC
 I APCLDEP]"" S APCLII=APCLDEP D CALC
 I APCLRET]"" S APCLII=APCLRET D CALC
 I APCLRETD]"" S APCLII=APCLRETD D CALC
END ;
 S APCLET=$H
 Q
 ;
CALC ;find patients and their visits
 S APCLPAT=0
PAT S APCLPAT=$O(^AUPNPAT("AD",APCLII,APCLPAT)) Q:APCLPAT=""
 G PAT:$$DEMO^APCLUTL(APCLPAT,$G(APCLDEMO))
 G PAT:'$D(^AUPNPAT(APCLPAT,41,DUZ(2))) ;must have hrcn at your facility
 S APCLHRCN=$P(^AUPNPAT(APCLPAT,41,DUZ(2),0),"^",2)
 G PAT:'$D(^DPT(APCLPAT,0)) S APCLNAME=$P(^(0),"^")
 ;
 S APCLEDT=9999999-APCLED-.0001
VST S APCLEDT=$O(^AUPNVSIT("AA",APCLPAT,APCLEDT)) G PAT:APCLEDT="",PAT:APCLEDT>APCLSD S APCLVDFN=0
VST1 S APCLVDFN=$O(^AUPNVSIT("AA",APCLPAT,APCLEDT,APCLVDFN)) G VST:APCLVDFN=""
 G VST1:'$D(^AUPNVSIT(APCLVDFN,0)) S APCLSTR=^(0)
 G VST1:$P(APCLSTR,"^",11) ;screen out deleted visits
 G VST1:$P(APCLSTR,"^",6)'=DUZ(2) ;screen out visits at other facilities
 ;
 S APCLVDT=$P(APCLSTR,"^"),X=$P(APCLSTR,"^",7)
 I (X'="A")&(X'="H")&(X'="S") G VST1
 ;set dental visits
 I $P(APCLSTR,"^",8)=APCLDEN,$D(APCLDEN) S ^XTMP("APCLYV1",APCLJOB,APCLBT,"D",APCLII,APCLNAME,APCLPAT,APCLVDT,APCLVDFN)=APCLHRCN G VST1
 ;set outpt node
 I X'="H",$D(APCLOP) S ^XTMP("APCLYV1",APCLJOB,APCLBT,"O",APCLII,APCLNAME,APCLPAT,APCLVDT,APCLVDFN)=APCLHRCN G VST1
 ;set inpt node
 G VST1:'$D(APCLIP) S APCLIDFN=$O(^AUPNVINP("AD",APCLVDFN,0)) G VST1:APCLIDFN=""
 S APCLDSCH=+^AUPNVINP(APCLIDFN,0)
 S ^XTMP("APCLYV1",APCLJOB,APCLBT,"I",APCLII,APCLNAME,APCLPAT,APCLVDT,APCLVDFN)=APCLHRCN_"^"_APCLDSCH G VST1
 ;
 Q