source: WorldVistAEHR/trunk/r/SCHEDULING-SD-SC/SCAPMC24.m@ 1710

Last change on this file since 1710 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 4.8 KB
RevLine 
[613]1SCAPMC24 ;ALB/REW - Team API's:TPTM ; 27 Jun 99 3:05 PM
2 ;;5.3;Scheduling;**41,148,177**;AUG 13, 1993
3 ;;1.0
4TPTM(SCTM,SCDATES,SCUSRA,SCROLEA,SCLIST,SCERR) ; -- positions for a pract
5 ; input:
6 ; SCTM = ien of TEAM File (#404.51) [required]
7 ; SCDATES("BEGIN") = begin date to search (inclusive)
8 ; [default: TODAY]
9 ; ("END") = end date to search (inclusive)
10 ; [default: TODAY]
11 ; ("INCL") = 1: only use patients who were assigned to
12 ; team for entire date range
13 ; 0: anytime in date range
14 ; [default: 1]
15 ; SCUSRA -array of pointers to user file - 8930
16 ; if none are defined - returns all usr classes
17 ; if @SCPURPA@('exclude') is defined - exclude listed usr class
18 ; SCROLEA - array of pointers to std position file 403.46 (per scusra)
19 ; SCLIST -array name to store list
20 ; [ex. ^TMP("SCPT",$J)]
21 ;
22 ; SCERR = array NAME to store error messages.
23 ; [ex. ^TMP("ORXX",$J)]
24 ;
25 ; Output:
26 ; SCLIST() = array of positions (includes SCTP xref)
27 ; Format:
28 ; Subscript: Sequential # from 1 to n
29 ; Piece Description
30 ; 1 IEN of TEAM POSITION File (#404.57)
31 ; 2 Name of Position
32 ; 3 IEN of Team #404.51
33 ; 4 IEN of file #404.59 (Tm Pos History)
34 ; 5 current effective date
35 ; 6 current inactivate date (if any)
36 ; 7 pointer to 403.46 (role)
37 ; 8 Name of Standard Role
38 ; 9 pointer to User Class (#8930)
39 ; 10 Name of User Class
40 ; Subscript: "SCTP",SCTM,IEN =""
41 ;
42 ; SCERR() = Array of DIALOG file messages(errors) .
43 ; @SCERR@(0) = number of errors, undefined if none
44 ; Format:
45 ; Subscript: Sequential # from 1 to n
46 ; Piece Description
47 ; 1 IEN of DIALOG file
48 ; Returned: 1 if ok, 0 if error
49 ; Other:
50 ; SCACTHIS = status (-1:err|0:inact|1:act)^404.59 ien ^actdt^inacdt
51 ;
52 ;
53ST N SCPTTP,SCPTTP0,SCTP,SCR,SCACTHIS,SCND,SCTPTM,SCTPA
54 N SCLSEQ,SCN,SCESEQ,SCPARM,SCBEGIN,SCEND,SCINCL,SCDTS
55 ; -- initialize control variables
56 G:'$$OKDATA PRACQ
57 ; -- loop through team positionS
58 S (SCTP,SCTPA)=0
59 F S SCTP=$O(^SCTM(404.57,"C",SCTM,SCTP)) Q:'SCTP Q:'$$TPVALBLD(SCTP,.SCDATES,.SCPOSA,.SCUSA,.SCPURPA,.SCROLEA,.SCLIST,.SCERR)
60PRACQ Q $G(@SCERR@(0))<1
61 ;
62TPVALBLD(SCTP,SCDATES,SCPOSA,SCUSA,SCPURPA,SCROLEA,SCLIST,SCERR) ;
63 ; this validates a team position & builds sclist array
64 ; returns 1 if ok, 0 if error
65 N SCTPDT,SCDDDD,SCTP0,SCU,SCR,SCTM
66 M SCDDDD=@SCDATES
67 S SCTP0=$G(^SCTM(404.57,SCTP,0))
68 S SCTPDT=-9999999 F S SCTPDT=$O(^SCTM(404.59,"AIDT",SCTP,1,SCTPDT)) Q:'SCTPDT D
69 .S SCACTHIS=$$ACTHIST^SCAPMCU2(404.59,SCTP,"SCDDDD",.SCERR,"SCTPTM")
70 .Q:'SCACTHIS
71 .S SCND=$G(^SCTM(404.57,SCTP,0))
72 .S SCU=$P(SCND,U,13)
73 .Q:'$$OKUSRCL^SCAPU1(.SCUSRA,.SCU)
74 .S SCR=+$P(SCND,U,3)
75 .Q:'$$OKARRAY^SCAPU1(.SCROLEA,.SCR)
76 .D BLD(.SCLIST,$P(SCTP0,U,2),SCTP,SCACTHIS,SCR)
77 .S SCDDDD("END")=$P(SCACTHIS,U,3)-.00001
78QTVALBLD Q $G(@SCERR@(0))<1
79 ;
80BLD(SCLIST,SCTM,SCTP,SCACTHIS,SCR) ; -- build list of positions
81 ;
82 ; SCLIST - output array
83 ; SCTM - pointer to 404.51
84 ; SCTP - pointer to 404.57
85 ; SCACTHIS- per $$acthis^scapmcu2(file,ien)
86 ; SCPTA - ien of pt team assignment
87 ; SCR - role
88 ;
89 ; this builds the array:
90 ; sclist(1->n)=SCTP^positionname^sctm^histien^effdt^inactdt^scr^rolename^scusr^usrname
91 ;
92 ; for each scpta zero node passed to it
93 ; AND a xref sclist('SCTP',SCTM,scpt,histien,scn)=""
94 N SCEFFDT,SCCNT,SCN,SCUSR
95 S:'$G(SCTM) SCTM=$P($G(^SCTM(404.57,+$G(SCTP),0)),U,2)
96 Q:$D(@SCLIST@("SCTP",SCTM,SCTP,$P(SCACTHIS,U,2)))
97 S SCN=$G(@SCLIST@(0),0)+1
98 S @SCLIST@(0)=SCN
99 S SCUSR=+$P(^SCTM(404.57,SCTP,0),U,13)
100 ; 1 ^ 2 ^ 3 ^ 4
101 ;
102 ;;bp/djb/11-2-98/Added STATUS field to the output array (SRS 3.2.3).
103 ;;old code begin
104 ;S @SCLIST@(SCN)=SCTP_U_$P($G(^SCTM(404.57,SCTP,0)),U,1)_U_SCTM_U_$P(SCACTHIS,U,2,4)_U_SCR_U_$P($G(^SD(403.46,SCR,0)),U,1)_U_SCUSR_U_$P($G(^USR(8930,SCUSR,0)),U,1)_U_$P($G(SCPTTP0),U,1)
105 ;;old code end
106 ;;new code begin
107 S @SCLIST@(SCN)=SCTP_U_$P($G(^SCTM(404.57,SCTP,0)),U,1)_U_SCTM_U_$P(SCACTHIS,U,2,4)_U_SCR_U_$P($G(^SD(403.46,SCR,0)),U,1)_U_SCUSR_U_$P($G(^USR(8930,SCUSR,0)),U,1)_U_$P($G(SCPTTP0),U,1)
108 ;;new code end
109 ;
110 ;THE 11TH $P WAS ADDED BY JLU
111 S @SCLIST@("SCTP",SCTM,SCTP,$P(SCACTHIS,U,2),SCN)=""
112 Q
113OKDATA() ;setup/check variables
114 N SCOK
115 S SCOK=1
116 D INIT^SCAPMCU1(.SCOK) ; set default dates & error array (if undefined)
117 IF '$D(^SCTM(404.51,+$G(SCTM),0)) D S SCOK=0
118 . S SCPARM("Team")=$G(SCTM,"Undefined")
119 . D ERR^SCAPMCU1(.SCESEQ,4045101,.SCPARM,"",.SCERR)
120 Q SCOK
121 ;
Note: See TracBrowser for help on using the repository browser.