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

SCMRBK.m

Go to the documentation of this file.
  1. SCMRBK ;ALB/SCK - Broker Utilities for multiple patient reassignments; 4/8/96
  1. ;;5.3;Scheduling;**148,157,204**;AUG 13, 1993
  1. ;
  1. Q
  1. ;
  1. PTGET(SCDATA,SC) ; Return a block of patients to the client
  1. ; 'SC GET PAT BLOCK'
  1. ;
  1. ; SCJOB = $J for the ^TMP global
  1. ; SCJOBID = The second subscript id for the ^TMP global
  1. ; SCSTART = Beginning entry number for the block retrieval in the ^TMP global
  1. ; SCEND = The ending entry number for the block retrieval
  1. ; SCLAST = The last entry number in the ^TMP global
  1. ;
  1. ; This RPC returns a list of patients from the temp global that was built by
  1. ; by the call to either SCMC BLD POS PAT LIST or SCMC BLD TEAM PAT LIST
  1. ;
  1. N SCJOB,SCSTART,SCEND,I,SCLAST,SCJOBID
  1. ;
  1. D CHK^SCUTBK
  1. D TMP^SCUTBK
  1. ;
  1. D PARSE^SCMCBK1(.SC)
  1. ;
  1. F I=SCSTART:1:SCEND Q:'$G(^TMP(SCJOB,SCJOBID,I),0) D
  1. . S SCDATA(I)=^TMP(SCJOB,SCJOBID,I)
  1. I SCEND>SCLAST K ^TMP(SCJOB,SCJOBID)
  1. ;
  1. D CLRVAR^SCMCBK1
  1. Q
  1. ;
  1. ; This is invoked after the Save button is clicked in Patient reasignment-both team and pos
  1. ; RPC - SC BLD REASSIGN PAT LST
  1. PTLSTBLD(SCOK,SCVAL) ; Build the list of patients to be assigned in the ^TMP($J,"SCPATIENT LIST",DFN) global
  1. ; 'SC BLD PAT LIST'
  1. ;
  1. N SCJOB,SCDFN
  1. ;
  1. D CHK^SCUTBK
  1. D TMP^SCUTBK
  1. ;
  1. S SCOK=0
  1. I SCVAL["Start" D G PTBLDQ
  1. . S SCOK=$J
  1. . K ^TMP(SCOK,"SC PATIENT LIST")
  1. ;
  1. S SCJOB=$P(SCVAL,U,1)
  1. S SCDFN=$P(SCVAL,U,2)
  1. S ^TMP(SCJOB,"SC PATIENT LIST",SCDFN)=$P(SCVAL,U,3) ; equals assignment IEN (PDR)
  1. S SCOK=1
  1. PTBLDQ ;
  1. Q
  1. ;
  1. ; This is invoked by RPC (SC FILE PAT TM REASGN) for team reasignment
  1. ;
  1. PTFILE(SCOK,SC) ; File the patient assignments in the ^TMP($J,"SC TEAM ASSIGN",SCDFN) global
  1. ; 'SCMC FILE PAT TM REASGN'
  1. ;
  1. N SCADDFLD,SCTEAM,SCFILE,SCJOB,SCNEW,SCOLD,SCBAD,SCERMSG,SCX,SCDTVAR,SCOTH
  1. N ZTPRI,ZTRTN,ZTDESC,ZTDTH,SCNOW
  1. ;
  1. D CHK^SCUTBK
  1. D TMP^SCUTBK ; this sets up a DUZ=.5 and a DT of the current date
  1. D NOW^%DTC
  1. S SCNOW=% ; get actual FM date/time for enter/edit documentation
  1. ;
  1. D PARSE^SCMCBK1(.SC)
  1. G:+$G(SCJOB)=0 FILEQ
  1. ;
  1. ; Additional fields for 404.42 PATIENT TEAM ASSIGNMENT FILE
  1. S SCADDFLD(.08)=$G(SC("TYPE"),99)
  1. S SCADDFLD(.1)=$G(SC("RESTRICT"),0)
  1. ; note, the fields below are not appropriate if team is being activated or modified. Be sure
  1. ; to kill as necessary before filing, and to add edit by and edit D/T where necessary - PDR
  1. S SCADDFLD(.11)=DUZ ; user entering
  1. S SCADDFLD(.12)=SCNOW ; entry date/time (changed from =DT - PDR)
  1. ;
  1. I $G(SC("BKG"))="1" D BKG(1) Q ;Bail out to run in background
  1. ;
  1. BKGTM ; Run Team Reassignment Filer in BKG
  1. I $D(ZTQUEUED) S SCJOB=$J ; want to use Task Manager assigned $J if BKG
  1. S SCX=$$ACPTRATM^SCAPMR6("^TMP(SCJOB,""SC PATIENT LIST"")",SCTEAM,SCFRMTM,.SCOTH,"SCADDFLD",SCDTVAR,"SCERMSG","SCNEW","SCOLD","SCBAD")
  1. I '$D(ZTQUEUED) D
  1. . D BAD^SCMCBK1(.SCBAD,.SCOLD,.SCOK) ; this sets up RPC return var SCOK for error report dialog
  1. . S SCOK(.1)=SCX_U_"FORE"
  1. ;
  1. K ^TMP(SCJOB,"SC PATIENT LIST")
  1. D CLRVAR^SCMCBK1
  1. ;
  1. FILEQ Q
  1. ;
  1. ; This is invoked by RPC ('SC FILE PAT POS REASGN') for position reasignment
  1. POSFILE(SCOK,SC) ; File the patient assignments in the ^TMP($J,"SC PATIENT LIST") global
  1. ; ' SCMC FILE PAT POS REASGN '
  1. ;
  1. N SCADDFLD,SCTEAM,SCFILE,SCJOB,SCNEW,SCOLD,SCBAD,SCERMSG,SCX
  1. N SCPOSTO,SCPOSFRM,SCDTVAR,SCMAFLD,SCADTM,SCNEW1,SCNOW
  1. ;
  1. D CHK^SCUTBK
  1. D TMP^SCUTBK
  1. S SCNOW=$$NOW^XLFDT
  1. ;
  1. D PARSE^SCMCBK1(.SC)
  1. S SCPOSTO=SC("POSITION")
  1. S SCPOSFRM=SC("FROMPOSITION")
  1. G:+$G(SCJOB)=0 FILEQ
  1. S SCADTM=1
  1. ;
  1. S SCADDFLD(.05)=$G(SC("TYPE"),0)
  1. S SCADDFLD(.06)=DUZ
  1. S SCADDFLD(.07)=SCNOW
  1. ;
  1. I $G(SC("BKG"))="1" D BKG(2) Q
  1. ;
  1. BKGPOS ; BACKGROUND JOB ENTRY POINT
  1. I $D(ZTQUEUED) S SCJOB=$J ; want to use Task Manager assigned $J if BKG
  1. S SCX=$$ACPTATP^SCAPMR21("^TMP(SCJOB,""SC PATIENT LIST"")",SCPOSTO,SCPOSFRM,"SCADDFLD",SCDTVAR,"SCERMSG",SCADTM,"","SCNEW","SCNEW1","SCOLD","SCBAD")
  1. ;
  1. I '$D(ZTQUEUED) D
  1. . D BAD2^SCMCBK1(.SCBAD,.SCOLD,.SCOK) ; this sets up RPC return var SCOK for error report dialog
  1. . S SCOK(.1)=SCX_U_"FORE"
  1. ;
  1. K ^TMP(SCJOB,"SC PATIENT LIST")
  1. D CLRVAR^SCMCBK1
  1. Q
  1. ;
  1. BLKPOS ;
  1. N SCX
  1. S SCX=$G(SCDTRNG("END"))
  1. S SCDTRNG("END")=3990101 ;check forever
  1. S SCOK1=$$PTTP^SCAPMC(SCBLOCK,"SCDTRNG","^TMP(""SCMC"",$J,""EXCLUDE PT"")","SCER2")
  1. S SCDTRNG("END")=SCX
  1. Q
  1. ;
  1. BLKTM ;
  1. N SCX
  1. S SCX=$G(SCDTRNG("END"))
  1. S SCDTRNG("END")=3990101 ;check forever
  1. S SCOK1=$$PTTM^SCAPMC(SCBLOCK,"SCDTRNG","^TMP(""SCMC"",$J,""EXCLUDE PT"")","SCER2")
  1. S SCDTRNG("END")=SCX
  1. Q
  1. ;
  1. ; This is used to get the patient list to fill the list box after team and position selection
  1. ;
  1. PTPOSLST(SCOK,SC) ; Get a list of of patients for a team position
  1. ; RPC:'SCMC BLD POS PAT LIST'
  1. ;
  1. N PD,FD,TD,ASNST,FC
  1. D NEWVAR^SCMCBK1
  1. D CHK^SCUTBK
  1. D TMP^SCUTBK
  1. S FD=SC("FROMDATE")
  1. S TD=SC("TODATE")
  1. S ASNSTAT=SC("ASSIGNSTAT") ; 0=assigned only, 1=Discharged only, 2=both
  1. ;
  1. D PARSE^SCMCBK1(.SC)
  1. ;
  1. K ^TMP($J,"SCPOS")
  1. ;
  1. S SCOK=0
  1. ; This date setting could be accomplished on GUI using the .MULT[] broker array, and
  1. ; loaded into SCDTRNG via the call to parse. I've opted to set the array explicitly
  1. ; here.
  1. S SCDTRNG("BEGIN")=FD
  1. S SCDTRNG("END")=TD
  1. S SCDTRNG("INCL")=0
  1. ; get list of pt active for time period specified
  1. ; future discharges included
  1. S SCOK=$$PTTP^SCAPMC11(SCFRMPOS,"SCDTRNG",.SCLOC,.SCERMSG)
  1. K ^TMP("SCMC",$J,"EXCLUDE PT")
  1. M ^TMP($J,"SC PCMM IN")=@SCLOC
  1. ;
  1. S I1=$G(^TMP($J,"SC PCMM IN",0))
  1. S FC=0 ; initialize filtered count of patients
  1. F I=1:1:I1 D
  1. . S PD=$G(^TMP($J,"SC PCMM IN",I)) ; get the discharge date
  1. . Q:$$FILTOUT(+$P(PD,U,5),+$P(PD,U,4))
  1. . S ^TMP($J,"PCMM TMP",I)=$G(^TMP($J,"SC PCMM IN",I))
  1. . S FC=FC+1
  1. D ALPHA^SCAPMCU2("^TMP($J,""PCMM TMP"")","^TMP($J,""SCPOS"")")
  1. S SCOK=$J_U_FC_U_SCOK
  1. ;
  1. D CLRVAR^SCMCBK1
  1. Q
  1. ;
  1. FILTOUT(DD,AD) ; FILTER OUT CANDIDATE PATIENTS
  1. ;bp/cmf 204t0 -- SCDTVAR(def = dt) replaces DT
  1. ; Want actives only
  1. Q:ASNSTAT=0 ((DD)&(DD'>SCDTVAR))!(AD>SCDTVAR)
  1. ; ; disch date before tomorrow, or assign date greater than today
  1. ;
  1. ; Want discharges between dates only
  1. Q:ASNSTAT=1 (DD>TD)!(DD<FD)
  1. ; ; disch date is after TO date, or discharge date is before FROM date
  1. ;
  1. ; Want discharges and actives from date
  1. Q:ASNSTAT=2 (DD&(DD<FD))!(AD>SCDTVAR)
  1. ; ; disch date less than FROM date, or assign date > dtvar
  1. Q 0
  1. ;
  1. ;
  1. ; used to get the patient list after a team selection
  1. ;
  1. PTTMLST(SCOK,SC) ; ; Get a list of of patients for a team - FILTER FOR ACTIVE
  1. ; RPC:'SCMC BLD TEAM PAT LIST'
  1. ;
  1. ;bp/cmf 204t0 -- SCDTVAR(def = dt) replaces DT
  1. N TD,SCDD
  1. D NEWVAR^SCMCBK1
  1. D CHK^SCUTBK
  1. D TMP^SCUTBK
  1. ;
  1. D PARSE^SCMCBK1(.SC)
  1. K ^TMP($J,"SCTEAM")
  1. ;
  1. S SCOK=0
  1. ; get list of patient team assignments ordered by q
  1. S SCOK=$$PTTM^SCAPMC2(SCFRMTM,"SCDTRNG",.SCLOC,"SCERMSG") ; SCLOC = ^TMP("SCTMP LIST",$J)
  1. K ^TMP("SCMC",$J,"EXCLUDE PT")
  1. M ^TMP($J,"SC PCMM IN")=@SCLOC
  1. ;
  1. S I=""
  1. F S I=$O(^TMP($J,"SC PCMM IN",I)) Q:'I D
  1. . S TD=^TMP($J,"SC PCMM IN",I)
  1. . S SCDD=$P(TD,U,5)
  1. . Q:(SCDD'="")&(SCDD'>SCDTVAR) ; filter discharged assignments
  1. . Q:$P(TD,U,4)>SCDTVAR ; filter future assignments
  1. . S ^TMP($J,"PCMM TMP",I)=^TMP($J,"SC PCMM IN",I)
  1. ;
  1. D ALPHA^SCAPMCU2("^TMP($J,""PCMM TMP"")","^TMP($J,""SCTEAM"")")
  1. ;
  1. S SCOK=$J_U_+$O(^TMP($J,"SCTEAM",""),-1)_U_SCOK
  1. ;
  1. D CLRVAR^SCMCBK1
  1. Q
  1. ;
  1. DISCHPOS(SCOK,SC) ; DISCHARGE POSITIONS FOR A TEAM - RPC: PDR SC DIS TEAM POS
  1. ; SC("DFN") = ptr to patient file
  1. ; SC("TMASGN") = ptr to team assignment file 404.42
  1. ; SC("DATE") = file date (date selected on client)
  1. N SCBEGIN,SCEND,SCINCL,SCDATES,SCERR
  1. D CHK^SCUTBK
  1. D TMP^SCUTBK
  1. S SCOK=1
  1. S SCERR="SCERRMSG"
  1. K @SCERR ;;bp/cmf 204 clean error array!!!!!!!!!! [iow-0899-40854]
  1. D DISCHPOS^SCRPMTA(SC("DFN"),SC("TMASGN"),SC("DATE"),SCERR)
  1. S SCOK='$D(@SCERR)
  1. Q
  1. ;
  1. BKG(SCX) ;hand off to taskman
  1. ;input SCX=toggle between team/position reassignment
  1. ;
  1. S ZTPRI=10
  1. S ZTRTN=$P($$S(SCX),"::")
  1. S ZTDESC=$P($$S(SCX),"::",2)
  1. S ZTDTH=$H
  1. S ZTSAVE("SC*")=""
  1. S ZTSAVE("^TMP($J,")=""
  1. I '$G(SC("NOP")) D ^%ZTLOAD ; define NOP on GUI side if don't want BKG
  1. S SCOK(0)=1_U_"BKG"_$G(ZTSK)
  1. S SCOK(.1)=$$PASSCNT^SCMCBK5($$S(3))_U_"BKG"_U_$G(SC("NOP"))
  1. Q
  1. ;
  1. S(SCX) Q $P($T(T+SCX),";;",2)
  1. ;
  1. T ;;
  1. ;;BKGTM^SCMRBK::PCMM TEAM REASSIGN BKG
  1. ;;BKGPOS^SCMRBK::PCMM POSITION REASSIGN BKG
  1. ;;^TMP($J,"SC PATIENT LIST")
  1. ;