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

SCDXPRN2.m

Go to the documentation of this file.
  1. SCDXPRN2 ;ALB/JRP - HISTORY FILE REPORTS;21-JUL-1997
  1. ;;5.3;Scheduling;**128,135,405,1015**;AUG 13, 1993;Build 21
  1. ;
  1. FULLHIST ;Print full transmission history report
  1. ; - Report based within the ACRP Transmission History file (#409.77)
  1. ; - User prompted for selection criteria
  1. ; Division (one/many/all) Clinic (o/m/a) Patient (o/m/a)
  1. ; - User prompted for transmission date range
  1. ; - Report formatted for 80 columns (allows output to screen)
  1. ;
  1. ;Declare variables
  1. N VAUTSTR,VAUTNI,VAUTVB,VAUTNALL,VAUTD,VAUTC,VAUTN
  1. N SCDXBEG,SCDXEND,SCDXGLO,X,Y,SCDXH,SCDXLOCK
  1. ;SD*5.3*405 lock user from running multiple times in same session
  1. I $D(^TMP("RPT-LOCK",$J,DUZ)) W !!,"Sorry, you either have this report already running or queued to run.",!,"Please try again later.",!! Q
  1. ;Initialize selection global
  1. S SCDXGLO=$NA(^TMP("SCDXPRN2",$J,"SELECT"))
  1. K @SCDXGLO
  1. ;Get division(s) - default to 'ALL' if single division
  1. S VAUTD=1 I ($P($G(^DG(43,1,"GL")),"^",2)) D DIVISION^VAUTOMA Q:(Y<0)
  1. ;Copy into global location [for tasking]
  1. ; Local array not deleted - it's required input for clinic selection
  1. M @SCDXGLO@("VAUTD")=VAUTD
  1. ;Get clinic(s)
  1. S VAUTNI=2 D CLINIC^VAUTOMA Q:(Y<0)
  1. ;Copy into global location [for tasking] and delete local array
  1. M @SCDXGLO@("VAUTC")=VAUTC
  1. K VAUTC
  1. ;Delete local array of selected divisions
  1. K VAUTD
  1. ;Get patient(s)
  1. S VAUTNI=2 D PATIENT^VAUTOMA Q:(Y<0)
  1. ;Copy into global location [for tasking] and delete array
  1. M @SCDXGLO@("VAUTN")=VAUTN
  1. K VAUTN
  1. ;Set allowable date range
  1. S SCDXBEG=2961001
  1. S SCDXEND=$$DT^XLFDT()
  1. ;Begin date help text
  1. S SCDXH("B",1)="Enter transmission date to begin search from"
  1. S SCDXH("B",2)=" "
  1. S SCDXH("B",3)=$$FMTE^XLFDT(SCDXBEG)_" is the earliest date allowed"
  1. S SCDXH("B",4)=$$FMTE^XLFDT(SCDXEND)_" will be the latest date allowed"
  1. S SCDXH("B",5)=" "
  1. S SCDXH("B",6)="Note: Encounter date does not always match date of"
  1. S SCDXH("B")=" transmission to the National Patient Care Database"
  1. ; End date help text
  1. S SCDXH("E",1)="Enter transmission date to end search at"
  1. S SCDXH("E",2)=" "
  1. S SCDXH("E",3)=$$FMTE^XLFDT(SCDXEND)_" is the latest date allowed"
  1. S SCDXH("E",4)=$$FMTE^XLFDT(SCDXBEG)_" was the earliest date allowed"
  1. S SCDXH("E",5)=" "
  1. S SCDXH("E",6)="Note: Encounter date does not always match date of"
  1. S SCDXH("E")=" transmission to the National Patient Care Database"
  1. S X=$$GETDTRNG^SCDXUTL1(SCDXBEG,SCDXEND,$NA(SCDXH("B")),$NA(SCDXH("E")))
  1. Q:(X<0)
  1. K SCDXH
  1. S SCDXBEG=+$P(X,"^",1)
  1. S SCDXEND=+$P(X,"^",2)
  1. S SCDXLOCK=$J_U_DUZ ;SD*5.3*405 lock variable for when report is queued
  1. S ^TMP("RPT-LOCK",$J,DUZ)="" ;SD*5.3*405 set lock for current user
  1. ;Queue/run
  1. W !!
  1. S ZTDESC="ACRP TRANSMISSION HISTORY REPORT"
  1. S ZTSAVE("SCDXBEG")=""
  1. S ZTSAVE("SCDXEND")=""
  1. S ZTSAVE("SCDXGLO")=""
  1. S ZTSAVE("SCDXLOCK")="" ;SD*5.3*405
  1. S ZTSAVE($$OREF^DILF(SCDXGLO))=""
  1. S IOP="Q"
  1. D EN^XUTMDEVQ("PRINT^SCDXPRN2",ZTDESC,.ZTSAVE)
  1. ;Done - reset IO variables (safety measure) and quit
  1. I POP K ^TMP("RPT-LOCK",$J,DUZ)
  1. I $D(X) I X="^" K ^TMP("RPT-LOCK",$J,DUZ)
  1. D HOME^%ZIS
  1. Q
  1. ;
  1. PRINT ;Print report
  1. ;Input : SCDXBEG - Begin date (FileMan)
  1. ; - Refers to date/time of transmission (not encounter)
  1. ; SCDXEND - End date (FileMan)
  1. ; - Refers to date/time of transmission (not encounter)
  1. ; SCDXGLO - Global containing selection criteria
  1. ; SCDXLOCK- Equals user's DUZ and locks the same user from
  1. ; queueing the report more than once at the same time
  1. ; This was output of calls to VAUTOMA for division,
  1. ; clinic, and patient (full global reference)
  1. ; Divisions selected Clinics selected Patients selected
  1. ; SCDXGLO("VAUTD") SCDXGLO("VAUTC") SCDXGLO("VAUTN")
  1. ; SCDXGLO("VAUTD",x) SCDXGLO("VAUTC",x) SCDXGLO("VAUTN",x)
  1. ;Output : None
  1. ;Notes : All input is REQUIRED - report will not be generated if
  1. ; any of the variables are not defined
  1. ; : All input (including global location) will be deleted on exit
  1. ; : User will be prompted for device except on queued entry
  1. ;
  1. ;Declare variables
  1. N DIC,L,BY,FR,TO,DHD,FLDS,DISPAR,DIOBEG,DIOEND,IOP,SCDXSLVE,DOLJ
  1. ;Define sort criteria
  1. S DIC="^SD(409.77,"
  1. S L=0
  1. ;Define sort array
  1. S BY(0)="^TMP(""SCDXPRN2"",$J,""SORT"","
  1. S L(0)=6
  1. ;Make FileMan think sort already done (set fake value into array)
  1. S ^TMP("SCDXPRN2",$J,"SORT",1,2,3,4,5,6)=""
  1. ;Define sort routine
  1. S DIOBEG="D SORT^SCDXPRN2"
  1. ;Define post-report action
  1. S DIOEND="K ^TMP(""SCDXPRN2"",$J,""SORT"")"
  1. ;Form feed for each clinic
  1. S DISPAR(0,2)="#^;"
  1. ;Define print fields
  1. S FLDS="[SCDX XMIT HIST FULL PRINT]"
  1. ;Define header & footer
  1. S DHD="[SCDX XMIT HIST FULL HEADER]-[SCDX XMIT HIST FULL FOOTER]"
  1. ;Use current device
  1. S IOP=IO
  1. ;Remember IO("S")
  1. S SCDXSLVE=+$G(IO("S"))
  1. ;Print report
  1. D EN1^DIP
  1. ;Reset IO("S")
  1. S:(SCDXSLVE) IO("S")=SCDXSLVE
  1. ;Delete input array & variables
  1. K @SCDXGLO
  1. K SCDXBEG,SCDXEND,SCDXGLO
  1. ;If queued, purge task
  1. S:($D(ZTQUEUED)) ZTREQ="@"
  1. ;SD*5.3*405 remove lock for current user
  1. K ^TMP("RPT-LOCK",$P(SCDXLOCK,U,1),$P(SCDXLOCK,U,2))
  1. Q
  1. ;
  1. SORT ;Sort routine
  1. ;Input : See TASK entry point
  1. ;Output : Global containing sorted entries for printing
  1. ; ^TMP("SCDXPRN2",$J,"SORT",Div,Clin,Pat,EncDate,VID,DA)
  1. ; Div = Division name Clin = Clinic name
  1. ; Pat = Patient name EncDate = Encounter date [no time]
  1. ; VID = Visit ID DA = Pointer to entry in 409.77
  1. ;Notes : ^TMP("SCDXPRN2",$J,"SORT") will be initialized upon entry
  1. ; : Existance & validity of input is assumed
  1. ;
  1. ;Declare variables
  1. N HISTPTR,NODE,DATE,NAME,CLINIC,DIVISION,VID
  1. N BEGDATE,ENDDATE,TMP,VAUTD,VAUTC,VAUTN
  1. ;Make begin and end dates opposing midnights
  1. S BEGDATE=$$FMADD^XLFDT($P(SCDXBEG,".",1),-1,23,59,59)
  1. S ENDDATE=$$FMADD^XLFDT($P(SCDXEND,".",1),0,23,59,59)
  1. ;All divisions selected ?
  1. S VAUTD=+$G(@SCDXGLO@("VAUTD"))
  1. ;All clinics selected ?
  1. S VAUTC=+$G(@SCDXGLO@("VAUTC"))
  1. ;All patients selected ?
  1. S VAUTN=+$G(@SCDXGLO@("VAUTN"))
  1. ;Initialize sort array
  1. K ^TMP("SCDXPRN2",$J,"SORT")
  1. ;Sort/screen
  1. F S BEGDATE=+$O(^SD(409.77,"AXMIT",BEGDATE)) Q:(('BEGDATE)!(BEGDATE>ENDDATE)) D Q:($$S^%ZTLOAD())
  1. .S HISTPTR=0
  1. .F S HISTPTR=+$O(^SD(409.77,"AXMIT",BEGDATE,HISTPTR)) Q:('HISTPTR) D Q:($$S^%ZTLOAD())
  1. ..;Grab zero node of entry
  1. ..S NODE=$G(^SD(409.77,HISTPTR,0))
  1. ..;Get encounter date (strip time)
  1. ..S TMP=+$P(NODE,"^",2)
  1. ..S DATE=$P(TMP,".",1)
  1. ..;Get patient
  1. ..S TMP=+$P(NODE,"^",3)
  1. ..S NAME=$P($G(^DPT(TMP,0),"UNKNOWN"),"^",1)
  1. ..;Patient selection screen
  1. ..I ('VAUTN) Q:('$D(@SCDXGLO@("VAUTN",TMP)))
  1. ..;Get clinic
  1. ..S TMP=+$P(NODE,"^",4)
  1. ..S CLINIC=$P($G(^SC(TMP,0),"UNKNOWN"),"^",1)
  1. ..;Clinic selection screen
  1. ..I ('VAUTC) Q:('$D(@SCDXGLO@("VAUTC",TMP)))
  1. ..;Get division
  1. ..S TMP=+$P(NODE,"^",5)
  1. ..S DIVISION=$P($G(^DG(40.8,TMP,0),"UNKNOWN"),"^",1)
  1. ..;Division selection screen
  1. ..I ('VAUTD) Q:('$D(@SCDXGLO@("VAUTD",TMP)))
  1. ..;Get visit ID
  1. ..S VID=+$P(NODE,"^",6)
  1. ..;Store in pre-sort array
  1. ..S ^TMP("SCDXPRN2",$J,"SORT",DIVISION,CLINIC,NAME,DATE,VID,HISTPTR)=""
  1. ;Done
  1. Q