VistA-WorldVistAEHR/r/SCHEDULING-SD-SC/SDOEQ.m

146 lines
4.0 KiB
Mathematica

SDOEQ ;ALB/MJK - Encounter Query Object Methods ;8/12/96
;;5.3;Scheduling;**131,132**;Aug 13, 1993
;
;
OE0(SDOE) ; -- get only supported 0th node fields
N X
S X=$G(^SCE(SDOE,0))
; -- null EXTENDED REFERENCE field (piece 9)
IF X]"" S $P(X,"^",9)=""
Q X
;
SDOE(SDOE,SDFIL,SDCB,SDSTOP) ; -- do filter and callback
N Y,Y0,SDOE0
S SDOE0=$$OE0(.SDOE)
;
; -- exit if null record
IF SDOE0="" G SDOEXQ
;
; -- execute filter
S Y=SDOE,Y0=SDOE0
X:SDFIL]"" SDFIL
;
; -- execute callback if passes filter
S Y=SDOE,Y0=SDOE0
IF $T X SDCB
SDOEXQ Q
;
SCAN(SDQ,SDIR,SDERR) ; -- full scan of all needed records
N SDCB,SDSTOP,SDIDX,SDFIL,X,SDQDIR
S SDSTOP=0
S X=$G(SDIR),SDQDIR=$S(X="":"FORWARD",1:X)
D INDEX^SDQ(.SDQ,.SDIDX,"GET",$G(SDERR))
IF '$$ERRCHK^SDQUT($G(SDERR)) D SCANCB^SDQ(.SDQ,.SDCB,"GET",$G(SDERR))
IF '$$ERRCHK^SDQUT($G(SDERR)) D FILTER^SDQ(.SDQ,.SDFIL,"GET",$G(SDERR))
IF $$ERRCHK^SDQUT($G(SDERR)) G SCANQ
;
IF SDIDX="PATIENT/DATE" D SCANPDT
IF SDIDX="VISIT" D SCANVST
IF SDIDX="PATIENT" D SCANPAT
IF SDIDX="DATE/TIME" D SCANDT
;
SCANQ Q
;
SCANPDT ; -- scan by patient and date
N SDFN,SDBEG,SDEND,SDDT,SDOE
D PAT^SDQ(.SDQ,.SDFN,"GET",$G(SDERR))
IF '$$ERRCHK^SDQUT($G(SDERR)) D DATE^SDQ(.SDQ,.SDBEG,.SDEND,"GET",$G(SDERR))
IF $$ERRCHK^SDQUT($G(SDERR)) G SCANPDTQ
;
IF SDQDIR="FORWARD" D
. S SDDT=SDBEG-.000001
. F S SDDT=$O(^SCE("ADFN",SDFN,SDDT)) Q:'SDDT!(SDDT>SDEND) D Q:SDSTOP
. . S SDOE=""
. . F S SDOE=$O(^SCE("ADFN",SDFN,SDDT,SDOE)) Q:SDOE="" D SDOE(.SDOE,.SDFIL,.SDCB,.SDSTOP) Q:SDSTOP
. ;
ELSE D
. S SDDT=SDEND+.000001
. F S SDDT=$O(^SCE("ADFN",SDFN,SDDT),-1) Q:'SDDT!(SDDT<SDBEG) D Q:SDSTOP
. . S SDOE=""
. . F S SDOE=$O(^SCE("ADFN",SDFN,SDDT,SDOE),-1) Q:SDOE="" D SDOE(.SDOE,.SDFIL,.SDCB,.SDSTOP) Q:SDSTOP
;
SCANPDTQ Q
;
SCANVST ; -- scan by visit
N SDVSIT,SDOE
S SDSTOP=0
D VISIT^SDQ(.SDQ,.SDVSIT,"GET",$G(SDERR))
IF $$ERRCHK^SDQUT($G(SDERR)) G SCANVSTQ
;
IF SDQDIR="FORWARD" D
. S SDOE=""
. F S SDOE=$O(^SCE("AVSIT",SDVSIT,SDOE)) Q:SDOE="" D SDOE(.SDOE,.SDFIL,.SDCB,.SDSTOP) Q:SDSTOP
. ;
ELSE D
. S SDOE=""
. F S SDOE=$O(^SCE("AVSIT",SDVSIT,SDOE),-1) Q:SDOE="" D SDOE(.SDOE,.SDFIL,.SDCB,.SDSTOP) Q:SDSTOP
;
SCANVSTQ Q
;
SCANDT ; -- date only scan
N SDDT,SDBEG,SDEND,SDOE
D DATE^SDQ(.SDQ,.SDBEG,.SDEND,"GET",$G(SDERR))
IF $$ERRCHK^SDQUT($G(SDERR)) G SCANDTQ
;
IF SDQDIR="FORWARD" D
. S SDDT=SDBEG-.000001
. F S SDDT=$O(^SCE("B",SDDT)) Q:SDDT=""!(SDDT>SDEND) D Q:SDSTOP
. . S SDOE=""
. . F S SDOE=$O(^SCE("B",SDDT,SDOE)) Q:SDOE="" D SDOE(.SDOE,.SDFIL,.SDCB,.SDSTOP) Q:SDSTOP
;
ELSE D
. S SDDT=SDEND+.000001
. F S SDDT=$O(^SCE("B",SDDT),-1) Q:SDDT=""!(SDDT<SDBEG) D Q:SDSTOP
. . S SDOE=""
. . F S SDOE=$O(^SCE("B",SDDT,SDOE),-1) Q:SDOE="" D SDOE(.SDOE,.SDFIL,.SDCB,.SDSTOP) Q:SDSTOP
;
SCANDTQ Q
;
SCANPAT ; -- patient only scan
N SDFN,SDOE
S SDSTOP=0
D PAT^SDQ(.SDQ,.SDFN,"GET",$G(SDERR))
IF $$ERRCHK^SDQUT($G(SDERR)) G SCANPATQ
;
IF SDQDIR="FORWARD" D
. S SDOE=""
. F S SDOE=$O(^SCE("C",SDFN,SDOE)) Q:SDOE="" D SDOE(.SDOE,.SDFIL,.SDCB,.SDSTOP) Q:SDSTOP
. ;
ELSE D
. S SDOE=""
. F S SDOE=$O(^SCE("C",SDFN,SDOE),-1) Q:SDOE="" D SDOE(.SDOE,.SDFIL,.SDCB,.SDSTOP) Q:SDSTOP
;
SCANPATQ Q
;
PAT(SDQ,SDFN,SDACT,SDERR) ; -- SDQ PATIENT
; API ID: 81
;
;
PATG ; -- goto entry point
; -- do validation checks
IF '$$QRY^SDQVAL(.SDQ,$G(SDERR)) G PATQ
IF '$$ACTION^SDQVAL(.SDACT,$G(SDERR)) G PATQ
IF SDACT="SET",'$$QRYINACT^SDQVAL(.SDQ,$G(SDERR)) G PATQ
IF SDACT="SET",'$$PAT^SDQVAL(.SDFN,$G(SDERR)) G PATQ
;
IF SDACT="SET" S @SDQUERY@(SDQ,"MASTER VALUE")=SDFN
IF SDACT="GET" S SDFN=$G(@SDQUERY@(SDQ,"MASTER VALUE"))
PATQ Q
;
VISIT(SDQ,SDVST,SDACT,SDERR) ; -- SDQ VISIT
; API ID: 84
;
;
VISITG ; -- goto entry point
; -- do validation checks
IF '$$QRY^SDQVAL(.SDQ,$G(SDERR)) G VISITQ
IF '$$ACTION^SDQVAL(.SDACT,$G(SDERR)) G VISITQ
IF SDACT="SET",'$$QRYINACT^SDQVAL(.SDQ,$G(SDERR)) G VISITQ
IF SDACT="SET",'$$VALVST^PXAPIOE(.SDVST,$G(SDERR)) G VISITQ
;
IF SDACT="SET" S @SDQUERY@(SDQ,"MASTER VALUE")=SDVST
IF SDACT="GET" S SDVST=$G(@SDQUERY@(SDQ,"MASTER VALUE"))
;
VISITQ Q
;