source: WorldVistAEHR/trunk/r/REGISTRATION-DGQE-DG-DPT-GRPX-VAD-VAF-VAS-VAT-VAU--VA-VIC--DGBT--DGJ--DGYA--VALM/DGRUGDS.m@ 824

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

initial load of WorldVistAEHR

File size: 6.9 KB
Line 
1DGRUGDS ;ALB/GRR - RAI/MDS DATA COLLECTION
2 ;;5.3;Registration;**303,359**;Aug 13, 1993
3 ;
4 ;Display option description and allow user to terminate process
5EN ;
6 W @IOF
7 N DGSTN,DGX,DGDIV
8 F I=0:1 S DGX=$P($T(TEXT+I),";;",2) Q:DGX="$END" W !,DGX
9 S DIR(0)="YA",DIR("B")="NO",DIR("A")="Do you wish to continue? "
10 S DIR("?")="Enter Yes to continue or No to quit"
11 D ^DIR K DIR
12 Q:'Y!$D(DIRUT)
13 ;
14 ;Ask user for division to seed
15DIV ;
16 W !
17 N DIR,DIRUT
18 S DIR(0)="PO^40.8:EMZ"
19 S DIR("A")="Enter the Division you want to do Data Seeding for"
20 S DIR("?")="Select the division you want to load the patient data for into the COTS database."
21 D ^DIR K DIR Q:$D(DIRUT)!(+Y'>0)
22 S DGDIV=Y
23 S DGSTN=$$SITE^VASITE($$NOW^XLFDT,+DGDIV)
24 W !!,?4,"You have selected: ",$P(DGDIV,"^",2)
25 W !,?4,"Station Number : ",$S(+DGSTN>0:$P(DGSTN,"^",3),1:"Undefined Station Number"),!
26 I +DGSTN<0 D G DIV
27 .W !?4,"You cannot proceed with this division until the station number is corrected."
28 .W !?4,"You may select another division or quit.",!
29 N DIR,DUOUT,DTOUT
30 S DIR(0)="YAO",DIR("A")="Is this correct? ",DIR("B")="YES"
31 S DIR("?")="Enter Yes or No. Yes will select, No will cancel."
32 D ^DIR K DIR Q:$D(DTOUT)!($D(DUOUT))
33 G:'Y DIV
34 W !
35 N ZTDESC,ZTSAVE,ZTIO,ZTDTH,X,ZTQUEUED,ZTREQ,ZTRTN
36 S ZTDESC="RAI/MDS DATA SEED FOR DIVISION "_$P(DGDIV,"^",2)
37 S ZTRTN="EN1^DGRUGDS",ZTIO=""
38 S DGDIV=+DGDIV
39 S ZTSAVE("DGDIV")="",ZTSAVE("DGSTN")=""
40 D ^%ZTLOAD
41 I '$G(ZTSK) W !,"** The data seed process was not tasked **"
42 I $G(ZTSK) W !,"The data seed process has been tasked (#",ZTSK,")"
43 W !
44 Q
45EN1 ;
46 N DGSENM,DGIEN,DGRSIED,DGWARD,DGWARD,DGWIEN,DGWDIV,DGSEED,DGMDT,DGRUGDS
47 S U="^",DGSENM="DGRU-RAI-A01-SERVER",DGRSIED=$O(^ORD(101,"B",DGSENM,0)) ;SET VARIABLES TO CALL HL7 INIT FUNCTION
48 D INIT^HLFNC2(DGSENM,.HL) ;Initialize A01 server, sets HL7 variables
49 I $O(HL(""))']"" D Q ;WAS UNABLE TO INTIALIZE
50 .S HLERR(1)=HL
51 .;S DGWARD="" F S DGWARD=$O(^DGPM("CN",DGWARD)) Q:DGWARD="" S DGWIEN=+$O(^DIC(42,"B",DGWARD,0)) I $$GET1^DIQ(42,DGWIEN,.035,"I")=1 D ;loop through active patients, if ward is RAI/MDS flagged, continue
52 .;S DGWDIV=$$GET1^DIQ(42,DGWIEN,.015,"I") I DGWDIV=DGDIV S DGIEN=0 F S DGIEN=$O(^DGPM("CN",DGWARD,DGIEN)) Q:DGIEN'>0 D ;If ward in the division selected, continue
53 ;..S DFN=$$GET1^DIQ(405,DGIEN,.03,"I") Q:DFN="" ;get patient ien
54 ;..S DGMDT=$$GET1^DIQ(405,DGIEN,.01,"I") Q:DGMDT=""
55 ;..S DGSEED=1 D BLDMSG^DGRUADT1(DFN,"A01",DGIEN,DGMDT,DGWIEN)
56 ;
57 S DGRUGDS=0
58 S DGWARD=""
59 ;Loop through active patients
60 F S DGWARD=$O(^DGPM("CN",DGWARD)) Q:(DGWARD="")!(DGRUGDS) D
61 .;Task asked to stop ?
62 .S X="Looping through ward "_DGWARD
63 .S DGRUGDS=$$S^%ZTLOAD(X) Q:DGRUGDS
64 .S DGWIEN=+$O(^DIC(42,"B",DGWARD,0))
65 .;Not an RAI/MDS ward
66 .Q:'$$GET1^DIQ(42,DGWIEN,.035,"I")
67 .S DGWDIV=$$GET1^DIQ(42,DGWIEN,.015,"I")
68 .;Ward not in selected division
69 .Q:DGWDIV'=DGDIV
70 .;Loop through movements
71 .S DGIEN=0
72 .F S DGIEN=$O(^DGPM("CN",DGWARD,DGIEN)) Q:(DGIEN'>0)!(DGRUGDS) D
73 ..;Get patient pointer and movement date/time
74 ..S DFN=$$GET1^DIQ(405,DGIEN,.03,"I") Q:DFN=""
75 ..S DGMDT=$$GET1^DIQ(405,DGIEN,.01,"I") Q:DGMDT=""
76 ..;Send message to RAI/MDS machine
77 ..S DGSEED=1 D BLDMSG^DGRUADT1(DFN,"A01",DGIEN,DGMDT,DGWIEN)
78 ..;Task asked to stop ?
79 ..S X="Looping through ward "_DGWARD_" -- Last DFN sent was "_DFN
80 ..S DGRUGDS=$$S^%ZTLOAD(X) Q:DGRUGDS
81 ;Update task message with completion status
82 I DGRUGDS S X=$$S^%ZTLOAD("Task stopped as requested")
83 I 'DGRUGDS S X=$$S^%ZTLOAD("Task ran to completion")
84 Q
85 ;
86TEXT ;;This option will do the data seeding of patient data in the RAI/MDS COTS system.
87 ;;HL7 A01 Admit messages will be created for patients currently active in wards
88 ;;assigned to the selected division. This option should be run only once per
89 ;;division and the COTS system database should be empty of patient data prior
90 ;;to using this option.
91 ;;
92 ;;***NOTE***
93 ;;
94 ;;It is extremely important that both the Ward translation file (#46.12) and the
95 ;;Room-Bed Translation file (#46.13) be complete if they are needed for use.
96 ;;The RAI/MDS flag must be set to YES for the RAI/MDS wards in the selected
97 ;;division BEFORE this option is run.
98 ;;
99 ;;$END
100 ;;
101 ;Entry point for individual data seed
102EN3 ;
103 W @IOF
104 N DGINPT,DGPTNM,DGFNM,DGLNM
105 F I=0:1 S DGX=$P($T(TEXT3+I),";;",2) Q:DGX="$END" W !,DGX
106 S DIR(0)="YA",DIR("B")="NO",DIR("A")="Do you wish to continue? "
107 S DIR("?")="Enter Yes to continue or No to quit"
108 D ^DIR K DIR
109 Q:'Y!$D(DIRUT)
110 ;
111 ;Select patient(s)
112INPAT ;
113 W !
114 N DIR,DIRUT,DFN,DGIEN,DGWIEN,DGMDT
115 S DIR(0)="PAO^2:EMZ"
116 S DIR("A")="Enter the patient you want to data seed: "
117 S DIR("?")="Select the patient you want to load into the COTS database."
118 D ^DIR K DIR Q:$D(DIRUT)!(+Y'>0)
119 S DGINPT=+Y
120 S DGPTNM=$$GET1^DIQ(2,DGINPT,.01)
121 S DGFNM=$P(DGPTNM,",",2)
122 S DGLNM=$P(DGPTNM,",",1)
123 S DGPTNM=DGFNM_" "_DGLNM
124 W !!,?4,"You have selected: ",DGPTNM
125 W !
126 I +DGINPT<0 D G INPAT
127 .W !?4,"You cannot proceed with this patient"
128 .W !?4,"You may select another patient or quit.",!
129 N DIR,DUOUT,DTOUT
130 S DIR(0)="YAO",DIR("A")="Is this correct? ",DIR("B")="YES"
131 S DIR("?")="Enter Yes or No. Yes will select this patient. No will cancel the selection of this patient."
132 D ^DIR K DIR Q:$D(DTOUT)!($D(DUOUT))
133 G:'Y INPAT D EN4
134 ;Allow another selection
135 W !
136 S DIR(0)="YAO",DIR("A")="Select another patient? ",DIR("B")="NO"
137 S DIR("?")="Enter Yes or No. Yes will allow you to select another patient."
138 D ^DIR K DIR Q:$D(DTOUT)!($D(DUOUT))!('Y)
139 G:Y INPAT
140 W !
141 Q
142 ;
143 ;Set variables to call HL7 Function
144EN4 ;
145 N DGSENM,DGIEN,DGRSIED,DGWARD,DGWARD,DGWIEN,DGWDIV,DGSEED,DGMDT,DGRUGDS
146 S U="^",DGSENM="DGRU-RAI-A01-SERVER",DGRSIED=$O(^ORD(101,"B",DGSENM,0))
147 D INIT^HLFNC2(DGSENM,.HL) ;Initialize A01 server, sets HL7 variables
148 I $O(HL(""))']"" D Q ;WAS UNABLE TO INTIALIZE
149 .S HLERR(1)=HL
150 ;
151 ;Get selected patient's last ward location. If RAI ward, send message.
152 ;If not an RAI ward, allow another inpatient selection. If current
153 ;ward location is empty, patient is inactive & allow another selection.
154ACTIVE ;
155 S DFN=DGINPT
156 S DGRUGDS=0
157 S VAIP("D")="LAST"
158 D IN5^VADPT
159 I '$$CHKWARD^DGRUUTL(+$P(VAIP(5),"^")) W !!?4,DGPTNM_" is not in an RAI ward." D EXIT Q
160 I $$GET1^DIQ(2,DFN,.1)="" W !!?4,DGPTNM_" is not an active patient in an RAI ward." D EXIT Q
161 I $$CHKWARD^DGRUUTL(+$P(VAIP(5),"^")) S DGWIEN=+$P(VAIP(5),"^"),DGIEN=VAIP(1),DGMDT=+$P(VAIP(3),"^")
162 S DGSEED=1 D BLDMSG^DGRUADT1(DFN,"A01",DGIEN,DGMDT,DGWIEN)
163 W !!?4,"Sending message..."
164 D EXIT
165 Q
166 ;Reset variables for next selection
167EXIT ;
168 K DFN,DGIEN,DGINPT,DGWIEN,DGMDT,VAIP
169 ;
170TEXT3 ;;This option will do the data seeding of patient data in the RAI/MDS COTS system.
171 ;;HL7 A01 Admit messages will be created for selected patients currently active in
172 ;;RAI designated wards.
173 ;;
174 ;;***NOTE***
175 ;;
176 ;;It is extremely important that both the Ward translation file (#46.12)and the
177 ;;Room-Bed Translation file (#46.13) be complete if they are needed for use.
178 ;;The RAI/MDS flag must be set to YES for the RAI/MDS wards in the selected
179 ;;division BEFORE this option is run.
180 ;;
181 ;;$END
182 ;;
Note: See TracBrowser for help on using the repository browser.