Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: SCAPMC4

SCAPMC4.m

Go to the documentation of this file.
  1. SCAPMC4 ;ALB/REW - Team API's:TMINST ; JUN 30, 1995
  1. ;;5.3;Scheduling;**41**;AUG 13, 1993
  1. ;;1.0
  1. TMINST(SCINST,SCDATES,SCPURPA,SCLIST,SCERR) ; -- list of teams for institution
  1. ; input:
  1. ; SCINST = ien of INSTITUTION file (#4)
  1. ; SCDATES("BEGIN") = begin date to search (inclusive)
  1. ; [default: TODAY]
  1. ; ("END") = end date to search (inclusive)
  1. ; [default: TODAY]
  1. ; ("INCL") = 1: only use patients who were assigned to
  1. ; team for entire date range
  1. ; 0: anytime in date range
  1. ; [default: 1]
  1. ; SCPURPA -array of pointers to team purpose file 403.47
  1. ; if none are defined - returns all teams
  1. ; if @SCPURPA@('exclude') is defined - exclude listed teams
  1. ; SCLIST -array name to store list
  1. ; [ex. ^TMP("SCTM",$J)]
  1. ;
  1. ; SCERR = array NAME to store error messages.
  1. ; [ex. ^TMP("ORXX",$J)]
  1. ;
  1. ; Output:
  1. ; SCLIST() = array of teams
  1. ; Format:
  1. ; Subscript: Sequential # from 1 to n
  1. ; Piece Description
  1. ; 1 IEN of TEAM file entry
  1. ; 2 Name of team
  1. ; 3 current effective date
  1. ; 4 current inactivate date (if any)
  1. ;
  1. ; SCERR() = Array of DIALOG file messages(errors) .
  1. ; Foramt:
  1. ; @SCERR@(0) = Number of errors, undefined if none
  1. ; Subscript: Sequential # from 1 to n
  1. ; Piece Description
  1. ; 1 IEN of DIALOG file
  1. ;
  1. ;
  1. ; Returned: 1 if ok, 0 if error
  1. ;
  1. ; -- initialize control variables
  1. ST N SCTM,SCTM0,SCX,SCPRP,SCTMINST
  1. N SCLSEQ,SCN,SCESEQ,SCPARM,SCP,SCBEGIN,SCEND,SCINCL,SCDTS
  1. G:'$$OKDATA PRACQ ;check/setup variables
  1. ;
  1. ; -- loop through teams for institution
  1. S SCTM=0
  1. F S SCTM=$O(^SCTM(404.51,"AINST",SCINST,SCTM)) Q:'SCTM D
  1. .S SCTM0=$G(^SCTM(404.51,SCTM,0))
  1. .Q:SCTM0=""
  1. .S SCPRP=$P(SCTM0,U,3)
  1. .Q:'$$OKARRAY^SCAPU1(.SCPURPA,SCPRP)
  1. .S ACTHIST=$$ACTHIST^SCAPMCU2(404.58,SCTM,SCDATES,.SCERR,"SCTMINST")
  1. .Q:ACTHIST'>0
  1. .D BLDTM(SCTM,SCDATES,ACTHIST,.SCLIST,.SCERR)
  1. PRACQ Q $G(@SCERR@(0))<1
  1. ;
  1. BLDTM(SCTM,SCDATES,ACTHIST,SCLIST,SCERR) ;build team list
  1. ; ACTHIST is per $$acthist - dates may be tighter than team activation
  1. ; e.g. practitioners' dates will be dates they not team is active
  1. N SCACT,SCINACT
  1. S SCACT=+$P(ACTHIST,U,3)
  1. Q:'SCACT
  1. S SCINACT=@SCDATES@("END")
  1. S SCINACT=$S('SCINACT:$P(ACTHIST,U,4),'$P(ACTHIST,U,4):SCINACT,(SCINACT<$P(ACTHIST,U,4)):SCINACT,1:$P(ACTHIST,U,4))
  1. Q:$D(@SCLIST@("SCTM",SCTM,SCACT))
  1. S SCN=$G(@SCLIST@(0),0)+1
  1. S @SCLIST@(0)=SCN
  1. S @SCLIST@(SCN)=SCTM_U_$P(^SCTM(404.51,SCTM,0),U,1)_U_SCACT_U_SCINACT
  1. S @SCLIST@("SCTM",SCTM,SCACT,SCN)=""
  1. Q
  1. OKDATA() ;check/setup variables - return 1 if ok; 0 if error
  1. N SCOK
  1. S SCOK=1
  1. D INIT^SCAPMCU1(.SCOK) ; set default dates & error array (if undefined)
  1. IF '$D(^DIC(4,+$G(SCINST),0)) D S SCOK=0
  1. . S SCPARM("INSTITUTION")=$G(SCINST,"Undefined")
  1. . D ERR^SCAPMCU1(.SCESEQ,4045101,.SCPARM,"",.SCERR)
  1. Q SCOK