source: WorldVistAEHR/trunk/r/SCHEDULING-SD-SC/SCENIA2.m@ 1361

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

initial load of WorldVistAEHR

File size: 5.7 KB
RevLine 
[613]1SCENIA2 ;ALB/SCK - INCOMPLETE ENCOUNTER ERROR DISPLAY PROTOCOLS, CONT. ; OCT 21, 1998
2 ;;5.3;Scheduling;**66,132,158**;AUG 13, 1993
3 ;
4EVT1(SDXMT,INF) ; Returns ifn for ^SC(clinic,"S",date,1,ifn)
5 N SINDX,SDDA
6 ;
7 S SINDX=0 F S SINDX=$O(^SC(INF("CLINIC"),"S",INF("ENCOUNTER"),1,SINDX)) Q:'SINDX>0 D Q:$D(SDDA)
8 . I +^SC(INF("CLINIC"),"S",INF("ENCOUNTER"),1,SINDX,0)=INF("DFN") S SDDA=SINDX
9 Q $G(SDDA)
10 ;
11EI ; Entry point for the SCENI ENCOUNTER INFORMATION protocol
12 I '$D(SD53P158) N SD53P158 S SD53P158="LM" ; Called via LM.
13 I '$D(^XUSEC("SCENI ENCOUNTER EDIT",DUZ)) D Q
14 . W !,$C(7),"You do not have this security key, contact your supervisor."
15 ;
16 N SDATA,SCEN,SDXMT,SCXER,SDOE,SCINF,SCSTAT,SDEVT,SDHDL,SDDA,SCELAP,SCSTPLC,OLDSC,SDQUIT,SDLOG
17 ;
18 K PARENT,VISIT
19 D HDLKILL^SDAMEVT
20 S SDXMT=$G(^TMP("SCENI XMT",$J,0)) Q:'SDXMT
21 S SCSTAT=$$OPENC^SCUTIE1(SDXMT,"SCINF")
22 I SCSTAT<0 D G EIQ
23 . W !!,$C(7),"Entry "_$P(^SD(409.73,SDXMT,0),U),?5,$G(SCINF("ERROR"))
24 . D PAUSE^VALM1
25 ;
26 I SCSTAT>0 D G EIQ
27 . W !!,$C(7),"This is a deleted entry. Encounter information cannot be changed."
28 . D PAUSE^VALM1
29 ;
30 S DFN=SCINF("DFN")
31 S SDOE=$P(^SD(409.73,SDXMT,0),U,2)
32 S SDHDL=$$HANDLE^SDAMEVT($P($G(^SCE(SDOE,0)),U,8)),SDDA=$$EVT1(SDXMT,.SCINF)
33 Q:SDHDL']""
34 ;
35 S SDATA=SDDA_"^"_DFN_"^"_SCINF("ENCOUNTER")_"^"_SCINF("CLINIC")
36 S SDQUIT=0
37 ;
38 L +^SCE(SDOE):0 I '$T D G EIQ
39 . W !?5,$CHAR(7),"Another user is editing this entry"
40 I SD53P158="LM" D FULL^VALM1
41 K DIRUT
42 W !
43 D BEFORE^SDAMEVT(.SDATA,DFN,SCINF("ENCOUNTER"),SCINF("CLINIC"),SDDA,SDHDL)
44 ;
45 K OLDSC S OLDSC=+$P($G(^SCE(SDOE,0)),U,3)
46 S DIR(0)="409.68,.03",DA=SDOE
47 D ^DIR K DIR G:$D(DIRUT)!(Y="") EIQ
48 S $P(SCSTPLC,U)=+Y
49 D SET(+Y,.03,SDOE)
50 ;
51 S DIR(0)="409.68,.11",DA=SDOE
52 D ^DIR K DIR G:$D(DIRUT)!(Y="") A1
53 S $P(SCSTPLC,U,2)=+Y
54 D SET(+Y,.11,SDOE)
55 ;
56 ; ** Display current Appt. Type and Elig. Codes
57 N SD1 S SD1=$P($G(^SCE(SDOE,0)),U,10)
58 W !!!,$C(7),"Current Appointment Type for Encounter: "_$S($G(SD1):$P(^SD(409.1,SD1,0),U),1:"")
59 K SD1 S SD1=$P($G(^SCE(SDOE,0)),U,13)
60 W !,"Current Eligibility for Encounter: "_$S($G(SD1):$P(^DIC(8,SD1,0),U),1:""),!
61 ;
62 S DIR(0)="YA",DIR("B")="NO",DIR("A")="Change Eligibility/Appointment type? " D ^DIR K DIR G:$D(DIRUT)!(Y=0) A1
63 ;
64 W !,"The following are system defaults only.",!
65 ;
66 S SCELAP=$$ELAP^SDPCE(DFN,SCINF("CLINIC"))
67 ;
68 N SDPRIM
69 S SDPRIM=$$ONEELIG
70 ;if only a primary ask if they want to change to it and change
71 I SDPRIM,+SDPRIM'=SD1 DO
72 .N DIR
73 .S DIR(0)="YA",DIR("B")="YES"
74 .S DIR("A",1)="There is only a primary eligibility for this patient: "_$P(SDPRIM,U,2)
75 .S DIR("A")="Do you wish to change the encounter to this? "
76 .S DIR("?")="No other Eligibilities are selectable."
77 .S DIR("?",1)="YES will result in the current primary Eligibility being used for the encounter."
78 .S DIR("?",2)="NO will result in the encounter's Eligibility being left the same."
79 .D ^DIR
80 .I Y=1 S $P(SCELAP,U,1)=+SDPRIM,$P(SCELAP,U,2)=$P(SDPRIM,U,2)
81 .E S $P(SCELAP,U,1)=SD1,$P(SCELAP,U,2)=$P($G(^DIC(8,+SD1,0)),U,1)
82 .Q
83 ;
84 D SET(+SCELAP,.13,SDOE)
85 D SET(+$P(SCELAP,U,3),.1,SDOE)
86A1 D RESYNC(SCSTPLC,$G(SCELAP),SDOE,OLDSC,DFN)
87 D LOGDATA^SDAPIAP(SDOE,.SDLOG)
88 D AFTER^SDAMEVT(.SDATA,DFN,SCINF("ENCOUNTER"),SCINF("CLINIC"),SDDA,SDHDL)
89 ;
90 D EVT^SDAMEVT(.SDATA,5,0,SDHDL)
91 I '$D(SDOK) D I $G(RTN)<0 G EIQ
92 . S RTN=$$VALIDATE^SCMSVUT2(SDXMT)
93 . I RTN<0 D ERMSG^SCENIA1(5) Q
94 . S RTN=$$SETRFLG^SCENIA1(SDXMT)
95 . I RTN<0 D ERMSG^SCENIA1(3) Q
96 I $D(SDOK) S SDOK=1
97 L -^SCE(SDOE):0
98EIQ K OLDSC
99 Q
100 ;
101SET(SDVAL,SDFLD,DA) ; Set updated entry into file #409.68.
102 ;
103 S ^TMP("SCENI EDIN",$J,409.68,DA_",",SDFLD)=SDVAL
104 D FILE^DIE("K","^TMP(""SCENI EDIN"",$J)")
105 I $D(^TMP("DIERR",$J,1)) W !!,"???"
106 K ^TMP("SCENI EDIN",$J),^TMP("DIERR",$J)
107 Q
108 ;
109UPDENC ; Update Outpatient Encounter Option entry point
110 N SDOE,SDXMT,DFN,SDOK
111 N SD53P158 S SD53P158="OPT" ;Entered via menu option.
112 ;
113 S SDOK=0
114 K ^TMP("SCENI XMT",$J)
115 S DIR(0)="PA^409.68:EMQ",DIR("S")="I $D(^SD(409.73,""AENC"",Y))"
116 S DIR("A")="Select Encounter to update: "
117 S DIR("?")="Enter partial name, last four, or date of encounter."
118 S DIR("??")="^S %DT=""PX"" D HELP^%DTC"
119 D ^DIR K DIR G UPDQ:$D(DIRUT)
120 ;
121 S SDOE=+Y
122 S SDXMT=$O(^SD(409.73,"AENC",SDOE,0))
123 S ^TMP("SCENI XMT",$J,0)=SDXMT
124 D EI
125UPDQ ;
126 K DFN
127 Q
128 ;
129RESYNC(STPL,SCELP,SDOE,SCOLD,SDFN) ;
130 N SDOEC,SDCDT
131 ;
132 ; ** Update any child encounters and for each child encounter, search for
133 ; any entries in the Scheduling Visits File, #409.5. If there is a
134 ; match, update then entry in #409.5
135 ;
136 ;everthing else
137 S SDOEC=""
138 F S SDOEC=$O(^SCE("APAR",SDOE,SDOEC)) Q:'SDOEC D
139 . I +$P($G(^SCE(SDOE,0)),U,13)>0 D SET(+$P($G(^SCE(SDOE,0)),U,13),.13,SDOEC)
140 . I +$P($G(^SCE(SDOE,0)),U,10)>0 D SET(+$P($G(^SCE(SDOE,0)),U,10),.1,SDOEC)
141 . I +$P($G(^SCE(SDOE,0)),U,11)>0 D SET(+$P($G(^SCE(SDOE,0)),U,11),.11,SDOEC)
142 . I "2"[+$P($G(^SCE(SDOEC,0)),U,8),($P($G(^SCE(SDOEC,0)),U,3)=SCOLD) D SET(+$P($G(^SCE(SDOE,0)),U,3),.03,SDOEC)
143 ;
144 ; ** Update the entry in the Clinic Appointment multiple for the encounter
145 S SDOEDT=$P($G(^SCE(SDOE,0)),U),SDCLN=$P($G(^(0)),U,4)
146 S SDN1=0 F S SDN1=$O(^SC(SDCLN,"S",SDOEDT,1,SDN1)) Q:'SDN1 D
147 . I $P($G(^SC(SDCLN,"S",SDOEDT,1,SDN1,0)),U)=SDFN D
148 .. S DIE="^SC(SDCLN,""S"",SDOEDT,1,",DA(2)=SDCLN,DA(1)=SDOEDT,DA=SDN1
149 .. S DR="30////"_$P(SCELP,U)
150 .. L +^SC(SDCLN,"S",SDOEDT,1,SDN1)
151 .. D ^DIE K DIE,DR,DA
152 .. L -^SC(SDCLN,"S",SDOEDT,1,SDN1)
153 ;
154 ; ** Update the entry in the Patient Appointment multiple for the encounter.
155 I $D(^DPT(SDFN,"S",SDOEDT,0)),($P(^(0),U,20)=SDOE) D
156 . S DIE="^DPT(SDFN,""S"",",DA(1)=SDFN,DA=SDOEDT
157 . S DR="9.5////"_$P(SCELP,U,3)
158 . L +^DPT(SDFN,"S",SDOEDT)
159 . D ^DIE K DIE,DR,DA
160 . L -^DPT(SDFN,"S",SDOEDT)
161 ;
162 W !,"Updating Completed."
163 Q
164 ;
165ONEELIG() ;
166 ;tests for and returns the primary if that is the only eligibility
167 ;
168 N VAEL
169 D ELIG^VADPT
170 Q $S($O(VAEL(1,0)):0,1:VAEL(1))
171 ;
Note: See TracBrowser for help on using the repository browser.