| 1 | HDISVF08 ;ALB/RMO - 7118.22 File Utilities/API Cont.; 1/18/05@1:57:00
 | 
|---|
| 2 |  ;;1.0;HEALTH DATA & INFORMATICS;;Feb 22, 2005
 | 
|---|
| 3 |  ;
 | 
|---|
| 4 |  ;---- Begin HDIS Facility Term/Concept Association file (#7118.22) API(s) ----
 | 
|---|
| 5 |  ;
 | 
|---|
| 6 | FINDFAC(HDISYIEN,HDISFIEN,HDISTIEN,HDISIREF,HDISADDF,HDISAIEN,HDISERRM) ;Find or Add a New Facility Term/Concept Entry
 | 
|---|
| 7 |  ; Input  -- HDISYIEN HDIS System file (#7118.21) IEN
 | 
|---|
| 8 |  ;           HDISFIEN HDIS File/Field file (#7115.6) IEN
 | 
|---|
| 9 |  ;           HDISTIEN HDIS Term/Concept VUID Association file (#7118.11) IEN
 | 
|---|
| 10 |  ;           HDISIREF Internal Reference  (Optional)
 | 
|---|
| 11 |  ;           HDISADDF Add a New Entry Flag  (Optional- Default 0)
 | 
|---|
| 12 |  ;                    1=Yes and 0=No
 | 
|---|
| 13 |  ; Output -- 1=Successful and 0=Failure
 | 
|---|
| 14 |  ;           If Successful:
 | 
|---|
| 15 |  ;           HDISAIEN  HDIS Facility Term/Concept Association file IEN
 | 
|---|
| 16 |  ;           If Failure:
 | 
|---|
| 17 |  ;           HDISERRM  Error Message  (Optional)
 | 
|---|
| 18 |  N HDISI,HDISOKF
 | 
|---|
| 19 |  ;Initialize ouput
 | 
|---|
| 20 |  S (HDISAIEN,HDISERRM)=""
 | 
|---|
| 21 |  ;Check for missing variables, exit if not defined
 | 
|---|
| 22 |  I $G(HDISYIEN)'>0!($G(HDISFIEN)'>0)!($G(HDISTIEN)'>0) D  G FINDFACQ
 | 
|---|
| 23 |  . S HDISERRM="Required Variable Missing."
 | 
|---|
| 24 |  ;Check for existing System, File/Field, Term/Concept and Internal Reference, return entry and exit if it exists
 | 
|---|
| 25 |  I $D(^HDISF(7118.22,"AS",HDISYIEN,HDISFIEN,HDISTIEN)) D  G ADDFACQ:$G(HDISAIEN)
 | 
|---|
| 26 |  . S HDISI=0
 | 
|---|
| 27 |  . F  S HDISI=$O(^HDISF(7118.22,"AS",HDISYIEN,HDISFIEN,HDISTIEN,HDISI))  Q:'HDISI!($G(HDISAIEN))  D
 | 
|---|
| 28 |  . . I $D(^HDISF(7118.22,HDISI,0)),$P(^(0),"^",3)=$G(HDISIREF) D
 | 
|---|
| 29 |  . . . S HDISAIEN=HDISI
 | 
|---|
| 30 |  . . . S HDISOKF=1
 | 
|---|
| 31 |  ;If flag set, Add a New Facility Term/Concept Entry
 | 
|---|
| 32 |  I $G(HDISADDF) S HDISOKF=$$ADDFAC(HDISYIEN,HDISFIEN,HDISTIEN,$G(HDISIREF),.HDISAIEN,.HDISERRM)
 | 
|---|
| 33 | FINDFACQ Q +$G(HDISOKF)
 | 
|---|
| 34 |  ;
 | 
|---|
| 35 | ADDFAC(HDISYIEN,HDISFIEN,HDISTIEN,HDISIREF,HDISAIEN,HDISERRM) ;Find or Add a New Facility Term/Concept Entry
 | 
|---|
| 36 |  ; Input  -- HDISYIEN HDIS System file (#7118.21) IEN
 | 
|---|
| 37 |  ;           HDISFIEN HDIS File/Field file (#7115.6) IEN
 | 
|---|
| 38 |  ;           HDISTIEN HDIS Term/Concept VUID Association file (#7118.11) IEN
 | 
|---|
| 39 |  ;           HDISIREF Internal Reference  (Optional)
 | 
|---|
| 40 |  ; Output -- 1=Successful and 0=Failure
 | 
|---|
| 41 |  ;           If Successful:
 | 
|---|
| 42 |  ;           HDISAIEN  HDIS Facility Term/Concept Association file IEN
 | 
|---|
| 43 |  ;           If Failure:
 | 
|---|
| 44 |  ;           HDISERRM  Error Message  (Optional)
 | 
|---|
| 45 |  N HDISFDA,HDISIEN,HDISMSG,HDISOKF
 | 
|---|
| 46 |  ;Initialize ouput
 | 
|---|
| 47 |  S (HDISAIEN,HDISERRM)=""
 | 
|---|
| 48 |  ;Set array for System, File/Field, Internal Reference, Term/Concept and Date/Time Term/Concept Associated
 | 
|---|
| 49 |  S HDISFDA(7118.22,"+1,",.01)=$G(HDISYIEN)
 | 
|---|
| 50 |  S HDISFDA(7118.22,"+1,",.02)=$G(HDISFIEN)
 | 
|---|
| 51 |  I $D(HDISIREF) S HDISFDA(7118.22,"+1,",.03)=$G(HDISIREF)
 | 
|---|
| 52 |  S HDISFDA(7118.22,"+1,",.04)=$G(HDISTIEN)
 | 
|---|
| 53 |  S HDISFDA(7118.22,"+1,",.05)=$$NOW^XLFDT
 | 
|---|
| 54 |  D UPDATE^DIE("","HDISFDA","HDISIEN","HDISMSG")
 | 
|---|
| 55 |  ;Check for error
 | 
|---|
| 56 |  I $D(HDISMSG("DIERR")) D
 | 
|---|
| 57 |  . S HDISERRM=$G(HDISMSG("DIERR",1,"TEXT",1))
 | 
|---|
| 58 |  ELSE  D
 | 
|---|
| 59 |  . S HDISAIEN=+$G(HDISIEN(1))
 | 
|---|
| 60 |  . S HDISOKF=1
 | 
|---|
| 61 |  D CLEAN^DILF
 | 
|---|
| 62 | ADDFACQ Q +$G(HDISOKF)
 | 
|---|
| 63 |  ;
 | 
|---|
| 64 | GETIENS(HDISYIEN,HDISFIEN,HDISTIEN,HDISIENS) ;Get IENS for Facility Term/Concept by System, File/Field and Term/Concept
 | 
|---|
| 65 |  ; Input  -- HDISYIEN HDIS System file (#7118.21) IEN
 | 
|---|
| 66 |  ;           HDISFIEN HDIS File/Field file (#7115.6) IEN
 | 
|---|
| 67 |  ;           HDISTIEN HDIS Term/Concept VUID Association file (#7118.11) IEN
 | 
|---|
| 68 |  ; Output -- 1=Successful and 0=Failure
 | 
|---|
| 69 |  ;           If Successful:
 | 
|---|
| 70 |  ;           HDISIENS Array where HDISIENS(IEN)=Internal Reference field (#.03)
 | 
|---|
| 71 |  N HDISI
 | 
|---|
| 72 |  ;Initialize ouput
 | 
|---|
| 73 |  K HDISIENS
 | 
|---|
| 74 |  ;Check for missing variables, exit if not defined
 | 
|---|
| 75 |  I $G(HDISYIEN)'>0!($G(HDISFIEN)'>0)!($G(HDISTIEN)'>0) G GETIENSQ
 | 
|---|
| 76 |  S HDISI=0
 | 
|---|
| 77 |  F  S HDISI=$O(^HDISF(7118.22,"AS",HDISYIEN,HDISFIEN,HDISTIEN,HDISI))  Q:'HDISI  D
 | 
|---|
| 78 |  . I $D(^HDISF(7118.22,HDISI,0)) S HDISIENS(HDISI)=$P(^(0),"^",3)
 | 
|---|
| 79 | GETIENSQ Q +$S($D(HDISIENS):1,1:0)
 | 
|---|
| 80 |  ;
 | 
|---|
| 81 |  ;---- End HDIS Facility Term/Concept Association file (#7118.22) ----
 | 
|---|