SCMCCV2 ;ALB/JLU;PC Attending conversion;6/4/1999
;;5.3;Scheduling;**195**;AUG 13, 1993
;
STRTQJOB ;this is the start of the queue job to convert PC Attending
;Assignments.
;The following variables are defined when the job starts
;SCMCTM(X) the array of team IENs as subscripts
;SCMCPOS(X) the array of positions as subscripts
;SCMCFIX is set to either F for fix of C for Check
;SCMCTYPE is set to A for ALL, T for team or P for position
;
N STOP,ZSTOP,SCMCCNT
S SCMCCNT="0^0^0" ;total count^fixed count^err count
S (STOP,ZSTOP)=0
D INIT^SCMCCV1
D BLDLIST
D:$D(^TMP("SCMC",$J)) PROCLIST
D MAIL ;WATCH FOR ZSTOP
K ^TMP("SCMC",$J),^XTMP("SCMCATTCONV")
Q
;
;
BLDLIST ;gathers all the PC Attending Assignments within PCMM database.
;this will be placed in the following global for processing
;^TMP("SCMC",$J,TM IEN,POS IEN,POS ASGN IEN 404.43)=DFN^ASGNDT
;
N DFN,ASGNDT,TMPOS,POSASGN,TMASGN,TMASGNZ,TM
K ^TMP("SCMC",$J)
;
F DFN=0:0 S DFN=$O(^SCPT(404.43,"APCPOS",DFN)) Q:DFN="" F ASGNDT=0:0 S ASGNDT=$O(^SCPT(404.43,"APCPOS",DFN,2,ASGNDT)) Q:ASGNDT="" DO
.F TMPOS=0:0 S TMPOS=$O(^SCPT(404.43,"APCPOS",DFN,2,ASGNDT,TMPOS)) Q:TMPOS="" F POSASGN=0:0 S POSASGN=$O(^SCPT(404.43,"APCPOS",DFN,2,ASGNDT,TMPOS,POSASGN)) Q:POSASGN="" DO
..S TMASGN=+$G(^SCPT(404.43,POSASGN,0))
..I 'TMASGN Q
..I +$P(^SCPT(404.43,POSASGN,0),U,4),$P(^(0),U,4)
0 S ERR="-Bad team assignment pointer.",RES=0 D SETERR(ERR)
;
S TMASGN=$G(^SCPT(404.42,TMASGN,0))
I TMASGN="" S ERR="-Missing Team Assignment.",RES=0 D SETERR(ERR)
;
I $P(TMASGN,U,9)>0 S ERR="-Patient Team Assignment status is discharged.",RES=0 D SETERR(ERR)
;
I $P(TMASGN,U,8)'=1 S ERR="-PC Role only allowed if Patient Team Assignment is for Primary Care",RES=0 D SETERR(ERR)
;
CHKQ Q RES
;
;
MAIL ;sets up message for conversion and delivers.
;
N XMY,XMTEST,XMSUB,XMDUZ,CNTR
;
D INIT^SCMCCV1
I '$D(^TMP("SCMC",$J)) D
. D SET("")
. D SET("No PC Attending Assignments to evaluate!")
. Q
E D
. D TEXT
. D TOTALS
. D ERRORS
. Q
D ^XMD
Q
;
;
TEXT ;fills in the text of the message
;
D HDR
I SCMCTYPE="A" D LISTA
I SCMCTYPE="T" D LISTT
I SCMCTYPE="P" D LISTP
I ZSTOP D STOPPED
Q
;
;
HDR ;header for check mode.
;
D SET("The conversion software was run in a "_$S(SCMCFIX="C":"'CHECK'",1:"'FIX'")_" mode.")
;
I SCMCFIX="C" D SET("No actual conversion took place.")
E DO
.D SET("When possible the PC Attending assignment was changed to PC Practitioner.")
.D SET("If it could not be converted an error message is listed and the assignment was left in its original state.")
.Q
;
D SET("")
Q
;
;
LISTA ;
D SET("All PCMM Teams and Positions were reviewed.")
Q
;
;
LISTT ;
N VAR
D SET("Team(s):")
S VAR=0
F S VAR=$O(SCMCTM(VAR)) Q:VAR="" D SET($P(^SCTM(404.51,VAR,0),U,1))
D SET(" ")
D SET("All positions for each team are included.")
Q
;
;
LISTP ;
N VAR
D SET("Team:")
S VAR=$O(SCMCTM(0))
D SET($P(^SCTM(404.51,VAR,0),U,1))
D SET(" ")
D SET("Position(s):")
S VAR=0
F S VAR=$O(SCMCPOS(VAR)) Q:VAR="" D SET($P(^SCTM(404.57,VAR,0),U,1))
Q
;
;
TOTALS ;fills the totals into the message.
;
D SET(" ")
D SET(" ")
D SET("Assignments reviewed: "_$P(SCMCCNT,U,1))
D SET("Assignments "_$S(SCMCFIX="C":"that would have been ",1:"")_"converted: "_$P(SCMCCNT,U,2))
D SET("Assignments that could not be converted: "_$P(SCMCCNT,U,3))
D SET(" ")
Q
;
;
ERRORS ;load in the error messages into the report.
;
;^TMP("SCMC",$J,"ERR",TEAM,POSITION,DFN,1) = PATIENT^SSN^ASSIGNMENT DATE
;
N VAR
D SET(" ")
D SET(" ")
D SET("The following assignments could not be converted and why:")
D SET(" ")
D SET("Patient Name SSN Team Position Assignment Date")
D SET("------------------------------------------------------------------------------")
;
N TM,POS,ASGNDT,DFN
S TM=""
F S TM=$O(^TMP("SCMC",$J,"ERR",TM)) Q:TM="" DO
.D SET(" ")
.D SET(" ")
.D SET("Team==> "_TM)
.S POS="" F S POS=$O(^TMP("SCMC",$J,"ERR",TM,POS)) Q:POS="" DO
..D SET("Position==> "_POS_" ("_^TMP("SCMC",$J,"ERR",TM,POS)_")")
..F DFN=0:0 S DFN=$O(^TMP("SCMC",$J,"ERR",TM,POS,DFN)) Q:DFN="" DO
...N PAT,VAR1,LP,ERR,TITLE
...S VAR1=^TMP("SCMC",$J,"ERR",TM,POS,DFN,1)
...S TITLE=$P(VAR1,U,1)
...D PADTO(25,.TITLE)
...S TITLE=TITLE_$E($P(VAR1,U,2),6,9)
...D PADTO(31,.TITLE)
...S TITLE=TITLE_$E(TM,1,15)
...D PADTO(48,.TITLE)
...S TITLE=TITLE_$E(POS,1,15)
...D PADTO(65,.TITLE)
...S TITLE=TITLE_$P(VAR1,U,3)
...D SET(TITLE)
...F LP=2:1 S ERR=$G(^TMP("SCMC",$J,"ERR",TM,POS,DFN,LP)) Q:ERR="" D SET(" "_ERR)
...Q
..Q
.Q
Q
;
;
PADTO(TOT,VAR) ;
S VAR=$$LJ^XLFSTR(VAR,TOT)
Q
;
;
SET(X) ;sets data into the correct mail storage global
;
S CNTR=CNTR+1
S ^TMP("SCMC",$J,"MSG",CNTR,0)=X
Q
;
;
STOPPED ;
D SET(" ")
D SET("*** The conversion job was stopped by request.")
D SET("*** Some data was still processed.")
D SET("*** Contact your IRM for more information. ***")
Q