source: FOIAVistA/trunk/r/ORDER_ENTRY_RESULTS_REPORTING-OR-OCX--ORRC--ORRJ/ORQPTQ6.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: 7.1 KB
Line 
1ORQPTQ6 ; SLC/PKS [8/27/03 11:20am]
2 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**82,85,187**;Dec 17, 1997
3 ;
4 ; Called by BUILD^ORQPT (LM) and DEFLIST^ORQPTQ11 (GUI).
5 ;
6 Q
7 ;
8COMBPTS(ORQLM,ORQCPTR,ORBDATE,OREDATE) ; Build "Combination" pt. list.
9 ; SLC/PKS.
10 ;
11 ; NOTE: Any calls to this tag need to deal with ORQLM passed
12 ; variable appropriately. Notice where it is evaluated
13 ; and make sure code specifies the setting of ORQLM (a
14 ; boolean variable) properly for the call.
15 ;
16 ; Variables used:
17 ;
18 ; MSG = Holds error message, if any.
19 ; ORBDATE = PASSED: Beginning date for clinic appointments.
20 ; OREDATE = PASSED: End date for clinic appointments.
21 ; ORQCNT = Counter for patients.
22 ; ORQCPTR = PASSED: Combination file [^OR(100.24,] pointer.
23 ; ORQDUZ = DUZ of current user.
24 ; ORQERR = Array for error msg(s) return from DB calls.
25 ; ORQFILE = Combo source entry file.
26 ; ORQLM = PASSED: Called from LM ("1") or GUI ("0")?
27 ; ORQPDAT = String holder for arrays and ^TMP file values.
28 ; ORQPDOB = Patient DOB.
29 ; ORQPFMDT = Hold app't date/time in FM internal format.
30 ; ORQPIEN = Variable for patient IEN, ^TMP("OR",$J,"PTSCOMBO")
31 ; ORQPMOR = Appointment or Room/Bed information.
32 ; ORQPNM = Variable for patient name, ^TMP("OR",$J,"PTSCOMBO")
33 ; ORQPSNM = Source name display string holder.
34 ; ORQPSSN = Patient ID (first letter of last name, last 4 SSN).
35 ; ORQPSTAT = Ipt or Opt (or C/NS) status for clinic lists.
36 ; ORQPTMP = Temporary string construction holder.
37 ; ORQPTR = Pointer to combo source entry.
38 ; ORQRTN = Holds return value from DB calls.
39 ; ORQSPCH = Holds return value from SELCHK^ORWPT.
40 ; ORQSRC = Variable to hold each combo source subscript.
41 ; ORQSRCID = IEN of source.
42 ; ORQTXT = Variable to hold stored values.
43 ; ORY = Array used in sub-calls.
44 ;
45 ; (NOTE: LCNT,LIST,MSG,NUM,SORT new'd in calling routines for LM.)
46 ;
47 N ORQCNT,ORQDUZ,ORQERR,ORQFILE,ORQPCNT,ORQPDAT,ORQPDOB,ORQPFMDT,ORQPIEN,ORQPNM,ORQPMOR,ORQPSNM,ORQPSSN,ORQPSTAT,ORQPTMP,ORQPTR,ORQRTN,ORQSPCH,ORQSRC,ORQSRCID,ORQTXT,ORY
48 ;
49 K ^TMP("OR",$J,"PATIENTS") ; Safety cleanup.
50 ;
51 ; Do preliminary settings, cleanup, look for an existing user record:
52 S MSG="" ; Default.
53 I '$D(DUZ) D
54 .S MSG="No user DUZ info."
55 .I 'ORQLM D GUIABORT
56 .Q
57 S ORQDUZ=DUZ
58 K ORQERR
59 S ORQRTN=$$FIND1^DIC(100.24,"","QX",ORQDUZ,"","","ORQERR")
60 K ORQERR
61 D CLEAN^DILF ; Clean up after DB call.
62 ;
63 ; If no combination record, then punt:
64 I +ORQRTN<1 D
65 .S MSG="No combination entry."
66 .I 'ORQLM D GUIABORT
67 .Q
68 ;
69 I ORQLM D CLEAN^VALM10 ; VALM housekeeping.
70 ;
71 ; Order through the user's combination source entries:
72 I 'ORQLM S SORT="A" ; Required variable for PTSCOMBO^ORQPTQ5.
73 S ORQSRC=0
74 F S ORQSRC=$O(^OR(100.24,ORQRTN,.01,ORQSRC)) Q:'ORQSRC D
75 .K ORY ; Clean up each time.
76 .S ORQTXT="" ; Initialize.
77 .S ORQTXT=$G(^OR(100.24,ORQRTN,.01,ORQSRC,0)) ; Get record's value.
78 .;
79 .; In case of error, punt:
80 .I ORQTXT="" D
81 ..S MSG="Combination source entry error."
82 ..I 'ORQLM D GUIABORT ; GUI is different.
83 ..Q
84 .I ORQTXT="" Q
85 .S ORQPTR=$P(ORQTXT,";") ; Get pointer.
86 .S ORQFILE="^"_$P(ORQTXT,";",2) ; Get file.
87 .;
88 .; Get info for each source entry and build ORY array accordingly.
89 .I ORQFILE="^DIC(42," D Q ; Wards.
90 ..D WARDPTS^ORQPTQ2(.ORY,ORQPTR)
91 ..I $D(ORY) D PTSCOMBO^ORQPTQ5("W",ORQPTR) ; Process ORY array.
92 .I ORQFILE="^VA(200," D Q ; Providers.
93 ..D PROVPTS^ORQPTQ2(.ORY,ORQPTR)
94 ..I $D(ORY) D PTSCOMBO^ORQPTQ5("P",ORQPTR) ; Process ORY array.
95 .I ORQFILE="^DIC(45.7," D Q ; Specialties.
96 ..D SPECPTS^ORQPTQ2(.ORY,ORQPTR)
97 ..I $D(ORY) D PTSCOMBO^ORQPTQ5("S",ORQPTR) ; Process ORY array.
98 .I ORQFILE="^OR(100.21," D Q ; Team Lists
99 ..D TEAMPTS^ORQPTQ1(.ORY,ORQPTR)
100 ..I $D(ORY) D PTSCOMBO^ORQPTQ5("T",ORQPTR) ; Process ORY array.
101 .I ORQFILE="^SC(" D Q ; Clinics.
102 ..D CLINPTS^ORQPTQ2(.ORY,ORQPTR,ORBDATE,OREDATE)
103 ..I $D(ORY) D PTSCOMBO^ORQPTQ5("C",ORQPTR) ; Process ORY array.
104 ;
105 ; Order thru ^TMP file "B" node entries returned by previous calls:
106 S ORQCNT=0 ; Reset for final use.
107 I $D(^TMP("OR",$J,"PATIENTS")) D
108 .S ORQPDAT=""
109 .F S ORQPDAT=$O(^TMP("OR",$J,"PATIENTS","B",ORQPDAT)) Q:ORQPDAT="" D
110 ..;
111 ..; Clear variables each time through:
112 ..S (ORQTXT,ORQPFMDT,ORQPIEN,ORQPNM,ORQPSSN,ORQPSTAT,ORQPDOB,ORQPSNM,ORQPMOR,ORQSRCID)=""
113 ..;
114 ..; Retrieve node's value:
115 ..S ORQTXT=$G(^TMP("OR",$J,"PATIENTS","B",ORQPDAT))
116 ..;
117 ..; Set indvidual variables:
118 ..S ORQPIEN=$P(ORQTXT,U) ; Patient DFN.
119 ..S ORQPNM=$P(ORQTXT,U,2) ; Patient name.
120 ..S ORQPSSN=$P(ORQTXT,U,3) ; Patient ID.
121 ..S ORQPDOB=$P(ORQTXT,U,4) ; Patient DOB.
122 ..S ORQPSNM=$P(ORQTXT,U,5) ; Source data.
123 ..S ORQPMOR=$P(ORQTXT,U,6) ; App't or R/B info.
124 ..S ORQSRCID=$P(ORQTXT,U,7) ; Source IEN.
125 ..S ORQPFMDT=$P(ORQTXT,U,8) ; App't FM date/time.
126 ..S ORQPSTAT=$P(ORQTXT,U,9) ; Ipt/Opt status.
127 ..S ORQCNT=ORQCNT+1 ; Increment counter.
128 ..;
129 ..; If a "sensitive" patient, reassign SSN, DOB data:
130 ..S ORQSPCH=$$SSN^DPTLK1(ORQPIEN)
131 ..I ORQSPCH["*" S ORQPSSN=""
132 ..S ORQPDOB=$$DOB^DPTLK1(ORQPIEN)
133 ..;
134 ..; Make some preliminary data settings:
135 ..S ORQPTMP=""
136 ..I ORQPSNM'="" S ORQPTMP=ORQPSNM_" "
137 ..S ORQPTMP=ORQPTMP_ORQPMOR
138 ..;
139 ..; Write new ^TMP file "PATIENTS" nodes:
140 ..I ORQLM D ; For LM.
141 ...S ^TMP("OR",$J,"PATIENTS","IDX",ORQCNT)=ORQPIEN_U_ORQPNM
142 ...S ^TMP("OR",$J,"PATIENTS",ORQCNT,0)=$$LJ^XLFSTR(ORQCNT,5)_$$LJ^XLFSTR(ORQPNM,31)_$$LJ^XLFSTR(ORQPSSN,10)_$$LJ^XLFSTR(ORQPDOB,15)_ORQPTMP_$$LJ^XLFSTR(ORQPDOB,15)_$$RJ^XLFSTR(ORQSRCID,8)_" "_ORQPFMDT
143 ...D CNTRL^VALM10(ORQCNT,1,5,IOINHI,IOINORM)
144 ..;
145 ..I 'ORQLM D ; For GUI.
146 ...S ORQTXT=ORQPIEN_U_ORQPNM_U_ORQPSNM_U_ORQPMOR_U_ORQPSSN_U_ORQPDOB_U_ORQSRCID_U_ORQPFMDT_U_ORQPSTAT
147 ...S ^TMP("OR",$J,"PATIENTS",ORQCNT,0)=ORQTXT ; Actual global write.
148 ;
149 ; Set counters for return, if applicable; do cleanup:
150 I ORQCNT S (LCNT,NUM)=ORQCNT
151 K ORY
152 ;
153 ; If no patients found, prepare user message:
154 I 'ORQCNT S MSG="No patients found."
155 ;
156 ; If an error message exists, dump any partial processing and quit:
157 I MSG'="" D Q
158 .I 'ORQLM D GUIABORT
159 .I ORQLM K ^TMP("OR",$J,"PATIENTS")
160 ;
161 ; Next lines create #line^^#pts^context value entry:
162 I ORQLM D
163 .S ^TMP("OR",$J,"PATIENTS",0)=ORQCNT_U_ORQCNT_U_$G(LIST)
164 .S ^TMP("OR",$J,"PATIENTS","#")=$O(^ORD(101,"B","ORQPT SELECT PATIENT",0))_"^1:"_ORQCNT
165 ;
166 ; Standard clean-up for GUI:
167 I 'ORQLM D
168 .K LCNT,LIST,MSG,NUM,SORT
169 .K ^TMP("OR",$J,"PATIENTS","B")
170 ;
171 Q
172 ;
173GUIABORT ; Cleanup when aborting when called from GUI.
174 ;
175 K ^TMP("OR",$J,"PATIENTS")
176 S ^TMP("OR",$J,"PATIENTS",0)=""
177 K LCNT,LIST,MSG,NUM,SORT
178 ;
179 Q
180 ;
Note: See TracBrowser for help on using the repository browser.