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

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

initial load of FOIAVistA 6/30/08 version

File size: 3.3 KB
Line 
1DGENDBS ;ALB/RMO/CJM - Database Server Utilities; [ 03/23/95 11:08 AM ]
2 ;;5.3;Registration;**122,147,182**;08/13/93
3 ;
4UPD(FILE,DGENDA,DATA,ERROR) ;File data into an existing record.
5 ; Input:
6 ; FILE - File or sub-file number
7 ; DGENDA - New name for traditional DA array, with same meaning.
8 ; Pass by reference.
9 ; DATA - Data array to file (pass by reference)
10 ; Format: DATA(<field #>)=<value>
11 ;
12 ; Output:
13 ; Function Value - 0=error and 1=no error
14 ; ERROR - optional error message - if needed, pass by reference
15 ;
16 ; Example: To update a record in subfile 2.0361 in record with ien=353,
17 ; subrecord ien=68, with the field .01 value = 21:
18 ; S DATA(.01)=21,DGENDA=68,DGENDA(1)=353 I $$UPD^DGENDBS(2.0361,.DGENDA,.DATA,.ERROR) W !,"DONE"
19 ;
20 N FDA,FIELD,IENS,ERRORS
21 ;
22 ;IENS - Internal Entry Number String defined by FM
23 ;FDA - the FDA array as defined by FM
24 ;
25 I '$G(DGENDA) S ERROR="IEN OF RECORD TO BE UPDATED NOT SPECIFIED" Q 0
26 S IENS=$$IENS^DILF(.DGENDA)
27 S FIELD=0
28 F S FIELD=$O(DATA(FIELD)) Q:'FIELD D
29 .S FDA(FILE,IENS,FIELD)=$G(DATA(FIELD))
30 D FILE^DIE("K","FDA","ERRORS(1)")
31 I +$G(DIERR) D
32 .S ERROR=$G(ERRORS(1,"DIERR",1,"TEXT",1))
33 E D
34 .S ERROR=""
35 ;
36 I $S(+$G(DIERR):0,1:1) D CLEAN^DILF Q 1
37 E D CLEAN^DILF Q 0
38 ;
39ADD(FILE,DGENDA,DATA,ERROR,IEN) ;
40 ;Description: Creates a new record and files the data.
41 ; Input:
42 ; FILE - File or sub-file number
43 ; DGENDA - New name for traditional FileMan DA array with same
44 ; meaning. Pass by reference. Only needed if adding to a
45 ; subfile.
46 ; DATA - Data array to file, pass by reference
47 ; Format: DATA(<field #>)=<value>
48 ; IEN - internal entry number to use (optional)
49 ;
50 ; Output:
51 ; Function Value - If no error then it returns the ien of the created record, else returns NULL.
52 ; DGENDA - returns the ien of the new record, NULL if none created. If needed, pass by reference.
53 ; ERROR - optional error message - if needed, pass by reference
54 ;
55 ; Example: To add a record in subfile 2.0361 in the record with ien=353
56 ; with the field .01 value = 21:
57 ; S DATA(.01)=21,DGENDA(1)=353 I $$ADD^DGENDBS(2.0361,.DGENDA,.DATA) W !,"DONE"
58 ;
59 ; Example: If creating a record not in a subfile, would look like this:
60 ; S DATA(.01)=21 I $$ADD^DGENDBS(867,,.DATA) W !,"DONE"
61 ;
62 N FDA,FIELD,IENA,IENS,ERRORS
63 ;
64 ;IENS - Internal Entry Number String defined by FM
65 ;IENA - the Internal Entry Numebr Array defined by FM
66 ;FDA - the FDA array defined by FM
67 ;IEN - the ien of the new record
68 ;
69 S DGENDA="+1"
70 S IENS=$$IENS^DILF(.DGENDA)
71 S FIELD=0
72 F S FIELD=$O(DATA(FIELD)) Q:'FIELD D
73 .S FDA(FILE,IENS,FIELD)=$G(DATA(FIELD))
74 I $G(IEN) S IENA(1)=IEN
75 D UPDATE^DIE("","FDA","IENA","ERRORS(1)")
76 I +$G(DIERR) D
77 .S ERROR=$G(ERRORS(1,"DIERR",1,"TEXT",1))
78 .S IEN=""
79 E D
80 .S IEN=IENA(1)
81 .S ERROR=""
82 D CLEAN^DILF
83 S DGENDA=IEN
84 Q IEN
85 ;
86TESTVAL(FILE,FIELD,VALUE) ;
87 ;Description: returns 1 if VALUE is a valid value for FIELD in FILE
88 ;
89 Q:(('$G(FILE))!('$G(FIELD))) 0
90 ;
91 N DISPLAY,VALID,RESULT
92 S VALID=1
93 ;
94 ;if there is no external value then it is not valid
95 S DISPLAY=$$EXTERNAL^DILFD(FILE,FIELD,"F",VALUE)
96 I (DISPLAY="") S VALID=0
97 ;
98 I VALID,$$GET1^DID(FILE,FIELD,"","TYPE")'["POINTER" D
99 .D CHK^DIE(FILE,FIELD,,VALUE,.RESULT) I RESULT="^" S VALID=0 Q
100 Q VALID
Note: See TracBrowser for help on using the repository browser.