INHUTC5 ;KN,bar; 26 Sep 97 22:03; Interface Message/Error Search
;;3.01;BHL IHS Interfaces with GIS;;JUL 01, 2001
;COPYRIGHT 1991-2000 SAIC
;;COPYRIGHT 1997 SAIC
;
; Interface Message/Error Search Part II (INHUTC5)
; This sub-module contains functions FIND, MSGTEST, and ERRTEST.
Q
FIND(INQUIT,INOPT,INIEN,INSRCH) ; Build IEN message
;
; Description: Based on search type INSRCH("TYPE"), the function
; FIND loops through global ^INTHU or ^INTHER from the date-start
; to date-end and calls MSGTEST or ERRTEST to build the list of
; matching records. The matching records will be stored
; in array INIEN. FIND will stop depending on set parameters
; and return the stop reason.
;
; Parameters:
; INQUIT = Search status at stop (returned)
; 1 = max found reached
; 2 = max search reached
; 3 = no more to search
; 4 = user abort
; error = error text
; INOPT = Array of user defined options and run parameters
; INIEN = Array to store found records, pass by reference
; used with indirection ie; @INIEN@(X) (returned)
; INSRCH = Array of search criteria, pass by reference
; Optional. Only needed if calling repeatedly
; So values do not need to be rebuilt with each call
;
N INA,IND,INM,INX,INFND,INTYPE,INFILE,INRVSRCH
; get search criteria values
I '$D(INSRCH) S INQUIT=$$GATHER^INHUTC6($G(INOPT("CRITERIA")),.INSRCH) Q:'INQUIT
; setup file stuff, search starting point, listing direction
S INTYPE=$G(INSRCH("TYPE")),INFILE=$G(INSRCH("FILENAME")),IND=$G(INSRCH("IND")),INRVSRCH=$S('INSRCH("INORDER"):-1,1:1)
; set counters and stop values
S INSRCH("INSRCHCT")=$G(INOPT("INSRCHCT")),INSRCH("INFNDCT")=$G(INOPT("INFNDCT"))
S INSRCH("FNDSTP")=$S($D(INOPT("MAXFND")):INSRCH("INFNDCT")+INOPT("MAXFND"),1:0)
S INSRCH("SRCHSTP")=$S($D(INOPT("MAXSRCH")):INSRCH("INSRCHCT")+INOPT("MAXSRCH"),1:0)
; Loop through date/time
S INQUIT=0 F D Q:INQUIT
. S IND=$O(@INFILE@("B",IND),INRVSRCH) I 'IND S INQUIT=3 Q
. ; check for stop dates
. I (INRVSRCH>-1)&(IND>INSRCH("INEND")) S INQUIT=3 Q
. I (INRVSRCH=-1)&(IND<INSRCH("INSTART")) S INQUIT=3 Q
. ; loop thru entries
. ; do not quit loop at this level. this value is not held
. ; and entries will be skipped on next call.
. S INM="" F S INM=$O(@INFILE@("B",IND,INM),INRVSRCH) Q:'INM D
.. ; increment search count, check for stop
.. S INSRCH("INSRCHCT")=INSRCH("INSRCHCT")+1
.. I INSRCH("SRCHSTP"),INSRCH("INSRCHCT")'<INSRCH("SRCHSTP") S INQUIT=2
.. ; test entry for match on criteria
.. S INFND=0
.. D:INTYPE="TRANSACTION" MSGTEST^INHUTC51(.INFND,INM,.INSRCH)
.. D:INTYPE="ERROR" ERRTEST^INHUTC51(.INFND,INM,.INSRCH)
.. ;IHS branch
.. I '$$SC^INHUTIL1 D Q
... Q:'INFND
... S INSRCH("INFNDCT")=INSRCH("INFNDCT")+1
... D SETTMP^INHUTC52(INM,.INSRCH)
.. ; if found inc count, check for stop
.. I INFND D
... S INSRCH("INFNDCT")=INSRCH("INFNDCT")+1
... I INSRCH("FNDSTP"),INSRCH("INFNDCT")'<INSRCH("FNDSTP") S INQUIT=1
... ; format the return string for entry INM
... I '$D(INOPT("DISPFORMAT")) S @INIEN@(INSRCH("INFNDCT"))=INM
... E X INOPT("DISPFORMAT")
.. ; Merge to ^Utility if memory is low
.. I INIEN'["^",$S<INSRCH("SPACE") N INX S INX=INIEN,INIEN="^UTILITY(""INL"","_$J_")" K @INIEN M @INIEN=@INX K @INX,INX
.. ; every 100 searched...
.. I '(INSRCH("INSRCHCT")#100) D
... ; update search screen
... D:$D(DWLRF) DISPCNT
... ; allow user to abort on long search
... I $E(IOST)="C" R %#1:0 S:%="^" INQUIT=4
; update ListMan if needed
I $D(DWLRF) S $P(@DWLRF,U,2)=$S(INQUIT>2:0,1:+INSRCH("INFNDCT")) D DISPCNT
; save off values for next call,return count to caller by setting values in INOPT
S INSRCH("IND")=$S(INQUIT>2:"",1:IND),INOPT("INSRCHCT")=INSRCH("INSRCHCT"),INOPT("INFNDCT")=INSRCH("INFNDCT")
I '$G(INOPT("NONINTER")) D
. I INQUIT=4 D MS(INST_" Search Aborted.",1) Q
. I INQUIT=3,INOPT("INFNDCT")=0 D MS("No "_INST_"s found that match critieria.",1)
Q
;
DISPCNT ; display count on screen, called only from FIND
D MS("SEARCHING... Searched:"_$J(INSRCH("INSRCHCT"),8)_" Found:"_$J(INSRCH("INFNDCT"),8))
Q
;
MS(INX,INCR) ;print message on 23th line
Q:'$$SC^INHUTIL1 ;Don't go here if IHS
N DX,DY,% S DY=22,DX=0,DWDM=1 X DWXY,DIJC("N") W $E(INX,1,80)_$J("",IOM-$L(INX))
I $G(INCR) S %=$$CR^UTSRD
Q
;
INHUTC5 ;KN,bar; 26 Sep 97 22:03; Interface Message/Error Search
+1 ;;3.01;BHL IHS Interfaces with GIS;;JUL 01, 2001
+2 ;COPYRIGHT 1991-2000 SAIC
+3 ;;COPYRIGHT 1997 SAIC
+4 ;
+5 ; Interface Message/Error Search Part II (INHUTC5)
+6 ; This sub-module contains functions FIND, MSGTEST, and ERRTEST.
+7 QUIT
FIND(INQUIT,INOPT,INIEN,INSRCH) ; Build IEN message
+1 ;
+2 ; Description: Based on search type INSRCH("TYPE"), the function
+3 ; FIND loops through global ^INTHU or ^INTHER from the date-start
+4 ; to date-end and calls MSGTEST or ERRTEST to build the list of
+5 ; matching records. The matching records will be stored
+6 ; in array INIEN. FIND will stop depending on set parameters
+7 ; and return the stop reason.
+8 ;
+9 ; Parameters:
+10 ; INQUIT = Search status at stop (returned)
+11 ; 1 = max found reached
+12 ; 2 = max search reached
+13 ; 3 = no more to search
+14 ; 4 = user abort
+15 ; error = error text
+16 ; INOPT = Array of user defined options and run parameters
+17 ; INIEN = Array to store found records, pass by reference
+18 ; used with indirection ie; @INIEN@(X) (returned)
+19 ; INSRCH = Array of search criteria, pass by reference
+20 ; Optional. Only needed if calling repeatedly
+21 ; So values do not need to be rebuilt with each call
+22 ;
+23 NEW INA,IND,INM,INX,INFND,INTYPE,INFILE,INRVSRCH
+24 ; get search criteria values
+25 IF '$DATA(INSRCH)
SET INQUIT=$$GATHER^INHUTC6($GET(INOPT("CRITERIA")),.INSRCH)
IF 'INQUIT
QUIT
+26 ; setup file stuff, search starting point, listing direction
+27 SET INTYPE=$GET(INSRCH("TYPE"))
SET INFILE=$GET(INSRCH("FILENAME"))
SET IND=$GET(INSRCH("IND"))
SET INRVSRCH=$SELECT('INSRCH("INORDER"):-1,1:1)
+28 ; set counters and stop values
+29 SET INSRCH("INSRCHCT")=$GET(INOPT("INSRCHCT"))
SET INSRCH("INFNDCT")=$GET(INOPT("INFNDCT"))
+30 SET INSRCH("FNDSTP")=$SELECT($DATA(INOPT("MAXFND")):INSRCH("INFNDCT")+INOPT("MAXFND"),1:0)
+31 SET INSRCH("SRCHSTP")=$SELECT($DATA(INOPT("MAXSRCH")):INSRCH("INSRCHCT")+INOPT("MAXSRCH"),1:0)
+32 ; Loop through date/time
+33 SET INQUIT=0
FOR
Begin DoDot:1
+34 SET IND=$ORDER(@INFILE@("B",IND),INRVSRCH)
IF 'IND
SET INQUIT=3
QUIT
+35 ; check for stop dates
+36 IF (INRVSRCH>-1)&(IND>INSRCH("INEND"))
SET INQUIT=3
QUIT
+37 IF (INRVSRCH=-1)&(IND<INSRCH("INSTART"))
SET INQUIT=3
QUIT
+38 ; loop thru entries
+39 ; do not quit loop at this level. this value is not held
+40 ; and entries will be skipped on next call.
+41 SET INM=""
FOR
SET INM=$ORDER(@INFILE@("B",IND,INM),INRVSRCH)
IF 'INM
QUIT
Begin DoDot:2
+42 ; increment search count, check for stop
+43 SET INSRCH("INSRCHCT")=INSRCH("INSRCHCT")+1
+44 IF INSRCH("SRCHSTP")
IF INSRCH("INSRCHCT")'<INSRCH("SRCHSTP")
SET INQUIT=2
+45 ; test entry for match on criteria
+46 SET INFND=0
+47 IF INTYPE="TRANSACTION"
DO MSGTEST^INHUTC51(.INFND,INM,.INSRCH)
+48 IF INTYPE="ERROR"
DO ERRTEST^INHUTC51(.INFND,INM,.INSRCH)
+49 ;IHS branch
+50 IF '$$SC^INHUTIL1
Begin DoDot:3
+51 IF 'INFND
QUIT
+52 SET INSRCH("INFNDCT")=INSRCH("INFNDCT")+1
+53 DO SETTMP^INHUTC52(INM,.INSRCH)
End DoDot:3
QUIT
+54 ; if found inc count, check for stop
+55 IF INFND
Begin DoDot:3
+56 SET INSRCH("INFNDCT")=INSRCH("INFNDCT")+1
+57 IF INSRCH("FNDSTP")
IF INSRCH("INFNDCT")'<INSRCH("FNDSTP")
SET INQUIT=1
+58 ; format the return string for entry INM
+59 IF '$DATA(INOPT("DISPFORMAT"))
SET @INIEN@(INSRCH("INFNDCT"))=INM
+60 IF '$TEST
XECUTE INOPT("DISPFORMAT")
End DoDot:3
+61 ; Merge to ^Utility if memory is low
+62 IF INIEN'["^"
IF $STORAGE<INSRCH("SPACE")
NEW INX
SET INX=INIEN
SET INIEN="^UTILITY(""INL"","_$JOB_")"
KILL @INIEN
MERGE @INIEN=@INX
KILL @INX,INX
+63 ; every 100 searched...
+64 IF '(INSRCH("INSRCHCT")#100)
Begin DoDot:3
+65 ; update search screen
+66 IF $DATA(DWLRF)
DO DISPCNT
+67 ; allow user to abort on long search
+68 IF $EXTRACT(IOST)="C"
READ %#1:0
IF %="^"
SET INQUIT=4
End DoDot:3
End DoDot:2
End DoDot:1
IF INQUIT
QUIT
+69 ; update ListMan if needed
+70 IF $DATA(DWLRF)
SET $PIECE(@DWLRF,U,2)=$SELECT(INQUIT>2:0,1:+INSRCH("INFNDCT"))
DO DISPCNT
+71 ; save off values for next call,return count to caller by setting values in INOPT
+72 SET INSRCH("IND")=$SELECT(INQUIT>2:"",1:IND)
SET INOPT("INSRCHCT")=INSRCH("INSRCHCT")
SET INOPT("INFNDCT")=INSRCH("INFNDCT")
+73 IF '$GET(INOPT("NONINTER"))
Begin DoDot:1
+74 IF INQUIT=4
DO MS(INST_" Search Aborted.",1)
QUIT
+75 IF INQUIT=3
IF INOPT("INFNDCT")=0
DO MS("No "_INST_"s found that match critieria.",1)
End DoDot:1
+76 QUIT
+77 ;
DISPCNT ; display count on screen, called only from FIND
+1 DO MS("SEARCHING... Searched:"_$JUSTIFY(INSRCH("INSRCHCT"),8)_" Found:"_$JUSTIFY(INSRCH("INFNDCT"),8))
+2 QUIT
+3 ;
MS(INX,INCR) ;print message on 23th line
+1 ;Don't go here if IHS
IF '$$SC^INHUTIL1
QUIT
+2 NEW DX,DY,%
SET DY=22
SET DX=0
SET DWDM=1
XECUTE DWXY
XECUTE DIJC("N")
WRITE $EXTRACT(INX,1,80)_$JUSTIFY("",IOM-$LENGTH(INX))
+3 IF $GET(INCR)
SET %=$$CR^UTSRD
+4 QUIT
+5 ;