HDISVF04 ;ALB/RMO - 7118.11 File Utilities/API Cont.; 1/10/05@11:37:00
;;1.0;HEALTH DATA & INFORMATICS;;Feb 22, 2005
;
;---- Begin HDIS Term/Concept VUID Association file (#7118.11) API(s) ----
;
GETTERM(HDISTERM,HDISFARY,HDISTIEN) ;Get a Term/Concept Entry by Term/Concept and File/Field
; Input -- HDISTERM Term/Concept Text
; HDISFARY File/Field Array - Pass by HDISFARY(HDIS File/Field file #7115.6 IEN)=""
; Output -- 1=Successful and 0=Failure
; If Successful:
; HDISTIEN HDIS Term/Concept VUID Association file IEN
N HDISFIEN,HDISI
;Initialize output
S HDISTIEN=""
;Check for missing variables, exit if not defined
I '$D(HDISTERM)!('$D(HDISFARY)) G GETTERMQ
;Check for existing Term/Concept and File/Field
S HDISFIEN=0
F S HDISFIEN=$O(HDISFARY(HDISFIEN)) Q:'HDISFIEN D
. I $D(^HDISV(7118.11,"AC",HDISFIEN)) D
. S HDISI=0
. F S HDISI=$O(^HDISV(7118.11,"AC",HDISFIEN,HDISI)) Q:'HDISI!($G(HDISTIEN)) D
. . I $D(^HDISV(7118.11,HDISI,0)),$P(^(0),"^",1)=HDISTERM D
. . . S HDISTIEN=HDISI
GETTERMQ Q +$S($G(HDISTIEN)>0:1,1:0)
;
ADDTERM(HDISTERM,HDISVUID,HDISFARY,HDISNTLF,HDISCKTF,HDISEDTM,HDISSTAT,HDISTIEN,HDISERRM) ;Add a New Term/Concept Entry
; Input -- HDISTERM Term/Concept Text
; HDISVUID VUID
; HDISFARY File/Field Array - Pass by HDISFARY(HDIS File/Field file #7115.6 IEN)=""
; HDISNTLF National Standard Flag (Optional- Default 0)
; 1=Yes and 0=No
; HDISCKTF Check for Existing Term/Concept Flag (Optional- Default 1)
; 1=Yes and 0=No
; HDISEDTM Effective Date/Time (Optional- Default NOW)
; HDISSTAT Status (Optional- Default 0)
; 1=Active and 0=Inactive
; Output -- 1=Successful and 0=Failure
; If Successful:
; HDISTIEN HDIS Term/Concept VUID Association file IEN
; If Failure:
; HDISERRM Error Message (Optional)
N HDISCNT,HDISERRF,HDISFDA,HDISFFNM,HDISFIEN,HDISI,HDISIEN,HDISIENS,HDISMSG,HDISNDTF,HDISOKF
;Initialize output
S (HDISTIEN,HDISERRM)=""
;Check for missing variables, exit if not defined
I '$D(HDISTERM)!($G(HDISVUID)'>0)!('$D(HDISFARY)) D G ADDTERMQ
. S HDISERRM="Required Variable Missing."
;Set National Standard Flag to default of 0, if needed
S HDISNTLF=$S('$D(HDISNTLF):0,1:HDISNTLF)
;Set No Effective Date/Time Flag to 1 if there is no Effective Date/Time and no Status
I '$G(HDISEDTM),'$G(HDISSTAT) D
. S HDISNDTF=1
;If No Effective Date/Time Flag is set to 1, Effective Date/Time Multiple should not be created
I '$G(HDISNDTF) D
. ;Set Effective Date/Time to default of NOW, if needed
. S HDISEDTM=$S('$D(HDISEDTM):$$NOW^XLFDT,1:HDISEDTM)
. ;Set Status to default of 0, if needed
. S HDISSTAT=$S('$D(HDISSTAT):0,1:HDISSTAT)
;Set Check for Existing Term/Concept Flag to default of 1, if needed
S HDISCKTF=$S('$D(HDISCKTF):1,1:HDISCKTF)
;Check for existing Term/Concept and File/Field, return error and exit if it exists
I $G(HDISCKTF),$$GETTERM(HDISTERM,.HDISFARY) D G ADDTERMQ
. S HDISERRM="Term/Concept and File/Field already exists."
;Check for existing Term/Concept and VUID, return error and exit if it exists
I $$GETIENS(HDISVUID,.HDISIENS) D G ADDTERMQ:$G(HDISERRF)
. S HDISI=0
. F S HDISI=$O(HDISIENS(HDISI)) Q:'HDISI!($G(HDISERRF)) I $G(HDISIENS(HDISI))=HDISTERM D
. . S HDISERRF=1
. . S HDISERRM="Term/Concept and VUID already exists."
;Set array for Term/Concept and VUID
S HDISFDA(7118.11,"+1,",.01)=$G(HDISTERM)
S HDISFDA(7118.11,"+1,",99.99)=$G(HDISVUID)
;Set array for National Standard Flag to Yes
I $G(HDISNTLF) D
. S HDISFDA(7118.11,"+1,",1.02)=1
ELSE D
. ;Set array for Date/Time Created and National Standard Flag to No
. S HDISFDA(7118.11,"+1,",1.01)=$$NOW^XLFDT
. S HDISFDA(7118.11,"+1,",1.02)=0
;If No Effective Date/Time Flag is set to 1, Effective Date/Time Multiple should not be created
I '$G(HDISNDTF) D
. ;Set array for Effective Date/Time and Status
. S HDISFDA(7118.12,"+2,+1,",.01)=$G(HDISEDTM)
. S HDISFDA(7118.12,"+2,+1,",.02)=$G(HDISSTAT)
;Set array for File/Field
S HDISFIEN=0
S HDISCNT=2
F S HDISFIEN=$O(HDISFARY(HDISFIEN)) Q:'HDISFIEN I $D(^HDIS(7115.6,HDISFIEN,0)) S HDISFFNM=$P(^(0),"^",1) D
. S HDISCNT=HDISCNT+1
. S HDISFDA(7118.13,"+"_HDISCNT_",+1,",.01)=HDISFFNM
D UPDATE^DIE("E","HDISFDA","HDISIEN","HDISMSG")
;Check for error
I $D(HDISMSG("DIERR")) D
. S HDISERRM=$G(HDISMSG("DIERR",1,"TEXT",1))
ELSE D
. S HDISTIEN=+$G(HDISIEN(1))
. S HDISOKF=1
D CLEAN^DILF
ADDTERMQ Q +$G(HDISOKF)
;
GETIENS(HDISVUID,HDISIENS) ;Get IENS for a Term/Concept by VUID
; Input -- HDISVUID VUID
; Output -- 1=Successful and 0=Failure
; If Successful:
; HDISIENS Array where HDISIENS(IEN)=Term/Concept field (#.01)
N HDISI
;Initialize output
K HDISIENS
;Check for missing variable, exit if not defined
I $G(HDISVUID)'>0 G GETIENSQ
;Check for entries by VUID
S HDISI=0
F S HDISI=$O(^HDISV(7118.11,"AVUID",HDISVUID,HDISI)) Q:'HDISI D
. I $D(^HDISV(7118.11,HDISI,0)) S HDISIENS(HDISI)=$P($G(^(0)),"^",1)
GETIENSQ Q +$S($D(HDISIENS):1,1:0)
;
GETVUID(HDISTIEN,HDISVUID) ;Get VUID for a Term/Concept by IEN
; Input -- HDISTIEN HDIS Term/Concept VUID Association file IEN
; Output -- 1=Successful and 0=Failure
; If Successful:
; HDISVUID VUID
;Initialize output
S HDISVUID=""
;Check for missing variable, exit if not defined
I $G(HDISTIEN)'>0 G GETVUIDQ
;Check for VUID by IEN
I $D(^HDISV(7118.11,HDISTIEN,"VUID")) S HDISVUID=$P($G(^("VUID")),"^",1)
GETVUIDQ Q +$S($G(HDISVUID)>0:1,1:0)
;
GETNTLF(HDISTIEN,HDISNTLF) ;Get National Standard Flag for a Term/Concept by IEN
; Input -- HDISTIEN HDIS Term/Concept VUID Association file IEN
; Output -- 1=Successful and 0=Failure
; If Successful:
; HDISNTLF National Standard Flag
;Initialize output
S HDISNTLF=""
;Check for missing variable, exit if not defined
I $G(HDISTIEN)'>0 G GETNTLFQ
;Check for National Standard Flag by IEN
I $D(^HDISV(7118.11,HDISTIEN,1)) S HDISNTLF=$P($G(^(1)),"^",2)
GETNTLFQ Q +$S($G(HDISNTLF)]"":1,1:0)
;
GETSTAT(HDISTIEN,HDISDTM,HDISEDTM,HDISSTAT) ;Get Effective Date and Status for a Term/Concept by IEN and Date/Time
; Input -- HDISTIEN HDIS Term/Concept VUID Association file IEN
; HDISDTM Date/Time (Optional- Default NOW for Current)
; Output -- 1=Successful and 0=Failure
; If Successful:
; HDISEDTM Effective Date/Time
; HDISSTAT Status
N HDIS0,HDISII
;Initialize output
S (HDISEDTM,HDISSTAT)=""
;Check for missing variable, exit if not defined
I $G(HDISTIEN)'>0 G GETSTATQ
;Set Date/Time to default of NOW for Current, if needed
S HDISDTM=$S('$D(HDISDTM):$$NOW^XLFDT,1:HDISDTM)
S:'$P(HDISDTM,".",2) HDISDTM=HDISDTM_.235959
;Get Effective Date/Time Multiple IEN by IEN and Date/Time
S HDISII=+$O(^(+$O(^HDISV(7118.11,HDISTIEN,"TERMSTATUS","B",HDISDTM),-1),0))
;Check for Effective Date/Time and Status
I $D(^HDISV(7118.11,HDISTIEN,"TERMSTATUS",HDISII,0)) S HDIS0=$G(^(0)) D
. S HDISEDTM=$P(HDIS0,"^",1)
. S HDISSTAT=$P(HDIS0,"^",2)
GETSTATQ Q +$S($G(HDISEDTM)'=""&($G(HDISSTAT)'=""):1,1:0)
;
;---- End HDIS Term/Concept VUID Association file (#7118.11) API(s) ----
HDISVF04 ;ALB/RMO - 7118.11 File Utilities/API Cont.; 1/10/05@11:37:00
+1 ;;1.0;HEALTH DATA & INFORMATICS;;Feb 22, 2005
+2 ;
+3 ;---- Begin HDIS Term/Concept VUID Association file (#7118.11) API(s) ----
+4 ;
GETTERM(HDISTERM,HDISFARY,HDISTIEN) ;Get a Term/Concept Entry by Term/Concept and File/Field
+1 ; Input -- HDISTERM Term/Concept Text
+2 ; HDISFARY File/Field Array - Pass by HDISFARY(HDIS File/Field file #7115.6 IEN)=""
+3 ; Output -- 1=Successful and 0=Failure
+4 ; If Successful:
+5 ; HDISTIEN HDIS Term/Concept VUID Association file IEN
+6 NEW HDISFIEN,HDISI
+7 ;Initialize output
+8 SET HDISTIEN=""
+9 ;Check for missing variables, exit if not defined
+10 IF '$DATA(HDISTERM)!('$DATA(HDISFARY))
GOTO GETTERMQ
+11 ;Check for existing Term/Concept and File/Field
+12 SET HDISFIEN=0
+13 FOR
SET HDISFIEN=$ORDER(HDISFARY(HDISFIEN))
IF 'HDISFIEN
QUIT
Begin DoDot:1
+14 IF $DATA(^HDISV(7118.11,"AC",HDISFIEN))
Begin DoDot:2
End DoDot:2
+15 SET HDISI=0
+16 FOR
SET HDISI=$ORDER(^HDISV(7118.11,"AC",HDISFIEN,HDISI))
IF 'HDISI!($GET(HDISTIEN))
QUIT
Begin DoDot:2
+17 IF $DATA(^HDISV(7118.11,HDISI,0))
IF $PIECE(^(0),"^",1)=HDISTERM
Begin DoDot:3
+18 SET HDISTIEN=HDISI
End DoDot:3
End DoDot:2
End DoDot:1
GETTERMQ QUIT +$SELECT($GET(HDISTIEN)>0:1,1:0)
+1 ;
ADDTERM(HDISTERM,HDISVUID,HDISFARY,HDISNTLF,HDISCKTF,HDISEDTM,HDISSTAT,HDISTIEN,HDISERRM) ;Add a New Term/Concept Entry
+1 ; Input -- HDISTERM Term/Concept Text
+2 ; HDISVUID VUID
+3 ; HDISFARY File/Field Array - Pass by HDISFARY(HDIS File/Field file #7115.6 IEN)=""
+4 ; HDISNTLF National Standard Flag (Optional- Default 0)
+5 ; 1=Yes and 0=No
+6 ; HDISCKTF Check for Existing Term/Concept Flag (Optional- Default 1)
+7 ; 1=Yes and 0=No
+8 ; HDISEDTM Effective Date/Time (Optional- Default NOW)
+9 ; HDISSTAT Status (Optional- Default 0)
+10 ; 1=Active and 0=Inactive
+11 ; Output -- 1=Successful and 0=Failure
+12 ; If Successful:
+13 ; HDISTIEN HDIS Term/Concept VUID Association file IEN
+14 ; If Failure:
+15 ; HDISERRM Error Message (Optional)
+16 NEW HDISCNT,HDISERRF,HDISFDA,HDISFFNM,HDISFIEN,HDISI,HDISIEN,HDISIENS,HDISMSG,HDISNDTF,HDISOKF
+17 ;Initialize output
+18 SET (HDISTIEN,HDISERRM)=""
+19 ;Check for missing variables, exit if not defined
+20 IF '$DATA(HDISTERM)!($GET(HDISVUID)'>0)!('$DATA(HDISFARY))
Begin DoDot:1
+21 SET HDISERRM="Required Variable Missing."
End DoDot:1
GOTO ADDTERMQ
+22 ;Set National Standard Flag to default of 0, if needed
+23 SET HDISNTLF=$SELECT('$DATA(HDISNTLF):0,1:HDISNTLF)
+24 ;Set No Effective Date/Time Flag to 1 if there is no Effective Date/Time and no Status
+25 IF '$GET(HDISEDTM)
IF '$GET(HDISSTAT)
Begin DoDot:1
+26 SET HDISNDTF=1
End DoDot:1
+27 ;If No Effective Date/Time Flag is set to 1, Effective Date/Time Multiple should not be created
+28 IF '$GET(HDISNDTF)
Begin DoDot:1
+29 ;Set Effective Date/Time to default of NOW, if needed
+30 SET HDISEDTM=$SELECT('$DATA(HDISEDTM):$$NOW^XLFDT,1:HDISEDTM)
+31 ;Set Status to default of 0, if needed
+32 SET HDISSTAT=$SELECT('$DATA(HDISSTAT):0,1:HDISSTAT)
End DoDot:1
+33 ;Set Check for Existing Term/Concept Flag to default of 1, if needed
+34 SET HDISCKTF=$SELECT('$DATA(HDISCKTF):1,1:HDISCKTF)
+35 ;Check for existing Term/Concept and File/Field, return error and exit if it exists
+36 IF $GET(HDISCKTF)
IF $$GETTERM(HDISTERM,.HDISFARY)
Begin DoDot:1
+37 SET HDISERRM="Term/Concept and File/Field already exists."
End DoDot:1
GOTO ADDTERMQ
+38 ;Check for existing Term/Concept and VUID, return error and exit if it exists
+39 IF $$GETIENS(HDISVUID,.HDISIENS)
Begin DoDot:1
+40 SET HDISI=0
+41 FOR
SET HDISI=$ORDER(HDISIENS(HDISI))
IF 'HDISI!($GET(HDISERRF))
QUIT
IF $GET(HDISIENS(HDISI))=HDISTERM
Begin DoDot:2
+42 SET HDISERRF=1
+43 SET HDISERRM="Term/Concept and VUID already exists."
End DoDot:2
End DoDot:1
IF $GET(HDISERRF)
GOTO ADDTERMQ
+44 ;Set array for Term/Concept and VUID
+45 SET HDISFDA(7118.11,"+1,",.01)=$GET(HDISTERM)
+46 SET HDISFDA(7118.11,"+1,",99.99)=$GET(HDISVUID)
+47 ;Set array for National Standard Flag to Yes
+48 IF $GET(HDISNTLF)
Begin DoDot:1
+49 SET HDISFDA(7118.11,"+1,",1.02)=1
End DoDot:1
+50 IF '$TEST
Begin DoDot:1
+51 ;Set array for Date/Time Created and National Standard Flag to No
+52 SET HDISFDA(7118.11,"+1,",1.01)=$$NOW^XLFDT
+53 SET HDISFDA(7118.11,"+1,",1.02)=0
End DoDot:1
+54 ;If No Effective Date/Time Flag is set to 1, Effective Date/Time Multiple should not be created
+55 IF '$GET(HDISNDTF)
Begin DoDot:1
+56 ;Set array for Effective Date/Time and Status
+57 SET HDISFDA(7118.12,"+2,+1,",.01)=$GET(HDISEDTM)
+58 SET HDISFDA(7118.12,"+2,+1,",.02)=$GET(HDISSTAT)
End DoDot:1
+59 ;Set array for File/Field
+60 SET HDISFIEN=0
+61 SET HDISCNT=2
+62 FOR
SET HDISFIEN=$ORDER(HDISFARY(HDISFIEN))
IF 'HDISFIEN
QUIT
IF $DATA(^HDIS(7115.6,HDISFIEN,0))
SET HDISFFNM=$PIECE(^(0),"^",1)
Begin DoDot:1
+63 SET HDISCNT=HDISCNT+1
+64 SET HDISFDA(7118.13,"+"_HDISCNT_",+1,",.01)=HDISFFNM
End DoDot:1
+65 DO UPDATE^DIE("E","HDISFDA","HDISIEN","HDISMSG")
+66 ;Check for error
+67 IF $DATA(HDISMSG("DIERR"))
Begin DoDot:1
+68 SET HDISERRM=$GET(HDISMSG("DIERR",1,"TEXT",1))
End DoDot:1
+69 IF '$TEST
Begin DoDot:1
+70 SET HDISTIEN=+$GET(HDISIEN(1))
+71 SET HDISOKF=1
End DoDot:1
+72 DO CLEAN^DILF
ADDTERMQ QUIT +$GET(HDISOKF)
+1 ;
GETIENS(HDISVUID,HDISIENS) ;Get IENS for a Term/Concept by VUID
+1 ; Input -- HDISVUID VUID
+2 ; Output -- 1=Successful and 0=Failure
+3 ; If Successful:
+4 ; HDISIENS Array where HDISIENS(IEN)=Term/Concept field (#.01)
+5 NEW HDISI
+6 ;Initialize output
+7 KILL HDISIENS
+8 ;Check for missing variable, exit if not defined
+9 IF $GET(HDISVUID)'>0
GOTO GETIENSQ
+10 ;Check for entries by VUID
+11 SET HDISI=0
+12 FOR
SET HDISI=$ORDER(^HDISV(7118.11,"AVUID",HDISVUID,HDISI))
IF 'HDISI
QUIT
Begin DoDot:1
+13 IF $DATA(^HDISV(7118.11,HDISI,0))
SET HDISIENS(HDISI)=$PIECE($GET(^(0)),"^",1)
End DoDot:1
GETIENSQ QUIT +$SELECT($DATA(HDISIENS):1,1:0)
+1 ;
GETVUID(HDISTIEN,HDISVUID) ;Get VUID for a Term/Concept by IEN
+1 ; Input -- HDISTIEN HDIS Term/Concept VUID Association file IEN
+2 ; Output -- 1=Successful and 0=Failure
+3 ; If Successful:
+4 ; HDISVUID VUID
+5 ;Initialize output
+6 SET HDISVUID=""
+7 ;Check for missing variable, exit if not defined
+8 IF $GET(HDISTIEN)'>0
GOTO GETVUIDQ
+9 ;Check for VUID by IEN
+10 IF $DATA(^HDISV(7118.11,HDISTIEN,"VUID"))
SET HDISVUID=$PIECE($GET(^("VUID")),"^",1)
GETVUIDQ QUIT +$SELECT($GET(HDISVUID)>0:1,1:0)
+1 ;
GETNTLF(HDISTIEN,HDISNTLF) ;Get National Standard Flag for a Term/Concept by IEN
+1 ; Input -- HDISTIEN HDIS Term/Concept VUID Association file IEN
+2 ; Output -- 1=Successful and 0=Failure
+3 ; If Successful:
+4 ; HDISNTLF National Standard Flag
+5 ;Initialize output
+6 SET HDISNTLF=""
+7 ;Check for missing variable, exit if not defined
+8 IF $GET(HDISTIEN)'>0
GOTO GETNTLFQ
+9 ;Check for National Standard Flag by IEN
+10 IF $DATA(^HDISV(7118.11,HDISTIEN,1))
SET HDISNTLF=$PIECE($GET(^(1)),"^",2)
GETNTLFQ QUIT +$SELECT($GET(HDISNTLF)]"":1,1:0)
+1 ;
GETSTAT(HDISTIEN,HDISDTM,HDISEDTM,HDISSTAT) ;Get Effective Date and Status for a Term/Concept by IEN and Date/Time
+1 ; Input -- HDISTIEN HDIS Term/Concept VUID Association file IEN
+2 ; HDISDTM Date/Time (Optional- Default NOW for Current)
+3 ; Output -- 1=Successful and 0=Failure
+4 ; If Successful:
+5 ; HDISEDTM Effective Date/Time
+6 ; HDISSTAT Status
+7 NEW HDIS0,HDISII
+8 ;Initialize output
+9 SET (HDISEDTM,HDISSTAT)=""
+10 ;Check for missing variable, exit if not defined
+11 IF $GET(HDISTIEN)'>0
GOTO GETSTATQ
+12 ;Set Date/Time to default of NOW for Current, if needed
+13 SET HDISDTM=$SELECT('$DATA(HDISDTM):$$NOW^XLFDT,1:HDISDTM)
+14 IF '$PIECE(HDISDTM,".",2)
SET HDISDTM=HDISDTM_.235959
+15 ;Get Effective Date/Time Multiple IEN by IEN and Date/Time
+16 SET HDISII=+$ORDER(^(+$ORDER(^HDISV(7118.11,HDISTIEN,"TERMSTATUS","B",HDISDTM),-1),0))
+17 ;Check for Effective Date/Time and Status
+18 IF $DATA(^HDISV(7118.11,HDISTIEN,"TERMSTATUS",HDISII,0))
SET HDIS0=$GET(^(0))
Begin DoDot:1
+19 SET HDISEDTM=$PIECE(HDIS0,"^",1)
+20 SET HDISSTAT=$PIECE(HDIS0,"^",2)
End DoDot:1
GETSTATQ QUIT +$SELECT($GET(HDISEDTM)'=""&($GET(HDISSTAT)'=""):1,1:0)
+1 ;
+2 ;---- End HDIS Term/Concept VUID Association file (#7118.11) API(s) ----