source: WorldVistAEHR/trunk/r/SCHEDULING-SD-SC/SCMCQK2.m@ 1710

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

initial load of WorldVistAEHR

File size: 7.3 KB
RevLine 
[613]1SCMCQK2 ;ALB/REW - Single Pt Tm/Pt Tm Pos Assign and Discharge ; 07 Oct 2002 12:10 PM
2 ;;5.3;Scheduling;**297**;AUG 13, 1993
3 ;
4DSPL ;
5 N LP,SCD,SCPOS
6 S SCTOK=$$TMPT^SCAPMC3(DFN,"SCDT","","SCD","SCER1")
7 S SCOK=$$TPPT^SCAPMC(DFN,"","","","","","","SCPOS","SCBKERR")
8 ;
9 ;loop through positions only getting the ones associated with the team
10 ;and that are active.
11 ;
12 F LP=0:0 S LP=$O(SCPOS(LP)) Q:'LP D
13 .I $P(SCPOS(LP),U,6)]"" K SCPOS(LP) Q
14 .S SCPOS("T",$P(SCPOS(LP),U,3),+SCPOS(LP))=SCPOS(LP)
15 S CNT=0,POS=0
16 F LP=0:0 S LP=$O(SCD(LP)) Q:'LP S A=SCD(LP) I '$P(A,U,8) D
17 .I 'CNT W !!,"NON PC ASSIGNMENTS",!
18 .S CNT=CNT+1 W !,CNT,?4,"Non-PC Team: "_$P(A,U,2),?48,"Phone: "_$P($G(^SCTM(404.51,+A,0)),U,2) S DATA(CNT)=+A
19 .F I=0:0 S I=$O(SCPOS("T",+A,I)) Q:'I D
20 ..I $P(DATA(CNT),U,2) S CNT=CNT+1
21 ..S B=SCPOS("T",+A,I)
22 ..S DATA(CNT)=(+A)_U_(+B),POS=1
23 ..S SCPR=$$GETPRTP^SCAPMCU2(+B,DT),RES=$$NEWPERSN^SCMCGU(+SCPR,"SCPR")
24 ..W:$X>76 !,CNT,?4,"Non-PC Team: "_$P(A,U,2),?48,"Phone: "_$P($G(^SCTM(404.51,+A,0)),U,2)
25 ..W !,?7,"Provider: "_$P(SCPR,U,2),?45,"Position: "_$P(B,U,2)_" "
26 ..W !,?10,"Pager: "_$P($G(SCPR(+SCPR)),U,5),?48,"Phone: ",$P($G(SCPR(+SCPR)),U,2),?77," "
27 I 'CNT W !,"No active NON PC ASSIGNMENTS for this patient",!
28 Q
29NPC N SCDT,SCER1,SCD,SCPOS
30 D DSPL
31 S DIR(0)="SO^0:NONE;1:TEAM ASSIGNMENT;"_$S(CNT:"2:POSITION ASSIGNMENT;3:UNASSIGNMENT;",1:"")
32 S DIR("B")=1
33 D ^DIR
34 I Y=0 Q
35 I Y=U Q
36 I Y=1 D ASTM G NPC
37READ S:CNT=1 X=1 I CNT>1 W !,"Select 1-"_CNT_": " R X:DTIME Q:X=U S X=+X I X>CNT!X<1 G READ
38 I Y=3 S DATA=DATA(+X) S SCTPSTAT=1,SCTP=+$P(DATA,U,2),SCTM=+DATA D UNTP:SCTP,UNTM:'SCTP G NPC
39 S DATA=DATA(+X),SCTM=+DATA S SCSELECT=$$SELPOS() G NPC:'$L(SCSELECT) D ASTP G NPC
40 Q
41UNTP ;unassign patient from position
42 IF '$G(SCTP) W !,"No position defined" Q
43 N OK,SCER,SCCL,SCBEGIN,SCN,SCLIST,SCEND,SCINCL,SCLSEQ,SCDATES,SCDTS
44 S OK=0
45 W !,"About to Unassign "_$$NAME(DFN)_" from: ",!,?8,$$POSITION(SCTP)_" position ["_$P($$GETPRTP^SCAPMCU2(SCTP,DT),U,2)_"]"
46 S SCDISCH=$$DATE("D")
47 G:SCDISCH<1 QTUNTP
48 G:'$$CONFIRM() QTUNTP
49 S OK=$$INPTSCTP^SCAPMC22(DFN,SCTP,SCDISCH,.SCER)
50 G:OK'>0 QTUNTP
51 S SCCL=$P($G(^SCTM(404.57,+$G(SCTP),0)),U,9)
52QTUNTP W !,"Position Unassignment "_$S(OK:"made.",1:"NOT made.")
53 Q
54 ;
55 ;
56UNTM ;
57 ;assign patient from non pc team (and pc position if possible)
58 N OK,SCER,SCBEGIN,SCN,SCLIST,SCEND,SCINCL,SCLSEQ,SCDATES,SCDTS,OK2,OK3
59 S OK=0
60 W !!,"About to Unassign "_$$NAME(DFN)_" from "_$$TEAMNM(SCTM)_" team"
61 W:'SCTPSTAT !,?5,"AND from "_$$POSITION(SCTP)_" position ["_$$WRITETP^SCMCDD1(SCTP)_"]"
62 S SCDISCH=$$DATE("D")
63 G:SCDISCH<1 QTUNTM
64 G:'$$CONFIRM() QTUNTM
65 IF 'SCTPSTAT D G:OK2'>0 QTUNTM
66 .W !,"Unassigned."
67 .S OK2=$$INPTSCTP^SCAPMC22(DFN,SCTP,SCDISCH,.SCER)
68 .IF OK2>0 D
69 ..W "made."
70 ..S SCCL=$P(^SCTM(404.57,SCTP,0),U,9)
71 S OK3=$$ALLPOS^SCMCQK1()
72 IF $$OKINPTTM^SCMCTMU2(DFN,SCTM,SCDISCH) D
73 .S OK=$$INPTSCTM^SCAPMC7(DFN,SCTM,SCDISCH,.SCER)
74 ELSE D
75 . W !,"Future/Current Patient-Position Assignment exists"
76QTUNTM W !,"Team Unassignment "_$S(OK:"made",1:"NOT made.")
77 Q
78 ;
79ASTM ;assign patient to team
80 N DIC,Y,OK,SCTM,SCTMFLDS,SCER,SCBEGIN,SCN,SCLIST,SCEND,SCINCL,SCLSEQ,SCDATES,SCDTS
81 S OK=0
82 W !!,"About to Assign "_$$NAME(DFN)_" to a non primary care team"
83 I $$SC^SCMCQK1(DFN) W !!,"********** This patient is 50 percent or greater service-connected ************"
84 S DIC="^SCTM(404.51,"
85 S DIC(0)="AEMQZ"
86 S DIC("S")="IF $$ACTTM^SCMCTMU(Y,DT) I $$NEW^SCMCQK2()"
87 ; - select from active teams that can not be PC Teams
88 D ^DIC
89 G:Y<1 QTASTM
90 S SCTM=+Y
91 S SCASSDT=$$DATE("A")
92 G:SCASSDT<1 QTASTM
93 S SCTMCT=$$TEAMCNT^SCAPMCU1(SCTM)
94 S SCTMMAX=$P($$GETEAM^SCAPMCU3(SCTM),"^",8)
95 I SCTMCT'<SCTMMAX D G QTASTM:'$$YESNO2()
96 .W !,"This assignment will reach or exceeded the maximum set for this team."
97 .W !,"Currently assigned: "_SCTMCT
98 .W !,"Maximum set for team: "_SCTMMAX
99 I SCTMCT<SCTMMAX,'$$CONFIRM() G QTASTM
100 S SCTM=+Y
101 ;setup fields
102 ;S SCTMFLDS(.08)=1 ;primary care assignment
103 S SCTMFLDS(.11)=$G(DUZ,.5)
104 D NOW^%DTC S SCTMFLDS(.12)=%
105 IF $$ACPTTM^SCAPMC(DFN,SCTM,"SCTMFLDS",SCASSDT,"SCTPTME") D
106 .S SCSELECT=$$SELPOS()
107 .D:$L(SCSELECT) ASTP ;prompt for position prompt
108 .S OK=1
109QTASTM W !,"Team Assignment "_$S(OK:"made",1:"NOT made.")
110 Q
111ASTP ;assign patient to practitioner
112 N DIC,Y,OK,SCCL,X,SCTPFLDS,SCER,SCBEGIN,SCN,SCLIST,SCEND,SCINCL,SCLSEQ,SCDATES,SCDTS
113 S OK=0
114 W !!,"About to Assign "_$$NAME(DFN)_" to non PC Position Assignment"
115 I $$SC^SCMCQK1(DFN) W !!,"********** This patient is 50 percent or greater service-connected ************"
116 ;lookup to display only position and [practitioner]
117 IF SCSELECT="PRACT" D
118 .S DIC("W")="N SCP1 S SCP1=$G(^SCTM(404.52,Y,0)) W "" ["",$P($G(^VA(200,+$P(SCP1,U,3),0)),U,1),""]"""
119 .S DIC("A")="POSITION's Current PRACTITIONER: "
120 .S DIC="^SCTM(404.52,"
121 .;Must be from team, must be active,must not have future inactivation
122 .S DIC("S")="I $$PRACSCR^SCMCQK2(Y)"
123 .S D="C"
124 ELSE D
125 .S DIC="^SCTM(404.57,"
126 .S D="B"
127 .S DIC("A")="POSITION's Name: "
128 .S DIC("S")="I $$POSSCR^SCMCQK2(Y)"
129 S DIC(0)="AEMQZ"
130 D MIX^DIC1
131 G:Y<1 QTASTP
132 IF SCSELECT="PRACT" D
133 .S SCTP=$P(Y,U,2)
134 ELSE D
135 .S SCTP=$P(Y,U,1)
136 S SCASSDT=$$DATE("A")
137 G:SCASSDT<1 QTASTP
138 S SCTMCT=$$PCPOSCNT^SCAPMCU1(SCTP),SCTMMAX=+$P($G(^SCTM(404.57,SCTP,0)),U,8)
139 I SCTMCT'<SCTMMAX D G QTASTP:'$$YESNO2
140 .W !,"This assignment will reach or exceeded the maximum set for this position."
141 .W !,"Currently assigned: "_SCTMCT
142 .W !,"Maximum set for position: "_SCTMMAX
143 G:'$$CONFIRM() QTASTP
144 ;setup fields
145 S SCTPFLDS(.03)=SCASSDT
146 ;S SCTPFLDS(.05)=1 ;pc pract role
147 S SCTPFLDS(.06)=$G(DUZ,.5)
148 D NOW^%DTC S SCTPFLDS(.07)=%
149 IF $$ACPTTP^SCAPMC21(DFN,SCTP,"SCTPFLDS",SCASSDT,"SCTPTME",0) D
150 .S OK=1
151 .S SCCL=$P(^SCTM(404.57,SCTP,0),U,9)
152QTASTP W !,"Position Assignment "_$S(OK:"made",1:"NOT made.")
153 Q
154NAME(DFN) ;return patient name
155 Q $P($G(^DPT(DFN,0)),U,1)
156 ;
157POSITION(SCTP) ;return position name
158 Q $P($G(^SCTM(404.57,SCTP,0)),U,1)
159 ;
160TEAMNM(SCTM) ;return team name
161 Q $P($G(^SCTM(404.51,SCTM,0)),U,1)
162 ;
163CLINIC(SCCL) ;return clinic name
164 Q $P($G(^SC(+SCCL,0)),U,1)
165 ;
166YESNO() ;
167 N DIR,X,Y
168 S DIR(0)="Y",DIR("B")="YES"
169 D ^DIR
170 Q Y>0
171 ;
172YESNO2() ;
173 N DIR,X,Y
174 S DIR(0)="Y",DIR("B")="NO"
175 S DIR("A")="Do you wish to continue with the assignment (Yes/No)?"
176 D ^DIR
177 Q Y>0
178CONFIRM() ;confirmation call
179 N DIR,X,Y
180 S DIR("A")="Are you sure (Yes/No)"
181 S DIR(0)="Y"
182 D ^DIR
183 Q +Y=1
184 ;
185SELPOS() ;return way to select position: 1=PRACT,2=POSIT,3=NONE
186 N DIR,X,Y
187 W !,"Choose way to select NON PC POSITION Assignment: "
188 S DIR(0)="SO^0:NONE;1:BY PRACTITIONER ASSIGNMENT;2:BY POSITION ASSIGNMENT"
189 S DIR("B")=1
190 D ^DIR
191 Q $S(Y'>0:"",+Y=1:"PRACT",1:"POSIT")
192 ;
193DATE(TYPE) ;return date type=A or D
194 N DIR,X,Y
195 S DIR("A")=$S(TYPE="A":"Assignment",1:"Unassignment")_" date: "
196 S DIR(0)="DA^::EXP"
197 S Y=$S($D(SCDISCH):SCDISCH,$D(SCASSDT):SCASSDT,(TYPE="A"):"TODAY",1:"TODAY-1")
198 X ^DD("DD")
199 S DIR("B")=Y
200 D ^DIR
201 Q Y
202 ;
203PRACSCR(SC40452) ;screen for for file 404.52
204 N SCP,SCNODE,OK
205 S SCP=$G(^SCTM(404.52,SC40452,0))
206 S OK=0
207 G:'SCP QTPP
208 S SCNODE=$G(^SCTM(404.57,+SCP,0))
209 S OK=$S($P(SCNODE,U,2)'=SCTM:0,$P(SCNODE,U,4):0,($O(^SCTM(404.52,"AIDT",+SCP,1,""))'=-$P(SCP,U,2)):0,($O(^SCTM(404.52,"AIDT",+SCP,0,-$P(SCP,U,2)),-1)):0,($$ACTTP^SCMCTPU(+SCP)>0):1,1:0)
210QTPP Q OK
211 ;
212POSSCR(SCTP) ;screen for file 404.57
213 N SCNODE
214 S SCNODE=$G(^SCTM(404.57,SCTP,0))
215 Q $S($P(SCNODE,U,2)'=SCTM:0,$P(SCNODE,U,4):0,($$ACTTP^SCMCTPU(SCTP)>0):1,1:0)
216 Q
217NEW() ;
218 F I=0:0 S I=$O(SCD(I)) Q:'I I (+SCD(I))=(+Y) Q
219 Q 'I
Note: See TracBrowser for help on using the repository browser.