DGENUPL5 ;ALB/KCL/GSN - PROCESS INCOMING (Z11 EVENT TYPE) HL7 MESSAGES ; 5/6/03 2:45pm
 ;;5.3;Registration;**222,504,952**;08/13/93;Build 160
 ;
 ;DG*5.3*504 - Now, only updates the DG SECURITY LOG file #38.1 Zero
 ;             node, when SECURITY LEVEL [#2] goes from a Non-sensitive
 ;             value to a Sensitive value, i.e. (null or 0) to 1.
GETLOCKS(DFN) ;
 ; Description - Locks first the patient enrollment history, then the patient record. Used to synchronize the upload with registration and load/edit.
 ;
 ;Input: DFN - ien of patient record.
 ;Output: none
 ;
 N COUNT,DGIEN33
 F COUNT=1:1:500 Q:$$BEGUPLD^DGENUPL3(DFN)
 F COUNT=1:1:500 Q:$$LOCK^DGENA1(DFN)
 F COUNT=1:1:500 Q:$$LOCK^DGENPTA1(DFN)
 S DGIEN33=+$O(^DGOTH(33,"B",DFN,"")) I DGIEN33 F COUNT=1:1:500 Q:$$LOCK^DGOTHUT1(DGIEN33)  ; DG*5.3*952
 Q
 ;
 ;
UNLOCK(DFN) ;
 ; Description: releases the locks obtained by GETLOCKS()
 ;
 ;Input: DFN - ien of patient record
 ;Output: none
 ;
 N DGIEN33
 D ENDUPLD^DGENUPL3(DFN)
 D UNLOCK^DGENA1(DFN)
 D UNLOCK^DGENPTA1(DFN)
 S DGIEN33=+$O(^DGOTH(33,"B",DFN,"")) I DGIEN33 D UNLOCK^DGOTHUT1(DGIEN33) ; DG*5.3*952
 Q
 ;
 ;
SECUPLD(DFN,DGSEC,OLDSEC) ;
 ; Description: Upload a patient security record receieved from the
 ;              HEC. The consistency checks on the record are assumed
 ;              to have been completed.
 ;
 ;  Input:
 ;     DFN - PATIENT ien
 ;   DGSEC - as array containing the patient security record, pass
 ;           by reference
 ;
 ; Output:
 ;  OLDSEC - as array containing the patient security record, prior
 ;           to upload of security data from HEC, pass by reference
 ;   
 ;
 N SECIEN
 ;
 ; is there a local security log record for the patient?
 S SECIEN=$$FINDSEC^DGENSEC(DFN)
 ;
 ; if local security record, obtain record prior to upload
 I $$GET^DGENSEC(SECIEN,.OLDSEC)
 ;
 ; if no local security log record for the patient, create a new
 ; security log entry with HEC security
 I 'SECIEN D
 .I $$STORE^DGENSEC(.DGSEC)
 E  D
 .; otherwise update the existing security log entry with HEC security
 .; if new level = Yes and old level Not = Yes          (DG*5.3*504)
 .I $G(DGSEC("LEVEL"))=1,$G(OLDSEC("LEVEL"))'=1 D
 ..I $$UPDATE^DGENSEC(DFN,.DGSEC)
 .E  D
 ..; since no update occurring, then set arrays the same to prevent an
 ..; Audit record from being created later.
 ..M DGSEC=OLDSEC
 ;
 Q
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HDGENUPL5   2430     printed  Sep 23, 2025@20:19:13                                                                                                                                                                                                    Page 2
DGENUPL5  ;ALB/KCL/GSN - PROCESS INCOMING (Z11 EVENT TYPE) HL7 MESSAGES ; 5/6/03 2:45pm
 +1       ;;5.3;Registration;**222,504,952**;08/13/93;Build 160
 +2       ;
 +3       ;DG*5.3*504 - Now, only updates the DG SECURITY LOG file #38.1 Zero
 +4       ;             node, when SECURITY LEVEL [#2] goes from a Non-sensitive
 +5       ;             value to a Sensitive value, i.e. (null or 0) to 1.
GETLOCKS(DFN) ;
 +1       ; Description - Locks first the patient enrollment history, then the patient record. Used to synchronize the upload with registration and load/edit.
 +2       ;
 +3       ;Input: DFN - ien of patient record.
 +4       ;Output: none
 +5       ;
 +6        NEW COUNT,DGIEN33
 +7        FOR COUNT=1:1:500
               if $$BEGUPLD^DGENUPL3(DFN)
                   QUIT 
 +8        FOR COUNT=1:1:500
               if $$LOCK^DGENA1(DFN)
                   QUIT 
 +9        FOR COUNT=1:1:500
               if $$LOCK^DGENPTA1(DFN)
                   QUIT 
 +10      ; DG*5.3*952
           SET DGIEN33=+$ORDER(^DGOTH(33,"B",DFN,""))
           IF DGIEN33
               FOR COUNT=1:1:500
                   if $$LOCK^DGOTHUT1(DGIEN33)
                       QUIT 
 +11       QUIT 
 +12      ;
 +13      ;
UNLOCK(DFN) ;
 +1       ; Description: releases the locks obtained by GETLOCKS()
 +2       ;
 +3       ;Input: DFN - ien of patient record
 +4       ;Output: none
 +5       ;
 +6        NEW DGIEN33
 +7        DO ENDUPLD^DGENUPL3(DFN)
 +8        DO UNLOCK^DGENA1(DFN)
 +9        DO UNLOCK^DGENPTA1(DFN)
 +10      ; DG*5.3*952
           SET DGIEN33=+$ORDER(^DGOTH(33,"B",DFN,""))
           IF DGIEN33
               DO UNLOCK^DGOTHUT1(DGIEN33)
 +11       QUIT 
 +12      ;
 +13      ;
SECUPLD(DFN,DGSEC,OLDSEC) ;
 +1       ; Description: Upload a patient security record receieved from the
 +2       ;              HEC. The consistency checks on the record are assumed
 +3       ;              to have been completed.
 +4       ;
 +5       ;  Input:
 +6       ;     DFN - PATIENT ien
 +7       ;   DGSEC - as array containing the patient security record, pass
 +8       ;           by reference
 +9       ;
 +10      ; Output:
 +11      ;  OLDSEC - as array containing the patient security record, prior
 +12      ;           to upload of security data from HEC, pass by reference
 +13      ;   
 +14      ;
 +15       NEW SECIEN
 +16      ;
 +17      ; is there a local security log record for the patient?
 +18       SET SECIEN=$$FINDSEC^DGENSEC(DFN)
 +19      ;
 +20      ; if local security record, obtain record prior to upload
 +21       IF $$GET^DGENSEC(SECIEN,.OLDSEC)
 +22      ;
 +23      ; if no local security log record for the patient, create a new
 +24      ; security log entry with HEC security
 +25       IF 'SECIEN
               Begin DoDot:1
 +26               IF $$STORE^DGENSEC(.DGSEC)
               End DoDot:1
 +27      IF '$TEST
               Begin DoDot:1
 +28      ; otherwise update the existing security log entry with HEC security
 +29      ; if new level = Yes and old level Not = Yes          (DG*5.3*504)
 +30               IF $GET(DGSEC("LEVEL"))=1
                       IF $GET(OLDSEC("LEVEL"))'=1
                           Begin DoDot:2
 +31                           IF $$UPDATE^DGENSEC(DFN,.DGSEC)
                           End DoDot:2
 +32              IF '$TEST
                       Begin DoDot:2
 +33      ; since no update occurring, then set arrays the same to prevent an
 +34      ; Audit record from being created later.
 +35                       MERGE DGSEC=OLDSEC
                       End DoDot:2
               End DoDot:1
 +36      ;
 +37       QUIT