source: WorldVistAEHR/trunk/r/SCHEDULING-SD-SC/SCAPMC4.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: 3.0 KB
Line 
1SCAPMC4 ;ALB/REW - Team API's:TMINST ; JUN 30, 1995
2 ;;5.3;Scheduling;**41**;AUG 13, 1993
3 ;;1.0
4TMINST(SCINST,SCDATES,SCPURPA,SCLIST,SCERR) ; -- list of teams for institution
5 ; input:
6 ; SCINST = ien of INSTITUTION file (#4)
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 ; SCPURPA -array of pointers to team purpose file 403.47
16 ; if none are defined - returns all teams
17 ; if @SCPURPA@('exclude') is defined - exclude listed teams
18 ; SCLIST -array name to store list
19 ; [ex. ^TMP("SCTM",$J)]
20 ;
21 ; SCERR = array NAME to store error messages.
22 ; [ex. ^TMP("ORXX",$J)]
23 ;
24 ; Output:
25 ; SCLIST() = array of teams
26 ; Format:
27 ; Subscript: Sequential # from 1 to n
28 ; Piece Description
29 ; 1 IEN of TEAM file entry
30 ; 2 Name of team
31 ; 3 current effective date
32 ; 4 current inactivate date (if any)
33 ;
34 ; SCERR() = Array of DIALOG file messages(errors) .
35 ; Foramt:
36 ; @SCERR@(0) = Number of errors, undefined if none
37 ; Subscript: Sequential # from 1 to n
38 ; Piece Description
39 ; 1 IEN of DIALOG file
40 ;
41 ;
42 ; Returned: 1 if ok, 0 if error
43 ;
44 ; -- initialize control variables
45ST N SCTM,SCTM0,SCX,SCPRP,SCTMINST
46 N SCLSEQ,SCN,SCESEQ,SCPARM,SCP,SCBEGIN,SCEND,SCINCL,SCDTS
47 G:'$$OKDATA PRACQ ;check/setup variables
48 ;
49 ; -- loop through teams for institution
50 S SCTM=0
51 F S SCTM=$O(^SCTM(404.51,"AINST",SCINST,SCTM)) Q:'SCTM D
52 .S SCTM0=$G(^SCTM(404.51,SCTM,0))
53 .Q:SCTM0=""
54 .S SCPRP=$P(SCTM0,U,3)
55 .Q:'$$OKARRAY^SCAPU1(.SCPURPA,SCPRP)
56 .S ACTHIST=$$ACTHIST^SCAPMCU2(404.58,SCTM,SCDATES,.SCERR,"SCTMINST")
57 .Q:ACTHIST'>0
58 .D BLDTM(SCTM,SCDATES,ACTHIST,.SCLIST,.SCERR)
59PRACQ Q $G(@SCERR@(0))<1
60 ;
61BLDTM(SCTM,SCDATES,ACTHIST,SCLIST,SCERR) ;build team list
62 ; ACTHIST is per $$acthist - dates may be tighter than team activation
63 ; e.g. practitioners' dates will be dates they not team is active
64 N SCACT,SCINACT
65 S SCACT=+$P(ACTHIST,U,3)
66 Q:'SCACT
67 S SCINACT=@SCDATES@("END")
68 S SCINACT=$S('SCINACT:$P(ACTHIST,U,4),'$P(ACTHIST,U,4):SCINACT,(SCINACT<$P(ACTHIST,U,4)):SCINACT,1:$P(ACTHIST,U,4))
69 Q:$D(@SCLIST@("SCTM",SCTM,SCACT))
70 S SCN=$G(@SCLIST@(0),0)+1
71 S @SCLIST@(0)=SCN
72 S @SCLIST@(SCN)=SCTM_U_$P(^SCTM(404.51,SCTM,0),U,1)_U_SCACT_U_SCINACT
73 S @SCLIST@("SCTM",SCTM,SCACT,SCN)=""
74 Q
75OKDATA() ;check/setup variables - return 1 if ok; 0 if error
76 N SCOK
77 S SCOK=1
78 D INIT^SCAPMCU1(.SCOK) ; set default dates & error array (if undefined)
79 IF '$D(^DIC(4,+$G(SCINST),0)) D S SCOK=0
80 . S SCPARM("INSTITUTION")=$G(SCINST,"Undefined")
81 . D ERR^SCAPMCU1(.SCESEQ,4045101,.SCPARM,"",.SCERR)
82 Q SCOK
Note: See TracBrowser for help on using the repository browser.