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

ADEGRL2.m

Go to the documentation of this file.
ADEGRL2 ; IHS/HQT/MJL - DENTAL ENTRY PART 3 ;  [ 03/24/1999   9:04 AM ]
 ;;6.0;ADE;**26**;APRIL 1999;Build 13
 ;;IHS/OIT/GAB 10.2014 Modified for 2015 Code Updates - PATCH 26
 ;
 ;        RETURNS ADENEWVS=1 AND ADEVDATE (IF A NEW VISIT),
 ;                ADENEWVS=0 AND ADEDFN (IF OLD VISIT)
 ;                Y=1 IF SUCCESSFUL, OTHERWISE Y=0
 ;        IF NO TIME ENTERED, DEFAULTS TO 0800 ***TODO: Parameterize
 ;------->GET VISIT DATE
CTRL D VSLOOK
 G:'Y END
 ;------->CHECK DATE OF DEATH
 D DOD G:'Y CTRL
 ;------->CHECK DELIVERY MODE
 I 'ADENEWVS D DELIV G:'Y CTRL
END Q
DELIV I ADECON,$P(^ADEPCD(ADEDFN,0),U,9)'="c" W !?5,"***Only CONTRACT Visits may be edited in this mode***" S Y=0 Q
 I ADEDIR,$P(^ADEPCD(ADEDFN,0),U,9)="c" W !?5,"***CONTRACT Visits cannot be selected in this option***" S Y=0 Q
 Q
DOD S X=ADEVDATE,%DT="T" D ^%DT
 I $D(^DPT(ADEPAT,.35)),$P(^(.35),U),$P(^(.35),U)<Y S Y=0 W !?5,"***PATIENT DIED BEFORE THIS DATE***",*7 Q
 I Y<2840101 S Y=0 W !?5,"***MUST BE AFTER 1 JANUARY 84***",*7 Q
 S Y=1
 Q
VSLOOK ;EP
 S ADENEWVS=0 K ADEDFN,ADEVDATE
 N ADETIMEE
 S ADETIMEE="08" ;***TODO: Replace with site parameter
 R !!,"Date of Visit: ",X:DTIME
 I '$T!(X["^")!(X="") S Y=0 Q
 ;------->FORCED NEW VISIT WITH QUOTES
 I X[$C(34) S X=$P(X,$C(34),2),%DT="TEP",%DT(0)=-(DT+.235959) D ^%DT K %DT G:Y<1 VSLOOK X ^DD("DD") S ADENEWVS=1,ADEVDATE=Y,Y=1 Q
 I X["?" D VSHELP G VSLOOK
 S %DT="TEP",%DT(0)=-(DT+.235959) D ^%DT K %DT G:Y<1 VSLOOK
 ;I '$D(^ADEPCD("DATE",ADEPAT,Y)) S ADENEWVS=1 S:$P(Y,".",2)="" $P(Y,".",2)=$S(ADETIMEE]"":ADETIMEE,1:"09") X ^DD("DD") S ADEVDATE=Y,Y=1 Q
 I '$D(^ADEPCD("DATE",ADEPAT,Y)) S:$P(Y,".",2)="" $P(Y,".",2)=$S(ADETIMEE]"":ADETIMEE,1:"09") I '$D(^ADEPCD("DATE",ADEPAT,Y)) S ADENEWVS=1 X ^DD("DD") S ADEVDATE=Y,Y=1 Q
 ;------->AT LEAST ONE VISIT ALREADY EXISTS FOR DATE
 S ADEVFM=Y X ^DD("DD") S ADEVDATE=Y
 S ADEVCNT=0,ADEDFN=0
 F ADE=0:0 S ADEDFN=$O(^ADEPCD("DATE",ADEPAT,ADEVFM,ADEDFN)) Q:ADEDFN=""  D VSLOOK4
 I ADEVCNT=1 S ADEDFN=ADEVDFN(1) S ADENEWVS=0,Y=1 K ADEVDFN Q
 I ADEVCNT=0 S ADENEWVS=1,Y=1 Q
 ;------->MORE THAN ONE VISIT FOR DATE
 F ADE=1:1:ADEVCNT S ADEDFN=ADEVDFN(ADE) D VSHELP1
 W !,"Select Visit Number 1-",ADE,": "
 R ADEX:DTIME
 I '$T!(ADEX="") S Y=0 K ADEVDFN,ADEVCNT,ADEVFM,ADE,ADEVDATE G VSLOOK
 I +ADEX<1!(+ADEX>ADEVCNT) W *7," ??" K ADEVDFN,ADEVCNT,ADEVFM,ADE,ADEVDATE G VSLOOK
 S ADEDFN=ADEVDFN(ADEX) S Y=1,ADENEWVS=0
 K ADEVDFN,ADEX,ADE,ADEVCNT Q
VSLOOK4 Q:'$D(^ADEPCD(ADEDFN,0))
 I '$D(ADEDIR) S ADEVCNT=ADEVCNT+1,ADEVDFN(ADEVCNT)=ADEDFN Q
 I ADEDIR,$P(^ADEPCD(ADEDFN,0),U,9)'="c" S ADEVCNT=ADEVCNT+1,ADEVDFN(ADEVCNT)=ADEDFN Q
 I ADECON,$P(^ADEPCD(ADEDFN,0),U,9)="c" S ADEVCNT=ADEVCNT+1,ADEVDFN(ADEVCNT)=ADEDFN Q
 Q
VSHELP I X'="?" S XQH="ADE-DVIS-DATE" D EN^XQH K XQH D ^ADECLS Q
 W !,"You may enter a new visit if you wish."
 W !,"Enter two question marks `??' for general help on entering dates, or"
 W !,"Enter the Date of an old Visit"
 Q:'$D(^ADEPCD("DATE",ADEPAT))
 W !,"Choose from:"
 S ADEVFM=0 F ADE=0:0 S ADEVFM=$O(^ADEPCD("DATE",ADEPAT,ADEVFM)) Q:'+ADEVFM  S ADEDFN=0 S Y=ADEVFM X ^DD("DD") F ADEQ=0:0 S ADEDFN=$O(^ADEPCD("DATE",ADEPAT,ADEVFM,ADEDFN)) Q:'+ADEDFN  D VSHELP1
VSHELP0 K ADEQ Q
VSHELP1 Q:'$D(^ADEPCD(ADEDFN,0))
 I $D(ADECON),ADECON,$P(^ADEPCD(ADEDFN,0),U,9)'="c" Q
 I $D(ADEDIR),ADEDIR,$P(^ADEPCD(ADEDFN,0),U,9)="c" Q
 W ! W:+ADE ADE,". " W Y
 W ?20,"  ",$S($P(^ADEPCD(ADEDFN,0),U,9)="c":"CONTRACT",1:"DIRECT")
 I $P(^ADEPCD(ADEDFN,0),U,4)]"",$D(^DIC(16,$P(^ADEPCD(ADEDFN,0),U,4),0)) W ?30,"  ",$P(^(0),U) ;IHS/HMW 1-4-90
 I $D(^AUTTADA("B","9140")),$O(^AUTTADA("B","9140",0)),$D(^ADEPCD(ADEDFN,"ADA","B",$O(^AUTTADA("B","9140",0)))) W ?60,"<CANCELLATION>"
 I $D(^AUTTADA("B","9130")),$O(^AUTTADA("B","9130",0)),$D(^ADEPCD(ADEDFN,"ADA","B",$O(^AUTTADA("B","9130",0)))) W ?60,"<BROKEN APPT.>"
 ;/IHS/OIT/GAB Patch #26 Added below two lines for 2015 codes, will be replacing 9130 & 9140 (don't remove old codes yet)
 I $D(^AUTTADA("B","9987")),$O(^AUTTADA("B","9987",0)),$D(^ADEPCD(ADEDFN,"ADA","B",$O(^AUTTADA("B","9987",0)))) W ?60,"<CANCELLATION>"
 I $D(^AUTTADA("B","9986")),$O(^AUTTADA("B","9986",0)),$D(^ADEPCD(ADEDFN,"ADA","B",$O(^AUTTADA("B","9986",0)))) W ?60,"<MISSED APPT.>"
 Q