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

ADEFLEX0.m

Go to the documentation of this file.
ADEFLEX0 ; IHS/HQT/MJL  - EXTRACT F- DATA PART 2 ;  [ 03/29/1999  8:33 AM ]
 ;;6.0;ADE;;APRIL 1999
 ; ^ADEFDATA is a transient, non-fileman working global
 W !!,"Fluoride Data Extraction for Transmission to Area/DPSB",!!
 D ^XBKVAR
 G:'$D(^ADEFDATA) OK
 W "The data extraction holding area will be purged if you continue.",!
CONFIRM R "Ok to continue? N// ",X:DTIME S:'$T X=U S X=$E(X_"N")
 I X["?" W !,"It is ok to clear the data extraction holding file if a cartridge",!,"containing that extracted data has been made and sent to AREA or DPSB.",! G CONFIRM
 I "Yy"'[X W " -- data extraction canceled.",! G QUIT
OK G:$D(ADEREX) ASKDEV
DATE S U="^",%DT="AXEP",%DT("A")="SELECT BEGINNING DATE: " D ^%DT
 G:Y<0 QUIT S ADEB=Y,%DT(0)=ADEB,%DT("A")="SELECT ENDING DATE: " D ^%DT
 G:X="^" DATE G:Y<0 QUIT S ADEND=Y
ASKDEV S %ZIS="Q" D ^%ZIS G QUIT:POP I $D(IO("Q")) K IO("Q") D QUE W !,"REQUEST QUEUED." G QUIT
 U IO G START
QUE S ZTRTN="START^ADEFLEX0",ZTDESC="DENTAL FLUORIDATION DATA",ZTSAVE("ADEND")="",ZTSAVE("ADEB")="",ZTSAVE("ADEXDT")="" S:$D(ADEREX) ZTSAVE("ADEREX")="",ZTSAVE("ADEXDA")=""
 S:$D(ADERERUN) ZTSAVE("ADERERUN")="",ZTSAVE("ADEXDA")="" D ^%ZTLOAD Q
END S ^ADEFDATA(0)=$P(^AUTTLOC($P(^AUTTSITE(1,0),U,1),0),U,10)_U_$P(^DIC(4,$P(^AUTTSITE(1,0),U,1),0),U,1)_U_(17000000+DT)_U_(17000000+ADEB)_U_(17000000+ADEND)_"^^"_(ADERC-1)
 D
 . N DIE,DR,DA,ADELAST
 . S DIE="^ADELOG(",DA=ADEXDA,ADELAST=1
 . S DR="3///"_(ADERC-1)_";5///COMPLETED NORMALLY"
 . I $D(ADEREX) S DR="3///"_(ADERC-1)
 . D ^DIE
 . K DIE,DR,DA,ADELAST
 W !!,?15,"PROCESSING COMPLETE. ",ADERC-1," RECORDS PROCESSED."
 D ^%ZISC
QUIT K ADEB,ADEBD,ADED0,ADED1,ADEDUZ,ADEEQ,ADEFDV,ADEID,ADELAST,ADELDAY,ADEND,ADENM,ADENO,ADEPPM,ADERC,ADERERUN,ADERES,ADESFC,ADESTAT,ADEWP,ADEXDA,ADEXDT,ADEXNOD,ADERR,ADESSN,ADEREX
 Q
START ;
 U IO ;D HOME^%ZIS
 W !!!,?15,"FLUORIDATION DATA EXTRACTION BEGUN...",!!,?15,"RECORD SCANNING "
 ;S ADEBD=ADEB-1,ADERC=1 K ^ADEFDATA ;NON-FILEMAN EXTRACT GLOBAL
 S ADEBD=ADEB-1,ADERC=1
 D:$D(^ADEFDATA)
 .S ADESUB="" F  S ADESUB=$O(^ADEFDATA(ADESUB)) Q:ADESUB=""  K ^ADEFDATA(ADESUB)
 .K ADESUB
 I $D(ADERERUN) D
 . Q:'$D(ADEXDA)
 . Q:'+ADEXDA
 . Q:'$D(^ADELOG(ADEXDA,0))
 . S DIK="^ADELOG(",DA=ADEXDA
 . D ^DIK
 . K DIK,DA
 I '$D(ADEREX) D
 . N DIC,X,DR,ADELAST
 . S DIC="^ADELOG(",DIC(0)="L",X=ADEXDT
 . S DIC("DR")="1///"_ADEB_";2///"_ADEND_";3///0;4///F;5///ABORTED"
 . S ADELAST=1
 . K DD,DO
 . D FILE^DICN
 . S ADEXDA=+Y
 . K DIC,X,DR,ADELAST
S1 S ADED0=0,ADEBD=$O(^ADEFLU("AB",ADEBD)) G:(ADEBD>ADEND)!(ADEBD="") END
S2 ;EP
 S ADED1=0,ADENM="",ADESFC="",ADED0=$O(^ADEFLU("AB",ADEBD,ADED0)) G:(ADED0="") S1
 G:'$D(^ADEFLU(ADED0,0)) ERR1^ADEFLEX1 S ADEWP=$P(^ADEFLU(ADED0,0),U)
 G:'$D(^ADEWS(ADEWP,0)) ERR2^ADEFLEX1 S ADEWP=^ADEWS(ADEWP,0),ADENM=$P(ADEWP,U),ADESFC=$P(ADEWP,U,2) G:(ADENM="")!(ADESFC="") ERR3^ADEFLEX1
S3 ;EP
 S ADED1=$O(^ADEFLU("AB",ADEBD,ADED0,ADED1)) G:ADED1="" S2
 G:'$D(^ADEFLU(ADED0,1,ADED1,0)) ERR4^ADEFLEX1
 S ADENO=^ADEFLU(ADED0,1,ADED1,0)
 I '$D(ADEREX),$P(ADENO,U,5)]"" G S3
 I $D(ADEREX),$P(ADENO,U,5)'=ADEXDT G S3
 S ADEEQ=$P(ADENO,U,3) S:ADEEQ="O" ADEEQ="X" G:ADEEQ="" ERR5^ADEFLEX1
 S ADEID=$P(ADENO,U,4) G:ADEID="" ERR6^ADEFLEX1
 G:'$D(^DIC(16,ADEID,0)) ERR7^ADEFLEX1
 S ADESSN=$P(^DIC(16,ADEID,0),U,9) G:ADESSN'?9N ERR8^ADEFLEX1 S ADEID=ADESSN
 S ADEPPM=$P(ADENO,U,2) G:ADEPPM="" ERR9^ADEFLEX1 S ADEPPM=ADEPPM*10,ADEPPM="000"_ADEPPM,ADEPPM=$E(ADEPPM,$L(ADEPPM)-2,$L(ADEPPM))
 ;S ^ADEFDATA(ADERC)="AD2^21^"_$E(ADEBD,4,5)_$E(ADEBD,6,7)_$E(ADEBD,2,3)_U_ADEEQ_ADESFC_ADEPPM_U_ADEID,ADERC=ADERC+1
 S ^ADEFDATA(ADERC)="AD2^21^"_(17000000+ADEBD)_U_ADEEQ_ADESFC_ADEPPM_U_ADEID,ADERC=ADERC+1
 I '$D(ADEREX) S DIE=9002002.1,DA=ADED0,DR="1///`"_ADED1,DR(2,9002002.11)="4////"_DT D ^DIE
 W "." G S3