source: WorldVistAEHR/trunk/r/SCHEDULING-SD-SC/SCCVEDI1.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: 4.6 KB
RevLine 
[613]1SCCVEDI1 ;ALB/RMO,TMP - Disposition Conversion cont.; [ 04/05/95 8:12 AM ]
2 ;;5.3;Scheduling;**211**;Aug 13, 1993
3 ;
4CON(SCCVEVT,DFN,SCDTM,SCCVDIS) ; Should conversion event be processed for disposition
5 ; Input -- SCCVEVT Conversion event
6 ; DFN Patient IEN
7 ; SCDTM Visit date/time
8 ; SCCVDIS Array of disposition clinics
9 ;
10 ; Output -- 1=Yes and 0=No
11 ;
12 N SCECSTAT,Y,SCOE,SCDIS0,SCTYPE,SCDIV
13 S SCDIS0=$G(^DPT(DFN,"DIS",9999999-SCDTM,0))
14 S SCTYPE=$P(SCDIS0,U,2)
15 S SCDIV=+$P(SCDIS0,U,4)
16 S SCOE=+$P(SCDIS0,U,18)
17 S SCECSTAT=$P(SCDIS0,U,19)
18 ;
19 ; -- do checks
20 S Y=1
21 ; -- don't use if date is greater than ACRP date
22 IF Y,$P(SCDTM,".")>SCCVACRP S Y=0
23 ; -- don't use if application w/o exam
24 IF Y,SCTYPE=2 S Y=0
25 ; -- don't use if no dispo clinic division & > 1 defined for site
26 IF Y,'$G(SCCVDIS(SCDIV)),'$G(SCCVDIS(0)) S Y=0
27 ; -- don't use if convert and already converted
28 IF Y,SCCVEVT=1,SCECSTAT S Y=0
29 ; -- don't use if re-convert and not converted
30 IF Y,SCCVEVT=2,'SCECSTAT S Y=0
31 ; -- don't use if estimate and converted
32 IF Y,'SCCVEVT,SCECSTAT S Y=0
33 ; -- if check out required then must have a co completion date/time
34 IF Y,$$REQ^SDM1A(SCDTM)="CO",'$P($G(^SCE(SCOE,0)),U,7) S Y=0
35 Q +$G(Y)
36 ;
37EN(SCCVEVT,DFN,SCDTM,SCLOG) ; Entry point to convert a disposition
38 ; Input -- SCCVEVT Conversion event
39 ; 0=Estimate 1=Convert 2=Re-convert
40 ; DFN Patient IEN
41 ; SCDTM Visit date/time
42 ; SCLOG Scheduling conversion log IEN [optional]
43 N SCCV,SCOE,SCCONS,SCEST
44 ;
45 S SCCONS("SRCE")="SD TO PCE DB CONV"
46 S SCCONS("PKG")=$O(^DIC(9.4,"C","SD",0))
47 ;
48 ;Set up the array for extracting a default disp clinic for the division
49 I '$D(SCCVDIS) D
50 . N SCCL,SCDIV,Z
51 . S Z=0 F S Z=$O(^PX(815,1,"DHL",Z)) Q:'Z S SCCL=+$G(^(Z,0)),SCDIV=$P($G(^SC(SCCL,0)),U,15) I SCDIV,'$D(SCCVDIS(SCDIV)) S SCCVDIS(SCDIV)=SCCL
52 . ; Default (0) is used if division does not have a valid disp clinic
53 . S SCCVDIS(0)=+$P($G(^SD(404.91,1,"CNV")),U,2)
54 ;
55 ; Check if disposition should be processed
56 IF '$$CON(SCCVEVT,DFN,SCDTM,.SCCVDIS) G ENQ
57 ;
58 ; Set-up conversion array and variables
59 D SET^SCCVEDI3(SCCVEVT,+$G(SCLOG),DFN,.SCOE,.SCCV)
60 ;
61 I 'SCCVEVT,$G(SCCV("ERR")) G ENQ
62 ;
63 ; Don't process no new enctr or visit needed & no error to log
64 I '$G(SCCV("NEW")),'$D(SCCV("ERR")) G ENQ
65 ;
66 ; Increment number of dispositions found (estimating only)
67 I 'SCCVEVT D INCRTOT^SCCVEGU1(.SCTOT,5,1),EN^SCCVZZ("DIS-5",SCOE,SCDTM)
68 ;
69 ; Log error if no encounter or no visit - exit if no encounter
70 I SCCVEVT,$S('$G(SCOE):1,1:'$P($G(SCCV("OE",0)),U,5)) D G:'$G(SCOE) ENQ
71 . N SCE,SCERRIP,Y
72 . S SCERRIP(1)=$P($G(^DPT(DFN,0)),U)
73 . S Y=SCDTM D D^DIQ S SCERRIP(2)=Y
74 . S SCERRIP(5)=$$OTHERR^SCCVU2($G(SCCV("ERR")))
75 . S SCERRIP(4)=$S('$G(SCOE):"Outpatient encounter",1:"Visit")
76 . S SCE("DFN")=DFN,SCE("ENC")=$G(SCOE),SCE("VSIT")="",SCE("DATE")=SCDTM
77 . D GETERR^SCCVLOG1(4049005.003,.SCE,.SCERRIP,$G(SCLOG),0,.SCERRMSG)
78 . S:$G(SCOE) ^XTMP("SCCV-ERR-"_+SCLOG,"NO-VIS",SCOE)=""
79 . S SCTOT(2.06)=$G(SCTOT(2.06))+1
80 ;
81 G:$G(SCCV("ERR")) ENQ
82 ;
83 ; Convert additional disposition data
84 I SCCVEVT D ENC(SCOE,.SCCV)
85 ;
86 ; Convert children
87 D CHLD^SCCVEAP2(SCOE,.SCCV,$G(SCLOG))
88 ;
89 ; Invoke DATA-TO-PCE call, store any errors
90 I $S('SCCVEVT:1,1:$P($G(^SCE(SCOE,0)),U,5)) D DATA2PCE^SCCVPCE(SCOE,.SCCONS,SCCVEVT,$G(SCOEP),"","",.SCEST)
91 ;
92 I 'SCCVEVT D G ENQ ;Estimate exits here
93 .F Z=1:1:3 I $P(SCEST,U,Z) D INCRTOT^SCCVEGU1(.SCTOT,Z+8,$P(SCEST,U,Z)) D EN^SCCVZZ("DIS-"_(Z+8),SCOE,SCDTM,"","",$P(SCEST,U,Z))
94 ;
95 ; Update disposition as converted
96 D DONE(DFN,SCDTM,1)
97 ;
98 ; Update last entry and number of records
99 I $G(SCLOG) D UPDREC^SCCVLOG(SCLOG,SCOE,"CST")
100 I '$G(SCLOG) S SCTOT("OK")=1
101 ;
102ENQ Q
103 ;
104ENC(SCOE,SCCV) ; Convert additional disposition data for the encounter
105 ; $$GETDISP^SDVIST2 creates the encounter and seeds it with disp data
106 ; Input -- SCOE Outpatient encounter IEN
107 ; SCCV Conversion array
108 ; Output -- None
109 N SCDATA
110 I $G(SCCV("VST")),'$P($G(^SCE(SCOE,0)),U,5) S SCDATA(.05)=SCCV("VST") ; visit file entry
111 S:$G(SCCV("NEW"))=1 SCDATA(901)=1 ; created by conversion
112 I $G(SCCV("VST")) D ENCCNV^SCCVEAP1(.SCDATA)
113 I $D(SCDATA) D UPD^SCCVDBU(409.68,SCOE,.SCDATA)
114 ;
115ENCQ Q
116 ;
117DONE(DFN,SCDTM,SCECSTAT) ; Update disposition encounter conversion status
118 ; Input -- DFN Patient IEN
119 ; SCDTM Visit date/time
120 ; SCECSTAT Encounter conversion status
121 ; Output -- None
122 N SCDATA,SCIENS
123 S SCIENS=(9999999-SCDTM)_","_DFN
124 S:'$P($G(^DPT(DFN,"DIS",+SCIENS,0)),U,19) SCDATA(19)=SCECSTAT ; encounter conversion status
125 I $D(SCDATA) D UPD^SCCVDBU(2.101,SCIENS,.SCDATA)
126 Q
127 ;
Note: See TracBrowser for help on using the repository browser.