HDISVU02 ;BPFO/JRP - STORE VUIDS FOR SET OF CODES;5/12/2005
;;1.0;HEALTH DATA & INFORMATICS;**1,2**;Feb 22, 2005
;
VUIDL(TAG,ROUTINE) ;Instantiate VUIDs for set of code fields
; Input: TAG - Line tag under which VUID data has been placed
; ROUTINE - Routine line tag is in
; Leave blank if in this routine
;Output: 0 = Stop post-install (error)
; 1 = Continue with post-install
; Notes: Data lines must be in the format
; File~Field~Code~VUID~Status~EffectiveDateTime
; (Status and EffectiveDateTime must be in internal format)
; (Default value for Status is 0 - Inactive)
; (Default value for EffectiveDateTime is NOW)
; : Call assumes that all input (TAG & ROUTINE) is valid
; : Call assumes that data lines are valid
; (i.e. no missing/bad data)
; : The incoming status/date will not be stored in an existing
; entry for the VUID if the currently stored status is the
; same as the input status.
;
N OFFSET,DATA,FILE,FIELD,IREF,VUID,STAT,STDT,DONE,RESULT,HDIMSG
S ROUTINE=$G(ROUTINE)
S RESULT=1
S DONE=0
F OFFSET=1:1 D Q:DONE
.S DATA=$S(ROUTINE="":$T(@TAG+OFFSET),1:$T(@TAG+OFFSET^@ROUTINE))
.S DATA=$P(DATA,";;",2)
.I DATA="" S DONE=1 Q
.S FILE=$P(DATA,"~",1)
.S FIELD=$P(DATA,"~",2)
.S IREF=$P(DATA,"~",3)
.S VUID=$P(DATA,"~",4)
.S STAT=$P(DATA,"~",5)
.I STAT="" S STAT=0
.S STDT=$P(DATA,"~",6)
.I STDT="" S STDT=$$NOW^XLFDT()
.I '$$STOREIT(FILE,FIELD,IREF,VUID,STAT,STDT) D
..S HDIMSG(1)="**"
..S HDIMSG(2)="** Unable to store VUID and/or status information for file"
..S HDIMSG(3)="** "_FILE_", field "_FIELD_", and internal value "_IREF
..S HDIMSG(4)="**"
..D MES^XPDUTL(.HDIMSG) K HDIMSG
..S RESULT=0
Q RESULT
;
STOREIT(FILE,FIELD,IREF,VUID,STAT,STDT) ;Store VUID info
; Input: FILE - File number
; FIELD - Field number
; IREF - Internal reference
; VUID - VUID
; STAT - Status
; 0 = Inacive (default) 1 = Active
; STDT - Status Date/Time (FileMan)
; (Defaults to NOW)
;Output: 1 = Success
; 0 = Failure
; Notes: Existance/validity of input assumed (internal call)
; : Call will automatically inactivate terms when appropriate
; : The input status/date will not be stored in an existing
; entry for the VUID if the currently stored status is the
; same as the input status. Success (1) will be returned.
;
N MASTER,CURSTAT
S STAT=+$G(STAT)
S STDT=+$G(STDT)
I 'STDT S STDT=$$NOW^XLFDT()
;Is VUID already on file
S CURSTAT=$$GETSTAT^XTID(FILE,FIELD,IREF)
;Don't store new date for same status (return SUCCESS)
I $P(CURSTAT,"^",1)=STAT Q 1
;Store VUID (also sets master entry flag, if appropriate)
I '$$SETVUID^XTID(FILE,FIELD,IREF,VUID) Q 0
;Inactivate non-master entries
I '$$GETMASTR^XTID(FILE,FIELD,IREF) D
.S STAT=0
.S STDT=$$NOW^XLFDT()
;Store status
Q $$SETSTAT^XTID(FILE,FIELD,IREF,STAT,STDT)
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HHDISVU02 3065 printed Dec 13, 2024@01:57:06 Page 2
HDISVU02 ;BPFO/JRP - STORE VUIDS FOR SET OF CODES;5/12/2005
+1 ;;1.0;HEALTH DATA & INFORMATICS;**1,2**;Feb 22, 2005
+2 ;
VUIDL(TAG,ROUTINE) ;Instantiate VUIDs for set of code fields
+1 ; Input: TAG - Line tag under which VUID data has been placed
+2 ; ROUTINE - Routine line tag is in
+3 ; Leave blank if in this routine
+4 ;Output: 0 = Stop post-install (error)
+5 ; 1 = Continue with post-install
+6 ; Notes: Data lines must be in the format
+7 ; File~Field~Code~VUID~Status~EffectiveDateTime
+8 ; (Status and EffectiveDateTime must be in internal format)
+9 ; (Default value for Status is 0 - Inactive)
+10 ; (Default value for EffectiveDateTime is NOW)
+11 ; : Call assumes that all input (TAG & ROUTINE) is valid
+12 ; : Call assumes that data lines are valid
+13 ; (i.e. no missing/bad data)
+14 ; : The incoming status/date will not be stored in an existing
+15 ; entry for the VUID if the currently stored status is the
+16 ; same as the input status.
+17 ;
+18 NEW OFFSET,DATA,FILE,FIELD,IREF,VUID,STAT,STDT,DONE,RESULT,HDIMSG
+19 SET ROUTINE=$GET(ROUTINE)
+20 SET RESULT=1
+21 SET DONE=0
+22 FOR OFFSET=1:1
Begin DoDot:1
+23 SET DATA=$SELECT(ROUTINE="":$TEXT(@TAG+OFFSET),1:$TEXT(@TAG+OFFSET^@ROUTINE))
+24 SET DATA=$PIECE(DATA,";;",2)
+25 IF DATA=""
SET DONE=1
QUIT
+26 SET FILE=$PIECE(DATA,"~",1)
+27 SET FIELD=$PIECE(DATA,"~",2)
+28 SET IREF=$PIECE(DATA,"~",3)
+29 SET VUID=$PIECE(DATA,"~",4)
+30 SET STAT=$PIECE(DATA,"~",5)
+31 IF STAT=""
SET STAT=0
+32 SET STDT=$PIECE(DATA,"~",6)
+33 IF STDT=""
SET STDT=$$NOW^XLFDT()
+34 IF '$$STOREIT(FILE,FIELD,IREF,VUID,STAT,STDT)
Begin DoDot:2
+35 SET HDIMSG(1)="**"
+36 SET HDIMSG(2)="** Unable to store VUID and/or status information for file"
+37 SET HDIMSG(3)="** "_FILE_", field "_FIELD_", and internal value "_IREF
+38 SET HDIMSG(4)="**"
+39 DO MES^XPDUTL(.HDIMSG)
KILL HDIMSG
+40 SET RESULT=0
End DoDot:2
End DoDot:1
if DONE
QUIT
+41 QUIT RESULT
+42 ;
STOREIT(FILE,FIELD,IREF,VUID,STAT,STDT) ;Store VUID info
+1 ; Input: FILE - File number
+2 ; FIELD - Field number
+3 ; IREF - Internal reference
+4 ; VUID - VUID
+5 ; STAT - Status
+6 ; 0 = Inacive (default) 1 = Active
+7 ; STDT - Status Date/Time (FileMan)
+8 ; (Defaults to NOW)
+9 ;Output: 1 = Success
+10 ; 0 = Failure
+11 ; Notes: Existance/validity of input assumed (internal call)
+12 ; : Call will automatically inactivate terms when appropriate
+13 ; : The input status/date will not be stored in an existing
+14 ; entry for the VUID if the currently stored status is the
+15 ; same as the input status. Success (1) will be returned.
+16 ;
+17 NEW MASTER,CURSTAT
+18 SET STAT=+$GET(STAT)
+19 SET STDT=+$GET(STDT)
+20 IF 'STDT
SET STDT=$$NOW^XLFDT()
+21 ;Is VUID already on file
+22 SET CURSTAT=$$GETSTAT^XTID(FILE,FIELD,IREF)
+23 ;Don't store new date for same status (return SUCCESS)
+24 IF $PIECE(CURSTAT,"^",1)=STAT
QUIT 1
+25 ;Store VUID (also sets master entry flag, if appropriate)
+26 IF '$$SETVUID^XTID(FILE,FIELD,IREF,VUID)
QUIT 0
+27 ;Inactivate non-master entries
+28 IF '$$GETMASTR^XTID(FILE,FIELD,IREF)
Begin DoDot:1
+29 SET STAT=0
+30 SET STDT=$$NOW^XLFDT()
End DoDot:1
+31 ;Store status
+32 QUIT $$SETSTAT^XTID(FILE,FIELD,IREF,STAT,STDT)