DGENSEC ;ALB/KCL/CKN - Patient Security API's ; 5/11/05 12:02pm
;;5.3;Registration;**222,653**;Aug 13,1993;Build 2
;
;
LOCK(DFN) ;
; Description: Used to lock the DG SECURITY LOG record for a patient
;
; Input:
; DFN - internal entry number of record in the DG SECURITY LOG file
;
; Output:
; Function Value: Returns 1 if the DG SECURITY LOG record can be
; locked, otherwise returns 0 on failure
;
I $G(DFN) L +^DGSL(38.1,DFN,0):2
Q $T
;
;
UNLOCK(DFN) ;
; Description: Used to unlock the DG SECURITY LOG record for a patient
;
; Input:
; DFN - internal entry number of record in the DG SECURITY LOG file
;
; Output:
; None
;
I $G(DFN) L -^DGSL(38.1,DFN,0)
Q
;
;
FINDSEC(DFN) ;
; Description: Used to find a record in the DG SECURITY LOG file
;
; Input:
; DFN - Patient IEN
;
; Output:
; Function Value: If successful, returns internal entry number of
; DG SECURITY LOG file, otherwise returns 0 on failure
;
Q:'$G(DFN)="" 0
Q +$O(^DGSL(38.1,"B",DFN,0))
;
;
GET(SECIEN,DGSEC) ;
; Description: Used to obtain a record in the DG SECURITY LOG file. The values will be returned in the DGSEC() array.
;
; Input:
; SECIEN - internal entry number of record in the DG SECURITY LOG file
;
; Output:
; DGSEC - the patient security array, passed by reference
; subscripts are:
; "DFN" Patient
; "LEVEL" Security Level
; "USER" Security Assigned By
; "DATETIME" Date/Time Security Assigned
; "SOURCE" Secuity Source
;
N SUB,NODE0
K DGSEC S DGSEC=""
;
I '$G(SECIEN) D Q 0
.F SUB="DFN","LEVEL","USER","DATETIME","SOURCE" S DGSEC(SUB)=""
;
S NODE0=$G(^DGSL(38.1,SECIEN,0))
S DGSEC("DFN")=$P(NODE0,"^")
S DGSEC("LEVEL")=$P(NODE0,"^",2)
S DGSEC("USER")=$P(NODE0,"^",3)
S DGSEC("DATETIME")=$P(NODE0,"^",4)
S DGSEC("SOURCE")=$P(NODE0,"^",5)
Q 1
;
;
STORE(DGSEC,ERROR) ;
; Description: Creates a new entry in the DG SECURITY LOG file.
;
; Input:
; DGSEC - as array containing the DG SECURITY LOG record,
; passed by reference
;
; Output:
; Function Value: Returns internal entry number of the entry created,
; otherwise 0 is returned
; ERROR - (optional) if not successful, an error msg is
; returned, pass by reference
;
N DA,DD,DIC,DIE,DLAYGO,DO,DR,X,Y
S DIC(0)="L",(X,DINUM)=DGSEC("DFN"),DIC="^DGSL(38.1,",DLAYGO=38.1
D FILE^DICN
I Y=-1 S ERROR="FILEMAN UNABLE TO CREATE DG SECURITY LOG RECORD" Q 0
S DA=+Y
;
I 'DA S ERROR="FILEMAN UNABLE TO CREATE DG SECURITY LOG RECORD" Q 0
;
; edit/update the new record
I '$$UPDATE(DA,.DGSEC,.ERROR) S ERROR="FILEMAN UNABLE TO CREATE DG SECURITY LOG RECORD" Q 0
;
; quit with ien
Q DA
;
;
UPDATE(DFN,DGSEC,ERROR) ;
; Description: Updates a DG SECURITY LOG record for a patient. This
; function locks the DG SECURITY LOG record and releases the lock
; when the update is complete.
;
; Input:
; DFN - internal entry number of record in the DG SECURITY LOG file
; DGSEC - the DG SECURITY LOG array, passed by reference
;
; Output:
; Function Value - Returns 1 if successful, otherwise 0
; ERROR - if not successful, an error message is returned,
; pass by reference
;
N SUCCESS,DATA
S SUCCESS=1
S ERROR=""
;
D ; drops out if an invalid condition is found
.I $G(DFN),$D(^DGSL(38.1,DFN,0))
.E S SUCCESS=0,ERROR="DG SECURITY LOG RECORD NOT FOUND" Q
.I '$$LOCK(DFN) S SUCCESS=0,ERROR="SECURITY LOG RECORD IS LOCKED, CAN NOT BE EDITED" Q
.S DATA(2)=DGSEC("LEVEL")
.S DATA(3)=DGSEC("USER")
.S DATA(4)=DGSEC("DATETIME")
.S DATA(5)=DGSEC("SOURCE")
.I '$$UPD^DGENDBS(38.1,DFN,.DATA) S ERROR="FILEMAN UNABLE TO PERFORM UPDATE",SUCCESS=0 Q
;
D UNLOCK(DFN)
;
Q SUCCESS
;
;
CHECK(DGSEC,ERROR) ;
; Description: Performs validation checks on DG SECURITY LOG record
; contained in the DGSEC array.
;
; Input:
; DGSEC - as the patient security array, passed by reference
;
; Output:
; Function Value - Returns 1 if validation checks passed, 0 otherwise
; ERROR - if validation checks fail, an error message is
; returned, pass by reference
;
N VALID,RESULT,EXTERNAL
S VALID=1,ERROR=""
;
D ; drops out of block if an invalid condition is found
.;
.I '$G(DGSEC("DFN")) S VALID=0,ERROR="PATIENT NOT FOUND IN DATABASE" Q
.I '$D(^DPT(DGSEC("DFN"),0)) S VALID=0,ERROR="PATIENT NOT FOUND IN DATABASE" Q
.;
.; check for required fields
.I $G(DGSEC("LEVEL"))="" S VALID=0,ERROR="REQUIRED FIELD 'SECURITY LEVEL' MISSING" Q
.I $G(DGSEC("USER"))="" S VALID=0,ERROR="REQUIRED FIELD 'SECURITY ASSIGNED BY' MISSING" Q
.I $G(DGSEC("DATETIME"))="" S VALID=0,ERROR="REQUIRED FIELD 'DATE/TIME SECURITY ASSIGNED' MISSING" Q
.I $G(DGSEC("SOURCE"))="" S VALID=0,ERROR="REQUIRED FIELD 'SECURITY SOURCE' MISSING" Q
.;
.; apply consistency rules
.I DGSEC("LEVEL")'=1 S VALID=0,ERROR="'SECURITY LEVEL' OTHER THAN SENSITIVE NOT ALLOWED" Q
.;Remove consistency check for SOURCE - DG*5.3*653
.;I DGSEC("SOURCE")'="AAC" S VALID=0,ERROR="'SECURITY SOURCE' OTHER THAN AAC NOT ALLOWED" Q
.;
.; check if field values are valid
.S EXTERNAL=$$EXTERNAL^DILFD(38.1,2,"",DGSEC("LEVEL"))
.I EXTERNAL="" S VALID=0,ERROR="'SECURITY LEVEL' NOT VALID" Q
.S EXTERNAL=$$EXTERNAL^DILFD(38.1,4,"",DGSEC("DATETIME"))
.I EXTERNAL="" S VALID=0,ERROR="'DATE/TIME SECURITY ASSIGNED' NOT VALID" Q
.I ($L($G(DGSEC("SOURCE")))<1)!($L($G(DGSEC("SOURCE")))>65) S VALID=0,ERROR="'SECURITY SOURCE' NOT VALID" Q
;
Q VALID
;
;
EXT(SUB,VALUE) ; Description: Given the subscript used in the PATIENT SECURITY
; array and a field value, this function returns the external
; representation of the value, as defined in the fields output
; transform of the DG SECURITY LOG file.
;
; Input:
; SUB - array subscript defined for the PATIENT SECURITY object
; VALUE - field value
;
; Output:
; Function Value - Returns the external value of the field
;
Q:(('$G(SUB)="")!($G(VALUE)="")) ""
;
N FIELD
S FIELD=$S(SUB="DFN":.01,SUB="LEVEL":2,SUB="USER":3,SUB="DATETIME":4,SUB="SOURCE":5,1:"")
;
Q:(FIELD="") ""
;
Q $$EXTERNAL^DILFD(38.1,FIELD,"F",VALUE)
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HDGENSEC 6405 printed Nov 22, 2024@17:53:11 Page 2
DGENSEC ;ALB/KCL/CKN - Patient Security API's ; 5/11/05 12:02pm
+1 ;;5.3;Registration;**222,653**;Aug 13,1993;Build 2
+2 ;
+3 ;
LOCK(DFN) ;
+1 ; Description: Used to lock the DG SECURITY LOG record for a patient
+2 ;
+3 ; Input:
+4 ; DFN - internal entry number of record in the DG SECURITY LOG file
+5 ;
+6 ; Output:
+7 ; Function Value: Returns 1 if the DG SECURITY LOG record can be
+8 ; locked, otherwise returns 0 on failure
+9 ;
+10 IF $GET(DFN)
LOCK +^DGSL(38.1,DFN,0):2
+11 QUIT $TEST
+12 ;
+13 ;
UNLOCK(DFN) ;
+1 ; Description: Used to unlock the DG SECURITY LOG record for a patient
+2 ;
+3 ; Input:
+4 ; DFN - internal entry number of record in the DG SECURITY LOG file
+5 ;
+6 ; Output:
+7 ; None
+8 ;
+9 IF $GET(DFN)
LOCK -^DGSL(38.1,DFN,0)
+10 QUIT
+11 ;
+12 ;
FINDSEC(DFN) ;
+1 ; Description: Used to find a record in the DG SECURITY LOG file
+2 ;
+3 ; Input:
+4 ; DFN - Patient IEN
+5 ;
+6 ; Output:
+7 ; Function Value: If successful, returns internal entry number of
+8 ; DG SECURITY LOG file, otherwise returns 0 on failure
+9 ;
+10 if '$GET(DFN)=""
QUIT 0
+11 QUIT +$ORDER(^DGSL(38.1,"B",DFN,0))
+12 ;
+13 ;
GET(SECIEN,DGSEC) ;
+1 ; Description: Used to obtain a record in the DG SECURITY LOG file. The values will be returned in the DGSEC() array.
+2 ;
+3 ; Input:
+4 ; SECIEN - internal entry number of record in the DG SECURITY LOG file
+5 ;
+6 ; Output:
+7 ; DGSEC - the patient security array, passed by reference
+8 ; subscripts are:
+9 ; "DFN" Patient
+10 ; "LEVEL" Security Level
+11 ; "USER" Security Assigned By
+12 ; "DATETIME" Date/Time Security Assigned
+13 ; "SOURCE" Secuity Source
+14 ;
+15 NEW SUB,NODE0
+16 KILL DGSEC
SET DGSEC=""
+17 ;
+18 IF '$GET(SECIEN)
Begin DoDot:1
+19 FOR SUB="DFN","LEVEL","USER","DATETIME","SOURCE"
SET DGSEC(SUB)=""
End DoDot:1
QUIT 0
+20 ;
+21 SET NODE0=$GET(^DGSL(38.1,SECIEN,0))
+22 SET DGSEC("DFN")=$PIECE(NODE0,"^")
+23 SET DGSEC("LEVEL")=$PIECE(NODE0,"^",2)
+24 SET DGSEC("USER")=$PIECE(NODE0,"^",3)
+25 SET DGSEC("DATETIME")=$PIECE(NODE0,"^",4)
+26 SET DGSEC("SOURCE")=$PIECE(NODE0,"^",5)
+27 QUIT 1
+28 ;
+29 ;
STORE(DGSEC,ERROR) ;
+1 ; Description: Creates a new entry in the DG SECURITY LOG file.
+2 ;
+3 ; Input:
+4 ; DGSEC - as array containing the DG SECURITY LOG record,
+5 ; passed by reference
+6 ;
+7 ; Output:
+8 ; Function Value: Returns internal entry number of the entry created,
+9 ; otherwise 0 is returned
+10 ; ERROR - (optional) if not successful, an error msg is
+11 ; returned, pass by reference
+12 ;
+13 NEW DA,DD,DIC,DIE,DLAYGO,DO,DR,X,Y
+14 SET DIC(0)="L"
SET (X,DINUM)=DGSEC("DFN")
SET DIC="^DGSL(38.1,"
SET DLAYGO=38.1
+15 DO FILE^DICN
+16 IF Y=-1
SET ERROR="FILEMAN UNABLE TO CREATE DG SECURITY LOG RECORD"
QUIT 0
+17 SET DA=+Y
+18 ;
+19 IF 'DA
SET ERROR="FILEMAN UNABLE TO CREATE DG SECURITY LOG RECORD"
QUIT 0
+20 ;
+21 ; edit/update the new record
+22 IF '$$UPDATE(DA,.DGSEC,.ERROR)
SET ERROR="FILEMAN UNABLE TO CREATE DG SECURITY LOG RECORD"
QUIT 0
+23 ;
+24 ; quit with ien
+25 QUIT DA
+26 ;
+27 ;
UPDATE(DFN,DGSEC,ERROR) ;
+1 ; Description: Updates a DG SECURITY LOG record for a patient. This
+2 ; function locks the DG SECURITY LOG record and releases the lock
+3 ; when the update is complete.
+4 ;
+5 ; Input:
+6 ; DFN - internal entry number of record in the DG SECURITY LOG file
+7 ; DGSEC - the DG SECURITY LOG array, passed by reference
+8 ;
+9 ; Output:
+10 ; Function Value - Returns 1 if successful, otherwise 0
+11 ; ERROR - if not successful, an error message is returned,
+12 ; pass by reference
+13 ;
+14 NEW SUCCESS,DATA
+15 SET SUCCESS=1
+16 SET ERROR=""
+17 ;
+18 ; drops out if an invalid condition is found
Begin DoDot:1
+19 IF $GET(DFN)
IF $DATA(^DGSL(38.1,DFN,0))
+20 IF '$TEST
SET SUCCESS=0
SET ERROR="DG SECURITY LOG RECORD NOT FOUND"
QUIT
+21 IF '$$LOCK(DFN)
SET SUCCESS=0
SET ERROR="SECURITY LOG RECORD IS LOCKED, CAN NOT BE EDITED"
QUIT
+22 SET DATA(2)=DGSEC("LEVEL")
+23 SET DATA(3)=DGSEC("USER")
+24 SET DATA(4)=DGSEC("DATETIME")
+25 SET DATA(5)=DGSEC("SOURCE")
+26 IF '$$UPD^DGENDBS(38.1,DFN,.DATA)
SET ERROR="FILEMAN UNABLE TO PERFORM UPDATE"
SET SUCCESS=0
QUIT
End DoDot:1
+27 ;
+28 DO UNLOCK(DFN)
+29 ;
+30 QUIT SUCCESS
+31 ;
+32 ;
CHECK(DGSEC,ERROR) ;
+1 ; Description: Performs validation checks on DG SECURITY LOG record
+2 ; contained in the DGSEC array.
+3 ;
+4 ; Input:
+5 ; DGSEC - as the patient security array, passed by reference
+6 ;
+7 ; Output:
+8 ; Function Value - Returns 1 if validation checks passed, 0 otherwise
+9 ; ERROR - if validation checks fail, an error message is
+10 ; returned, pass by reference
+11 ;
+12 NEW VALID,RESULT,EXTERNAL
+13 SET VALID=1
SET ERROR=""
+14 ;
+15 ; drops out of block if an invalid condition is found
Begin DoDot:1
+16 ;
+17 IF '$GET(DGSEC("DFN"))
SET VALID=0
SET ERROR="PATIENT NOT FOUND IN DATABASE"
QUIT
+18 IF '$DATA(^DPT(DGSEC("DFN"),0))
SET VALID=0
SET ERROR="PATIENT NOT FOUND IN DATABASE"
QUIT
+19 ;
+20 ; check for required fields
+21 IF $GET(DGSEC("LEVEL"))=""
SET VALID=0
SET ERROR="REQUIRED FIELD 'SECURITY LEVEL' MISSING"
QUIT
+22 IF $GET(DGSEC("USER"))=""
SET VALID=0
SET ERROR="REQUIRED FIELD 'SECURITY ASSIGNED BY' MISSING"
QUIT
+23 IF $GET(DGSEC("DATETIME"))=""
SET VALID=0
SET ERROR="REQUIRED FIELD 'DATE/TIME SECURITY ASSIGNED' MISSING"
QUIT
+24 IF $GET(DGSEC("SOURCE"))=""
SET VALID=0
SET ERROR="REQUIRED FIELD 'SECURITY SOURCE' MISSING"
QUIT
+25 ;
+26 ; apply consistency rules
+27 IF DGSEC("LEVEL")'=1
SET VALID=0
SET ERROR="'SECURITY LEVEL' OTHER THAN SENSITIVE NOT ALLOWED"
QUIT
+28 ;Remove consistency check for SOURCE - DG*5.3*653
+29 ;I DGSEC("SOURCE")'="AAC" S VALID=0,ERROR="'SECURITY SOURCE' OTHER THAN AAC NOT ALLOWED" Q
+30 ;
+31 ; check if field values are valid
+32 SET EXTERNAL=$$EXTERNAL^DILFD(38.1,2,"",DGSEC("LEVEL"))
+33 IF EXTERNAL=""
SET VALID=0
SET ERROR="'SECURITY LEVEL' NOT VALID"
QUIT
+34 SET EXTERNAL=$$EXTERNAL^DILFD(38.1,4,"",DGSEC("DATETIME"))
+35 IF EXTERNAL=""
SET VALID=0
SET ERROR="'DATE/TIME SECURITY ASSIGNED' NOT VALID"
QUIT
+36 IF ($LENGTH($GET(DGSEC("SOURCE")))<1)!($LENGTH($GET(DGSEC("SOURCE")))>65)
SET VALID=0
SET ERROR="'SECURITY SOURCE' NOT VALID"
QUIT
End DoDot:1
+37 ;
+38 QUIT VALID
+39 ;
+40 ;
EXT(SUB,VALUE) ; Description: Given the subscript used in the PATIENT SECURITY
+1 ; array and a field value, this function returns the external
+2 ; representation of the value, as defined in the fields output
+3 ; transform of the DG SECURITY LOG file.
+4 ;
+5 ; Input:
+6 ; SUB - array subscript defined for the PATIENT SECURITY object
+7 ; VALUE - field value
+8 ;
+9 ; Output:
+10 ; Function Value - Returns the external value of the field
+11 ;
+12 if (('$GET(SUB)="")!($GET(VALUE)=""))
QUIT ""
+13 ;
+14 NEW FIELD
+15 SET FIELD=$SELECT(SUB="DFN":.01,SUB="LEVEL":2,SUB="USER":3,SUB="DATETIME":4,SUB="SOURCE":5,1:"")
+16 ;
+17 if (FIELD="")
QUIT ""
+18 ;
+19 QUIT $$EXTERNAL^DILFD(38.1,FIELD,"F",VALUE)