source: FOIAVistA/tag/r/SCHEDULING-SD-SC/SCCVEAP1.m@ 794

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

initial load of FOIAVistA 6/30/08 version

File size: 5.2 KB
Line 
1SCCVEAP1 ;ALB/RMO,TMP - Appointment Conversion cont.; [ 04/05/95 10:19 AM ]
2 ;;5.3;Scheduling;**211**;Aug 13, 1993
3 ;
4CON(SCCVEVT,DFN,SCDTM) ; Should conversion event be processed for appointment
5 ; Input -- SCCVEVT Conversion event
6 ; DFN Patient IEN
7 ; SCDTM Appointment date/time
8 ;
9 ; Output -- 1=Yes and 0=No
10 ;
11 N SCECSTAT,Y,SCOE,SCAPT0
12 S SCAPT0=$G(^DPT(DFN,"S",SCDTM,0))
13 S SCOE=+$P(SCAPT0,U,20)
14 S SCECSTAT=$P(SCAPT0,U,23)
15 ;
16 S Y=1
17 IF Y,$P(SCDTM,".")>SCCVACRP S Y=0 ; Greater than ACRP date
18 IF SCCVEVT=1,SCECSTAT S Y=0 ; Convert/already converted
19 IF Y,SCCVEVT=2,'SCECSTAT S Y=0 ; Re-convert/never converted
20 IF Y,'SCCVEVT,SCECSTAT S Y=0 ; Estimate/already converted
21 ;
22 ; -- if check out required then must have a co completion date/time
23 IF Y,$$REQ^SDM1A(SCDTM)="CO",'$P($G(^SCE(SCOE,0)),U,7) S Y=0
24 ;
25 ; -- following is commented out ; left for reference purposes
26 ; -- if no enc and no ^sc appt node (purged) then don't convert
27 ;IF Y,'SCOE,'$$FIND^SDAM2(DFN,SCDTM,+SCAPT0) S Y=0
28 Q +$G(Y)
29 ;
30EN(SCCVEVT,DFN,SCDTM,SCCLN,SCDA,SCLOG) ; Entry point to convert an appointment
31 ; Input -- SCCVEVT Conversion event
32 ; 0=Estimate 1=Convert 2=Re-convert
33 ; DFN Patient IEN
34 ; SCDTM Appointment date/time
35 ; SCCLN Clinic IEN
36 ; SCDA Clinic appt patient sub-file IEN [optional]
37 ; SCLOG Scheduling conversion log IEN [optional]
38 ;
39 N SCCV,SCOE,SCCONS,SCEST
40 ;
41 S SCCONS("SRCE")="SD TO PCE DB CONV"
42 S SCCONS("PKG")=$O(^DIC(9.4,"C","SD",0))
43 ;
44 ; Check if appointment should be processed
45 IF '$$CON(SCCVEVT,DFN,SCDTM) G ENQ
46 ;
47 ; Set-up conversion array and variables
48 D SET^SCCVEAP3(SCCVEVT,+$G(SCLOG),DFN,SCDTM,SCCLN,.SCDA,.SCOE,.SCCV)
49 ;
50 I 'SCCVEVT,$G(SCCV("ERR")) G ENQ ; if error found - ignore for estimate
51 ;
52 ; Don't process no new enctr or visit needed & no error to log
53 I '$G(SCCV("NEW")),'$D(SCCV("ERR")) G ENQ
54 ;
55 ; -- saved for reference
56 ; I $S('SCCVEVT:'$G(SCCV("NEW")),'$G(SCCV("NEW")):'$D(SCCV("ERR")),1:0) G ENQ
57 ;
58 ; Increment number of appointments found (estimating only)
59 I 'SCCVEVT D
60 . D INCRTOT^SCCVEGU1(.SCTOT,3,1)
61 . D EN^SCCVZZ("APPT-3",SCOE,SCDTM,$P($G(SCCV("PT",0)),U),+$P($G(SCCV("OE",0)),U,6))
62 ;
63 ; Log error if there is no encounter or visit/exit if no encounter
64 I SCCVEVT,$S('$G(SCOE):1,1:'$P($G(SCCV("OE",0)),U,5)) D G:'$G(SCOE) ENQ
65 . N SCE,SCERRIP,Y
66 . S SCERRIP(1)=$P($G(^DPT(DFN,0)),U)
67 . S Y=SCDTM D D^DIQ S SCERRIP(2)=Y
68 . S SCERRIP(3)=$P($G(^SC(SCCLN,0)),U)
69 . S SCERRIP(4)=$S('$G(SCOE):"Outpatient encounter",1:"Visit")
70 . S SCERRIP(5)=$$OTHERR^SCCVU2($G(SCCV("ERR")))
71 . S SCE("DFN")=DFN,SCE("ENC")=$G(SCOE),SCE("VSIT")="",SCE("DATE")=SCDTM
72 . D GETERR^SCCVLOG1(4049005.002,.SCE,.SCERRIP,$G(SCLOG),0,.SCERRMSG)
73 . S SCTOT(2.06)=$G(SCTOT(2.06))+1
74 . S:$G(SCOE) ^XTMP("SCCV-ERR-"_+$G(SCLOG),"NO-VIS",SCOE)=""
75 ;
76 G:$G(SCCV("ERR")) ENQ
77 ;
78 ; Create stop codes, visit for ancillary tests
79 D ANC^SCCVEAP2($G(SCOE),DFN,SCDTM,SCCLN,.SCCV,$G(SCLOG))
80 ;
81 ; Convert children
82 D CHLD^SCCVEAP2(SCOE,.SCCV,$G(SCLOG))
83 ;
84 ; Invoke DATA-TO-PCE call, store any errors
85 I $S('SCCVEVT:1,1:$P($G(^SCE(SCOE,0)),U,5)) D DATA2PCE^SCCVPCE(SCOE,.SCCONS,SCCVEVT,$G(SCOEP),"","",.SCEST)
86 ;
87 I 'SCCVEVT D G ENQ ;Estimate exits here
88 .F Z=1:1:3 I $P(SCEST,U,Z) D INCRTOT^SCCVEGU1(.SCTOT,Z+8,$P(SCEST,U,Z)) D EN^SCCVZZ("APPT-"_(Z+8),SCOE,SCDTM,$P($G(SCCV("PT",0)),U),+$P($G(SCCV("OE",0)),U,6),$P(SCEST,U,Z))
89 ;
90 ; Convert additional appt data
91 D ENC(SCOE,.SCCV)
92 ;
93 ; Update appointment as converted
94 D DONE(DFN,SCDTM,1)
95 ;
96 ; Update last entry and number of records
97 I $G(SCLOG) D UPDREC^SCCVLOG(SCLOG,SCOE,"CST")
98 I '$G(SCLOG) S SCTOT("OK")=1
99 ;
100ENQ Q
101 ;
102ENC(SCOE,SCCV) ; Update additional appt data for encounter
103 ; Input -- SCOE Outpatient encounter IEN
104 ; SCCV Conversion array
105 ; Output -- None
106 N SCDATA,SCOEC
107 I $G(SCCV("VST")),'$P(^SCE(SCOE,0),U,5) S SCDATA(.05)=SCCV("VST")
108 S:$G(SCCV("NEW"))=1 SCDATA(901)=1 ; Created by conversion
109 ;
110 I $G(SCCV("HIST")) D ; Stop code created historically
111 . I '$P($G(^SCE(SCOE,"CNV")),U,3),$P($G(^(0)),U,3) S SCDATA(903)=1
112 . Q:'$O(^SCE("APAR",SCOE,0))
113 . S SCOEC=0 F S SCOEC=$O(^SCE("APAR",SCOE,SCOEC)) Q:'SCOEC S SCOEC(SCOEC)=""
114 ;
115 I $P($G(^SCE(SCOE,0)),U,5) D ENCCNV(.SCDATA)
116 I $D(SCDATA) D UPD^SCCVDBU(409.68,SCOE,.SCDATA) ;Update parent
117 ;
118 I $O(SCOEC(0)) D ; update children of encounter
119 . N SCDATC
120 . S SCOEC=0
121 . F S SCOEC=$O(SCOEC(SCOEC)) Q:'SCOEC D
122 .. N SCDATC
123 .. I '$G(^SCE(SCOEC,"CNV")),$G(SCCV("NEW"))=1 S SCDATC(901)=1
124 .. I $P($G(^SCE(SCOEC,0)),U,3),'$P($G(^("CNV")),U,3) S SCDATC(903)=1
125 .. I $P($G(^SCE(SCOEC,0)),U,5) D ENCCNV(.SCDATC)
126 .. I $D(SCDATC) D UPD^SCCVDBU(409.68,SCOEC,.SCDATC)
127 ;
128ENCQ Q
129 ;
130DONE(DFN,SCDTM,SCECSTAT) ; Update appointment encounter conversion status
131 ; Input -- DFN Patient IEN
132 ; SCDTM Appointment date/time
133 ; SCECSTAT Encounter conversion status
134 ; Output -- None
135 N SCDATA,SCIENS
136 S SCIENS=SCDTM_","_DFN
137 S:'$P($G(^DPT(DFN,"S",SCDTM,0)),U,23) SCDATA(23.1)=SCECSTAT ; encounter conversion status
138 I $D(SCDATA) D UPD^SCCVDBU(2.98,SCIENS,.SCDATA)
139 Q
140 ;
141ENCCNV(DATA) ; Set nodes to update 'conversion processed' fields in encounter
142 S DATA(904)=1,DATA(905)=+$E($$NOW^XLFDT(),1,12)
143 I $G(SCCV("NEW"))=2 S DATA(101)=$G(DUZ),DATA(102)=DATA(905)
144 Q
145 ;
Note: See TracBrowser for help on using the repository browser.