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

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

initial load of FOIAVistA 6/30/08 version

File size: 6.1 KB
Line 
1DGENSEC ;ALB/KCL/CKN - Patient Security API's ; 5/11/05 12:02pm
2 ;;5.3;Registration;**222,653**;Aug 13,1993;Build 2
3 ;
4 ;
5LOCK(DFN) ;
6 ; Description: Used to lock the DG SECURITY LOG record for a patient
7 ;
8 ; Input:
9 ; DFN - internal entry number of record in the DG SECURITY LOG file
10 ;
11 ; Output:
12 ; Function Value: Returns 1 if the DG SECURITY LOG record can be
13 ; locked, otherwise returns 0 on failure
14 ;
15 I $G(DFN) L +^DGSL(38.1,DFN,0):2
16 Q $T
17 ;
18 ;
19UNLOCK(DFN) ;
20 ; Description: Used to unlock the DG SECURITY LOG record for a patient
21 ;
22 ; Input:
23 ; DFN - internal entry number of record in the DG SECURITY LOG file
24 ;
25 ; Output:
26 ; None
27 ;
28 I $G(DFN) L -^DGSL(38.1,DFN,0)
29 Q
30 ;
31 ;
32FINDSEC(DFN) ;
33 ; Description: Used to find a record in the DG SECURITY LOG file
34 ;
35 ; Input:
36 ; DFN - Patient IEN
37 ;
38 ; Output:
39 ; Function Value: If successful, returns internal entry number of
40 ; DG SECURITY LOG file, otherwise returns 0 on failure
41 ;
42 Q:'$G(DFN)="" 0
43 Q +$O(^DGSL(38.1,"B",DFN,0))
44 ;
45 ;
46GET(SECIEN,DGSEC) ;
47 ; Description: Used to obtain a record in the DG SECURITY LOG file. The values will be returned in the DGSEC() array.
48 ;
49 ; Input:
50 ; SECIEN - internal entry number of record in the DG SECURITY LOG file
51 ;
52 ; Output:
53 ; DGSEC - the patient security array, passed by reference
54 ; subscripts are:
55 ; "DFN" Patient
56 ; "LEVEL" Security Level
57 ; "USER" Security Assigned By
58 ; "DATETIME" Date/Time Security Assigned
59 ; "SOURCE" Secuity Source
60 ;
61 N SUB,NODE0
62 K DGSEC S DGSEC=""
63 ;
64 I '$G(SECIEN) D Q 0
65 .F SUB="DFN","LEVEL","USER","DATETIME","SOURCE" S DGSEC(SUB)=""
66 ;
67 S NODE0=$G(^DGSL(38.1,SECIEN,0))
68 S DGSEC("DFN")=$P(NODE0,"^")
69 S DGSEC("LEVEL")=$P(NODE0,"^",2)
70 S DGSEC("USER")=$P(NODE0,"^",3)
71 S DGSEC("DATETIME")=$P(NODE0,"^",4)
72 S DGSEC("SOURCE")=$P(NODE0,"^",5)
73 Q 1
74 ;
75 ;
76STORE(DGSEC,ERROR) ;
77 ; Description: Creates a new entry in the DG SECURITY LOG file.
78 ;
79 ; Input:
80 ; DGSEC - as array containing the DG SECURITY LOG record,
81 ; passed by reference
82 ;
83 ; Output:
84 ; Function Value: Returns internal entry number of the entry created,
85 ; otherwise 0 is returned
86 ; ERROR - (optional) if not successful, an error msg is
87 ; returned, pass by reference
88 ;
89 N DA,DD,DIC,DIE,DLAYGO,DO,DR,X,Y
90 S DIC(0)="L",(X,DINUM)=DGSEC("DFN"),DIC="^DGSL(38.1,",DLAYGO=38.1
91 D FILE^DICN
92 I Y=-1 S ERROR="FILEMAN UNABLE TO CREATE DG SECURITY LOG RECORD" Q 0
93 S DA=+Y
94 ;
95 I 'DA S ERROR="FILEMAN UNABLE TO CREATE DG SECURITY LOG RECORD" Q 0
96 ;
97 ; edit/update the new record
98 I '$$UPDATE(DA,.DGSEC,.ERROR) S ERROR="FILEMAN UNABLE TO CREATE DG SECURITY LOG RECORD" Q 0
99 ;
100 ; quit with ien
101 Q DA
102 ;
103 ;
104UPDATE(DFN,DGSEC,ERROR) ;
105 ; Description: Updates a DG SECURITY LOG record for a patient. This
106 ; function locks the DG SECURITY LOG record and releases the lock
107 ; when the update is complete.
108 ;
109 ; Input:
110 ; DFN - internal entry number of record in the DG SECURITY LOG file
111 ; DGSEC - the DG SECURITY LOG array, passed by reference
112 ;
113 ; Output:
114 ; Function Value - Returns 1 if successful, otherwise 0
115 ; ERROR - if not successful, an error message is returned,
116 ; pass by reference
117 ;
118 N SUCCESS,DATA
119 S SUCCESS=1
120 S ERROR=""
121 ;
122 D ; drops out if an invalid condition is found
123 .I $G(DFN),$D(^DGSL(38.1,DFN,0))
124 .E S SUCCESS=0,ERROR="DG SECURITY LOG RECORD NOT FOUND" Q
125 .I '$$LOCK(DFN) S SUCCESS=0,ERROR="SECURITY LOG RECORD IS LOCKED, CAN NOT BE EDITED" Q
126 .S DATA(2)=DGSEC("LEVEL")
127 .S DATA(3)=DGSEC("USER")
128 .S DATA(4)=DGSEC("DATETIME")
129 .S DATA(5)=DGSEC("SOURCE")
130 .I '$$UPD^DGENDBS(38.1,DFN,.DATA) S ERROR="FILEMAN UNABLE TO PERFORM UPDATE",SUCCESS=0 Q
131 ;
132 D UNLOCK(DFN)
133 ;
134 Q SUCCESS
135 ;
136 ;
137CHECK(DGSEC,ERROR) ;
138 ; Description: Performs validation checks on DG SECURITY LOG record
139 ; contained in the DGSEC array.
140 ;
141 ; Input:
142 ; DGSEC - as the patient security array, passed by reference
143 ;
144 ; Output:
145 ; Function Value - Returns 1 if validation checks passed, 0 otherwise
146 ; ERROR - if validation checks fail, an error message is
147 ; returned, pass by reference
148 ;
149 N VALID,RESULT,EXTERNAL
150 S VALID=1,ERROR=""
151 ;
152 D ; drops out of block if an invalid condition is found
153 .;
154 .I '$G(DGSEC("DFN")) S VALID=0,ERROR="PATIENT NOT FOUND IN DATABASE" Q
155 .I '$D(^DPT(DGSEC("DFN"),0)) S VALID=0,ERROR="PATIENT NOT FOUND IN DATABASE" Q
156 .;
157 .; check for required fields
158 .I $G(DGSEC("LEVEL"))="" S VALID=0,ERROR="REQUIRED FIELD 'SECURITY LEVEL' MISSING" Q
159 .I $G(DGSEC("USER"))="" S VALID=0,ERROR="REQUIRED FIELD 'SECURITY ASSIGNED BY' MISSING" Q
160 .I $G(DGSEC("DATETIME"))="" S VALID=0,ERROR="REQUIRED FIELD 'DATE/TIME SECURITY ASSIGNED' MISSING" Q
161 .I $G(DGSEC("SOURCE"))="" S VALID=0,ERROR="REQUIRED FIELD 'SECURITY SOURCE' MISSING" Q
162 .;
163 .; apply consistency rules
164 .I DGSEC("LEVEL")'=1 S VALID=0,ERROR="'SECURITY LEVEL' OTHER THAN SENSITIVE NOT ALLOWED" Q
165 .;Remove consistency check for SOURCE - DG*5.3*653
166 .;I DGSEC("SOURCE")'="AAC" S VALID=0,ERROR="'SECURITY SOURCE' OTHER THAN AAC NOT ALLOWED" Q
167 .;
168 .; check if field values are valid
169 .S EXTERNAL=$$EXTERNAL^DILFD(38.1,2,"",DGSEC("LEVEL"))
170 .I EXTERNAL="" S VALID=0,ERROR="'SECURITY LEVEL' NOT VALID" Q
171 .S EXTERNAL=$$EXTERNAL^DILFD(38.1,4,"",DGSEC("DATETIME"))
172 .I EXTERNAL="" S VALID=0,ERROR="'DATE/TIME SECURITY ASSIGNED' NOT VALID" Q
173 .I ($L($G(DGSEC("SOURCE")))<1)!($L($G(DGSEC("SOURCE")))>65) S VALID=0,ERROR="'SECURITY SOURCE' NOT VALID" Q
174 ;
175 Q VALID
176 ;
177 ;
178EXT(SUB,VALUE) ; Description: Given the subscript used in the PATIENT SECURITY
179 ; array and a field value, this function returns the external
180 ; representation of the value, as defined in the fields output
181 ; transform of the DG SECURITY LOG file.
182 ;
183 ; Input:
184 ; SUB - array subscript defined for the PATIENT SECURITY object
185 ; VALUE - field value
186 ;
187 ; Output:
188 ; Function Value - Returns the external value of the field
189 ;
190 Q:(('$G(SUB)="")!($G(VALUE)="")) ""
191 ;
192 N FIELD
193 S FIELD=$S(SUB="DFN":.01,SUB="LEVEL":2,SUB="USER":3,SUB="DATETIME":4,SUB="SOURCE":5,1:"")
194 ;
195 Q:(FIELD="") ""
196 ;
197 Q $$EXTERNAL^DILFD(38.1,FIELD,"F",VALUE)
Note: See TracBrowser for help on using the repository browser.