source: qrda/C0Q/trunk/p/C0QHF.m

Last change on this file was 1501, checked in by Sam Habiel, 12 years ago

Latest routines; T11 copy

File size: 3.2 KB
Line 
1C0QHF ; GPL - Health Factor Utility Routines ;9/02/11 17:05
2 ;;1.0;C0Q;;May 21, 2012;Build 63
3 ;Copyright 2011 George Lilly. Licensed under the terms of the GNU
4 ;General Public License See attached copy of the License.
5 ;
6 ;This program is free software; you can redistribute it and/or modify
7 ;it under the terms of the GNU General Public License as published by
8 ;the Free Software Foundation; either version 2 of the License, or
9 ;(at your option) any later version.
10 ;
11 ;This program is distributed in the hope that it will be useful,
12 ;but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;GNU General Public License for more details.
15 ;
16 ;You should have received a copy of the GNU General Public License along
17 ;with this program; if not, write to the Free Software Foundation, Inc.,
18 ;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 ;
20 Q
21 ;
22 ; these routines are for quick lookups on HEALTH FACTOR and V HEALTH FACTOR
23 ; files...
24 ;
25 ; from the DD:
26 ;STANDARD DATA DICTIONARY #9000010.23 -- V HEALTH FACTORS FILE
27 ;STORED IN ^AUPNVHF( (6744 ENTRIES)
28 ;CROSS REFERENCED BY: PATIENT NAME(AATOO), HEALTH FACTOR(AATOO1), VISIT(AD),
29 ; VISIT(AV10), HEALTH FACTOR(B), PATIENT NAME(C)
30 ;
31 ;STANDARD DATA DICTIONARY #9999999.64 -- HEALTH FACTORS FILE
32 ;STORED IN ^AUTTHF( (8656 ENTRIES)
33 ;CROSS REFERENCED BY: CATEGORY(AC), ENTRY TYPE(AD), FACTOR(B), SYNONYM(D)
34 ;
35HFYN(DFN,C0QHF) ; EXTRINSIC RETURNS 1 (YES) OR 0 (NO) IF A PATIENT
36 ; HAS A HEALTH FACTOR
37 N ZI,ZJ,ZR
38 S ZI=$O(^AUTTHF("B",C0QHF,"")) ; HEALTH FACTOR IEN
39 I ZI="" D Q 0 ;
40 . W !,"BAD HEALTH FACTOR: ",C0QHF
41 I $D(^AUPNVHF("AA",DFN,ZI)) S ZR=1
42 E S ZR=0
43 Q ZR
44 ;
45HFIEN(ZHF) ; EXTRINSIC RETURNS THE IEN OF THE HEALTHFACTOR
46 N ZI
47 S ZI=$O(^AUTTHF("B",ZHF,"")) ; HEALTH FACTOR IEN
48 Q ZI
49 ;
50VHFIEN(DFN,ZHF) ; EXTRINSIC RETURNS THE LAST IEN OF THIS HEALTH FACTOR
51 ; FOR THE PATIENT
52 N ZG,ZJ,ZK
53 S ZG=$$HFIEN(ZHF)
54 I ZG="" Q ; OPPS HEALTH FACTOR NOT FOUND
55 S ZJ=$O(^AUPNVHF("AA",DFN,ZG,""),-1) ;DATE
56 S ZK=$O(^AUPNVHF("AA",DFN,ZG,ZJ,"")) ;IEN
57 Q ZK
58 ;
59HFCAT(RTN,DFN,C0QHFCAT) ; C0QFHCAT IS A HEALTH FACTOR CATEGORY
60 ; RTN IS PASSED BY REFERENCE AND RETURNS AN ARRAY OF HEALTH FACTORS
61 ; THAT THE PATIENT HAS IN THE CATEGORY. RETURNS NULL IF NONE
62 ; FORMAT RNT(HEALTH FACTOR IEN,HEALTH FACTOR NAME)=""
63 N ZI
64 S ZI=$O(^AUTTHF("B",C0QHFCAT,"")) ; HEALTH FACTOR CATEGORY IEN
65 N C0QN,C0QO,C0QR
66 S C0QO=$NA(^AUPNVHF("AA",DFN)) ; ALL THE PATIENT'S HEALTH FACTORS
67 S C0QN=$NA(^AUTTHF("AC",ZI)) ; ALL HEALTH FACTORS IN THIS CATEGORY
68 D UNITY^C0QSET("C0QR",C0QN,C0QO) ; THE DIFFERENCE
69 K RTN ; CLEAR THE RETURN ARRAY
70 N ZJ S ZJ=""
71 F S ZJ=$O(C0QR(1,ZJ)) Q:ZJ="" D ; FOR ALL HEALTH FACTOR MATCHES
72 . S RTN(ZJ,$P(^AUTTHF(ZJ,0),"^",1))=""
73 Q
74 ;
75HFLCAT(RTN,C0QHFCAT) ; RETURNS A LIST OF PATIENTS WHO HAVE A HEALTH FACTOR
76 ; IN THE C0QHFCAT CATEGORY. RTN IS PASSED BY REFERENCE
77 ; THIS WILL BE HARD TO DO WITHOUT SOME NEW INDEXES
78 Q
79 ;
80HFLPAT(RTN,C0QHF) ; RETURNS A LIST OF PATIENTS WHO HAVE A SPECIFIC HEALTH
81 ; FACTOR. RTN IS PASSED BY REFERENCE
82 ; THIS ONE ALSO WILL BE HARD TO DO QUICKLY WITHOUT A NEW INDEX
83 Q
84 ;
85INDEXES(DDREF) ;PRINT THE INDEXES ACTUALLY ON FILE DDREF
86 ; IE D INDEXES($NA(^DD))
87 N ZI
88 S ZI="A"
89 F S ZI=$O(@DDREF@(ZI)) Q:ZI="" W !,ZI
90 Q
91 ;
Note: See TracBrowser for help on using the repository browser.