- DGSDU ;ALB/TMP - ACRP API UTILITIES ; 12/8/97 15:09
- ;;5.3;Registration;**151**;Aug 13, 1993
- ;;
- SCAN(DGINDX,DGVAL,DGFILTER,DGCBK,DGCLOSE,DGQUERY,DGDIR) ; Scan encounters
- ; *** NOTE *** When using this call, the variable passed as DGQUERY
- ; must be newed or killed in the callling program
- ; DGINDX = index name property of the query object
- ; DGVAL = array of data elements for start/end of search
- ; DGVAL("DFN") = patient DFN
- ; DGVAL("BDT") = begin date
- ; DGVAL("EDT") = end date
- ; DGVAL("VIS") = encounter file ien
- ; DGFILTER = the executable code to use to screen entries
- ; DGCBK = the executable scan callback code to create the result set
- ; DGCLOSE = Flag that says whether or not to close the QUERY object
- ; 1 = Perform close 0 or null = Do not close object
- ; DGQUERY = the # of the current query, if not a new query. If passed by
- ; reference and query closed, this variable will be nulled
- ; DGDIR = the direction of the scan (optional)
- ; null, undefined or FORWARD : Scan forwards
- ; BACKWARD : Scan backwards
- ;
- N QUERY
- S QUERY=$G(DGQUERY)
- I '$G(QUERY) D
- .D OPEN^SDQ(.DGQUERY) Q:'$G(DGQUERY)
- .D INDEX^SDQ(.DGQUERY,DGINDX,"SET")
- .I $G(DGFILTER)'="" D FILTER^SDQ(.DGQUERY,DGFILTER,"SET")
- .D SCANCB^SDQ(.DGQUERY,DGCBK,"SET")
- I $G(QUERY) D ACTIVE^SDQ(.DGQUERY,"FALSE","SET")
- D SETINDX(.DGQUERY,DGINDX)
- D ACTIVE^SDQ(.DGQUERY,"TRUE","SET")
- S:$G(DGDIR)="" DGDIR="FORWARD"
- D SCAN^SDQ(.DGQUERY,DGDIR)
- I $G(DGCLOSE) D CLOSE(.DGQUERY)
- SCANQ Q
- ;
- CLOSE(DGQUERY) ; Close the query
- G:'$G(DGQUERY) CLOSEQ
- D CLOSE^SDQ(.DGQUERY)
- CLOSEQ Q
- ;
- SETINDX(DGQUERY,DGINDX) ;
- I DGINDX="PATIENT/DATE" D PAT,DATE
- I DGINDX="DATE/TIME" D DATE
- I DGINDX="PATIENT" D PAT
- I DGINDX="VISIT" D VIS
- Q
- ;
- PAT ; Verify patient
- D PAT^SDQ(.DGQUERY,$G(DGVAL("DFN")),"SET")
- Q
- ;
- DATE ; Verify date range
- D DATE^SDQ(.DGQUERY,$G(DGVAL("BDT")),$G(DGVAL("EDT")),"SET")
- Q
- ;
- VIS ; Verify visit
- D VISIT^SDQ(.DGQUERY,$G(DGVAL("VIS")),"SET")
- Q
- ;
- SCE(DGOE,PC,NODE,ZXERR) ; Returns the specific piece or entire node of the enctr
- ; NODE = the node to return ... if undefined, the 0-node is assumed
- ; If PC is null or undefined, the whole node is returned, otherwise
- ; just the PC-piece is returned
- ; DGERR = the name of the array where errors should be passed back in
- ; (pass in quotes I.E.: "DGERR"). If no name passed, errors are
- ; not returned
- N DGX
- S:$G(NODE)="" NODE=0
- D GETGEN^SDOE(DGOE,"DGX",$G(ZXERR))
- I $G(ZXERR)="" K ^TMP("DIERR",$J)
- S DGX=$S($G(PC):$P($G(DGX(NODE)),U,+PC),1:$G(DGX(NODE)))
- Q DGX
- ;
- --- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HDGSDU 2694 printed Jan 18, 2025@03:59:31 Page 2
- DGSDU ;ALB/TMP - ACRP API UTILITIES ; 12/8/97 15:09
- +1 ;;5.3;Registration;**151**;Aug 13, 1993
- +2 ;;
- SCAN(DGINDX,DGVAL,DGFILTER,DGCBK,DGCLOSE,DGQUERY,DGDIR) ; Scan encounters
- +1 ; *** NOTE *** When using this call, the variable passed as DGQUERY
- +2 ; must be newed or killed in the callling program
- +3 ; DGINDX = index name property of the query object
- +4 ; DGVAL = array of data elements for start/end of search
- +5 ; DGVAL("DFN") = patient DFN
- +6 ; DGVAL("BDT") = begin date
- +7 ; DGVAL("EDT") = end date
- +8 ; DGVAL("VIS") = encounter file ien
- +9 ; DGFILTER = the executable code to use to screen entries
- +10 ; DGCBK = the executable scan callback code to create the result set
- +11 ; DGCLOSE = Flag that says whether or not to close the QUERY object
- +12 ; 1 = Perform close 0 or null = Do not close object
- +13 ; DGQUERY = the # of the current query, if not a new query. If passed by
- +14 ; reference and query closed, this variable will be nulled
- +15 ; DGDIR = the direction of the scan (optional)
- +16 ; null, undefined or FORWARD : Scan forwards
- +17 ; BACKWARD : Scan backwards
- +18 ;
- +19 NEW QUERY
- +20 SET QUERY=$GET(DGQUERY)
- +21 IF '$GET(QUERY)
- Begin DoDot:1
- +22 DO OPEN^SDQ(.DGQUERY)
- if '$GET(DGQUERY)
- QUIT
- +23 DO INDEX^SDQ(.DGQUERY,DGINDX,"SET")
- +24 IF $GET(DGFILTER)'=""
- DO FILTER^SDQ(.DGQUERY,DGFILTER,"SET")
- +25 DO SCANCB^SDQ(.DGQUERY,DGCBK,"SET")
- End DoDot:1
- +26 IF $GET(QUERY)
- DO ACTIVE^SDQ(.DGQUERY,"FALSE","SET")
- +27 DO SETINDX(.DGQUERY,DGINDX)
- +28 DO ACTIVE^SDQ(.DGQUERY,"TRUE","SET")
- +29 if $GET(DGDIR)=""
- SET DGDIR="FORWARD"
- +30 DO SCAN^SDQ(.DGQUERY,DGDIR)
- +31 IF $GET(DGCLOSE)
- DO CLOSE(.DGQUERY)
- SCANQ QUIT
- +1 ;
- CLOSE(DGQUERY) ; Close the query
- +1 if '$GET(DGQUERY)
- GOTO CLOSEQ
- +2 DO CLOSE^SDQ(.DGQUERY)
- CLOSEQ QUIT
- +1 ;
- SETINDX(DGQUERY,DGINDX) ;
- +1 IF DGINDX="PATIENT/DATE"
- DO PAT
- DO DATE
- +2 IF DGINDX="DATE/TIME"
- DO DATE
- +3 IF DGINDX="PATIENT"
- DO PAT
- +4 IF DGINDX="VISIT"
- DO VIS
- +5 QUIT
- +6 ;
- PAT ; Verify patient
- +1 DO PAT^SDQ(.DGQUERY,$GET(DGVAL("DFN")),"SET")
- +2 QUIT
- +3 ;
- DATE ; Verify date range
- +1 DO DATE^SDQ(.DGQUERY,$GET(DGVAL("BDT")),$GET(DGVAL("EDT")),"SET")
- +2 QUIT
- +3 ;
- VIS ; Verify visit
- +1 DO VISIT^SDQ(.DGQUERY,$GET(DGVAL("VIS")),"SET")
- +2 QUIT
- +3 ;
- SCE(DGOE,PC,NODE,ZXERR) ; Returns the specific piece or entire node of the enctr
- +1 ; NODE = the node to return ... if undefined, the 0-node is assumed
- +2 ; If PC is null or undefined, the whole node is returned, otherwise
- +3 ; just the PC-piece is returned
- +4 ; DGERR = the name of the array where errors should be passed back in
- +5 ; (pass in quotes I.E.: "DGERR"). If no name passed, errors are
- +6 ; not returned
- +7 NEW DGX
- +8 if $GET(NODE)=""
- SET NODE=0
- +9 DO GETGEN^SDOE(DGOE,"DGX",$GET(ZXERR))
- +10 IF $GET(ZXERR)=""
- KILL ^TMP("DIERR",$JOB)
- +11 SET DGX=$SELECT($GET(PC):$PIECE($GET(DGX(NODE)),U,+PC),1:$GET(DGX(NODE)))
- +12 QUIT DGX
- +13 ;