SCDXPRN2 ;ALB/JRP - HISTORY FILE REPORTS;21-JUL-1997
;;5.3;Scheduling;**128,135,405,621,670**;AUG 13, 1993;Build 18
;
FULLHIST ;Print full transmission history report
; - Report based within the ACRP Transmission History file (#409.77)
; - User prompted for selection criteria
; Division (one/many/all) Clinic (o/m/a) Patient (o/m/a)
; - User prompted for transmission date range
; - Report formatted for 80 columns (allows output to screen)
;
; Changes made for SD*5.3*670 to resolve issue with queued print jobs on
; multiple machine and Linux based systems.
; Removed extraneous indirection to prevent excessive overhead.
; Changed ^TMP($J entries to ^XTMP(DUZ to prevent non-translatable job replications
; and /tmp/ variations. This allows Multimachine systems to print, which will fail otherwise.
; Also removed ZTQUEUED and Q:($$S^%ZTLOAD())checks as they
; are no longer relevant.
;Declare variables
N VAUTSTR,VAUTNI,VAUTVB,VAUTNALL,VAUTD,VAUTC,VAUTN
N SCDXBEG,SCDXEND,X,Y,SCDXH,SCDXLOCK
;SD*5.3*405 lock user from running multiple times in same session
I $D(^XTMP("RPT-LOCK",DUZ)) W !!,"Sorry, you either have this report already running or queued to run.",!,"Please try again later.",!! Q
;Initialize selection global
K ^XTMP("SCDXPRN2",DUZ,"SELECT")
;Get division(s) - default to 'ALL' if single division
S VAUTD=1 I ($P($G(^DG(43,1,"GL")),"^",2)) D DIVISION^VAUTOMA Q:(Y<0)
;Merge into global location [for tasking]
; Preserve local array - it's required input for clinic selection
M ^XTMP("SCDXPRN2",DUZ,"SELECT","VAUTD")=VAUTD
;Get clinic(s)
S VAUTNI=2 D CLINIC^VAUTOMA Q:(Y<0)
;Merge into global location [for tasking] and delete local array
M ^XTMP("SCDXPRN2",DUZ,"SELECT","VAUTC")=VAUTC
K VAUTC
;Delete local array of selected divisions
K VAUTD
;Get patient(s)
S VAUTNI=2 D PATIENT^VAUTOMA Q:(Y<0)
;Merge into global location [for tasking] and delete array
M ^XTMP("SCDXPRN2",DUZ,"SELECT","VAUTN")=VAUTN
K VAUTN
;Set allowable date range
S SCDXBEG=2961001
S SCDXEND=$$DT^XLFDT()
;Begin date help text
S SCDXH("B",1)="Enter transmission date to begin search from"
S SCDXH("B",2)=" "
S SCDXH("B",3)=$$FMTE^XLFDT(SCDXBEG)_" is the earliest date allowed"
S SCDXH("B",4)=$$FMTE^XLFDT(SCDXEND)_" will be the latest date allowed"
S SCDXH("B",5)=" "
S SCDXH("B",6)="Note: Encounter date does not always match date of"
S SCDXH("B")=" transmission to the National Patient Care Database"
; End date help text
S SCDXH("E",1)="Enter transmission date to end search at"
S SCDXH("E",2)=" "
S SCDXH("E",3)=$$FMTE^XLFDT(SCDXEND)_" is the latest date allowed"
S SCDXH("E",4)=$$FMTE^XLFDT(SCDXBEG)_" was the earliest date allowed"
S SCDXH("E",5)=" "
S SCDXH("E",6)="Note: Encounter date does not always match date of"
S SCDXH("E")=" transmission to the National Patient Care Database"
S X=$$GETDTRNG^SCDXUTL1(SCDXBEG,SCDXEND,$NA(SCDXH("B")),$NA(SCDXH("E")))
Q:(X<0)
K SCDXH
S SCDXBEG=+$P(X,"^",1)
S SCDXEND=+$P(X,"^",2)
S SCDXLOCK="SCDXPRN2"_U_DUZ ;SD*5.3*405 lock variable for when report is queued
S ^XTMP("RPT-LOCK",DUZ)="" ;SD*5.3*405 set lock for current user
D PRINT^SCDXPRN2
;Done - reset IO variables (safety measure) and quit
K ^XTMP("RPT-LOCK",DUZ),DDBRZIS
D HOME^%ZIS
Q
;
PRINT ;Print report
;Input : SCDXBEG - Begin date (FileMan)
; - Refers to date/time of transmission (not encounter)
; SCDXEND - End date (FileMan)
; - Refers to date/time of transmission (not encounter)
; ^XTMP("SCDXPRN2",DUZ,"SELECT") - Global containing selection criteria
; SCDXLOCK- Equals user's DUZ and locks the same user from
; queueing the report more than once at the same time
; This was output of calls to VAUTOMA for division,
; clinic, and patient (full global reference)
; Divisions selected Clinics selected Patients selected
; ^XTMP("SCDXPRN2",DUZ,"SELECT") ^("VAUTD") ^("VAUTC") ^("VAUTN")
; ^("VAUTD",x) ^("VAUTC",x) ^("VAUTN",x)
;Output : None
;Notes : All input is REQUIRED - report will not be generated if
; any of the variables are not defined
; : All input (including global location) will be deleted on exit
; : User will be prompted for device except on queued entry
;
;Declare variables
N DIC,L,BY,FR,TO,DHD,FLDS,DISPAR,DIOBEG,DIOEND,IOP,DOLJ
;Define sort criteria
S DIC="^SD(409.77,"
S L=0
;Define sort array
S BY(0)="^XTMP(""SCDXPRN2"","_DUZ_",""SORT"","
S L(0)=6
;Set purge criteria as required for ^XTMP usage.
S ^XTMP("SCDXPRN2",0)=$$FMADD^XLFDT($$DT^XLFDT(),1)_","_$$DT^XLFDT()
;Define sort routine
S DIOBEG="D SORT^SCDXPRN2"
;Define post-report action
;*670 Allow EN1^DIP to do the full cleanup
S DIOEND="K ^XTMP(""SCDXPRN2"","_DUZ_")"
;Form feed for each clinic
S DISPAR(0,2)="#^;"
;Define print fields
S FLDS="[SCDX XMIT HIST FULL PRINT]"
;Define header & footer
S DHD="[SCDX XMIT HIST FULL HEADER]-[SCDX XMIT HIST FULL FOOTER]"
;Print report, Set Browser variable to prevent page length issues.
S %ZIS="QM",DDBRZIS=1
D EN1^DIP
;SD*5.3*405 remove lock for current user
;K ^XTMP("RPT-LOCK",$P(SCDXLOCK,U,1),$P(SCDXLOCK,U,2))
Q
;
SORT ;Sort routine
;Input : See TASK entry point
;Output : Global containing sorted entries for printing
; ^XTMP("SCDXPRN2",$J,"SORT",Div,Clin,Pat,EncDate,VID,DA)
; Div = Division name Clin = Clinic name
; Pat = Patient name EncDate = Encounter date [no time]
; VID = Visit ID DA = Pointer to entry in 409.77
;Notes : ^XTMP("SCDXPRN2",DUZ,"SORT") will be initialized upon entry
; : Existance & validity of input is assumed
;
;Declare variables
N HISTPTR,NODE,DATE,NAME,CLINIC,DIVISION,VID
N BEGDATE,ENDDATE,TMP,VAUTD,VAUTC,VAUTN
;Make begin and end dates opposing midnights
S BEGDATE=$$FMADD^XLFDT($P(SCDXBEG,".",1),-1,23,59,59)
S ENDDATE=$$FMADD^XLFDT($P(SCDXEND,".",1),0,23,59,59)
;All divisions selected ?
S VAUTD=+$G(^XTMP("SCDXPRN2",DUZ,"SELECT","VAUTD"))
;All clinics selected ?
S VAUTC=+$G(^XTMP("SCDXPRN2",DUZ,"SELECT","VAUTC"))
;All patients selected ?
S VAUTN=+$G(^XTMP("SCDXPRN2",DUZ,"SELECT","VAUTN"))
;Initialize sort array
K ^XTMP("SCDXPRN2",DUZ,"SORT")
;Sort/screen
F S BEGDATE=+$O(^SD(409.77,"AXMIT",BEGDATE)) Q:(('BEGDATE)!(BEGDATE>ENDDATE)) D
.S HISTPTR=0
.F S HISTPTR=+$O(^SD(409.77,"AXMIT",BEGDATE,HISTPTR)) Q:('HISTPTR) D
..;Grab zero node of entry
..S NODE=$G(^SD(409.77,HISTPTR,0))
..;Get encounter date (strip time)
..S TMP=+$P(NODE,"^",2)
..S DATE=$P(TMP,".",1)
..;Get patient
..S TMP=+$P(NODE,"^",3)
..S NAME=$P($G(^DPT(TMP,0),"UNKNOWN"),"^",1)
..;Patient selection screen
..I ('VAUTN) Q:('$D(^XTMP("SCDXPRN2",DUZ,"SELECT","VAUTN",TMP)))
..;Get clinic
..S TMP=+$P(NODE,"^",4)
..S CLINIC=$P($G(^SC(TMP,0),"UNKNOWN"),"^",1)
..;Clinic selection screen
..I ('VAUTC) Q:('$D(^XTMP("SCDXPRN2",DUZ,"SELECT","VAUTC",TMP)))
..;Get division
..S TMP=+$P(NODE,"^",5)
..S DIVISION=$P($G(^DG(40.8,TMP,0),"UNKNOWN"),"^",1)
..;Division selection screen
..I ('VAUTD) Q:('$D(^XTMP("SCDXPRN2",DUZ,"SELECT","VAUTD",TMP)))
..;Get visit ID
..S VID=+$P(NODE,"^",6)
..;Store in pre-sort array
..S ^XTMP("SCDXPRN2",DUZ,"SORT",DIVISION,CLINIC,NAME,DATE,VID,HISTPTR)=""
..Q
.Q
;Done
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSCDXPRN2 7589 printed Dec 13, 2024@02:39:29 Page 2
SCDXPRN2 ;ALB/JRP - HISTORY FILE REPORTS;21-JUL-1997
+1 ;;5.3;Scheduling;**128,135,405,621,670**;AUG 13, 1993;Build 18
+2 ;
FULLHIST ;Print full transmission history report
+1 ; - Report based within the ACRP Transmission History file (#409.77)
+2 ; - User prompted for selection criteria
+3 ; Division (one/many/all) Clinic (o/m/a) Patient (o/m/a)
+4 ; - User prompted for transmission date range
+5 ; - Report formatted for 80 columns (allows output to screen)
+6 ;
+7 ; Changes made for SD*5.3*670 to resolve issue with queued print jobs on
+8 ; multiple machine and Linux based systems.
+9 ; Removed extraneous indirection to prevent excessive overhead.
+10 ; Changed ^TMP($J entries to ^XTMP(DUZ to prevent non-translatable job replications
+11 ; and /tmp/ variations. This allows Multimachine systems to print, which will fail otherwise.
+12 ; Also removed ZTQUEUED and Q:($$S^%ZTLOAD())checks as they
+13 ; are no longer relevant.
+14 ;Declare variables
+15 NEW VAUTSTR,VAUTNI,VAUTVB,VAUTNALL,VAUTD,VAUTC,VAUTN
+16 NEW SCDXBEG,SCDXEND,X,Y,SCDXH,SCDXLOCK
+17 ;SD*5.3*405 lock user from running multiple times in same session
+18 IF $DATA(^XTMP("RPT-LOCK",DUZ))
WRITE !!,"Sorry, you either have this report already running or queued to run.",!,"Please try again later.",!!
QUIT
+19 ;Initialize selection global
+20 KILL ^XTMP("SCDXPRN2",DUZ,"SELECT")
+21 ;Get division(s) - default to 'ALL' if single division
+22 SET VAUTD=1
IF ($PIECE($GET(^DG(43,1,"GL")),"^",2))
DO DIVISION^VAUTOMA
if (Y<0)
QUIT
+23 ;Merge into global location [for tasking]
+24 ; Preserve local array - it's required input for clinic selection
+25 MERGE ^XTMP("SCDXPRN2",DUZ,"SELECT","VAUTD")=VAUTD
+26 ;Get clinic(s)
+27 SET VAUTNI=2
DO CLINIC^VAUTOMA
if (Y<0)
QUIT
+28 ;Merge into global location [for tasking] and delete local array
+29 MERGE ^XTMP("SCDXPRN2",DUZ,"SELECT","VAUTC")=VAUTC
+30 KILL VAUTC
+31 ;Delete local array of selected divisions
+32 KILL VAUTD
+33 ;Get patient(s)
+34 SET VAUTNI=2
DO PATIENT^VAUTOMA
if (Y<0)
QUIT
+35 ;Merge into global location [for tasking] and delete array
+36 MERGE ^XTMP("SCDXPRN2",DUZ,"SELECT","VAUTN")=VAUTN
+37 KILL VAUTN
+38 ;Set allowable date range
+39 SET SCDXBEG=2961001
+40 SET SCDXEND=$$DT^XLFDT()
+41 ;Begin date help text
+42 SET SCDXH("B",1)="Enter transmission date to begin search from"
+43 SET SCDXH("B",2)=" "
+44 SET SCDXH("B",3)=$$FMTE^XLFDT(SCDXBEG)_" is the earliest date allowed"
+45 SET SCDXH("B",4)=$$FMTE^XLFDT(SCDXEND)_" will be the latest date allowed"
+46 SET SCDXH("B",5)=" "
+47 SET SCDXH("B",6)="Note: Encounter date does not always match date of"
+48 SET SCDXH("B")=" transmission to the National Patient Care Database"
+49 ; End date help text
+50 SET SCDXH("E",1)="Enter transmission date to end search at"
+51 SET SCDXH("E",2)=" "
+52 SET SCDXH("E",3)=$$FMTE^XLFDT(SCDXEND)_" is the latest date allowed"
+53 SET SCDXH("E",4)=$$FMTE^XLFDT(SCDXBEG)_" was the earliest date allowed"
+54 SET SCDXH("E",5)=" "
+55 SET SCDXH("E",6)="Note: Encounter date does not always match date of"
+56 SET SCDXH("E")=" transmission to the National Patient Care Database"
+57 SET X=$$GETDTRNG^SCDXUTL1(SCDXBEG,SCDXEND,$NAME(SCDXH("B")),$NAME(SCDXH("E")))
+58 if (X<0)
QUIT
+59 KILL SCDXH
+60 SET SCDXBEG=+$PIECE(X,"^",1)
+61 SET SCDXEND=+$PIECE(X,"^",2)
+62 ;SD*5.3*405 lock variable for when report is queued
SET SCDXLOCK="SCDXPRN2"_U_DUZ
+63 ;SD*5.3*405 set lock for current user
SET ^XTMP("RPT-LOCK",DUZ)=""
+64 DO PRINT^SCDXPRN2
+65 ;Done - reset IO variables (safety measure) and quit
+66 KILL ^XTMP("RPT-LOCK",DUZ),DDBRZIS
+67 DO HOME^%ZIS
+68 QUIT
+69 ;
PRINT ;Print report
+1 ;Input : SCDXBEG - Begin date (FileMan)
+2 ; - Refers to date/time of transmission (not encounter)
+3 ; SCDXEND - End date (FileMan)
+4 ; - Refers to date/time of transmission (not encounter)
+5 ; ^XTMP("SCDXPRN2",DUZ,"SELECT") - Global containing selection criteria
+6 ; SCDXLOCK- Equals user's DUZ and locks the same user from
+7 ; queueing the report more than once at the same time
+8 ; This was output of calls to VAUTOMA for division,
+9 ; clinic, and patient (full global reference)
+10 ; Divisions selected Clinics selected Patients selected
+11 ; ^XTMP("SCDXPRN2",DUZ,"SELECT") ^("VAUTD") ^("VAUTC") ^("VAUTN")
+12 ; ^("VAUTD",x) ^("VAUTC",x) ^("VAUTN",x)
+13 ;Output : None
+14 ;Notes : All input is REQUIRED - report will not be generated if
+15 ; any of the variables are not defined
+16 ; : All input (including global location) will be deleted on exit
+17 ; : User will be prompted for device except on queued entry
+18 ;
+19 ;Declare variables
+20 NEW DIC,L,BY,FR,TO,DHD,FLDS,DISPAR,DIOBEG,DIOEND,IOP,DOLJ
+21 ;Define sort criteria
+22 SET DIC="^SD(409.77,"
+23 SET L=0
+24 ;Define sort array
+25 SET BY(0)="^XTMP(""SCDXPRN2"","_DUZ_",""SORT"","
+26 SET L(0)=6
+27 ;Set purge criteria as required for ^XTMP usage.
+28 SET ^XTMP("SCDXPRN2",0)=$$FMADD^XLFDT($$DT^XLFDT(),1)_","_$$DT^XLFDT()
+29 ;Define sort routine
+30 SET DIOBEG="D SORT^SCDXPRN2"
+31 ;Define post-report action
+32 ;*670 Allow EN1^DIP to do the full cleanup
+33 SET DIOEND="K ^XTMP(""SCDXPRN2"","_DUZ_")"
+34 ;Form feed for each clinic
+35 SET DISPAR(0,2)="#^;"
+36 ;Define print fields
+37 SET FLDS="[SCDX XMIT HIST FULL PRINT]"
+38 ;Define header & footer
+39 SET DHD="[SCDX XMIT HIST FULL HEADER]-[SCDX XMIT HIST FULL FOOTER]"
+40 ;Print report, Set Browser variable to prevent page length issues.
+41 SET %ZIS="QM"
SET DDBRZIS=1
+42 DO EN1^DIP
+43 ;SD*5.3*405 remove lock for current user
+44 ;K ^XTMP("RPT-LOCK",$P(SCDXLOCK,U,1),$P(SCDXLOCK,U,2))
+45 QUIT
+46 ;
SORT ;Sort routine
+1 ;Input : See TASK entry point
+2 ;Output : Global containing sorted entries for printing
+3 ; ^XTMP("SCDXPRN2",$J,"SORT",Div,Clin,Pat,EncDate,VID,DA)
+4 ; Div = Division name Clin = Clinic name
+5 ; Pat = Patient name EncDate = Encounter date [no time]
+6 ; VID = Visit ID DA = Pointer to entry in 409.77
+7 ;Notes : ^XTMP("SCDXPRN2",DUZ,"SORT") will be initialized upon entry
+8 ; : Existance & validity of input is assumed
+9 ;
+10 ;Declare variables
+11 NEW HISTPTR,NODE,DATE,NAME,CLINIC,DIVISION,VID
+12 NEW BEGDATE,ENDDATE,TMP,VAUTD,VAUTC,VAUTN
+13 ;Make begin and end dates opposing midnights
+14 SET BEGDATE=$$FMADD^XLFDT($PIECE(SCDXBEG,".",1),-1,23,59,59)
+15 SET ENDDATE=$$FMADD^XLFDT($PIECE(SCDXEND,".",1),0,23,59,59)
+16 ;All divisions selected ?
+17 SET VAUTD=+$GET(^XTMP("SCDXPRN2",DUZ,"SELECT","VAUTD"))
+18 ;All clinics selected ?
+19 SET VAUTC=+$GET(^XTMP("SCDXPRN2",DUZ,"SELECT","VAUTC"))
+20 ;All patients selected ?
+21 SET VAUTN=+$GET(^XTMP("SCDXPRN2",DUZ,"SELECT","VAUTN"))
+22 ;Initialize sort array
+23 KILL ^XTMP("SCDXPRN2",DUZ,"SORT")
+24 ;Sort/screen
+25 FOR
SET BEGDATE=+$ORDER(^SD(409.77,"AXMIT",BEGDATE))
if (('BEGDATE)!(BEGDATE>ENDDATE))
QUIT
Begin DoDot:1
+26 SET HISTPTR=0
+27 FOR
SET HISTPTR=+$ORDER(^SD(409.77,"AXMIT",BEGDATE,HISTPTR))
if ('HISTPTR)
QUIT
Begin DoDot:2
+28 ;Grab zero node of entry
+29 SET NODE=$GET(^SD(409.77,HISTPTR,0))
+30 ;Get encounter date (strip time)
+31 SET TMP=+$PIECE(NODE,"^",2)
+32 SET DATE=$PIECE(TMP,".",1)
+33 ;Get patient
+34 SET TMP=+$PIECE(NODE,"^",3)
+35 SET NAME=$PIECE($GET(^DPT(TMP,0),"UNKNOWN"),"^",1)
+36 ;Patient selection screen
+37 IF ('VAUTN)
if ('$DATA(^XTMP("SCDXPRN2",DUZ,"SELECT","VAUTN",TMP)))
QUIT
+38 ;Get clinic
+39 SET TMP=+$PIECE(NODE,"^",4)
+40 SET CLINIC=$PIECE($GET(^SC(TMP,0),"UNKNOWN"),"^",1)
+41 ;Clinic selection screen
+42 IF ('VAUTC)
if ('$DATA(^XTMP("SCDXPRN2",DUZ,"SELECT","VAUTC",TMP)))
QUIT
+43 ;Get division
+44 SET TMP=+$PIECE(NODE,"^",5)
+45 SET DIVISION=$PIECE($GET(^DG(40.8,TMP,0),"UNKNOWN"),"^",1)
+46 ;Division selection screen
+47 IF ('VAUTD)
if ('$DATA(^XTMP("SCDXPRN2",DUZ,"SELECT","VAUTD",TMP)))
QUIT
+48 ;Get visit ID
+49 SET VID=+$PIECE(NODE,"^",6)
+50 ;Store in pre-sort array
+51 SET ^XTMP("SCDXPRN2",DUZ,"SORT",DIVISION,CLINIC,NAME,DATE,VID,HISTPTR)=""
+52 QUIT
End DoDot:2
+53 QUIT
End DoDot:1
+54 ;Done
+55 QUIT