source: WorldVistAEHR/trunk/r/SCHEDULING-SD-SC/SCCVEAP2.m@ 1259

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

initial load of WorldVistAEHR

File size: 6.3 KB
Line 
1SCCVEAP2 ;ALB/RMO,TMP - Appointment Conversion cont.; [ 04/05/95 10:19 AM ]
2 ;;5.3;Scheduling;**211**;Aug 13, 1993
3 ;
4VISIT(SCDTM,SCCV) ;Create visit when encounter already exists
5 ; Input -- SCDTM Appointment date/time
6 ; SCCV Conversion array
7 ; Output -- Visit file IEN
8 N SCVSIT,SCDATA,SCCVT,SCOE
9 IF '$G(SCCV("OE",0)) G VISITQ
10 S SCOE=$G(SCCV("OE"))
11 S SCVSIT("DFN")=$P(SCCV("OE",0),U,2)
12 IF 'SCVSIT("DFN") G VISITQ
13 ;
14 S SCVSIT("CLN")=$S('$G(SCCV("CSC")):$P(SCCV("OE",0),U,3),1:SCCV("CSC"))
15 ;
16 S SCVSIT("DIV")=$P(SCCV("OE",0),U,11)
17 S SCVSIT("ELG")=$P(SCCV("OE",0),U,13)
18 S SCVSIT("LOC")=$P(SCCV("OE",0),U,4)
19 S SCVSIT("TYP")=$P(SCCV("OE",0),U,10)
20 S SCVSIT("STA")=$P(SCCV("OE",0),U,12)
21 S SCVSIT("ORG")=$G(SCCV("ORG"))
22 ;
23 D SETSCCVT(.SCCVT,.SCCONS)
24 IF $G(SCCV("PAR")) S SCVSIT("PAR")=SCCV("PAR")
25 ;
26 ; -- use parent's visit if a/e, location same, clinic stop same
27 IF $G(SCVSIT("PAR")),SCVSIT("ORG")=2 D
28 . N SCOEP0
29 . S SCOEP0=$G(^SCE(SCVSIT("PAR"),0))
30 . IF $P(SCOEP0,U,5),SCVSIT("LOC")=$P(SCOEP0,U,4),SCVSIT("CLN")=$P(SCOEP0,U,3) S SCVSIT("VST")=$P(SCOEP0,U,5)
31 ;
32 IF '$G(SCVSIT("VST")) D VISIT^SDVSIT0(SCDTM,.SCVSIT)
33 ;
34 IF $G(SCVSIT("VST")) S SCTOT(1.02)=$G(SCTOT(1.02))+1
35 ;
36 IF $G(SCVSIT("VST")),'$P(SCCV("OE",0),U,5) D
37 . ; -- fix invalid date/time of a/e to sync w/visit
38 . IF SCVSIT("ORG")=2,+SCCV("OE",0)'=SCDTM S SCDATA(.01)=SCDTM
39 . S SCDATA(.05)=SCVSIT("VST")
40 . D UPD^SCCVDBU(409.68,SCOE,.SCDATA)
41 ;
42 S SCCV("OE",0)=$G(^SCE(SCOE,0))
43 S SCCV("VST")=$G(SCVSIT("VST"))
44 ;
45VISITQ Q $G(SCVSIT("VST"))
46 ;
47ANC(SCOEP,DFN,SCDTM,SCCLN,SCCV,SCLOG) ;Create stp code enctr/visit for ancillary tests
48 ; Input -- SCOEP Parent encounter (if known)
49 ; DFN Patient IEN
50 ; SCDTM Appointment date/time
51 ; SCCLN Clinic IEN
52 ; SCCV Conversion array
53 ; SCLOG Scheduling conversion log IEN [optional]
54 ; Output -- None
55 N SCANC,SCOE,SCSCD,SCSCDI,SCVSIT,SCT,SCADD
56 I $G(SCCV("PT",0))=""!$S(SCCV("EVT"):$G(SCCV("OE",0))="",1:0) G ANCQ
57 I $P(SCCV("PT",0),U,3)'="" S SCANC(108)=$P(SCCV("PT",0),U,3) ; lab
58 I $P(SCCV("PT",0),U,4)'="" S SCANC(105)=$P(SCCV("PT",0),U,4) ; x-ray
59 I $P(SCCV("PT",0),U,5)'="" S SCANC(107)=$P(SCCV("PT",0),U,5) ; ekg
60 S SCSCD=""
61 F S SCSCD=$O(SCANC(SCSCD)) Q:'SCSCD D
62 . S SCSCDI=+$O(^DIC(40.7,"C",SCSCD,0))
63 . ;
64 . S SCADD=$$CHK(DFN,SCDTM,SCCLN,.SCCV,SCSCDI,.SCOE)
65 . I SCADD D
66 . . ;Increment number of ancillaries found (estimating only)
67 . . S SCVSIT("DFN")=DFN
68 . . I 'SCCVEVT D Q
69 . . . F SCT=2,SCADD+6 D
70 . . . . N DFN
71 . . . . D INCRTOT^SCCVEGU1(.SCTOT,SCT,1),EN^SCCVZZ("AE-"_SCT,SCOE,SCANC(SCSCD),$P($G(SCCV("PT",0)),U),+$G(SCOEP),SCVSIT("DFN"))
72 . . ;
73 . . I SCADD=1 D
74 . . . S SCVSIT("CLN")=SCSCDI
75 . . . S SCVSIT("DIV")=$P(SCCV("OE",0),U,11)
76 . . . S SCVSIT("ELG")=$P(SCCV("OE",0),U,13)
77 . . . S SCVSIT("LOC")=SCCLN
78 . . . S SCVSIT("TYP")=$P(SCCV("OE",0),U,10)
79 . . . S SCVSIT("PAR")=$G(SCOEP)
80 . . . S SCVSIT("ORG")=2,SCVSIT("REF")=""
81 . . . D SETSCCVT(.SCCVT,.SCCONS)
82 . . . S SCOE=$$SDOE^SDVSIT(SCANC(SCSCD),.SCVSIT,"",$G(SCOEP))
83 . . . I '$G(SCVSIT("VST")) D Q
84 . . . . D CREATERR^SCCVLOG1(DFN,SCDTM,SCOE,2,SCCLN,SCSCD,$G(SCLOG))
85 . . . . S:$G(SCOE) ^XTMP("SCCV-ERR-"_+SCLOG,"NO-VIS",SCOE)=""
86 . . . . S SCTOT(2.06)=$G(SCTOT(2.06))+1
87 . . . Q:'SCOE
88 . . . S SCTOT(1.02)=$G(SCTOT(1.02))+1
89 . . . N SCCVX
90 . . . S SCCVX("HIST")=0
91 . . . S SCCVX("NEW")=1
92 . . . D ENC^SCCVEAP1(SCOE,.SCCVX)
93 . . ;
94 . . I SCADD=2,SCOE D
95 . . . N SCCVX,SCCVY
96 . . . S SCCVY("OE")=SCOE
97 . . . S SCCVY("OE",0)=$G(^SCE(SCOE,0))
98 . . . S SCCVY("PAR")=$P(SCCVY("OE",0),U,6)
99 . . . S SCCVY("ORG")=2
100 . . . S SCVSIT("VST")=$$VISIT(+SCCVY("OE",0),.SCCVY) ; create visit
101 . . . I 'SCVSIT("VST") D Q
102 . . . . D CREATERR^SCCVLOG1(DFN,+SCCVY("OE",0),SCOE,2,$P(SCCVY("OE",0),U,4),SCSCD,$G(SCLOG))
103 . . . . S ^XTMP("SCCV-ERR-"_+SCLOG,"NO-VIS",SCOE)=""
104 . . . . S SCTOT(2.06)=$G(SCTOT(2.06))+1
105 . . . N SCCVX
106 . . . S SCCVX("VST")=SCVSIT("VST") D ENC^SCCVEAP1(SCOE,.SCCVX)
107 ;
108ANCQ Q
109 ;
110CHK(DFN,SCDTM,SCCLN,SCCV,SCSCDI,SCOE) ;Check if stop code should be added for ancillary test
111 ; Input -- DFN Patient IEN
112 ; SCDTM Appointment date/time
113 ; SCCLN Clinic IEN
114 ; SCCV Conversion array
115 ; SCSCDI Clinic Stop Code IEN
116 ; Output -- 1=Add enctr and visit 2=Add only visit and 0=No,don't add
117 ; SCOE IEN of the encounter for the anc test
118 N Y,SCAEDTM,SCDA,SCOEC,SCOE00,SDQ
119 S Y=1,SCOE=""
120 ;
121 I $P($G(^SC(SCCLN,0)),U,17)="Y" S Y=0 G CHKQ ; non-count clinic
122 ;
123 ; The following line is commented out because although it would be a valid check, it is much too tight and thus inconsistent with the rest of the conversion
124 ;I $$REQ^SDM1A(SCDTM)="CO",'$P($G(SCCV("PT",0)),U,7) S Y=0 G CHKQ ; check out required but no checkout date, don't process
125 ;
126 S (SCOEC,SDQ)=0
127 F S SCOEC=$O(^SCE("APAR",+$G(SCOEP),SCOEC)) Q:'SCOEC D Q:SDQ
128 . S SCOE00=$G(^SCE(SCOEC,0))
129 . I $P(SCOE00,U,3)=SCSCDI D
130 . . S SDQ=1
131 . . I 'SCCVEVT,$P(SCOE00,U,8)=2 S Y=0 Q ;Will be counted with add/edits
132 . . I SCCVEVT<2 D Q ;Estimate/convert
133 . . . I $P(SCOE00,U,5) S Y=0 Q ;Already added
134 . . . S Y=2,SCOE=SCOEC ;Add visit only
135 . . I SCCVEVT=2 D Q ;Re-convert
136 . . . D RECNVT^SCCVEAP3(SCOEC,SCOE00,.SCCONS)
137 . . . I $D(^SCE(SCOEC,0)) S Y=2,SCOE=SCOEC Q ;Re-add visit only
138 . . . S Y=1 ;Re-add visit and encounter
139 ;
140CHKQ Q $G(Y)
141 ;
142CHLD(SCOEP,SCCV,SCLOG) ;Convert children
143 ; Input -- SCOEP Parent outpatient encounter IEN
144 ; SCCV Conversion array
145 ; SCLOG Scheduling conversion log IEN [optional]
146 ; Output -- None
147 N SCERRMSG,SCOE0,SCOEC,SCX,SDVIEN
148 S SCOEC=0
149 F S SCOEC=$O(^SCE("APAR",SCOEP,SCOEC)) Q:'SCOEC D
150 . S SCOE0=$G(^SCE(SCOEC,0))
151 . S SDVIEN=$$SDVIEN^SCCVU(+$P(SCOE0,U,2),+SCOE0)
152 . I 'SCCV("EVT"),$P(SCOE0,U,9) D Q:'SCX
153 . . F SCX=1:1:$L($P(SCOE0,U,9),":") I $P($G(^SDV(SDVIEN,"CS",+$P($P(SCOE0,U,9),":",SCX),0)),U,8)=SCOEC S SCX=0 Q ;When estimating, these should be counted in the add/edit loop
154 . I $P(SCOE0,U,8)=2,$P(SCOE0,U,9),'$P(SCOE0,U,5) D ;convert child add/edit
155 . . ;There should be only 1 ":" piece before 10/1/96, but this was
156 . . ; included in the case of bad data
157 . . F SCX=1:1:$L($P(SCOE0,U,9),":") D EN^SCCVEAE1(SCCV("EVT"),SDVIEN,+$P($P(SCOE0,U,9),":",SCX),SCOEP,$G(SCLOG))
158 Q
159 ;
160SETSCCVT(SCCVT,SCCONS) ; Set the SCCVT array for source and service type
161 S SCCVT("SOR")=SCCONS("SRCE")
162 S SCCVT("SVC")="E"
163 I $G(SCCV("ORG"))=3,$G(SCCV("LOC")) S SCCVT("LOC")=SCCV("LOC")
164 Q
165 ;
Note: See TracBrowser for help on using the repository browser.