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

SCAPMC2.m

Go to the documentation of this file.
  1. SCAPMC2 ;ALB/REW - Team API's: PTTM ; JUN 30, 1995
  1. ;;5.3;Scheduling;**41**;AUG 13, 1993
  1. ;;1.0
  1. PTTM(SCTEAM,SCDATES,SCLIST,SCERR) ; -- list of patient team assignments
  1. ; input:
  1. ; SCTEAM = ien of TEAM [required]
  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. ; SCLIST -array name to store list
  1. ; [ex. ^TMP("SCPT",$J)]
  1. ;
  1. ; SCERR = array NAME to store error messages.
  1. ; [ex. ^TMP("ORXX",$J)]
  1. ;
  1. ; Output:
  1. ; SCLIST() = array of patients
  1. ; Format:
  1. ; Subscript: Sequential # from 1 to n
  1. ; Piece Description
  1. ; 1 IEN of PATIENT file entry
  1. ; 2 Name of patient
  1. ; 3 IEN of Patient Team Assignment
  1. ; 4 Activation Date
  1. ; 5 Inactivation Date
  1. ; 6 Patient Long ID (SSN)
  1. ;
  1. ; SCERR() = Array of DIALOG file messages(errors) .
  1. ; @SCERR@(0)=number of errors, undefined if none
  1. ; Foramt:
  1. ; Subscript: Sequential # from 1 to n
  1. ; Piece Description
  1. ; 1 IEN of DIALOG file
  1. ;
  1. ; Returned: 1 if ok, 0 if error
  1. ;
  1. ;
  1. ST N SCPT,SCPTA,SCPTA0
  1. N SCLSEQ,SCN,SCESEQ,SCPARM,SCP,SCBEGIN,SCEND,SCINCL,SCDTS
  1. G:'$$OKDATA PRACQ ;check/setup variables
  1. ; -- loop through patient team assignments
  1. LP S SCPT=0
  1. F S SCPT=$O(^SCPT(404.42,"ATMPT",SCTEAM,SCPT)) Q:'SCPT D
  1. .S SCPTA=0
  1. .F S SCPTA=$O(^SCPT(404.42,"ATMPT",SCTEAM,SCPT,SCPTA)) Q:'SCPTA D
  1. ..S SCPTA0=$G(^SCPT(404.42,SCPTA,0))
  1. ..Q:'SCPTA0
  1. ..Q:'$$DTCHK^SCAPU1(SCBEGIN,SCEND,SCINCL,$P(SCPTA0,U,2),$P(SCPTA0,U,9))
  1. ..D BLD(.SCLIST,SCPTA,SCPTA0,.SCN)
  1. PRACQ Q $G(@SCERR@(0))<1
  1. ;
  1. ;
  1. BLD(SCLIST,SCPTA,SCPTA0,SCN) ; build list
  1. ;
  1. ; SCPA - ien of patient team assignment file #404.42
  1. ; SCEFFDT - negative of effective date
  1. ; SCN - current subscript (counter) 1->n
  1. ; SCPTA0 is 0 node of Patient Team Assignment file 1st piece is DFN
  1. ;
  1. ; this builds the array:
  1. ; sclist(1->n)=sc2^ptname^effdt^inactdt
  1. ; for each scpta zero node passed to it
  1. Q:'SCPTA!('SCPTA0) ;add error trapping?
  1. Q:$D(@SCLIST@("SCPTA",+SCPTA0,SCPTA))
  1. Q:$D(^TMP("SCMC",$J,"EXCLUDE PT","SCPTA",+SCPTA0))
  1. N SCEFFDT,SCCNT
  1. S SCN=SCN+1
  1. 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)
  1. ;_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
  1. S @SCLIST@("SCPTA",+SCPTA0,SCPTA,SCN)=""
  1. Q
  1. OKDATA() ;check/setup variables
  1. N SCOK
  1. S SCOK=1
  1. D INIT^SCAPMCU1(.SCOK) ; set default dates & error array (if undefined)
  1. IF '$D(^SCTM(404.51,+$G(SCTEAM),0)) D S SCOK=0
  1. . S SCPARM("TEAM")=$G(SCTEAM,"Undefined")
  1. . D ERR^SCAPMCU1(.SCESEQ,4045101,.SCPARM,"",.SCERR)
  1. ; -- is it a valid TEAM ien passed (Error # 4045101 in DIALOG file)
  1. IF '$D(^SCTM(404.51,+SCTEAM,0)) D S SCOK=0
  1. . S SCPARM("TEAM")=SCTEAM
  1. . D ERR^SCAPMCU1(SCESEQ,4045101,.SCPARM,"",.SCERR)
  1. Q SCOK