source: FOIAVistA/tag/r/REGISTRATION-DGQE-DG-DPT-GRPX-VAD-VAF-VAS-VAT-VAU--VA-VIC--DGBT--DGJ--DGYA--VALM/DGQESC2.m@ 1437

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

initial load of FOIAVistA 6/30/08 version

File size: 4.1 KB
Line 
1DGQESC2 ;ALB/JFP - VIC OUTPATIENT CLINIC SCAN ROUTINE ; 03/29/2004
2 ;;5.3;Registration;**73,568,725**;Aug 13, 1993;Build 12
3 ;;Per VHA Directive 10-93-142, this routine should not be modified.
4 ;
5ENO ; -- Entry Point
6 N DIR,Y
7 ;
8 S DIR(0)="YA"
9 S DIR("A")="Download Clinics patients to the VIC card station: "
10 S DIR("B")="NO"
11 S DIR("?")="Enter yes to download data."
12 D ^DIR
13 I Y D Q
14 .; -- New Variables
15 .N VAUTD,VAUTNI,VAUTC
16 .N DATE,DFNARR,CNT,Y,ERR,SDATE,EDATE,DFN,RESULTS
17 .N DIVFLAG,DIVISION,SELDIV
18 .N DGSUB,DGJ,DGUTD,DGWD,DGDV,ZTSTOP
19 .; -- Set Variables
20 .S VAUTD=1 ; -- All divisions selected
21 .D NOW^%DTC S DATE=%
22 .S DFNARR="^TMP(""DGQE-DFN"","_$J_")"
23 .K @DFNARR
24 .S CNT=0
25 .; -- Check for multi divisional hospital
26 .I $P(^DG(43,1,"GL"),"^",2)=1 D Q:Y=-1
27 ..D DIVISION^VAUTOMA
28 .; -- Check for Clinics within division or all
29 .S VAUTNI=2
30 .D CLINIC^VAUTOMA
31 .I Y=-1 Q
32 .; -- Download for date range
33 .S ERR=$$SDATE^DGQESC0()
34 .I ERR=-1 Q
35 .S SDATE=ERR
36 .S ERR=$$EDATE^DGQESC0(ERR)
37 .I ERR=-1 Q
38 .S EDATE=ERR
39 .S DIR(0)="YA"
40 .; -- Task off job
41 .S DIR("A")="Task job: "
42 .S DIR("B")="YES"
43 .S DIR("?")="Enter YES/NO to determine whether job is tasked"
44 .D ^DIR
45 .Q:$D(DIRUT)
46 .I Y D Q
47 ..D BATCH
48 ..I '$D(ZTSK) Q
49 ..W !,"Card(s) queued, task number = "_ZTSK
50 .D OUTSCAN
51 Q
52 ;
53EXIT ; -- Finish Process
54 I '$D(ZTQUEUED)&($P(RESULTS,"^",1)=0) W !!,CNT_" Outpatients down loaded to VIC work station"
55 K @DFNARR
56 Q
57 ;
58OUTSCAN ; Scan the clinics for appointments to create VIC cards
59 ;
60 N CLINIC,CLINDATE,DPTINFO,I,CLNARRAY,DGARRAY,DGDIV,SDCNT S I=1
61 K ^TMP($J,"SDAMA"),^TMP($J,"SDAMA301")
62 ;
63 I '$D(ZTQUEUED) W !!,"Note: Each Dot equals a clinic",!
64 I VAUTC,VAUTD D
65 .S CLINIC=0 F S CLINIC=$O(^SC(CLINIC)) Q:'CLINIC D
66 ..I $P(^SC(CLINIC,0),U,3)="C" D CBLD3(CLINIC)
67 ;
68 I VAUTC,'VAUTD S DGDIV="" D
69 .S DGDIV="" F S DGDIV=$O(VAUTD(DGDIV)) Q:'DGDIV D
70 ..S CLINIC=0 F S CLINIC=$O(^SC(CLINIC)) Q:'CLINIC D
71 ...I $P(^SC(CLINIC,0),U,3)="C",$P(^SC(CLINIC,0),U,15)=DGDIV D CBLD3(CLINIC)
72 ;
73 I 'VAUTC S CLINIC=0 F S CLINIC=$O(VAUTC(CLINIC)) Q:'CLINIC D CBLD3(CLINIC)
74 ;
75 D SDAMA,BLDTMP,BLDHL7
76 K DGARRAY,SDCNT,^TMP($J,"SDAMA301"),^TMP($J,"SDAMA")
77 Q
78CBLD3(CLINIC) ; Build array of specified Clinics for specified Divisions
79 S CLNARRAY(I)=$G(CLNARRAY(I))_CLINIC_";"
80 I $L(CLNARRAY(I))>120 S I=I+1
81 I '$D(ZTQUEUED) W "."
82 Q
83 ;
84SDAMA ; Build TMP Global with Appointment API Data for Report
85 S DGARRAY(1)=SDATE_";"_EDATE
86 S DGARRAY("FLDS")="2;3"
87 F I=1:1 Q:'$D(CLNARRAY(I)) D
88 .S DGARRAY(2)=CLNARRAY(I)
89 .I $$SDAPI^SDAMA301(.DGARRAY)>0 M ^TMP($J,"SDAMA")=^TMP($J,"SDAMA301")
90 .K ^TMP($J,"SDAMA301")
91 Q
92BLDHL7 ; -- Building HL7 batch message
93 S DFN=""
94 F S DFN=$O(@DFNARR@(DFN)) Q:'DFN S CNT=CNT+1
95 S RESULTS=$$EVENT^DGQEHL72("A08",DFNARR)
96 I '$D(ZTQUEUED)&($P(RESULTS,"^",1)=-1) D
97 .W !,"Clinic patients not downloaded. Error - ",$P(RESULTS,"^",2)
98 ; -- Clean up variables
99 D EXIT
100 Q
101 ;
102BLDTMP ;
103 ; -- Building Temporary Storage Data
104 S (ZTSTOP,CLINIC)=0 F S CLINIC=$O(^TMP($J,"SDAMA",CLINIC)) Q:'CLINIC!(ZTSTOP) D
105 .I $$S^%ZTLOAD S ZTSTOP=1 Q
106 .S DFN=0 F S DFN=$O(^TMP($J,"SDAMA",CLINIC,DFN)) Q:'DFN D
107 ..S CLINDATE=0 F S CLINDATE=$O(^TMP($J,"SDAMA",CLINIC,DFN,CLINDATE)) Q:'CLINDATE D
108 ...I $P($P(^TMP($J,"SDAMA",CLINIC,DFN,CLINDATE),U,3),";")="R" S @DFNARR@(DFN)=""
109 Q
110 ;
111CHKDIV ; -- Check to see if clinic is part of Division selected
112 ; -- re-sequences array
113 S DGSUB="" F DGJ=1:1 S DGSUB=$O(VAUTD(DGSUB)) Q:DGSUB="" S DGUTD(DGJ)=$G(VAUTD(DGSUB))
114 ;
115 S DIVFLAG=0
116 S DGWD=CLINIC
117 I DGWD S DGDV=$S('$D(^SC(DGWD,0)):0,+$P(^(0),"^",15):$P(^(0),"^",15),1:$O(^DG(40.8,0)))
118 I DGDV=0 S DIVFLAG=0 Q
119 S DIVISION=$P($G(^DG(40.8,DGDV,0)),U,1)
120 I DIVISION="" S DIVFLAG=0 Q
121 ;W !,"DIVISION = ",DIVISION
122 F DGJ=1:1 S SELDIV=DGUTD(DGJ) D Q:'$D(DGUTD(DGJ+1))
123 .;W !,"SELDIV = ",SELDIV
124 .I SELDIV=DIVISION S DIVFLAG=1 Q
125 Q
126 ;
127BATCH ; -- Entry point for placing cards on hold
128 N ZTRTN,ZTDESC,ZTIO,ZTDTH,ZTSAVE,G
129 ;
130 S ZTRTN="OUTSCAN^DGQESC2"
131 S ZTDESC="Download Outpatients to VIC work station via HL7"
132 S ZTIO=""
133 K ZTDTH
134 ;D NOW^%DTC S ZTDTH=%
135 F G="VAUTD","VAUTC","CNT","DFNARR","SDATE","EDATE" S:$D(@G) ZTSAVE(G)=""
136 S ZTSAVE("VAUTD(")="",ZTSAVE("VAUTC(")=""
137 D ^%ZTLOAD
138 Q
139 ;
140END ; -- End of Code
141 Q
142 ;
Note: See TracBrowser for help on using the repository browser.