Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: DGENSEC

DGENSEC.m

Go to the documentation of this file.
  1. DGENSEC ;ALB/KCL/CKN - Patient Security API's ; 5/11/05 12:02pm
  1. ;;5.3;Registration;**222,653**;Aug 13,1993;Build 2
  1. ;
  1. ;
  1. LOCK(DFN) ;
  1. ; Description: Used to lock the DG SECURITY LOG record for a patient
  1. ;
  1. ; Input:
  1. ; DFN - internal entry number of record in the DG SECURITY LOG file
  1. ;
  1. ; Output:
  1. ; Function Value: Returns 1 if the DG SECURITY LOG record can be
  1. ; locked, otherwise returns 0 on failure
  1. ;
  1. I $G(DFN) L +^DGSL(38.1,DFN,0):2
  1. Q $T
  1. ;
  1. ;
  1. UNLOCK(DFN) ;
  1. ; Description: Used to unlock the DG SECURITY LOG record for a patient
  1. ;
  1. ; Input:
  1. ; DFN - internal entry number of record in the DG SECURITY LOG file
  1. ;
  1. ; Output:
  1. ; None
  1. ;
  1. I $G(DFN) L -^DGSL(38.1,DFN,0)
  1. Q
  1. ;
  1. ;
  1. FINDSEC(DFN) ;
  1. ; Description: Used to find a record in the DG SECURITY LOG file
  1. ;
  1. ; Input:
  1. ; DFN - Patient IEN
  1. ;
  1. ; Output:
  1. ; Function Value: If successful, returns internal entry number of
  1. ; DG SECURITY LOG file, otherwise returns 0 on failure
  1. ;
  1. Q:'$G(DFN)="" 0
  1. Q +$O(^DGSL(38.1,"B",DFN,0))
  1. ;
  1. ;
  1. 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.
  1. ;
  1. ; Input:
  1. ; SECIEN - internal entry number of record in the DG SECURITY LOG file
  1. ;
  1. ; Output:
  1. ; DGSEC - the patient security array, passed by reference
  1. ; subscripts are:
  1. ; "DFN" Patient
  1. ; "LEVEL" Security Level
  1. ; "USER" Security Assigned By
  1. ; "DATETIME" Date/Time Security Assigned
  1. ; "SOURCE" Secuity Source
  1. ;
  1. N SUB,NODE0
  1. K DGSEC S DGSEC=""
  1. ;
  1. I '$G(SECIEN) D Q 0
  1. .F SUB="DFN","LEVEL","USER","DATETIME","SOURCE" S DGSEC(SUB)=""
  1. ;
  1. S NODE0=$G(^DGSL(38.1,SECIEN,0))
  1. S DGSEC("DFN")=$P(NODE0,"^")
  1. S DGSEC("LEVEL")=$P(NODE0,"^",2)
  1. S DGSEC("USER")=$P(NODE0,"^",3)
  1. S DGSEC("DATETIME")=$P(NODE0,"^",4)
  1. S DGSEC("SOURCE")=$P(NODE0,"^",5)
  1. Q 1
  1. ;
  1. ;
  1. STORE(DGSEC,ERROR) ;
  1. ; Description: Creates a new entry in the DG SECURITY LOG file.
  1. ;
  1. ; Input:
  1. ; DGSEC - as array containing the DG SECURITY LOG record,
  1. ; passed by reference
  1. ;
  1. ; Output:
  1. ; Function Value: Returns internal entry number of the entry created,
  1. ; otherwise 0 is returned
  1. ; ERROR - (optional) if not successful, an error msg is
  1. ; returned, pass by reference
  1. ;
  1. N DA,DD,DIC,DIE,DLAYGO,DO,DR,X,Y
  1. S DIC(0)="L",(X,DINUM)=DGSEC("DFN"),DIC="^DGSL(38.1,",DLAYGO=38.1
  1. D FILE^DICN
  1. I Y=-1 S ERROR="FILEMAN UNABLE TO CREATE DG SECURITY LOG RECORD" Q 0
  1. S DA=+Y
  1. ;
  1. I 'DA S ERROR="FILEMAN UNABLE TO CREATE DG SECURITY LOG RECORD" Q 0
  1. ;
  1. ; edit/update the new record
  1. I '$$UPDATE(DA,.DGSEC,.ERROR) S ERROR="FILEMAN UNABLE TO CREATE DG SECURITY LOG RECORD" Q 0
  1. ;
  1. ; quit with ien
  1. Q DA
  1. ;
  1. ;
  1. UPDATE(DFN,DGSEC,ERROR) ;
  1. ; Description: Updates a DG SECURITY LOG record for a patient. This
  1. ; function locks the DG SECURITY LOG record and releases the lock
  1. ; when the update is complete.
  1. ;
  1. ; Input:
  1. ; DFN - internal entry number of record in the DG SECURITY LOG file
  1. ; DGSEC - the DG SECURITY LOG array, passed by reference
  1. ;
  1. ; Output:
  1. ; Function Value - Returns 1 if successful, otherwise 0
  1. ; ERROR - if not successful, an error message is returned,
  1. ; pass by reference
  1. ;
  1. N SUCCESS,DATA
  1. S SUCCESS=1
  1. S ERROR=""
  1. ;
  1. D ; drops out if an invalid condition is found
  1. .I $G(DFN),$D(^DGSL(38.1,DFN,0))
  1. .E S SUCCESS=0,ERROR="DG SECURITY LOG RECORD NOT FOUND" Q
  1. .I '$$LOCK(DFN) S SUCCESS=0,ERROR="SECURITY LOG RECORD IS LOCKED, CAN NOT BE EDITED" Q
  1. .S DATA(2)=DGSEC("LEVEL")
  1. .S DATA(3)=DGSEC("USER")
  1. .S DATA(4)=DGSEC("DATETIME")
  1. .S DATA(5)=DGSEC("SOURCE")
  1. .I '$$UPD^DGENDBS(38.1,DFN,.DATA) S ERROR="FILEMAN UNABLE TO PERFORM UPDATE",SUCCESS=0 Q
  1. ;
  1. D UNLOCK(DFN)
  1. ;
  1. Q SUCCESS
  1. ;
  1. ;
  1. CHECK(DGSEC,ERROR) ;
  1. ; Description: Performs validation checks on DG SECURITY LOG record
  1. ; contained in the DGSEC array.
  1. ;
  1. ; Input:
  1. ; DGSEC - as the patient security array, passed by reference
  1. ;
  1. ; Output:
  1. ; Function Value - Returns 1 if validation checks passed, 0 otherwise
  1. ; ERROR - if validation checks fail, an error message is
  1. ; returned, pass by reference
  1. ;
  1. N VALID,RESULT,EXTERNAL
  1. S VALID=1,ERROR=""
  1. ;
  1. D ; drops out of block if an invalid condition is found
  1. .;
  1. .I '$G(DGSEC("DFN")) S VALID=0,ERROR="PATIENT NOT FOUND IN DATABASE" Q
  1. .I '$D(^DPT(DGSEC("DFN"),0)) S VALID=0,ERROR="PATIENT NOT FOUND IN DATABASE" Q
  1. .;
  1. .; check for required fields
  1. .I $G(DGSEC("LEVEL"))="" S VALID=0,ERROR="REQUIRED FIELD 'SECURITY LEVEL' MISSING" Q
  1. .I $G(DGSEC("USER"))="" S VALID=0,ERROR="REQUIRED FIELD 'SECURITY ASSIGNED BY' MISSING" Q
  1. .I $G(DGSEC("DATETIME"))="" S VALID=0,ERROR="REQUIRED FIELD 'DATE/TIME SECURITY ASSIGNED' MISSING" Q
  1. .I $G(DGSEC("SOURCE"))="" S VALID=0,ERROR="REQUIRED FIELD 'SECURITY SOURCE' MISSING" Q
  1. .;
  1. .; apply consistency rules
  1. .I DGSEC("LEVEL")'=1 S VALID=0,ERROR="'SECURITY LEVEL' OTHER THAN SENSITIVE NOT ALLOWED" Q
  1. .;Remove consistency check for SOURCE - DG*5.3*653
  1. .;I DGSEC("SOURCE")'="AAC" S VALID=0,ERROR="'SECURITY SOURCE' OTHER THAN AAC NOT ALLOWED" Q
  1. .;
  1. .; check if field values are valid
  1. .S EXTERNAL=$$EXTERNAL^DILFD(38.1,2,"",DGSEC("LEVEL"))
  1. .I EXTERNAL="" S VALID=0,ERROR="'SECURITY LEVEL' NOT VALID" Q
  1. .S EXTERNAL=$$EXTERNAL^DILFD(38.1,4,"",DGSEC("DATETIME"))
  1. .I EXTERNAL="" S VALID=0,ERROR="'DATE/TIME SECURITY ASSIGNED' NOT VALID" Q
  1. .I ($L($G(DGSEC("SOURCE")))<1)!($L($G(DGSEC("SOURCE")))>65) S VALID=0,ERROR="'SECURITY SOURCE' NOT VALID" Q
  1. ;
  1. Q VALID
  1. ;
  1. ;
  1. EXT(SUB,VALUE) ; Description: Given the subscript used in the PATIENT SECURITY
  1. ; array and a field value, this function returns the external
  1. ; representation of the value, as defined in the fields output
  1. ; transform of the DG SECURITY LOG file.
  1. ;
  1. ; Input:
  1. ; SUB - array subscript defined for the PATIENT SECURITY object
  1. ; VALUE - field value
  1. ;
  1. ; Output:
  1. ; Function Value - Returns the external value of the field
  1. ;
  1. Q:(('$G(SUB)="")!($G(VALUE)="")) ""
  1. ;
  1. N FIELD
  1. S FIELD=$S(SUB="DFN":.01,SUB="LEVEL":2,SUB="USER":3,SUB="DATETIME":4,SUB="SOURCE":5,1:"")
  1. ;
  1. Q:(FIELD="") ""
  1. ;
  1. Q $$EXTERNAL^DILFD(38.1,FIELD,"F",VALUE)