| 1 | HDISVF05 ;ALB/RMO - 7115.6 File Utilities/API Cont.; 1/11/05@2:37:00 | 
|---|
| 2 | ;;1.0;HEALTH DATA & INFORMATICS;;Feb 22, 2005 | 
|---|
| 3 | ; | 
|---|
| 4 | ;---- Begin HDIS File/Field file (#7115.6) API(s) ---- | 
|---|
| 5 | ; | 
|---|
| 6 | ADDFFNM(HDISFILN,HDISFLDN,HDISFIEN,HDISERRM) ;Add a New File/Field Entry | 
|---|
| 7 | ; Input  -- HDISFILN File Number | 
|---|
| 8 | ;           HDISFLDN Field Number  (Optional- Default .01) | 
|---|
| 9 | ; Output -- 1=Successful and 0=Failure | 
|---|
| 10 | ;           If Successful: | 
|---|
| 11 | ;           HDISFIEN  HDIS File/Field file IEN | 
|---|
| 12 | ;           If Failure: | 
|---|
| 13 | ;           HDISERRM  Error Message  (Optional) | 
|---|
| 14 | N HDISFDA,HDISFFNM,HDISIEN,HDISMSG,HDISOKF | 
|---|
| 15 | ;Initialize output | 
|---|
| 16 | S (HDISFIEN,HDISERRM)="" | 
|---|
| 17 | ;Check for missing variable, exit if not defined | 
|---|
| 18 | I $G(HDISFILN)'>0 D  G ADDFFNMQ | 
|---|
| 19 | . S HDISERRM="Required Variable Missing." | 
|---|
| 20 | ;Set Field Number to default of .01, if needed | 
|---|
| 21 | S HDISFLDN=$S('$D(HDISFLDN):.01,1:HDISFLDN) | 
|---|
| 22 | ;Set File/Field Name to file#~field# (i.e. 10.3~.01) | 
|---|
| 23 | S HDISFFNM=HDISFILN_"~"_HDISFLDN | 
|---|
| 24 | ;Check for existing File Number and Field Number, return error and exit if it exists | 
|---|
| 25 | I $D(^HDIS(7115.6,"AFIL",HDISFILN,HDISFLDN)) D  G ADDFFNMQ | 
|---|
| 26 | . S HDISERRM="File Number and Field Number already exists." | 
|---|
| 27 | ;Set array for File/Field Name, File Number and Field Number | 
|---|
| 28 | S HDISFDA(7115.6,"+1,",.01)=$G(HDISFFNM) | 
|---|
| 29 | S HDISFDA(7115.6,"+1,",.02)=$G(HDISFILN) | 
|---|
| 30 | S HDISFDA(7115.6,"+1,",.04)=$G(HDISFLDN) | 
|---|
| 31 | D UPDATE^DIE("E","HDISFDA","HDISIEN","HDISMSG") | 
|---|
| 32 | ;Check for error | 
|---|
| 33 | I $D(HDISMSG("DIERR")) D | 
|---|
| 34 | . S HDISERRM=$G(HDISMSG("DIERR",1,"TEXT",1)) | 
|---|
| 35 | ELSE  D | 
|---|
| 36 | . S HDISFIEN=+$G(HDISIEN(1)) | 
|---|
| 37 | . S HDISOKF=1 | 
|---|
| 38 | D CLEAN^DILF | 
|---|
| 39 | ADDFFNMQ Q +$G(HDISOKF) | 
|---|
| 40 | ; | 
|---|
| 41 | GETIEN(HDISFILN,HDISFLDN,HDISFIEN) ;Get IEN for a File/Field by File Number and Field Number | 
|---|
| 42 | ; Input  -- HDISFILN File Number | 
|---|
| 43 | ;           HDISFLDN Field Number  (Optional- Default .01) | 
|---|
| 44 | ; Output -- 1=Successful and 0=Failure | 
|---|
| 45 | ;           If Successful: | 
|---|
| 46 | ;           HDISFIEN  HDIS File/Field file IEN | 
|---|
| 47 | ;Initialize output | 
|---|
| 48 | S HDISFIEN="" | 
|---|
| 49 | ;Check for missing variable, exit if not defined | 
|---|
| 50 | I $G(HDISFILN)'>0 G GETIENQ | 
|---|
| 51 | ;Set Field Number to .01 default if needed | 
|---|
| 52 | S HDISFLDN=$S('$D(HDISFLDN):.01,1:HDISFLDN) | 
|---|
| 53 | ;Check for entry by File Number and Field Number | 
|---|
| 54 | S HDISFIEN=$O(^HDIS(7115.6,"AFIL",HDISFILN,HDISFLDN,0)) | 
|---|
| 55 | GETIENQ Q +$S($G(HDISFIEN)>0:1,1:0) | 
|---|
| 56 | ; | 
|---|
| 57 | GETFF(HDISFIEN,HDISFILN,HDISFLDN) ;Get File Number and Field Number for a File/Field by IEN | 
|---|
| 58 | ; Input  -- HDISFIEN  HDIS File/Field file IEN | 
|---|
| 59 | ; Output -- 1=Successful and 0=Failure | 
|---|
| 60 | ;           If Successful: | 
|---|
| 61 | ;           HDISFILN File Number | 
|---|
| 62 | ;           HDISFLDN Field Number | 
|---|
| 63 | N HDIS0 | 
|---|
| 64 | ;Initialize output | 
|---|
| 65 | S (HDISFILN,HDISFLDN)="" | 
|---|
| 66 | ;Check for missing variable, exit if not defined | 
|---|
| 67 | I $G(HDISFIEN)'>0 G GETFFQ | 
|---|
| 68 | ;Check for File Number and Field Number by IEN | 
|---|
| 69 | I $D(^HDIS(7115.6,HDISFIEN,0)) S HDIS0=$G(^(0)) D | 
|---|
| 70 | . S HDISFILN=$P(HDIS0,"^",2) | 
|---|
| 71 | . S HDISFLDN=$P(HDIS0,"^",4) | 
|---|
| 72 | GETFFQ Q +$S($G(HDISFILN)'=""&($G(HDISFLDN)'=""):1,1:0) | 
|---|
| 73 | ; | 
|---|
| 74 | ;---- End HDIS File/Field file (#7115.6) API(s) ---- | 
|---|