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

ZISFM.m

Go to the documentation of this file.
  1. ZISFM ;IRMFO-ALB/CJM - DEVICE HANDLER ;10/25/2011
  1. ;;8.0;KERNEL;**585**;JUL 10, 9;Build 23
  1. ;Per VHA Directive 10-93-142, this routine should not be modified.
  1. ;
  1. UPD(FILE,DA,DATA,ERROR) ;File data into an existing record.
  1. ; Input:
  1. ; FILE - File or sub-file number
  1. ; DA - Traditional DA array, with same meaning.
  1. ; Pass by reference.
  1. ; DATA - Data array to file (pass by reference)
  1. ; Format: DATA(<field #>)=<value>
  1. ;
  1. ; Output:
  1. ; Function Value - 0=error and 1=no error
  1. ; ERROR - optional error message - if needed, pass by reference
  1. ;
  1. ; Example: To update a record in subfile 2.0361 in record with ien=353,
  1. ; subrecord ien=68, with the field .01 value = 21:
  1. ; S DATA(.01)=21,DA=68,DA(1)=353 I $$UPD(2.0361,.DA,.DATA,.ERROR) W !,"DONE"
  1. ;
  1. N FDA,FIELD,IENS,ERRORS
  1. ;
  1. ;IENS - Internal Entry Number String defined by FM
  1. ;FDA - the FDA array as defined by FM
  1. ;
  1. I '$G(DA) S ERROR="IEN OF RECORD TO BE UPDATED NOT SPECIFIED" Q 0
  1. S IENS=$$IENS^DILF(.DA)
  1. S FIELD=0
  1. F S FIELD=$O(DATA(FIELD)) Q:'FIELD D
  1. .S FDA(FILE,IENS,FIELD)=$G(DATA(FIELD))
  1. D FILE^DIE("","FDA","ERRORS(1)")
  1. I +$G(DIERR) D
  1. .S ERROR=$G(ERRORS(1,"DIERR",1,"TEXT",1))
  1. E D
  1. .S ERROR=""
  1. ;
  1. D CLEAN^DILF
  1. Q $S(+$G(DIERR):0,1:1)
  1. ;
  1. ADD(FILE,DA,DATA,ERROR,IEN) ;
  1. ;Description: Creates a new record and files the data.
  1. ; Input:
  1. ; FILE - File or sub-file number
  1. ; DA - Traditional FileMan DA array with same
  1. ; meaning. Pass by reference. Only needed if adding to a
  1. ; subfile.
  1. ; DATA - Data array to file, pass by reference
  1. ; Format: DATA(<field #>)=<value>
  1. ; IEN - internal entry number to use (optional)
  1. ;
  1. ; Output:
  1. ; Function Value - If no error then it returns the ien of the created record, else returns NULL.
  1. ; DA - returns the ien of the new record, NULL if none created. If needed, pass by reference.
  1. ; ERROR - optional error message - if needed, pass by reference
  1. ;
  1. ; Example: To add a record in subfile 2.0361 in the record with ien=353
  1. ; with the field .01 value = 21:
  1. ; S DATA(.01)=21,DA(1)=353 I $$ADD(2.0361,.DA,.DATA) W !,"DONE"
  1. ;
  1. ; Example: If creating a record not in a subfile, would look like this:
  1. ; S DATA(.01)=21 I $$ADD(867,,.DATA) W !,"DONE"
  1. ;
  1. N FDA,FIELD,IENA,IENS,ERRORS
  1. ;
  1. ;IENS - Internal Entry Number String defined by FM
  1. ;IENA - the Internal Entry Number Array defined by FM
  1. ;FDA - the FDA array defined by FM
  1. ;IEN - the ien of the new record
  1. ;
  1. S DA="+1"
  1. S IENS=$$IENS^DILF(.DA)
  1. S FIELD=0
  1. F S FIELD=$O(DATA(FIELD)) Q:'FIELD D
  1. .S FDA(FILE,IENS,FIELD)=$G(DATA(FIELD))
  1. I $G(IEN) S IENA(1)=IEN
  1. D UPDATE^DIE("","FDA","IENA","ERRORS(1)")
  1. I +$G(DIERR) D
  1. .S ERROR=$G(ERRORS(1,"DIERR",1,"TEXT",1))
  1. .S IEN=""
  1. E D
  1. .S IEN=IENA(1)
  1. .S ERROR=""
  1. D CLEAN^DILF
  1. S DA=IEN
  1. Q IEN
  1. ;
  1. DELETE(FILE,DA,ERROR) ;Delete an existing record.
  1. N DATA
  1. S DATA(.01)="@"
  1. Q $$UPD(FILE,.DA,.DATA,.ERROR)
  1. Q
  1. ;
  1. ;
  1. ;
  1. ;
  1. ;
  1. ;
  1. ;
  1. ;
  1. ;