source: FOIAVistA/trunk/r/SCHEDULING-SD-SC/SDAMOL1.m@ 1397

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

initial load of FOIAVistA 6/30/08 version

File size: 5.6 KB
Line 
1SDAMOL1 ;ALB/CAW - Retroactive Appointment List (con't);4/15/92 ; 2/16/07 2:59pm
2 ;;5.3;Scheduling;**132,466,460**;Aug 13, 1993
3 ;
4 ;02/16/07 SD*5.3*466 Applied 466 changes to include inpatients
5 ;09/27/05 SD*5.3*460 Direct access to patient appointments is now encapsulated
6 ; via SDAPI API. SDAPI supports distributed appointment files
7 ; (whether actual files are located in VistA DB or non-VistA DB).
8 ; -- M.M.
9 ;****************************************************************************************
10 ;
11MAIN ; main sort, by division
12 N SDTMP,SDX,SDTMP1,SDTMP2
13 K ^TMP("SDRL",$J),^TMP("SDRAL",$J)
14 ;
15 ; -- get list of database close out dates
16 S SDTMP=SDBEG
17 F D S SDTMP=$$NEXTDT(SDTMP) Q:SDTMP>SDEND
18 . S SDX=$P($$CLOSEOUT^SCDXFU04(SDTMP),U,SDNPDB)
19 . IF SDX'=-1 S ^TMP("SDRL",$J,SDTMP)=SDX
20 ;
21 I ($D(VAUTC)>1)!($D(VAUTS)>1) D ; Return Appts for Specifc Clinics/Stop Codes.
22 .N SDARRAY,SDERR,SDRESULT K ^TMP($J,"SDAMA301")
23 .S SDARRAY(1)=SDBEG_";"_SDEND ; Date Range of Appts.
24 .I $D(VAUTC)>1 S SDARRAY(2)="VAUTC(" ; Search Appts for Selected Clinics.
25 .I $D(VAUTS)>1 D ; Search Appts for Selected Stop Codes.
26 ..S (SDARRAY(13),SDTMP1)=""
27 ..F S SDTMP1=$O(VAUTS(SDTMP1)) Q:SDTMP1="" D
28 ...S SDTMP2=+$P($G(^DIC(40.7,SDTMP1,0)),"^",2) I SDTMP2<1 Q
29 ...S SDARRAY(13)=SDARRAY(13)_SDTMP2_";"
30 .S SDARRAY("FLDS")="16",SDRESULT=$$SDAPI^SDAMA301(.SDARRAY)
31 .I SDRESULT<1 D D MAINQ Q ; SDAPI Returned an Error.
32 ..S SDERR=$$SDAPIERR^SDAMUTDT() I $L(SDERR) W !!,SDERR,! D OUT^SDUTL
33 ;
34 D SCAN
35 D BLD^SDAMOLP
36 ;
37MAINQ ; -- exit logic
38 K SDDV,SDSC,SDCLK,SDCLNM,SDCN,SDCNT,SDAD,SDATA,SDDFN,SDCLIN
39 K SDCLINIC,SDCLC,SDASH,SDCSC,SDDIV,SDDATE,SDAPPT,SDFLEN,SDFLG
40 K SDPAT,SDPAGE,SDSLEN,SDFST,SDROU,SDSEC,SDSTOP,SDSTPC,SDSTPCDE
41 K SDTYPE,SDVISIT,SDWHEN,SDVDT,SDVST,SDVSTDT,SDY,SDTRANS,SDTMP
42 K VA,VAERR,X,^TMP("SDRAL",$J),^TMP($J,"SDAMA301")
43 Q
44 ;
45SCAN ; -- api to invoke scan
46 ;
47 ; -- send message to task manager and check for stop request
48 IF $$S^%ZTLOAD("Searching for Retroactive Encounters...") S ZTSTOP=1 G SCANQ
49 N SDCB,SDQID
50 S SDCB="D CB^SDAMOL1(.Y,.Y0,.SDSTOP)"
51 D OPEN^SDQ(.SDQID)
52 D ACTIVE^SDQ(.SDQID,"FALSE","SET")
53 D INDEX^SDQ(.SDQID,"DATE/TIME","SET")
54 D DATE^SDQ(.SDQID,SDBEG,SDEND,"SET")
55 D SCANCB^SDQ(.SDQID,SDCB,"SET")
56 D ACTIVE^SDQ(.SDQID,"TRUE","SET")
57 D SCAN^SDQ(.SDQID,"FORWARD")
58 D CLOSE^SDQ(.SDQID)
59SCANQ Q
60 ;
61 ;
62CB(SDOE,SDOE0,SDSTOP) ; -- main callback
63 N SDVISIT,SDVSTDT,SDPAT,SDSC,SDCL,SDOEP,SDORG,SDEXT,SDDIV,SDOEU
64 N SDCLK,SDWHEN,SDCLNM,SDSTPCDE,SDTYPE,SDVSIT,SDCODT,SDSTATUS
65 ;
66 ; -- has user asked to stop job ; if yes, kill data & quit
67 IF $$S^%ZTLOAD() D G CBQ
68 . S (SDSTOP,ZTSTOP)=1
69 . K ^TMP("SDRAL",$J)
70 ;
71 ; -- set up variables for data fields
72 S SDVISIT=SDOE
73 S SDVSTDT=+SDOE0
74 S SDPAT=+$P(SDOE0,U,2)
75 S SDSC=+$P(SDOE0,U,3)
76 S SDCL=+$P(SDOE0,U,4)
77 S SDVSIT=+$P(SDOE0,U,5)
78 S SDOEP=+$P(SDOE0,U,6)
79 S SDCODT=+$P(SDOE0,U,7)
80 S SDORG=+$P(SDOE0,U,8)
81 S SDEXT=+$P(SDOE0,U,9)
82 S SDDIV=+$P(SDOE0,U,11)
83 S SDSTATUS=+$P(SDOE0,U,12)
84 S SDOEU=$G(^SCE(SDOE,"USER"))
85 S SDCLK=+SDOEU
86 S SDWHEN=+$P(SDOEU,U,4)
87 ;
88 ; -- drived data
89 IF 'SDWHEN,SDORG=1,SDEXT S SDWHEN=+$$APPT^SDAMOL1(SDCL,SDPAT,SDVSTDT) ; Return 'Date Appt Made'.
90 IF 'SDWHEN S SDWHEN=+$P($G(^AUPNVSIT(SDVSIT,0)),U,2)
91 S SDCLNM=$P($G(^SC(SDCL,0),0),U)
92 S SDSTPCDE=+$P($G(^DIC(40.7,SDSC,0)),U,2)
93 S SDTYPE=$S(SDORG=1:"APPOINTMENT",SDORG=2:"STANDALONE",SDORG=3:"DISPOSITION",1:"UNKNOWN")
94 ;
95 ; -- quit if encounter has parent
96 IF SDOEP G CBQ
97 ;
98 ; -- quit if no 'created' date found
99 IF 'SDWHEN G CBQ
100 ;
101 ; -- quit if 'created' before close out date
102 IF '$$TMP(+SDOE0,SDWHEN) G CBQ
103 ;
104 ; -- quit if no checked out completion date/time
105 IF 'SDCODT G CBQ
106 ;
107 ; -- quit if not status is not 'checked out' or 'inpatient'
108 IF "^8^2^"'[("^"_SDSTATUS_"^") G CBQ
109 ;
110 ;-- quit if non-count clinic
111 IF $P($G(^SC(SDCL,0)),U,17)="Y" G CBQ
112 ;
113 ; -- quit if division or clinic or stop code not valid for report
114 IF '$$DIV() G CBQ
115 IF '$$CLINIC() G CBQ
116 IF '$$STOP() G CBQ
117 ;
118 D SET
119CBQ Q
120 ;
121 ;
122NEXTDT(X1) ; -- get next date
123 N X2
124 S X2=1 D C^%DTC
125 Q X
126 ;
127SET ;^TMP("SDRAL",$J,Division,Stop Code,Visit Date,Patient)
128 ;
129 S ^TMP("SDRAL",$J,SDDIV,SDSTPCDE,SDVSTDT,SDPAT)=SDVISIT_U_SDWHEN_U_SDCLK_U_SDTYPE_U_^TMP("SDRL",$J,$P(SDVSTDT,"."))_U_SDCLNM
130SETQ Q
131 ;
132TMP(SDENCDT,SDMADE) ; -- Check to see if ^TMP("SDRL",$J,Encounter Date/Time)
133 ; exists
134 ; input - SDENCDT := encounter date/time
135 ; SDMADE := date encounter made
136 ;
137 ; output - 1 or 0
138 ;
139 IF '$D(^TMP("SDRL",$J,$P(SDENCDT,"."))) Q 0
140 Q ^TMP("SDRL",$J,$P(SDENCDT,"."))<(SDMADE_.9)
141 ;
142DIV() ; -- valid division for report ?
143 Q $S(VAUTD=1:1,1:$D(VAUTD(SDDIV)))
144 ;
145CLINIC() ; -- valid clinic for report ?
146 Q $S('$D(VAUTC):1,VAUTC=1:1,1:$D(VAUTC(SDCL)))
147 ;
148STOP() ; -- valid stop code for report ?
149 Q $S('$D(VAUTS):1,VAUTS=1:1,1:$D(VAUTS(SDSC)))
150 ;
151APPT(SDCL,SDPAT,SDVSTDT) ; Return 'Date Appt Made' field.
152 ; If user selected specific Clinic or Stop Code then SDAPI has been called in line tag MAIN+nnn above.
153 I ($D(VAUTC)>1)!($D(VAUTS)>1) Q $P($G(^TMP($J,"SDAMA301",SDPAT,SDCL,SDVSTDT)),U,16)
154 ;
155 ; If User selected ALL Clinics/Stop Codes then search for specific Appt.
156 N SDARRAY,SDERR,SDRESULT K ^TMP($J,"SDAMA301")
157 S SDARRAY(1)=SDVSTDT ; Specific Date of Appt.
158 S SDARRAY(2)=SDCL ; Specific Clinic.
159 S SDARRAY(4)=SDPAT ; Specific Patient.
160 S SDARRAY("MAX")=1 ; Should Return Only One Appt.
161 S SDARRAY("FLDS")="16",SDRESULT=$$SDAPI^SDAMA301(.SDARRAY)
162 I SDRESULT<1 D Q 0 ; SDAPI Returned an Error.
163 .S SDERR=$$SDAPIERR^SDAMUTDT() I $L(SDERR) W !!,SDERR,! D OUT^SDUTL
164 Q $P($G(^TMP($J,"SDAMA301",SDPAT,SDCL,SDVSTDT)),U,16) ; Return Date Appt Made.
165 ;
Note: See TracBrowser for help on using the repository browser.