source: FOIAVistA/trunk/r/SCHEDULING-SD-SC/SCCVEAP3.m@ 1608

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

initial load of FOIAVistA 6/30/08 version

File size: 4.6 KB
Line 
1SCCVEAP3 ;ALB/RMO,TMP - Appointment Conversion cont.; [ 04/05/95 10:19 AM ]
2 ;;5.3;Scheduling;**211**;Aug 13, 1993
3 ;
4SET(SCCVEVT,SCLOG,DFN,SCDTM,SCCLN,SCDA,SCOE,SCCV) ; Set variables
5 ; Input -- SCCVEVT Conversion event
6 ; SCLOG Scheduling conversion log IEN
7 ; DFN Patient IEN
8 ; SCDTM Appointment date/time
9 ; SCCLN Clinic IEN
10 ; Output -- SCDA Clinic appt patient sub-file IEN
11 ; SCOE Outpatient encounter IEN
12 ; SCCV Conversion array:
13 ; SCCV("EVT") Conversion event
14 ; ("LOG") Scheduling conversion log IEN
15 ; ("NEW") Outpatient encounter
16 ; created by conversion flag
17 ; 0 = no new encounter or visit
18 ; 1 = new encounter and visit
19 ; 2 = new visit only
20 ; ("SCDA") Multiple entry in ^SC for this pt
21 ; ("OE",0) Outpatient encounter 0th node
22 ; ("PT",0) Patient appt 0th node
23 ; ("PT","R") Patient appt "R" node (Remarks)
24 ; ("CL1",0) Clinic's 0th node
25 ; ("CL",0) Clinic appt patient 0th node
26 ; ("CL","C") Clinic appt patient "C" node (Check in/out)
27 ; ("ERR") Code for specific error, if any
28 ; ("VST") Visit file IEN
29 ;
30 N SCOE0,SCDATA,SCIENS
31 ;
32 S:'$G(SCDA) SCDA=+$$FIND^SDAM2(DFN,SCDTM,SCCLN) ; Find multiple entry in ^SC for this pt
33 ;
34 S SCOE=+$P($G(^DPT(DFN,"S",SCDTM,0)),U,20),SCOE0=$G(^SCE(SCOE,0))
35 ;
36 ; -- following is commented out ; left for reference purposes
37 ; -- this 'if' should always fail ; CON^SCCVEAP1 has this covered
38 ;IF 'SCOE,'SCDA S SCCV("ERR")=1 G SETQ
39 ;
40 S SCCV("SCDA")=SCDA
41 S SCCV("EVT")=SCCVEVT
42 ;
43 S SCCV("LOG")=SCLOG
44 S SCCV("PT",0)=$G(^DPT(DFN,"S",SCDTM,0)),SCCV("PT","R")=$G(^("R"))
45 S SCCV("CL",0)=$G(^SC(SCCLN,"S",SCDTM,1,SCDA,0)),SCCV("CL","C")=$G(^("C"))
46 S SCCV("CL1",0)=$G(^SC(SCCLN,0))
47 ;
48 ; On re-convert, delete previously converted data
49 I SCCVEVT=2 D
50 . N SCDATA
51 . ; only delete for reconvert if we created the encounter or completed
52 . ; the conversion by adding the visit
53 . Q:'$$CCREATE^SCCVU(SCOE)
54 . ;
55 . S SCCV("OE",0)=SCOE0
56 . D RECNVT(SCOE,SCOE0,.SCCONS)
57 . S SCOE0=$G(^SCE(SCOE,0)) S:SCOE0="" SCOE=0
58 ;
59 S SCCV("NEW")=$S('SCOE:1,'$P(SCOE0,U,5):2,1:0)
60 ;
61 G:'SCCV("NEW") SETQ ; Already has both an encounter and visit
62 ;
63 ; Increment total number of encounters/visits that would be created by
64 ; conversion (if estimating)
65 I 'SCCVEVT D G SETQ ; -- Estimate exits here
66 . D INCRTOT^SCCVEGU1(.SCTOT,SCCV("NEW")+6,1)
67 . D EN^SCCVZZ("APPT-"_(SCCV("NEW")+6),SCOE,SCDTM,$P($G(SCCV("PT",0)),U),+$P(SCOE0,U,6))
68 . D CREDIT^SCCVEAP4(SCOE,SCDTM,.SCCV,0)
69 ;
70 I 'SCOE D ; Create enctr/visit
71 . N SCCVT
72 . D SETSCCVT^SCCVEAP2(.SCCVT,.SCCONS)
73 . IF 'SCDA F L +^SC(SCCLN,"S",SCDTM,1,999999):5 IF $T S ^SC(SCCLN,"S",SCDTM,1,999999,0)=DFN Q
74 . S SCOE=$$GETAPT^SDVSIT2(DFN,SCDTM,SCCLN,"")
75 . IF 'SCDA K ^SC(SCCLN,"S",SCDTM,1,999999) L -^SC(SCCLN,"S",SCDTM,1,999999)
76 . Q:'SCOE
77 . I $P($G(^SCE(SCOE,0)),U,3) S SCCV("HIST")=1
78 . S SCTOT(1.02)=$G(SCTOT(1.02))+1
79 ;
80 S SCCV("OE")=+SCOE
81 S SCCV("OE",0)=$G(^SCE(+SCOE,0))
82 S SCCV("VST")=$P(SCCV("OE",0),U,5)
83 S SCCV("ORG")=1,SCCV("REF")=SCDA
84 ;
85 I 'SCCV("VST"),SCOE,SCCV("NEW")'=1 D
86 . S SCCV("VST")=$$VISIT^SCCVEAP2(SCDTM,.SCCV) ; create visit if encounter already exists, but no visit
87 . D CREDIT^SCCVEAP4(SCOE,SCDTM,.SCCV,SCCVEVT)
88 ;
89SETQ Q
90 ;
91RECNVT(SCOE,SCOE0,SCCONS) ;Delete data added by conversion
92 ;
93 N Z,SCVST,SCENC,SCENC0,SCCHLD,PXKNOEVT
94 ;
95 S PXKNOEVT=1 ;Don't want event driver to fire off
96 ;
97 S SCVST(0,SCOE,+$P(SCOE0,U,5))=+$G(^SCE(SCOE,"CNV")) ;Parent
98 D DELPTR(SCOE)
99 ;
100 S SCENC=0 F S SCENC=$O(^SCE("APAR",SCOE,SCENC)) Q:'SCENC D
101 . S SCVST(1,SCENC,+$P($G(^SCE(SCENC,0)),U,5))=+$G(^SCE(SCENC,"CNV"))
102 . D DELPTR(SCENC)
103 ;
104 S SCCHLD="" F S SCCHLD=$O(SCVST(SCCHLD)) Q:SCCHLD="" S SCENC=0 F S SCENC=$O(SCVST(SCCHLD,SCENC)) Q:'SCENC S SCVST="" F S SCVST=$O(SCVST(SCCHLD,SCENC,SCVST)) Q:SCVST="" D
105 . I SCVST(SCCHLD,SCENC,SCVST),$D(^SCE(SCENC,0)) D DELE^SCCVCST2(SCENC) ;Created by conversion - delete enctr
106 . Q:'SCVST!SCCHLD ;No need to delete children visits - they should go away w/parent
107 . S Z=$$DELVFILE^PXAPI("ALL",SCVST,$G(SCCONS("PKG")),$G(SCCONS("SRCE")))
108 Q
109 ;
110DELPTR(SCE) ; Delete visit pointer if encounter still exists
111 ; SCE = encounter IEN
112 N SCDATA
113 I $P($G(^SCE(SCE,0)),U,5) S SCDATA(.05)="@" D UPD^SCCVDBU(409.68,SCE,.SCDATA)
114 ;
115 Q
116 ;
Note: See TracBrowser for help on using the repository browser.