source: WorldVistAEHR/trunk/r/SCHEDULING-SD-SC/SCAPMC2.m@ 861

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

initial load of WorldVistAEHR

File size: 3.3 KB
Line 
1SCAPMC2 ;ALB/REW - Team API's: PTTM ; JUN 30, 1995
2 ;;5.3;Scheduling;**41**;AUG 13, 1993
3 ;;1.0
4PTTM(SCTEAM,SCDATES,SCLIST,SCERR) ; -- list of patient team assignments
5 ; input:
6 ; SCTEAM = ien of TEAM [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 ; SCLIST -array name to store list
16 ; [ex. ^TMP("SCPT",$J)]
17 ;
18 ; SCERR = array NAME to store error messages.
19 ; [ex. ^TMP("ORXX",$J)]
20 ;
21 ; Output:
22 ; SCLIST() = array of patients
23 ; Format:
24 ; Subscript: Sequential # from 1 to n
25 ; Piece Description
26 ; 1 IEN of PATIENT file entry
27 ; 2 Name of patient
28 ; 3 IEN of Patient Team Assignment
29 ; 4 Activation Date
30 ; 5 Inactivation Date
31 ; 6 Patient Long ID (SSN)
32 ;
33 ; SCERR() = Array of DIALOG file messages(errors) .
34 ; @SCERR@(0)=number of errors, undefined if none
35 ; Foramt:
36 ; Subscript: Sequential # from 1 to n
37 ; Piece Description
38 ; 1 IEN of DIALOG file
39 ;
40 ; Returned: 1 if ok, 0 if error
41 ;
42 ;
43ST N SCPT,SCPTA,SCPTA0
44 N SCLSEQ,SCN,SCESEQ,SCPARM,SCP,SCBEGIN,SCEND,SCINCL,SCDTS
45 G:'$$OKDATA PRACQ ;check/setup variables
46 ; -- loop through patient team assignments
47LP S SCPT=0
48 F S SCPT=$O(^SCPT(404.42,"ATMPT",SCTEAM,SCPT)) Q:'SCPT D
49 .S SCPTA=0
50 .F S SCPTA=$O(^SCPT(404.42,"ATMPT",SCTEAM,SCPT,SCPTA)) Q:'SCPTA D
51 ..S SCPTA0=$G(^SCPT(404.42,SCPTA,0))
52 ..Q:'SCPTA0
53 ..Q:'$$DTCHK^SCAPU1(SCBEGIN,SCEND,SCINCL,$P(SCPTA0,U,2),$P(SCPTA0,U,9))
54 ..D BLD(.SCLIST,SCPTA,SCPTA0,.SCN)
55PRACQ Q $G(@SCERR@(0))<1
56 ;
57 ;
58BLD(SCLIST,SCPTA,SCPTA0,SCN) ; build list
59 ;
60 ; SCPA - ien of patient team assignment file #404.42
61 ; SCEFFDT - negative of effective date
62 ; SCN - current subscript (counter) 1->n
63 ; SCPTA0 is 0 node of Patient Team Assignment file 1st piece is DFN
64 ;
65 ; this builds the array:
66 ; sclist(1->n)=sc2^ptname^effdt^inactdt
67 ; for each scpta zero node passed to it
68 Q:'SCPTA!('SCPTA0) ;add error trapping?
69 Q:$D(@SCLIST@("SCPTA",+SCPTA0,SCPTA))
70 Q:$D(^TMP("SCMC",$J,"EXCLUDE PT","SCPTA",+SCPTA0))
71 N SCEFFDT,SCCNT
72 S SCN=SCN+1
73 S @SCLIST@(SCN)=+SCPTA0_U_$P($G(^DPT(+SCPTA0,0)),U,1)_U_SCPTA_U_$P(SCPTA0,U,2)_U_$P(SCPTA0,U,9)_U_$P($G(^DPT(+SCPTA0,.36)),U,3)
74 ;_U_$P(SCPTA0,U,3)_U_$P($G(^SCTM(404.51,+$P(SCPTA0,U,3),0)),U,1) - didn't include team data to make return array generic
75 S @SCLIST@("SCPTA",+SCPTA0,SCPTA,SCN)=""
76 Q
77OKDATA() ;check/setup variables
78 N SCOK
79 S SCOK=1
80 D INIT^SCAPMCU1(.SCOK) ; set default dates & error array (if undefined)
81 IF '$D(^SCTM(404.51,+$G(SCTEAM),0)) D S SCOK=0
82 . S SCPARM("TEAM")=$G(SCTEAM,"Undefined")
83 . D ERR^SCAPMCU1(.SCESEQ,4045101,.SCPARM,"",.SCERR)
84 ; -- is it a valid TEAM ien passed (Error # 4045101 in DIALOG file)
85 IF '$D(^SCTM(404.51,+SCTEAM,0)) D S SCOK=0
86 . S SCPARM("TEAM")=SCTEAM
87 . D ERR^SCAPMCU1(SCESEQ,4045101,.SCPARM,"",.SCERR)
88 Q SCOK
Note: See TracBrowser for help on using the repository browser.