SCDXRT01 ;ALB/JRP - AMB CARE RETRANSMISSION;09-MAY-1996
;;5.3;Scheduling;**44,1015**;AUG 13, 1993;Build 21
;
RTRNRNG ;Mark all [Deleted] Outpatient Encounters for a user specified
; date range for retransmission to the National Ambulatory Care
; Database
;
;Input : None
;Output : None
;Note : User is prompted for the date range to retransmit
; : Encounters that are not contained in the Transmitted
; Outpatient Encounter file (#409.73) can not be
; retransmitted
; : [Deleted] Encounters that occurred before switching to new
; transmission format can not be retransmitted
; : [Deleted] Encounters that occurred within the last two days
; can not be retransmitted
;
;Declare variables
N MINDT,MAXDT,SCDXSTRT,SCDXEND,HELPTXT,X,%H,%,%I
N ZTSK,ZTDESC,ZTRTN,ZTIO,ZTDTH
W !!
;Cut-off date for old transmission format is earliest date
; allowed for retransmission (default to 10/1/96)
S MINDT=+$P($G(^SD(404.91,1,"AMB")),"^",2)
S:('MINDT) MINDT=2961001
;Today is the latest date allowed for retransmission
D NOW^%DTC
S MAXDT=X
;Set up help text for getting beginning and ending dates
S HELPTXT("BGN")="Enter the beginning date for retransmitting encounters"
S HELPTXT("END")="Enter the ending date for retransmitting encounters"
;Get beginning and ending dates
S X=$$GETDTRNG^SCDXUTL1(MINDT,MAXDT,"HELPTXT(""BGN"")","HELPTXT(""END"")")
;User abort / time out
Q:(X<0)
W !!
;Verify that user wants to do this
S SCDXSTRT=$P(X,"^",1)
S SCDXEND=$P(X,"^",2)
S DIR("A",1)=" "
S DIR("A",2)=" "
S X=(+$E(SCDXSTRT,4,5))_"/"_(+$E(SCDXSTRT,6,7))_"/"_(1700+$E(SCDXSTRT,1,3))
S DIR("A",3)="All outpatient encounters that occurred between "_X
S X=(+$E(SCDXEND,4,5))_"/"_(+$E(SCDXEND,6,7))_"/"_(1700+$E(SCDXEND,1,3))
S DIR("A",4)="and "_X_" will be marked for retransmission to the"
S DIR("A",5)="National Patient Care Database."
S DIR("A",6)=" "
S DIR("A",7)=" "
S DIR("A")="Are you sure you want to do this ? "
S DIR(0)="YA"
D ^DIR
;Not verified / user abort / time out
Q:('Y)
;Queue marking for retransmission
S ZTRTN="TASKRX^SCDXRT01"
S ZTDESC="Mark [Deleted] Outpatient Encounters for retransmission"
S ZTDTH=$H
S ZTIO=""
S ZTSAVE("SCDXSTRT")=SCDXSTRT
S ZTSAVE("SCDXEND")=SCDXEND
K ZTSK D ^%ZTLOAD
W:('$G(ZTSK)) !!,"** UNABLE TO QUEUE MARKING OF ENCOUNTERS FOR RETRANSMISSION **",!!
W:($G(ZTSK)) !!,"Marking of encounters for retransmission queued as task number ",ZTSK
W !!
Q
;
TASKRX ;Mark all [Deleted] Outpatient Encounters in a given date range
; for retransmission
;
;Input : SCDXSTRT - Date to begin marking encounters from
; (FileMan format) (Required)
; SCDXEND - Date to end marking encounters at
; (FileMan format) (Required)
;Output : None
;Notes : Encounters that are not contained in the Transmitted
; Outpatient Encounter file (#409.73) can not be
; retransmitted
; : This entry point should be used when marking for
; retransmission is being queued. If queued, ZTSTOP will
; be set accordingly.
;
;Check input
Q:('$G(SCDXSTRT))
Q:('$G(SCDXEND))
;Declare variables
N JUNK
;Call module to mark entries for retransmission
S JUNK=$$REXMIT(SCDXSTRT,SCDXEND)
;Set ZTSTOP accordingly
S:($P(JUNK,"^",4)) ZTSTOP=1
;Done
Q
;
REXMIT(STARTDT,ENDDT) ;Mark all [Deleted] Outpatient Encounters in a
; given date range for retransmission
;
;Input : STARTDT - Date to begin marking encounters from
; (FileMan format) (Required)
; ENDDT - Date to end marking encounters at (FileMan format)
; (Required)
;Output : Tot^Enc^Del^Stop - Number of [deleted] encounters marked for
; retransmission
; Tot - Total number of encounters marked
; Enc - Number of existing encounters marked
; Del - Number of deleted encounters marked
; Stop - Flag indicating if task was asked to stop
; 1 = Task was asked to stop
; 0 = Task was not asked to stop
; 0 - No encounters marked / bad input
;Notes : Encounters that are not contained in the Transmitted
; Outpatient Encounter file (#409.73) can not be
; retransmitted
;
;Check input
S STARTDT=+$G(STARTDT)
Q:('STARTDT)
S ENDDT=+$G(ENDDT)
Q:('ENDDT)
;Declare variables
N XMITPTR,ENCPTR,DELPTR,ENCDATE,EVNTDATE,DELCNT,ENCCNT,STOP,LOOP
S STOP=0
;Add one second before midnight to ending date
S ENDDT=ENDDT+.235959
;Find all deleted encounters that fall in date range
S ENCDATE=STARTDT-.000001
S DELCNT=0
F LOOP=1:1 S ENCDATE=+$O(^SD(409.74,"B",ENCDATE)) Q:(('ENCDATE)!(ENCDATE>ENDDT)) D Q:(STOP)
.;Check for request to stop
.I ('(LOOP#10)) S STOP=$$S^%ZTLOAD(DELCNT_" encounters have been marked for retransmission") Q:(STOP)
.S DELPTR=0
.F S DELPTR=+$O(^SD(409.74,"B",ENCDATE,DELPTR)) Q:('DELPTR) D
..;Find entry in Transmitted Outpatient Encounter file
..S XMITPTR=+$O(^SD(409.73,"ADEL",DELPTR,0))
..;Entry not found - don't retransmit
..Q:('XMITPTR)
..;Mark entry for retransmission
..D STREEVNT^SCDXFU01(XMITPTR,0)
..;Turn on transmission flag
..D XMITFLAG^SCDXFU01(XMITPTR)
..;Increment count of deleted encounters marked
..S DELCNT=DELCNT+1
;Task was asked to stop - abort
Q:(STOP) DELCNT_"^^"_DELCNT_"^1"
;Find all encounters that fall in date range
S ENCCNT=0
S ENCDATE=STARTDT-.000001
F LOOP=1:1 S ENCDATE=+$O(^SCE("B",ENCDATE)) Q:(('ENCDATE)!(ENCDATE>ENDDT)) D Q:(STOP)
.;Check for request to stop
.I ('(LOOP#10)) S STOP=$$S^%ZTLOAD((ENCCNT+DELCNT)_" encounters have been marked for retransmission") Q:(STOP)
.S ENCPTR=0
.F S ENCPTR=+$O(^SCE("B",ENCDATE,ENCPTR)) Q:('ENCPTR) D
..;Find entry in Transmitted Outpatient Encounter file
..S XMITPTR=+$O(^SD(409.73,"AENC",ENCPTR,0))
..;Entry not found - don't retransmit
..Q:('XMITPTR)
..;Mark entry for retransmission
..D STREEVNT^SCDXFU01(XMITPTR,0)
..;Turn on transmission flag
..D XMITFLAG^SCDXFU01(XMITPTR)
..;Increment count of encounters marked
..S ENCCNT=ENCCNT+1
;Done
Q (DELCNT+ENCCNT)_"^"_ENCCNT_"^"_DELCNT_"^"_STOP
SCDXRT01 ;ALB/JRP - AMB CARE RETRANSMISSION;09-MAY-1996
+1 ;;5.3;Scheduling;**44,1015**;AUG 13, 1993;Build 21
+2 ;
RTRNRNG ;Mark all [Deleted] Outpatient Encounters for a user specified
+1 ; date range for retransmission to the National Ambulatory Care
+2 ; Database
+3 ;
+4 ;Input : None
+5 ;Output : None
+6 ;Note : User is prompted for the date range to retransmit
+7 ; : Encounters that are not contained in the Transmitted
+8 ; Outpatient Encounter file (#409.73) can not be
+9 ; retransmitted
+10 ; : [Deleted] Encounters that occurred before switching to new
+11 ; transmission format can not be retransmitted
+12 ; : [Deleted] Encounters that occurred within the last two days
+13 ; can not be retransmitted
+14 ;
+15 ;Declare variables
+16 NEW MINDT,MAXDT,SCDXSTRT,SCDXEND,HELPTXT,X,%H,%,%I
+17 NEW ZTSK,ZTDESC,ZTRTN,ZTIO,ZTDTH
+18 WRITE !!
+19 ;Cut-off date for old transmission format is earliest date
+20 ; allowed for retransmission (default to 10/1/96)
+21 SET MINDT=+$PIECE($GET(^SD(404.91,1,"AMB")),"^",2)
+22 IF ('MINDT)
SET MINDT=2961001
+23 ;Today is the latest date allowed for retransmission
+24 DO NOW^%DTC
+25 SET MAXDT=X
+26 ;Set up help text for getting beginning and ending dates
+27 SET HELPTXT("BGN")="Enter the beginning date for retransmitting encounters"
+28 SET HELPTXT("END")="Enter the ending date for retransmitting encounters"
+29 ;Get beginning and ending dates
+30 SET X=$$GETDTRNG^SCDXUTL1(MINDT,MAXDT,"HELPTXT(""BGN"")","HELPTXT(""END"")")
+31 ;User abort / time out
+32 IF (X<0)
QUIT
+33 WRITE !!
+34 ;Verify that user wants to do this
+35 SET SCDXSTRT=$PIECE(X,"^",1)
+36 SET SCDXEND=$PIECE(X,"^",2)
+37 SET DIR("A",1)=" "
+38 SET DIR("A",2)=" "
+39 SET X=(+$EXTRACT(SCDXSTRT,4,5))_"/"_(+$EXTRACT(SCDXSTRT,6,7))_"/"_(1700+$EXTRACT(SCDXSTRT,1,3))
+40 SET DIR("A",3)="All outpatient encounters that occurred between "_X
+41 SET X=(+$EXTRACT(SCDXEND,4,5))_"/"_(+$EXTRACT(SCDXEND,6,7))_"/"_(1700+$EXTRACT(SCDXEND,1,3))
+42 SET DIR("A",4)="and "_X_" will be marked for retransmission to the"
+43 SET DIR("A",5)="National Patient Care Database."
+44 SET DIR("A",6)=" "
+45 SET DIR("A",7)=" "
+46 SET DIR("A")="Are you sure you want to do this ? "
+47 SET DIR(0)="YA"
+48 DO ^DIR
+49 ;Not verified / user abort / time out
+50 IF ('Y)
QUIT
+51 ;Queue marking for retransmission
+52 SET ZTRTN="TASKRX^SCDXRT01"
+53 SET ZTDESC="Mark [Deleted] Outpatient Encounters for retransmission"
+54 SET ZTDTH=$HOROLOG
+55 SET ZTIO=""
+56 SET ZTSAVE("SCDXSTRT")=SCDXSTRT
+57 SET ZTSAVE("SCDXEND")=SCDXEND
+58 KILL ZTSK
DO ^%ZTLOAD
+59 IF ('$GET(ZTSK))
WRITE !!,"** UNABLE TO QUEUE MARKING OF ENCOUNTERS FOR RETRANSMISSION **",!!
+60 IF ($GET(ZTSK))
WRITE !!,"Marking of encounters for retransmission queued as task number ",ZTSK
+61 WRITE !!
+62 QUIT
+63 ;
TASKRX ;Mark all [Deleted] Outpatient Encounters in a given date range
+1 ; for retransmission
+2 ;
+3 ;Input : SCDXSTRT - Date to begin marking encounters from
+4 ; (FileMan format) (Required)
+5 ; SCDXEND - Date to end marking encounters at
+6 ; (FileMan format) (Required)
+7 ;Output : None
+8 ;Notes : Encounters that are not contained in the Transmitted
+9 ; Outpatient Encounter file (#409.73) can not be
+10 ; retransmitted
+11 ; : This entry point should be used when marking for
+12 ; retransmission is being queued. If queued, ZTSTOP will
+13 ; be set accordingly.
+14 ;
+15 ;Check input
+16 IF ('$GET(SCDXSTRT))
QUIT
+17 IF ('$GET(SCDXEND))
QUIT
+18 ;Declare variables
+19 NEW JUNK
+20 ;Call module to mark entries for retransmission
+21 SET JUNK=$$REXMIT(SCDXSTRT,SCDXEND)
+22 ;Set ZTSTOP accordingly
+23 IF ($PIECE(JUNK,"^",4))
SET ZTSTOP=1
+24 ;Done
+25 QUIT
+26 ;
REXMIT(STARTDT,ENDDT) ;Mark all [Deleted] Outpatient Encounters in a
+1 ; given date range for retransmission
+2 ;
+3 ;Input : STARTDT - Date to begin marking encounters from
+4 ; (FileMan format) (Required)
+5 ; ENDDT - Date to end marking encounters at (FileMan format)
+6 ; (Required)
+7 ;Output : Tot^Enc^Del^Stop - Number of [deleted] encounters marked for
+8 ; retransmission
+9 ; Tot - Total number of encounters marked
+10 ; Enc - Number of existing encounters marked
+11 ; Del - Number of deleted encounters marked
+12 ; Stop - Flag indicating if task was asked to stop
+13 ; 1 = Task was asked to stop
+14 ; 0 = Task was not asked to stop
+15 ; 0 - No encounters marked / bad input
+16 ;Notes : Encounters that are not contained in the Transmitted
+17 ; Outpatient Encounter file (#409.73) can not be
+18 ; retransmitted
+19 ;
+20 ;Check input
+21 SET STARTDT=+$GET(STARTDT)
+22 IF ('STARTDT)
QUIT
+23 SET ENDDT=+$GET(ENDDT)
+24 IF ('ENDDT)
QUIT
+25 ;Declare variables
+26 NEW XMITPTR,ENCPTR,DELPTR,ENCDATE,EVNTDATE,DELCNT,ENCCNT,STOP,LOOP
+27 SET STOP=0
+28 ;Add one second before midnight to ending date
+29 SET ENDDT=ENDDT+.235959
+30 ;Find all deleted encounters that fall in date range
+31 SET ENCDATE=STARTDT-.000001
+32 SET DELCNT=0
+33 FOR LOOP=1:1
SET ENCDATE=+$ORDER(^SD(409.74,"B",ENCDATE))
IF (('ENCDATE)!(ENCDATE>ENDDT))
QUIT
Begin DoDot:1
+34 ;Check for request to stop
+35 IF ('(LOOP#10))
SET STOP=$$S^%ZTLOAD(DELCNT_" encounters have been marked for retransmission")
IF (STOP)
QUIT
+36 SET DELPTR=0
+37 FOR
SET DELPTR=+$ORDER(^SD(409.74,"B",ENCDATE,DELPTR))
IF ('DELPTR)
QUIT
Begin DoDot:2
+38 ;Find entry in Transmitted Outpatient Encounter file
+39 SET XMITPTR=+$ORDER(^SD(409.73,"ADEL",DELPTR,0))
+40 ;Entry not found - don't retransmit
+41 IF ('XMITPTR)
QUIT
+42 ;Mark entry for retransmission
+43 DO STREEVNT^SCDXFU01(XMITPTR,0)
+44 ;Turn on transmission flag
+45 DO XMITFLAG^SCDXFU01(XMITPTR)
+46 ;Increment count of deleted encounters marked
+47 SET DELCNT=DELCNT+1
End DoDot:2
End DoDot:1
IF (STOP)
QUIT
+48 ;Task was asked to stop - abort
+49 IF (STOP)
QUIT DELCNT_"^^"_DELCNT_"^1"
+50 ;Find all encounters that fall in date range
+51 SET ENCCNT=0
+52 SET ENCDATE=STARTDT-.000001
+53 FOR LOOP=1:1
SET ENCDATE=+$ORDER(^SCE("B",ENCDATE))
IF (('ENCDATE)!(ENCDATE>ENDDT))
QUIT
Begin DoDot:1
+54 ;Check for request to stop
+55 IF ('(LOOP#10))
SET STOP=$$S^%ZTLOAD((ENCCNT+DELCNT)_" encounters have been marked for retransmission")
IF (STOP)
QUIT
+56 SET ENCPTR=0
+57 FOR
SET ENCPTR=+$ORDER(^SCE("B",ENCDATE,ENCPTR))
IF ('ENCPTR)
QUIT
Begin DoDot:2
+58 ;Find entry in Transmitted Outpatient Encounter file
+59 SET XMITPTR=+$ORDER(^SD(409.73,"AENC",ENCPTR,0))
+60 ;Entry not found - don't retransmit
+61 IF ('XMITPTR)
QUIT
+62 ;Mark entry for retransmission
+63 DO STREEVNT^SCDXFU01(XMITPTR,0)
+64 ;Turn on transmission flag
+65 DO XMITFLAG^SCDXFU01(XMITPTR)
+66 ;Increment count of encounters marked
+67 SET ENCCNT=ENCCNT+1
End DoDot:2
End DoDot:1
IF (STOP)
QUIT
+68 ;Done
+69 QUIT (DELCNT+ENCCNT)_"^"_ENCCNT_"^"_DELCNT_"^"_STOP