RORUTL19 ;HCIOFO/SG - PATIENT DATA UTILITIES ; 1/29/07 9:53am
;;1.5;CLINICAL CASE REGISTRIES;**2**;Feb 17, 2006;Build 6
;
Q
;
;***** UPDATES THE LOCAL FIELDS
;
; IENS798 IENS of the registry record in the file #798
;
; .LFV Reference to a local variable that stores the
; list of the local field values
;
; Return Values:
; <0 Error code
; 0 Ok. No changes in local fields.
; >1 Ok. Local fields were modified.
;
UPDLFV(IENS798,LFV) ;
N DA,DIK,FLDIEN,IENS,IR,LFCNT,LFIEN,MOD,RC,RORFDA,RORLST,RORMSG,SCR
S (MOD,RC)=0
;
S (LFCNT,LFIEN)=0
F S LFIEN=$O(LFV(LFIEN)) Q:LFIEN'>0 D
. S LFCNT=LFCNT+1,IENS="?+"_LFCNT_","_IENS798
. S RORFDA(798.02,IENS,.01)=LFIEN
. S RORFDA(798.02,IENS,.02)=$P(LFV(LFIEN),U,5)
. S RORFDA(798.02,IENS,1)=$P(LFV(LFIEN),U,6)
;--- Delete values of active fields that are not present in the
; LFV array (deleted by the user). Values of inactive fields
;--- are always left intact.
S SCR="I $$LFACTIVE^RORDD01(+$G(^(0)))"
S IENS=","_IENS798
D LIST^DIC(798.02,IENS,"@;.01I",,,,,"B",SCR,,"RORLST","RORMSG")
Q:$G(DIERR) $$DBS^RORERR("RORMSG",-9,,,798.02,IENS)
S DIK=$$ROOT^DILFD(798.02,IENS),DA(1)=+IENS798
S IR=""
F S IR=$O(RORLST("DILIST","ID",IR)) Q:IR="" D
. S FLDIEN=+RORLST("DILIST","ID",IR,.01)
. I '$D(LFV(FLDIEN)) S DA=+RORLST("DILIST",2,IR) D ^DIK S MOD=1
;--- Store the data
I $D(RORFDA)>1 S MOD=1 D Q:RC<0 RC
. D UPDATE^DIE(,"RORFDA",,"RORMSG")
. S:$G(DIERR) RC=$$DBS^RORERR("RORMSG",-9,,,798.02,IENS798)
;--- Success
Q MOD
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HRORUTL19 1605 printed Dec 13, 2024@01:44:10 Page 2
RORUTL19 ;HCIOFO/SG - PATIENT DATA UTILITIES ; 1/29/07 9:53am
+1 ;;1.5;CLINICAL CASE REGISTRIES;**2**;Feb 17, 2006;Build 6
+2 ;
+3 QUIT
+4 ;
+5 ;***** UPDATES THE LOCAL FIELDS
+6 ;
+7 ; IENS798 IENS of the registry record in the file #798
+8 ;
+9 ; .LFV Reference to a local variable that stores the
+10 ; list of the local field values
+11 ;
+12 ; Return Values:
+13 ; <0 Error code
+14 ; 0 Ok. No changes in local fields.
+15 ; >1 Ok. Local fields were modified.
+16 ;
UPDLFV(IENS798,LFV) ;
+1 NEW DA,DIK,FLDIEN,IENS,IR,LFCNT,LFIEN,MOD,RC,RORFDA,RORLST,RORMSG,SCR
+2 SET (MOD,RC)=0
+3 ;
+4 SET (LFCNT,LFIEN)=0
+5 FOR
SET LFIEN=$ORDER(LFV(LFIEN))
if LFIEN'>0
QUIT
Begin DoDot:1
+6 SET LFCNT=LFCNT+1
SET IENS="?+"_LFCNT_","_IENS798
+7 SET RORFDA(798.02,IENS,.01)=LFIEN
+8 SET RORFDA(798.02,IENS,.02)=$PIECE(LFV(LFIEN),U,5)
+9 SET RORFDA(798.02,IENS,1)=$PIECE(LFV(LFIEN),U,6)
End DoDot:1
+10 ;--- Delete values of active fields that are not present in the
+11 ; LFV array (deleted by the user). Values of inactive fields
+12 ;--- are always left intact.
+13 SET SCR="I $$LFACTIVE^RORDD01(+$G(^(0)))"
+14 SET IENS=","_IENS798
+15 DO LIST^DIC(798.02,IENS,"@;.01I",,,,,"B",SCR,,"RORLST","RORMSG")
+16 if $GET(DIERR)
QUIT $$DBS^RORERR("RORMSG",-9,,,798.02,IENS)
+17 SET DIK=$$ROOT^DILFD(798.02,IENS)
SET DA(1)=+IENS798
+18 SET IR=""
+19 FOR
SET IR=$ORDER(RORLST("DILIST","ID",IR))
if IR=""
QUIT
Begin DoDot:1
+20 SET FLDIEN=+RORLST("DILIST","ID",IR,.01)
+21 IF '$DATA(LFV(FLDIEN))
SET DA=+RORLST("DILIST",2,IR)
DO ^DIK
SET MOD=1
End DoDot:1
+22 ;--- Store the data
+23 IF $DATA(RORFDA)>1
SET MOD=1
Begin DoDot:1
+24 DO UPDATE^DIE(,"RORFDA",,"RORMSG")
+25 if $GET(DIERR)
SET RC=$$DBS^RORERR("RORMSG",-9,,,798.02,IENS798)
End DoDot:1
if RC<0
QUIT RC
+26 ;--- Success
+27 QUIT MOD