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

ADEPEND.m

Go to the documentation of this file.
ADEPEND ; IHS/HQT/MJL  - ENDO REPORT ;11:43 AM  [ 03/24/1999   9:04 AM ]
 ;;6.0;ADE;;APRIL 1999
 ;
 N ADEDATE,DIR,ADEIOP,ADEU
 S ADEDATE=$$DATE^ADEPQA3() G:$$HAT^ADEPQA() END
 ;
 ;GET AND LOCK UNIQUE SUBSCRIPT FOR REPORT GLOBAL
 S ADEU=$$ADEU^ADEPENDA()
 K ^TMP("ADEPEND",ADEU) ;^TMP is a transient report global
 S ^TMP("ADEPEND",ADEU)="RUNNING"
 ;
 D ASKDEV^ADEPENDA("ZTM^ADEPEND","ENDODONTIC REPORT PROCESSING")
 I POP K ^TMP("ADEPEND",ADEU) G END
 ;FHL 9/9/98 I $D(ZTSK) G END
 I $D(ZTQUEUED) G END
 ;
ZTM ;EP - TASKMAN PROCESSING ENTRY POINT
 N ADESTP,ADEAGE,ADEPROV,ADEHYG,ADELOC,ADEADA,ADEEXT,ADEHDFNS,ADEHDFN,ADEHNAM,ADEROPT,ADEL,ADECOD,ADEOP,ADETNAM,ADETDFN
 I $D(ZTQUEUED) L +^TMP("ADEPEND",ADEU):1 I '$T S ZTREQ="@" G END
 ;
 S (ADESTP,ADEAGE,ADEPROV,ADEHYG,ADELOC)=0
 K ^ADEUTL("ADEPQA",$J)
 D GRP^ADEPENDA
 S ADEROPT="4^DENTAL"
 S ADEADA(1)="1^"_ADECOD("ACCESSED")_"^^^^^"
 S ADETNAM="ADEQAENDO"_$P($H,",",2)
 I $D(^DIBT("B",ADETNAM)) D  ;If template exists, delete it
 . S ADETDFN=$O(^DIBT("B",ADETNAM,0))
 . D DELTMP^ADEPQA(ADETDFN)
 S ADETDFN=$$TMPLAT^ADEPQA(ADETNAM,9002007) ;create template
 S ADEEXT=1
 D ROLL^ADEPQA
 ;
 S ADESTP="1^"_ADETDFN_"^"_9002007
 I '$D(^DIBT(ADETDFN,1)) D  G END ;No Endo Accesses
 . I $D(ZTQUEUED) S ZTREQ="@"
 . K ^TMP("ADEPEND",ADEU)
 . D DELTMP^ADEPQA(ADETDFN)
 ;
 S ADEL=0 F  S ADEL=$O(^DIBT(ADETDFN,1,ADEL)) Q:'+ADEL  D
 . S ADEHDFNS($P(^ADEPCD(ADEL,0),U,4))=""
 S ADEL=0,ADEHDFNS="" F  S ADEL=$O(ADEHDFNS(ADEL)) Q:'+ADEL  D
 . I ADEHDFNS="" S ADEHDFNS=ADEL,ADEHNAM(ADEL)=$P(^DIC(16,ADEL,0),U) Q
 . S $P(ADEHDFNS,",",$L(ADEHDFNS,",")+1)=ADEL,ADEHNAM(ADEL)=$P(^DIC(16,ADEL,0),U)
 S ADEPROV=1
 F ADEL=1:1:$L(ADEHDFNS,",") S ADEHDFN=$P(ADEHDFNS,",",ADEL),$P(ADEPROV,U,2)=ADEHDFN D TEMROLL
 K ^ADEUTL("ADEPQA",$J)
 D DELTMP^ADEPQA(ADETDFN)
 ;
 I $D(ZTQUEUED) D  G END
 . I $D(IOT),IOT'="HFS" D  Q
 . . S ZTREQ=$H_U_ADEIOP_U_"ENDODONTIC REPORT PRINTING"_U_"PRINT^ADEPEND"
 . D PRINT Q
 ;
 D PRINT
 ;
END I $D(ADEU) L -^TMP("ADEPEND",ADEU)
 D KILL^ADEPENDA
 Q
 ;
 ;------->SUBROUTINES
 ;
TEMROLL ;
 N ADEDFN
 S ADEDFN=0
 F  S ADEDFN=$O(^DIBT(ADETDFN,1,ADEDFN)) Q:'+ADEDFN  D
 . I $P(^ADEPCD(ADEDFN,0),U,4)=ADEHDFN S ADENOD=^ADEPCD(ADEDFN,0) D CALL
 Q
 ;
CALL ;FOR ADEADA(1) = accessed, accessed + extracted,
 ; +completed, +alloy restored, +crown restored
 N ADEJ,ADEK,ADEL,ADEPC
 S ADEADA(1)="1^"_ADECOD("ACCESSED")_"^^^^^"
 F ADEPC=1:1:5 D
 . I ADEPC>1 S $P(ADEADA(1),U,6)="Y",$P(ADEADA(1),U,5)=99999
 . I ADEPC=3 S $P(ADEADA(1),U,3)=ADECOD("EXTRACTED")
 . I ADEPC=2 S $P(ADEADA(1),U,3)=ADECOD("COMPLETED")
 . I ADEPC=4 S $P(ADEADA(1),U,3)=ADECOD("RESTORED")
 . I ADEPC=5 S $P(ADEADA(1),U,3)=ADECOD("CROWNED")
 . D CALL2
 Q
CALL2 F ADEOP=1:1:4 D
 . I ADEOP=1 S $P(ADEADA(1),U,7)=ADEOP("FIRST MOLARS")
 . I ADEOP=2 S $P(ADEADA(1),U,7)=ADEOP("OTHER MOLARS")
 . I ADEOP=3 S $P(ADEADA(1),U,7)=ADEOP("PREMOLARS")
 . I ADEOP=4 S $P(ADEADA(1),U,7)=ADEOP("ANTERIORS")
 . I ADEPC=1 D  D CALL1 Q
 . . I '$D(^TMP("ADEPEND",ADEU,ADEHNAM(ADEHDFN),$S(ADEOP=1:"FIRST MOLARS",ADEOP=2:"OTHER MOLARS",ADEOP=3:"PREMOLARS",1:"ANTERIORS"))) D
 . . . S ^TMP("ADEPEND",ADEU,ADEHNAM(ADEHDFN),$S(ADEOP=1:"FIRST MOLARS",ADEOP=2:"OTHER MOLARS",ADEOP=3:"PREMOLARS",1:"ANTERIORS"))="0^0^0^0^0"
 . I +^TMP("ADEPEND",ADEU,ADEHNAM(ADEHDFN),$S(ADEOP=1:"FIRST MOLARS",ADEOP=2:"OTHER MOLARS",ADEOP=3:"PREMOLARS",1:"ANTERIORS")) D CALL1
 Q
CALL1 N ADECNT,ADEJ,ADEK
 K ^ADEUTL("ADEPQA",$J)
 Q:'$$CODSCN^ADEPQA1D(ADEDFN)
 ;After search, count entries in ADEUTL("ADEPQA",$J)
 S (ADECNT,ADEJ)=0 F  S ADEJ=$O(^ADEUTL("ADEPQA",$J,ADEJ)) Q:'+ADEJ  D
 . S ADEK=0 F  S ADEK=$O(^ADEUTL("ADEPQA",$J,ADEJ,ADEK)) Q:'+ADEK  S ADECNT=ADECNT+1
 S $P(^TMP("ADEPEND",ADEU,ADEHNAM(ADEHDFN),$P("FIRST MOLARS,OTHER MOLARS,PREMOLARS,ANTERIORS",",",ADEOP)),U,ADEPC)=$P(^TMP("ADEPEND",ADEU,ADEHNAM(ADEHDFN),$P("FIRST MOLARS,OTHER MOLARS,PREMOLARS,ANTERIORS",",",ADEOP)),U,ADEPC)+ADECNT
 ;^TMP("ADEPEND",ADEU,"DENTIST NAME","TOOTH CAT.")="Total Accessed^+extracted^+completed^+alloy restored^+crown restored"
 Q
 ;
PRINT ;(See note at label PRINT in ADEPENDN)
 ;
 I '$D(^TMP("ADEPEND",ADEU)) G PRNEND
 I $O(^TMP("ADEPEND",ADEU,0))="" G PRNEND
 I $D(ZTQUEUED) L +^TMP("ADEPEND",ADEU):1 I '$T S ADENOLOK=1 G PRNEND
 N DIC,BY,FLDS,ADED0,ADED1,ADED2,DHD,Y,ADEDUZ,ADEZTSK
 S IOP=ADEIOP
 S %ZIS("IOPAR")=ADEIOPAR
 D ^%ZIS
 S IOP=ADEIOP
 S %ZIS("IOPAR")=ADEIOPAR
 S DIC="^ADEDUM(",BY="@NUMBER",(FR,TO)="",FLDS="[ADEP-ADEPEND]"
 S ADED0=0,ADED1=0
 S DHD=$O(^ADEPARAM(0)),DHD=$P(^ADEPARAM(DHD,0),U),DHD=$P(^DIC(4,DHD,0),U)
 S DHD=DHD_": ENDODONTIC TOOTH ACCESS"
 S Y=$P(ADEDATE,U,2) X ^DD("DD") S DHD=DHD_" ("_Y
 S Y=$P(ADEDATE,U,3) X ^DD("DD") S DHD=DHD_"-"_Y_")"
 ;FHL 9/9/98 I $D(ZTSK) S ADEZTSK=ZTSK K ZTSK
 I $D(ZTQUED) S ADEZTSK=ZTSK K ZTSK
 D EN1^DIP
 I $D(ADEZTSK) S ZTSK=ADEZTSK
PRNEND I $D(ZTQUEUED) S ZTREQ="@"
 I '$D(ADENOLOK) K ^TMP("ADEPEND",ADEU)
 K ADENOLOK
 Q