VBECDC02 ;hoifo/gjc-data conversion & pre-implementation;Nov 21, 2002
 ;;2.0;VBEC;;Jun 05, 2015;Build 4
 ;
 ;Medical Device #:
 ;Note: The food and Drug Administration classifies this software as a
 ;medical device.  As such, it may not be changed in any way.
 ;Modifications to this software may result in an adulterated medical
 ;device under 21CFR820, the use of which is considered to be a
 ;violation of US Federal Statutes.  Acquiring and implementing this
 ;software through the Freedom of Information Act requires the
 ;implementer to assume total responsibility for the software, and
 ;become a registered manufacturer of a medical device, subject to FDA
 ;regulations.
 ;
 ;Call to FILE^DIE is supported by IA: 2053
 ;Call to UPDATE^DIE is supported by IA: 2053
 ;
UP6001F(VBECIEN,LRFINI) ; file the date/time the process finished running for
 ; a record in the VBECS DATA INTEGRITY/CONVERSION STATISTICS (#6001)
 ; file.
 ; input: VBECIEN-the IEN of the record being updated
 ;        LRFINI-the date/time the process completed
 K LRFDA S LRFDA(6001,VBECIEN_",",.03)=LRFINI
 D FILE^DIE("","LRFDA","") K LRFDA
 Q
 ;
UP6001P(VBECIEN) ; delete a VBECS DATA INTEGRITY/CONVERSION STATISTICS
 ; file (#6001) record
 ; input: VBECIEN-the IEN of the record (file: 6001) being deleted
 K LRFDA S LRFDA(6001,VBECIEN_",",.01)="@"
 D FILE^DIE("","LRFDA","") K LRFDA
 Q
 ;
LOGEXC(VBECIEN,LRARY) ; log the error the error and relevant data
 ; Input: VBECIEN-IEN ('D0') of record in file 6001 (top-level)
 ;        LRARY-local array subscripted by...
 ;        .01-file navigated from
 ;        .02-the internal entry number of the file navigated from
 ;        .03-file navigated to
 ;        .04-the internal entry number of the file navigated from
 ;        .05-Lab Data patient identifier (1st of a possible two)
 ;        .06-Lab Data patient identifier (2nd of a possible two)
 ;        .07-duplicated component (blood product)
 ;        .08-duplicated component id (unit id)
 ;        .09-error message code (see ERRMSG subroutine)
 ;
 ; Fields .05-.08 identify the condition where the same patient or
 ; different patients have the same component/component id data
 ; associated with a transfusion record
 ;
 K LRD1,LRIEN,LROOT S LRX=0
 S LRD1=$O(^VBEC(6001,VBECIEN,"ERR",$C(32)),-1)
 S:LRD1="" LRD1=1 ;first instance of anomaly
 S LRIEN="+"_LRD1_","_VBECIEN_","
 F  S LRX=$O(LRARY(LRX)) Q:'LRX  S LROOT(1,6001.01,LRIEN,LRX)=LRARY(LRX)
 D UPDATE^DIE("","LROOT(1)","")
 K LRD1,LRIEN,LROOT,LRX
 Q
 ;
UP6001S(LRSTRT,LRPROC,LRWHO) ; Update the VBECS DATA INTEGRITY/CONVERSION
 ; STATISTICS (#6001) file.
 ;  input: LRSTRT=timestamp of when the process started
 ;         LRPROC=identify the process, 1 for data conversion
 ;                0 for data validation
 ;         LRWHO=user who is responsible for the process
 ; output: LRY(1)=ien of the newly created record in file 6001
 ;
 K LRFDA N LRY
 S LRFDA(1,6001,"+1,",.01)=LRSTRT,LRFDA(1,6001,"+1,",.02)=LRPROC,LRFDA(1,6001,"+1,",.04)=LRWHO
 D UPDATE^DIE("","LRFDA(1)","LRY") K LRFDA
 Q $G(LRY(1))
 ;
ERRMSG ; standard error messages
 ;;1;Laboratory Reference (#63) field, Patient (#2) file data corruption
 ;;2;Patient mismatch between files: Patient (#2) & Lab Data (#63)
 ;;3;Duplicate Patient Merge indicated in Patient Name
 ;;;
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HVBECDC02   3365     printed  Sep 23, 2025@20:20:07                                                                                                                                                                                                    Page 2
VBECDC02  ;hoifo/gjc-data conversion & pre-implementation;Nov 21, 2002
 +1       ;;2.0;VBEC;;Jun 05, 2015;Build 4
 +2       ;
 +3       ;Medical Device #:
 +4       ;Note: The food and Drug Administration classifies this software as a
 +5       ;medical device.  As such, it may not be changed in any way.
 +6       ;Modifications to this software may result in an adulterated medical
 +7       ;device under 21CFR820, the use of which is considered to be a
 +8       ;violation of US Federal Statutes.  Acquiring and implementing this
 +9       ;software through the Freedom of Information Act requires the
 +10      ;implementer to assume total responsibility for the software, and
 +11      ;become a registered manufacturer of a medical device, subject to FDA
 +12      ;regulations.
 +13      ;
 +14      ;Call to FILE^DIE is supported by IA: 2053
 +15      ;Call to UPDATE^DIE is supported by IA: 2053
 +16      ;
UP6001F(VBECIEN,LRFINI) ; file the date/time the process finished running for
 +1       ; a record in the VBECS DATA INTEGRITY/CONVERSION STATISTICS (#6001)
 +2       ; file.
 +3       ; input: VBECIEN-the IEN of the record being updated
 +4       ;        LRFINI-the date/time the process completed
 +5        KILL LRFDA
           SET LRFDA(6001,VBECIEN_",",.03)=LRFINI
 +6        DO FILE^DIE("","LRFDA","")
           KILL LRFDA
 +7        QUIT 
 +8       ;
UP6001P(VBECIEN) ; delete a VBECS DATA INTEGRITY/CONVERSION STATISTICS
 +1       ; file (#6001) record
 +2       ; input: VBECIEN-the IEN of the record (file: 6001) being deleted
 +3        KILL LRFDA
           SET LRFDA(6001,VBECIEN_",",.01)="@"
 +4        DO FILE^DIE("","LRFDA","")
           KILL LRFDA
 +5        QUIT 
 +6       ;
LOGEXC(VBECIEN,LRARY) ; log the error the error and relevant data
 +1       ; Input: VBECIEN-IEN ('D0') of record in file 6001 (top-level)
 +2       ;        LRARY-local array subscripted by...
 +3       ;        .01-file navigated from
 +4       ;        .02-the internal entry number of the file navigated from
 +5       ;        .03-file navigated to
 +6       ;        .04-the internal entry number of the file navigated from
 +7       ;        .05-Lab Data patient identifier (1st of a possible two)
 +8       ;        .06-Lab Data patient identifier (2nd of a possible two)
 +9       ;        .07-duplicated component (blood product)
 +10      ;        .08-duplicated component id (unit id)
 +11      ;        .09-error message code (see ERRMSG subroutine)
 +12      ;
 +13      ; Fields .05-.08 identify the condition where the same patient or
 +14      ; different patients have the same component/component id data
 +15      ; associated with a transfusion record
 +16      ;
 +17       KILL LRD1,LRIEN,LROOT
           SET LRX=0
 +18       SET LRD1=$ORDER(^VBEC(6001,VBECIEN,"ERR",$CHAR(32)),-1)
 +19      ;first instance of anomaly
           if LRD1=""
               SET LRD1=1
 +20       SET LRIEN="+"_LRD1_","_VBECIEN_","
 +21       FOR 
               SET LRX=$ORDER(LRARY(LRX))
               if 'LRX
                   QUIT 
               SET LROOT(1,6001.01,LRIEN,LRX)=LRARY(LRX)
 +22       DO UPDATE^DIE("","LROOT(1)","")
 +23       KILL LRD1,LRIEN,LROOT,LRX
 +24       QUIT 
 +25      ;
UP6001S(LRSTRT,LRPROC,LRWHO) ; Update the VBECS DATA INTEGRITY/CONVERSION
 +1       ; STATISTICS (#6001) file.
 +2       ;  input: LRSTRT=timestamp of when the process started
 +3       ;         LRPROC=identify the process, 1 for data conversion
 +4       ;                0 for data validation
 +5       ;         LRWHO=user who is responsible for the process
 +6       ; output: LRY(1)=ien of the newly created record in file 6001
 +7       ;
 +8        KILL LRFDA
           NEW LRY
 +9        SET LRFDA(1,6001,"+1,",.01)=LRSTRT
           SET LRFDA(1,6001,"+1,",.02)=LRPROC
           SET LRFDA(1,6001,"+1,",.04)=LRWHO
 +10       DO UPDATE^DIE("","LRFDA(1)","LRY")
           KILL LRFDA
 +11       QUIT $GET(LRY(1))
 +12      ;
ERRMSG    ; standard error messages
 +1       ;;1;Laboratory Reference (#63) field, Patient (#2) file data corruption
 +2       ;;2;Patient mismatch between files: Patient (#2) & Lab Data (#63)
 +3       ;;3;Duplicate Patient Merge indicated in Patient Name
 +4       ;;;