source: FOIAVistA/trunk/r/HEALTH_DATA_AND_INFORMATICS-HDI/HDISVF04.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 
1HDISVF04 ;ALB/RMO - 7118.11 File Utilities/API Cont.; 1/10/05@11:37:00
2 ;;1.0;HEALTH DATA & INFORMATICS;;Feb 22, 2005
3 ;
4 ;---- Begin HDIS Term/Concept VUID Association file (#7118.11) API(s) ----
5 ;
6GETTERM(HDISTERM,HDISFARY,HDISTIEN) ;Get a Term/Concept Entry by Term/Concept and File/Field
7 ; Input -- HDISTERM Term/Concept Text
8 ; HDISFARY File/Field Array - Pass by HDISFARY(HDIS File/Field file #7115.6 IEN)=""
9 ; Output -- 1=Successful and 0=Failure
10 ; If Successful:
11 ; HDISTIEN HDIS Term/Concept VUID Association file IEN
12 N HDISFIEN,HDISI
13 ;Initialize output
14 S HDISTIEN=""
15 ;Check for missing variables, exit if not defined
16 I '$D(HDISTERM)!('$D(HDISFARY)) G GETTERMQ
17 ;Check for existing Term/Concept and File/Field
18 S HDISFIEN=0
19 F S HDISFIEN=$O(HDISFARY(HDISFIEN)) Q:'HDISFIEN D
20 . I $D(^HDISV(7118.11,"AC",HDISFIEN)) D
21 . S HDISI=0
22 . F S HDISI=$O(^HDISV(7118.11,"AC",HDISFIEN,HDISI)) Q:'HDISI!($G(HDISTIEN)) D
23 . . I $D(^HDISV(7118.11,HDISI,0)),$P(^(0),"^",1)=HDISTERM D
24 . . . S HDISTIEN=HDISI
25GETTERMQ Q +$S($G(HDISTIEN)>0:1,1:0)
26 ;
27ADDTERM(HDISTERM,HDISVUID,HDISFARY,HDISNTLF,HDISCKTF,HDISEDTM,HDISSTAT,HDISTIEN,HDISERRM) ;Add a New Term/Concept Entry
28 ; Input -- HDISTERM Term/Concept Text
29 ; HDISVUID VUID
30 ; HDISFARY File/Field Array - Pass by HDISFARY(HDIS File/Field file #7115.6 IEN)=""
31 ; HDISNTLF National Standard Flag (Optional- Default 0)
32 ; 1=Yes and 0=No
33 ; HDISCKTF Check for Existing Term/Concept Flag (Optional- Default 1)
34 ; 1=Yes and 0=No
35 ; HDISEDTM Effective Date/Time (Optional- Default NOW)
36 ; HDISSTAT Status (Optional- Default 0)
37 ; 1=Active and 0=Inactive
38 ; Output -- 1=Successful and 0=Failure
39 ; If Successful:
40 ; HDISTIEN HDIS Term/Concept VUID Association file IEN
41 ; If Failure:
42 ; HDISERRM Error Message (Optional)
43 N HDISCNT,HDISERRF,HDISFDA,HDISFFNM,HDISFIEN,HDISI,HDISIEN,HDISIENS,HDISMSG,HDISNDTF,HDISOKF
44 ;Initialize output
45 S (HDISTIEN,HDISERRM)=""
46 ;Check for missing variables, exit if not defined
47 I '$D(HDISTERM)!($G(HDISVUID)'>0)!('$D(HDISFARY)) D G ADDTERMQ
48 . S HDISERRM="Required Variable Missing."
49 ;Set National Standard Flag to default of 0, if needed
50 S HDISNTLF=$S('$D(HDISNTLF):0,1:HDISNTLF)
51 ;Set No Effective Date/Time Flag to 1 if there is no Effective Date/Time and no Status
52 I '$G(HDISEDTM),'$G(HDISSTAT) D
53 . S HDISNDTF=1
54 ;If No Effective Date/Time Flag is set to 1, Effective Date/Time Multiple should not be created
55 I '$G(HDISNDTF) D
56 . ;Set Effective Date/Time to default of NOW, if needed
57 . S HDISEDTM=$S('$D(HDISEDTM):$$NOW^XLFDT,1:HDISEDTM)
58 . ;Set Status to default of 0, if needed
59 . S HDISSTAT=$S('$D(HDISSTAT):0,1:HDISSTAT)
60 ;Set Check for Existing Term/Concept Flag to default of 1, if needed
61 S HDISCKTF=$S('$D(HDISCKTF):1,1:HDISCKTF)
62 ;Check for existing Term/Concept and File/Field, return error and exit if it exists
63 I $G(HDISCKTF),$$GETTERM(HDISTERM,.HDISFARY) D G ADDTERMQ
64 . S HDISERRM="Term/Concept and File/Field already exists."
65 ;Check for existing Term/Concept and VUID, return error and exit if it exists
66 I $$GETIENS(HDISVUID,.HDISIENS) D G ADDTERMQ:$G(HDISERRF)
67 . S HDISI=0
68 . F S HDISI=$O(HDISIENS(HDISI)) Q:'HDISI!($G(HDISERRF)) I $G(HDISIENS(HDISI))=HDISTERM D
69 . . S HDISERRF=1
70 . . S HDISERRM="Term/Concept and VUID already exists."
71 ;Set array for Term/Concept and VUID
72 S HDISFDA(7118.11,"+1,",.01)=$G(HDISTERM)
73 S HDISFDA(7118.11,"+1,",99.99)=$G(HDISVUID)
74 ;Set array for National Standard Flag to Yes
75 I $G(HDISNTLF) D
76 . S HDISFDA(7118.11,"+1,",1.02)=1
77 ELSE D
78 . ;Set array for Date/Time Created and National Standard Flag to No
79 . S HDISFDA(7118.11,"+1,",1.01)=$$NOW^XLFDT
80 . S HDISFDA(7118.11,"+1,",1.02)=0
81 ;If No Effective Date/Time Flag is set to 1, Effective Date/Time Multiple should not be created
82 I '$G(HDISNDTF) D
83 . ;Set array for Effective Date/Time and Status
84 . S HDISFDA(7118.12,"+2,+1,",.01)=$G(HDISEDTM)
85 . S HDISFDA(7118.12,"+2,+1,",.02)=$G(HDISSTAT)
86 ;Set array for File/Field
87 S HDISFIEN=0
88 S HDISCNT=2
89 F S HDISFIEN=$O(HDISFARY(HDISFIEN)) Q:'HDISFIEN I $D(^HDIS(7115.6,HDISFIEN,0)) S HDISFFNM=$P(^(0),"^",1) D
90 . S HDISCNT=HDISCNT+1
91 . S HDISFDA(7118.13,"+"_HDISCNT_",+1,",.01)=HDISFFNM
92 D UPDATE^DIE("E","HDISFDA","HDISIEN","HDISMSG")
93 ;Check for error
94 I $D(HDISMSG("DIERR")) D
95 . S HDISERRM=$G(HDISMSG("DIERR",1,"TEXT",1))
96 ELSE D
97 . S HDISTIEN=+$G(HDISIEN(1))
98 . S HDISOKF=1
99 D CLEAN^DILF
100ADDTERMQ Q +$G(HDISOKF)
101 ;
102GETIENS(HDISVUID,HDISIENS) ;Get IENS for a Term/Concept by VUID
103 ; Input -- HDISVUID VUID
104 ; Output -- 1=Successful and 0=Failure
105 ; If Successful:
106 ; HDISIENS Array where HDISIENS(IEN)=Term/Concept field (#.01)
107 N HDISI
108 ;Initialize output
109 K HDISIENS
110 ;Check for missing variable, exit if not defined
111 I $G(HDISVUID)'>0 G GETIENSQ
112 ;Check for entries by VUID
113 S HDISI=0
114 F S HDISI=$O(^HDISV(7118.11,"AVUID",HDISVUID,HDISI)) Q:'HDISI D
115 . I $D(^HDISV(7118.11,HDISI,0)) S HDISIENS(HDISI)=$P($G(^(0)),"^",1)
116GETIENSQ Q +$S($D(HDISIENS):1,1:0)
117 ;
118GETVUID(HDISTIEN,HDISVUID) ;Get VUID for a Term/Concept by IEN
119 ; Input -- HDISTIEN HDIS Term/Concept VUID Association file IEN
120 ; Output -- 1=Successful and 0=Failure
121 ; If Successful:
122 ; HDISVUID VUID
123 ;Initialize output
124 S HDISVUID=""
125 ;Check for missing variable, exit if not defined
126 I $G(HDISTIEN)'>0 G GETVUIDQ
127 ;Check for VUID by IEN
128 I $D(^HDISV(7118.11,HDISTIEN,"VUID")) S HDISVUID=$P($G(^("VUID")),"^",1)
129GETVUIDQ Q +$S($G(HDISVUID)>0:1,1:0)
130 ;
131GETNTLF(HDISTIEN,HDISNTLF) ;Get National Standard Flag for a Term/Concept by IEN
132 ; Input -- HDISTIEN HDIS Term/Concept VUID Association file IEN
133 ; Output -- 1=Successful and 0=Failure
134 ; If Successful:
135 ; HDISNTLF National Standard Flag
136 ;Initialize output
137 S HDISNTLF=""
138 ;Check for missing variable, exit if not defined
139 I $G(HDISTIEN)'>0 G GETNTLFQ
140 ;Check for National Standard Flag by IEN
141 I $D(^HDISV(7118.11,HDISTIEN,1)) S HDISNTLF=$P($G(^(1)),"^",2)
142GETNTLFQ Q +$S($G(HDISNTLF)]"":1,1:0)
143 ;
144GETSTAT(HDISTIEN,HDISDTM,HDISEDTM,HDISSTAT) ;Get Effective Date and Status for a Term/Concept by IEN and Date/Time
145 ; Input -- HDISTIEN HDIS Term/Concept VUID Association file IEN
146 ; HDISDTM Date/Time (Optional- Default NOW for Current)
147 ; Output -- 1=Successful and 0=Failure
148 ; If Successful:
149 ; HDISEDTM Effective Date/Time
150 ; HDISSTAT Status
151 N HDIS0,HDISII
152 ;Initialize output
153 S (HDISEDTM,HDISSTAT)=""
154 ;Check for missing variable, exit if not defined
155 I $G(HDISTIEN)'>0 G GETSTATQ
156 ;Set Date/Time to default of NOW for Current, if needed
157 S HDISDTM=$S('$D(HDISDTM):$$NOW^XLFDT,1:HDISDTM)
158 S:'$P(HDISDTM,".",2) HDISDTM=HDISDTM_.235959
159 ;Get Effective Date/Time Multiple IEN by IEN and Date/Time
160 S HDISII=+$O(^(+$O(^HDISV(7118.11,HDISTIEN,"TERMSTATUS","B",HDISDTM),-1),0))
161 ;Check for Effective Date/Time and Status
162 I $D(^HDISV(7118.11,HDISTIEN,"TERMSTATUS",HDISII,0)) S HDIS0=$G(^(0)) D
163 . S HDISEDTM=$P(HDIS0,"^",1)
164 . S HDISSTAT=$P(HDIS0,"^",2)
165GETSTATQ Q +$S($G(HDISEDTM)'=""&($G(HDISSTAT)'=""):1,1:0)
166 ;
167 ;---- End HDIS Term/Concept VUID Association file (#7118.11) API(s) ----
Note: See TracBrowser for help on using the repository browser.