SCAPMC3 ;ALB/REW - Team API's:TMPT ; 6/3/99 3:18pm
;;5.3;Scheduling;**41,177,297,1015**;AUG 13, 1993;Build 21
;;1.0
TMPT(DFN,SCDATES,SCPURPA,SCLIST,SCERR) ; -- list of teams for a patient
; input:
; DFN = ien of PATIENT file [required]
; SCDATES("BEGIN") = begin date to search (inclusive)
; [default: TODAY]
; ("END") = end date to search (inclusive)
; [default: TODAY]
; ("INCL") = 1: only use patients who were assigned to
; team for entire date range
; 0: anytime in date range
; [default: 1]
; SCPURPA -array of pointers to team purpose file 403.47
; if none are defined - returns all teams
; if @SCPURPA@('exclude') is defined - exclude listed teams
; SCLIST -array name to store list
; [ex. ^TMP("SCPT",$J)]
;
; SCERR = array NAME to store error messages.
; [ex. ^TMP("ORXX",$J)]
;
; Output:
; SCLIST() = array of teams (includes SCTM xref)
; Format:
; Subscript: Sequential # from 1 to n
; Piece Description
; 1 IEN of TEAM file entry
; 2 Name of team
; 3 IEN of file #404.42 (Pt Tm Assignment)
; 4 current effective date
; 5 current inactivate date (if any)
; 6 pointer to 403.47 (purpose)
; 7 Name of Purpose
; 8 Is this the pt's PC Team?
; Subscript: "SCTM",SCTM,IEN =""
;
; SCERR() = Array of DIALOG file messages(errors) .
; @SCERR@(0) = number of errors, undefined if none
; Format:
; Subscript: Sequential # from 1 to n
; Piece Description
; 1 IEN of DIALOG file
; Returned: 1 if ok, 0 if error
;
;
;
ST N SCTM,SCPTA,SCPTA0,SCP,SCTMPT
N SCLSEQ,SCN,SCESEQ,SCPARM,SCP,SCBEGIN,SCEND,SCINCL,SCDTS
; -- initialize control variables
G:'$$OKDATA PRACQ
; -- loop through patient team assignments
S SCTM=0
F S SCTM=$O(^SCPT(404.42,"APTTM",DFN,SCTM)) Q:'SCTM D
.Q:1>$$ACTHIST^SCAPMCU2(404.58,SCTM,SCDATES,.SCERR,"SCTMPT")
.S SCP=$P(^SCTM(404.51,SCTM,0),U,3)
.Q:'$$OKARRAY^SCAPU1(SCPURPA,SCP)
.S SCPTA=0
.F S SCPTA=$O(^SCPT(404.42,"APTTM",DFN,SCTM,SCPTA)) Q:'SCPTA D
..S SCPTA0=$G(^SCPT(404.42,SCPTA,0))
..Q:'SCPTA0
..Q:'$$DTCHK^SCAPU1(SCBEGIN,SCEND,SCINCL,$P(SCPTA0,U,2),$P(SCPTA0,U,9))
..D BLD(.SCLIST,SCPTA,SCPTA0)
PRACQ Q $G(@SCERR@(0))<1
;
;
BLD(SCLIST,SCPTA,SCPTA0) ; -- build list of patient's teams
;
; SCLIST - output array
; SCPTA - ien of pt team assignment
; SCPTA0 - 0 node of pt team assignment file
;
; this builds the array:
; 1 2 3 4 5 6 7 8
; sclist(1->n)=sctm^tmname^scpta^effdt^inactdt^p403.47^purpname^pctm?
;
; for each scpta zero node passed to it
; AND a xref sclist('sctm',sctm,scpta,scn)=""
N SCEFFDT,SCCNT,SCTM,SCN,SCTMNODE,SCP,SCPC
S SCTM=$P(SCPTA0,U,3)
Q:$D(@SCLIST@("SCTM",SCTM,SCPTA))
S SCN=$G(@SCLIST@(0),0)+1
S @SCLIST@(0)=SCN
S SCTMNODE=$G(^SCTM(404.51,SCTM,0)),SCP=$P(SCTMNODE,U,3)
;is assignment type=1?
S SCPC=$P(SCPTA0,U,8)=1
S @SCLIST@(SCN)=SCTM_U_$P(SCTMNODE,U,1)_U_SCPTA_U_$P(SCPTA0,U,2)_U_$P(SCPTA0,U,9)_U_SCP_U_$S(SCP:$P($G(^SC(403.47,SCP,0)),U,1),1:SCP)_U_SCPC
S @SCLIST@("SCTM",SCTM,SCPTA,SCN)=""
Q
OKDATA() ;setup/check variables
N SCOK
S SCOK=1
S SCPURPA=$G(SCPURPA,"")
D INIT^SCAPMCU1(.SCOK) ; set default dates & error array (if undefined)
IF $L($G(SCPURPA))&($G(SCPURPA)'?1A1.7AN) D S SCOK=0
. S SCPARM("PURPOSE")=$G(SCPURPA,"Undefined")
. D ERR^SCAPMCU1(.SCESEQ,4045101,.SCPARM,"",.SCERR)
IF '$D(^DPT(+$G(DFN),0)) D S SCOK=0
. S SCPARM("PATIENT")=$G(PATIENT,"Undefined")
. D ERR^SCAPMCU1(.SCESEQ,4045101,.SCPARM,"",.SCERR)
; -- is it a valid DFN passed (Error # 20001 in DIALOG file)
IF '$D(^DPT(+DFN,0)) D S SCOK=0
. S SCPARM("PATIENT")=DFN
. D ERR^SCAPMCU1(SCESEQ,20001,.SCPARM,"",.SCERR)
Q SCOK
;
SCAPMC3 ;ALB/REW - Team API's:TMPT ; 6/3/99 3:18pm
+1 ;;5.3;Scheduling;**41,177,297,1015**;AUG 13, 1993;Build 21
+2 ;;1.0
TMPT(DFN,SCDATES,SCPURPA,SCLIST,SCERR) ; -- list of teams for a patient
+1 ; input:
+2 ; DFN = ien of PATIENT file [required]
+3 ; SCDATES("BEGIN") = begin date to search (inclusive)
+4 ; [default: TODAY]
+5 ; ("END") = end date to search (inclusive)
+6 ; [default: TODAY]
+7 ; ("INCL") = 1: only use patients who were assigned to
+8 ; team for entire date range
+9 ; 0: anytime in date range
+10 ; [default: 1]
+11 ; SCPURPA -array of pointers to team purpose file 403.47
+12 ; if none are defined - returns all teams
+13 ; if @SCPURPA@('exclude') is defined - exclude listed teams
+14 ; SCLIST -array name to store list
+15 ; [ex. ^TMP("SCPT",$J)]
+16 ;
+17 ; SCERR = array NAME to store error messages.
+18 ; [ex. ^TMP("ORXX",$J)]
+19 ;
+20 ; Output:
+21 ; SCLIST() = array of teams (includes SCTM xref)
+22 ; Format:
+23 ; Subscript: Sequential # from 1 to n
+24 ; Piece Description
+25 ; 1 IEN of TEAM file entry
+26 ; 2 Name of team
+27 ; 3 IEN of file #404.42 (Pt Tm Assignment)
+28 ; 4 current effective date
+29 ; 5 current inactivate date (if any)
+30 ; 6 pointer to 403.47 (purpose)
+31 ; 7 Name of Purpose
+32 ; 8 Is this the pt's PC Team?
+33 ; Subscript: "SCTM",SCTM,IEN =""
+34 ;
+35 ; SCERR() = Array of DIALOG file messages(errors) .
+36 ; @SCERR@(0) = number of errors, undefined if none
+37 ; Format:
+38 ; Subscript: Sequential # from 1 to n
+39 ; Piece Description
+40 ; 1 IEN of DIALOG file
+41 ; Returned: 1 if ok, 0 if error
+42 ;
+43 ;
+44 ;
ST NEW SCTM,SCPTA,SCPTA0,SCP,SCTMPT
+1 NEW SCLSEQ,SCN,SCESEQ,SCPARM,SCP,SCBEGIN,SCEND,SCINCL,SCDTS
+2 ; -- initialize control variables
+3 IF '$$OKDATA
GOTO PRACQ
+4 ; -- loop through patient team assignments
+5 SET SCTM=0
+6 FOR
SET SCTM=$ORDER(^SCPT(404.42,"APTTM",DFN,SCTM))
IF 'SCTM
QUIT
Begin DoDot:1
+7 IF 1>$$ACTHIST^SCAPMCU2(404.58,SCTM,SCDATES,.SCERR,"SCTMPT")
QUIT
+8 SET SCP=$PIECE(^SCTM(404.51,SCTM,0),U,3)
+9 IF '$$OKARRAY^SCAPU1(SCPURPA,SCP)
QUIT
+10 SET SCPTA=0
+11 FOR
SET SCPTA=$ORDER(^SCPT(404.42,"APTTM",DFN,SCTM,SCPTA))
IF 'SCPTA
QUIT
Begin DoDot:2
+12 SET SCPTA0=$GET(^SCPT(404.42,SCPTA,0))
+13 IF 'SCPTA0
QUIT
+14 IF '$$DTCHK^SCAPU1(SCBEGIN,SCEND,SCINCL,$PIECE(SCPTA0,U,2),$PIECE(SCPTA0,U,9))
QUIT
+15 DO BLD(.SCLIST,SCPTA,SCPTA0)
End DoDot:2
End DoDot:1
PRACQ QUIT $GET(@SCERR@(0))<1
+1 ;
+2 ;
BLD(SCLIST,SCPTA,SCPTA0) ; -- build list of patient's teams
+1 ;
+2 ; SCLIST - output array
+3 ; SCPTA - ien of pt team assignment
+4 ; SCPTA0 - 0 node of pt team assignment file
+5 ;
+6 ; this builds the array:
+7 ; 1 2 3 4 5 6 7 8
+8 ; sclist(1->n)=sctm^tmname^scpta^effdt^inactdt^p403.47^purpname^pctm?
+9 ;
+10 ; for each scpta zero node passed to it
+11 ; AND a xref sclist('sctm',sctm,scpta,scn)=""
+12 NEW SCEFFDT,SCCNT,SCTM,SCN,SCTMNODE,SCP,SCPC
+13 SET SCTM=$PIECE(SCPTA0,U,3)
+14 IF $DATA(@SCLIST@("SCTM",SCTM,SCPTA))
QUIT
+15 SET SCN=$GET(@SCLIST@(0),0)+1
+16 SET @SCLIST@(0)=SCN
+17 SET SCTMNODE=$GET(^SCTM(404.51,SCTM,0))
SET SCP=$PIECE(SCTMNODE,U,3)
+18 ;is assignment type=1?
+19 SET SCPC=$PIECE(SCPTA0,U,8)=1
+20 SET @SCLIST@(SCN)=SCTM_U_$PIECE(SCTMNODE,U,1)_U_SCPTA_U_$PIECE(SCPTA0,U,2)_U_$PIECE(SCPTA0,U,9)_U_SCP_U_$SELECT(SCP:$PIECE($GET(^SC(403.47,SCP,0)),U,1),1:SCP)_U_SCPC
+21 SET @SCLIST@("SCTM",SCTM,SCPTA,SCN)=""
+22 QUIT
OKDATA() ;setup/check variables
+1 NEW SCOK
+2 SET SCOK=1
+3 SET SCPURPA=$GET(SCPURPA,"")
+4 ; set default dates & error array (if undefined)
DO INIT^SCAPMCU1(.SCOK)
+5 IF $LENGTH($GET(SCPURPA))&($GET(SCPURPA)'?1A1.7AN)
Begin DoDot:1
+6 SET SCPARM("PURPOSE")=$GET(SCPURPA,"Undefined")
+7 DO ERR^SCAPMCU1(.SCESEQ,4045101,.SCPARM,"",.SCERR)
End DoDot:1
SET SCOK=0
+8 IF '$DATA(^DPT(+$GET(DFN),0))
Begin DoDot:1
+9 SET SCPARM("PATIENT")=$GET(PATIENT,"Undefined")
+10 DO ERR^SCAPMCU1(.SCESEQ,4045101,.SCPARM,"",.SCERR)
End DoDot:1
SET SCOK=0
+11 ; -- is it a valid DFN passed (Error # 20001 in DIALOG file)
+12 IF '$DATA(^DPT(+DFN,0))
Begin DoDot:1
+13 SET SCPARM("PATIENT")=DFN
+14 DO ERR^SCAPMCU1(SCESEQ,20001,.SCPARM,"",.SCERR)
End DoDot:1
SET SCOK=0
+15 QUIT SCOK
+16 ;