source: WorldVistAEHR/trunk/r/SCHEDULING-SD-SC/SCCVEAE1.m@ 1582

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

initial load of WorldVistAEHR

File size: 5.5 KB
Line 
1SCCVEAE1 ;ALB/RMO,TMP - Add/Edit Conversion cont.; [ 04/05/95 8:46 AM ]
2 ;;5.3;Scheduling;**211**;Aug 13, 1993
3 ;
4CON(SCCVEVT,SCDTM,SCVALDT,SCDA) ;Should conversion event be processed for add/edit
5 ; Input -- SCCVEVT Conversion event
6 ; SCDTM Visit date/time
7 ; SCVALDT Valid converted Visit date/time (SCDTM)
8 ; SCDA Clinic stop code sub-file IEN
9 ; Output -- 1=Yes and 0=No
10 ;
11 N SC0,SCECSTAT,Y,SCOE,SCSTOP,SCLN,DFN
12 S DFN=+$P($G(^SDV(SCDTM,0)),U,2)
13 S SC0=$G(^SDV(SCDTM,"CS",SCDA,0))
14 S SCSTOP=+SC0
15 S SCLN=+$P(SC0,U,3)
16 S SCOE=+$P(SC0,U,8)
17 S SCECSTAT=$P(SC0,U,9)
18 ;
19 ; -- do checks
20 S Y=1
21 IF Y,$P(SCVALDT,".")>SCCVACRP S Y=0 ; Greater than ACRP date
22 IF Y,SCCVEVT=1,SCECSTAT S Y=0 ; Convert/already converted
23 IF Y,SCCVEVT=2,'SCECSTAT S Y=0 ; Re-convert/never converted
24 IF Y,'SCCVEVT,SCECSTAT S Y=0 ; Estimate/already converted
25 ;
26 ; -- if check out required then must have a co completion date/time
27 IF Y,$$REQ^SDM1A(SCDTM)="CO",'$P($G(^SCE(SCOE,0)),U,7) S Y=0
28 ;
29 ; -- if a/e for 900 stop, same clinic, no enounter
30 ; and lower "CS" ien then current then don't convert
31 IF Y,SCCV900=SCSTOP,SCLN D
32 . N SCS,SCS0
33 . S SCS=0
34 . F S SCS=$O(^SDV(SCDTM,"CS",SCS)) Q:'SCS!(SCS=SCDA) S SCS0=$G(^(SCS,0)) IF +SCS0=SCCV900,+$P(SCS0,U,3)=SCLN,'$P(SCS0,U,8) S Y=0 Q
35 ;
36 ; -- if not a 900, did stop get added via appts? if so, don't convert.
37 IF Y,SCCV900'=SCSTOP D
38 . N SCAP,SCAP0,SCEND
39 . S SCAP=$P(SCDTM,"."),SCEND=SCAP+.24
40 . F S SCAP=$O(^DPT(DFN,"S",SCAP)) Q:'SCAP!(SCAP>SCEND) S SCAP0=$G(^(SCAP,0)) D Q:'Y
41 . . ; -- must be valid made appt
42 . . IF $P(SCAP0,U,2)'="",$P(SCAP0,U,2)'="I" Q
43 . . ; -- if clinic specified then appt must be for same clinic
44 . . IF SCLN,SCLN'=+SCAP0 Q
45 . . ; -- if enc exists & c/o, compare enc stop code with sdv stop code
46 . . IF $P(SCAP0,U,20) D Q
47 . . . IF $P($G(^SCE($P(SCAP0,U,20),0)),U,3)=SCSTOP,$P($G(^SCE($P(SCAP0,U,20),0)),U,7) S Y=0
48 . . ; -- compare clinic's stop code with sdv stop code
49 . . IF $P($G(^SC(+SCAP0,0)),U,7)=SCSTOP S Y=0 Q
50 ;
51 Q +$G(Y)
52 ;
53EN(SCCVEVT,SCDTM,SCDA,SCOEP,SCLOG) ; Entry point to convert an add/edit
54 ; Input -- SCCVEVT Conversion event
55 ; 0=Estimate 1=Convert 2=Re-convert
56 ; SCDTM ien of SDV entry (~Visit date/time)
57 ; SCDA Clinic stop code sub-file IEN
58 ; SCOEP Parent outpatient encounter IEN [optional]
59 ; SCLOG Scheduling conversion log IEN [optional]
60 N SCCV,SCOE,SCDATA,SCCONS,SCEST,Z,SCVALDT
61 ;
62 ; -- make sure sdv d/t is valid
63 S SCVALDT=$$DATECHCK^SDVSIT(SCDTM)
64 ;
65 S SCCONS("SRCE")="SD TO PCE DB CONV"
66 S SCCONS("PKG")=$O(^DIC(9.4,"C","SD",0))
67 ;
68 ; Check if add/edit should be processed
69 IF '$$CON(SCCVEVT,SCDTM,SCVALDT,SCDA) G ENQ
70 ;
71 ; Set-up conversion array and variables
72 D SET^SCCVEAE3(SCCVEVT,+$G(SCLOG),SCDTM,SCVALDT,SCDA,.SCOEP,.SCOE,.SCCV)
73 ;
74 I 'SCCVEVT,$G(SCCV("ERR")) G ENQ
75 ;
76 ; Skip if no new enctr or visit needed & no error to log
77 I '$G(SCCV("NEW")),'$D(SCCV("ERR")) G ENQ
78 ;
79 ; Increment number of add/edits found (estimating only)
80 I 'SCCVEVT D EN^SCCVZZ("AE-1",SCOE,SCDTM,SCDA,+$P($G(SCCV("OE",0)),U,6),+$P($G(SCCV("OE",0)),U,2)) D INCRTOT^SCCVEGU1(.SCTOT,1,1)
81 ;
82 ; Log error if no encounter or no visit, exit if no encounter
83 I SCCVEVT,$S('$G(SCOE):1,1:'$P($G(SCCV("OE",0)),U,5)) D G:'$G(SCOE) ENQ
84 . N SCERRIP,Y,SCE
85 . S Y=SCDTM D D^DIQ S SCERRIP(1)=Y
86 . S SCERRIP(2)=SCDA
87 . S SCERRIP(5)=$$OTHERR^SCCVU2($G(SCCV("ERR")))
88 . S SCERRIP(4)=$S('$G(SCOE):"Outpatient encounter",1:"Visit")
89 . S SCE("DFN")=$P($G(^SDV(SCDTM,0)),U,2),SCE("ENC")=$G(SCOE),SCE("VSIT")="",SCE("DATE")=SCDTM
90 . D GETERR^SCCVLOG1(4049005.001,.SCE,.SCERRIP,$G(SCLOG),0,.SCERRMSG)
91 . S SCTOT(2.06)=$G(SCTOT(2.06))+1
92 . S:$G(SCOE) ^XTMP("SCCV-ERR-"_+$G(SCLOG),"NO-VIS",SCOE)=""
93 ;
94 G:$G(SCCV("ERR")) ENQ
95 ;
96 ; Invoke DATA-TO-PCE call, store any errors
97 S SCEST=""
98 I $S('SCCVEVT:1,1:$P($G(^SCE(SCOE,0)),U,5)) D DATA2PCE^SCCVPCE(SCOE,.SCCONS,SCCVEVT,$S(SCCVEVT:$G(SCOEP),1:$P($G(^SCE(SCOE,0)),U,6)),SCDTM,SCDA,.SCEST)
99 ;
100 I 'SCCVEVT D G ENQ ;Estimate exits here
101 .F Z=1:1:3 I $P(SCEST,U,Z) D INCRTOT^SCCVEGU1(.SCTOT,Z+8,$P(SCEST,U,Z)) D EN^SCCVZZ("AE-"_(Z+8),SCOE,SCDTM,SCDA,+$G(SCOEP),$P(SCEST,U,Z))
102 ;
103 ; Convert additional add/edit data
104 D ENC(SCOE,.SCCV)
105 ;
106 ; Update add/edit as converted
107 D DONE(SCDTM,SCDA,1)
108 ;
109 ; Update last entry and number of records
110 I $G(SCLOG),'$G(SCOEP) D UPDREC^SCCVLOG(SCLOG,SCOE,"CST")
111 I '$G(SCLOG),$G(SCTOT("A/E")) S SCTOT("OK")=1
112ENQ Q
113 ;
114ENC(SCOE,SCCV) ; Convert additional add/edit data for encounter
115 ; Input -- SCOE Outpatient encounter IEN
116 ; SCCV Conversion array
117 ; Output -- None
118 N SCDATA
119 I $G(SCCV("VST")),'$P($G(^SCE(SCOE,0)),U,5) S SCDATA(.05)=SCCV("VST") ; visit file entry
120 I SCCV("NEW")=1 D ;Only if conversion adds the encounter
121 . I $P($G(SCCV("CS",0)),U,6)'="" S SCDATA(202)=$P(SCCV("CS",0),U,6)
122 . I $P($G(SCCV("CS",0)),U,2)'="" S SCDATA(101)=$P(SCCV("CS",0),U,2)
123 . I $P($G(SCCV("CS",1)),U)'="" S SCDATA(201)=$P(SCCV("CS",1),U)
124 . I $P($G(SCCV("CS",0)),U,7)'="" S SCDATA(902)=$P(SCCV("CS",0),U,7)
125 . S SCDATA(901)=1 ; created by conversion
126 I $G(SCCV("VST")) D ENCCNV^SCCVEAP1(.SCDATA)
127 I $D(SCDATA) D UPD^SCCVDBU(409.68,SCOE,.SCDATA)
128ENCQ Q
129 ;
130DONE(SCDTM,SCDA,SCECSTAT) ; Update add/edit encounter conversion status
131 ; Input -- SCDTM Visit date/time
132 ; SCDA Clinic stop code sub-file IEN
133 ; SCECSTAT Encounter conversion status
134 ; Output -- None
135 N SCDATA,SCIENS
136 S SCIENS=SCDA_","_SCDTM
137 S:'$P($G(^SDV(SCDTM,"CS",SCDA,0)),U,9) SCDATA(9)=SCECSTAT ; encounter conversion status
138 I $D(SCDATA) D UPD^SCCVDBU(409.51,SCIENS,.SCDATA)
139 Q
140 ;
Note: See TracBrowser for help on using the repository browser.