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

EASEZU1.m

Go to the documentation of this file.
  1. EASEZU1 ;ALB/jap,LBD - Utilities for 1010EZ Processing ; 9/19/12 11:28am
  1. ;;1.0;ENROLLMENT APPLICATION SYSTEM;**107**;Mar 15, 2001;Build 32
  1. ;
  1. KEY711(EASKEY) ;get file #711 record associated with key
  1. ;input EASKEY = character string equal to a 1010EZ Assigned Data Name OR Data Key
  1. ;output KEYIEN = pointer to file #711 for the 1010EZ data element is 1st piece;
  1. ; format: ien^Assigned Data Name^Data Key
  1. ; returns ".1" if EASKEY is invalid, i.e., data element is unknown
  1. ;
  1. N N,KEYIEN,X,XX,Y,DA,DIE,DR
  1. S KEYIEN=""
  1. ;key passed in is Data Key
  1. I EASKEY[".",EASKEY[";" D
  1. .S KEYIEN=$O(^EAS(711,"C",EASKEY,0)) Q:'KEYIEN
  1. .S X=$P(^EAS(711,KEYIEN,0),U,1)
  1. .S KEYIEN=KEYIEN_U_X_U_EASKEY
  1. ;key passed in is Assigned Data Name
  1. I KEYIEN="" D
  1. .I $L(EASKEY)>50 D
  1. ..;Fix problem when data passed in EASKEY is > 50 chars. (EAS*1*107)
  1. ..S EASKEY=$E(EASKEY,1,50)
  1. ..I $E(EASKEY,50)=" " S EASKEY=$E(EASKEY,1,49)
  1. .S KEYIEN=$O(^EAS(711,"AB",EASKEY,0)) Q:'KEYIEN
  1. .S X=$P(^EAS(711,KEYIEN,0),U,2)
  1. .S KEYIEN=KEYIEN_U_EASKEY_U_X
  1. I KEYIEN="" S KEYIEN=".1"
  1. Q KEYIEN
  1. ;
  1. DATA712(EASAPP,EASKEY,EASMM) ;get 1010EZ data associated with data key
  1. ;input EASAPP = ien to #712 for Application
  1. ; EASKEY = IEN to file #711;
  1. ; OR KEYIEN returned by KEY711^EASEZU1
  1. ; EASMM = multiple number; default is 1; optional
  1. ; pertains to data elements that may be multiple,
  1. ; i.e., additional child dependents
  1. ;
  1. ;output RTR = piece 1 - 1010EZ data associated with Data Key for this Application;
  1. ; piece 2 - subrecord ien associated with Data Key for this Application;
  1. ; returns ^ if data item not found in this Application
  1. ;
  1. N N,OUT,KEYIEN,MULTIPLE,X,RTR,IN,UP
  1. I '$D(^EAS(712,EASAPP,0)) Q U
  1. ;this is the "unknown" data element
  1. I EASKEY=.1 Q U
  1. I '$G(EASMM) S EASMM=1
  1. S KEYIEN=+EASKEY
  1. S OUT=0,N=0,X="",RTR=U
  1. F S N=$O(^EAS(712,EASAPP,10,"B",KEYIEN,N)) Q:'N D Q:OUT
  1. .S MULTIPLE=$P($G(^EAS(712,EASAPP,10,N,0)),U,2)
  1. .I MULTIPLE=EASMM D
  1. ..;use 'updated' data if present
  1. ..S X=$G(^EAS(712,EASAPP,10,N,1)),IN=$P(X,U,1),UP=$P(X,U,2)
  1. ..S RTR=$S(UP'="":UP,1:IN),RTR=RTR_U_N,OUT=1
  1. Q RTR
  1. ;
  1. LINKUP(EASAPP,EASAEL,EASLINK) ;place link into a file #712 Data Element subrecord
  1. ;input EASAPP = ien to #712 for Application
  1. ; EASAEL = ien to Data Elements subrecord in #712
  1. ; EASLINK = file ien OR file_ien;subfile_ien to link 1010EZ data
  1. ; with existing Patient database record
  1. ;exit if record/subrecord not valid in #712
  1. N DA,DR,DIE,X,Y
  1. Q:'EASAPP Q:'$D(^EAS(712,EASAPP,0))
  1. Q:'EASAEL Q:'$D(^EAS(712,EASAPP,10,EASAEL,0))
  1. ;place link in Data Element subrecord of #712
  1. S DA(1)=EASAPP,DA=EASAEL,DR(1)=10
  1. S DIE="^EAS(712,EASAPP,10,"
  1. S DR="2.1///^S X=EASLINK;"
  1. D ^DIE
  1. Q
  1. ;
  1. ADD71201(EASAPP,KEYIEN,LINK,MULTIPLE) ;add another subrecord to #712.01
  1. ;used in cases where Patient data exists but 1010EZ data does not;
  1. ;this new subrecord will hold the VistA database ien(s)
  1. ;
  1. ;input EASAPP = ien to file #712
  1. ; KEYIEN = ien to file #711 for data element
  1. ; LINK = ien(s) in VistA database;
  1. ; format: ien_main_file;ien_subfile
  1. ; MULTIPLE = default is 1; (optional)
  1. ; currently only needed for additional child dependents
  1. ; associated with Section IIB of the form.
  1. ;output NEWIEN = ien to new subrecord in sibfile #712.01
  1. N NEWIEN,LASTIEN,DA,DIC,DIE,DR,DLAYGO,DINUM,X,Y
  1. Q:'KEYIEN
  1. Q:LINK=""
  1. S LASTIEN=$O(^EAS(712,EASAPP,10,9999),-1),NEWIEN=LASTIEN+1
  1. ;create subrecord
  1. S DIC="^EAS(712,EASAPP,10,",DIC(0)="L",DLAYGO="",X=KEYIEN,DINUM=NEWIEN
  1. S DA(1)=EASAPP,DIC("P")=$P(^DD(712,10,0),U,2)
  1. K DD,DO D FILE^DICN
  1. ;file data element link
  1. S DIE="^EAS(712,EASAPP,10,",DA=NEWIEN,DA(1)=EASAPP,DR(1)="10;"
  1. S MULTIPLE=$G(MULTIPLE) S:'MULTIPLE MULTIPLE=1
  1. S DR=".1///^S X=MULTIPLE;2.1///^S X=LINK;"
  1. D ^DIE
  1. Q
  1. ;
  1. GETANY(EASAPP,EASDFN,EASAEL,EASKEY) ;get data from VistA database for any field related to 1010EZ
  1. ;input EASAPP = ien to #712 for Application
  1. ; EASDFN = ien to #2 for Applicant
  1. ; either EASAEL or EASKEY must be non-null
  1. ; EASAEL = ien to Data Elements subrecord in #712; optional
  1. ; EASKEY = data key from Data Elements subrecord in #712; optional
  1. ;
  1. ;output RTR = data obtained from Patient database; external format
  1. ; OR -1 if invalid input
  1. ;
  1. ;the "link" below is a pointer (ien) to file or subfile record that
  1. ; was previously found to contain data which potentially matches
  1. ; 1010EZ data
  1. ;
  1. N X,LINK,N,FILE,SUBFILE,FIELD,ARRAY,DIQ,DA,DR,DIC,RTR
  1. S EASKEY=$G(EASKEY),N=0
  1. I 'EASAEL,EASKEY="" Q -1
  1. I 'EASAEL,EASKEY'="" D
  1. .S EASAEL=$P($$DATA712(EASAPP,EASKEY),U,2) Q:'EASAEL
  1. .S N=$O(^EAS(711,"C",EASKEY,0))
  1. I EASKEY="",EASAEL S N=$P($G(^EAS(712,EASAPP,10,EASAEL,0)),U,1)
  1. I 'N Q -1
  1. ;database parameters in #711
  1. S X=$G(^EAS(711,N,1)),FILE=$P(X,U,1),SUBFILE=$P(X,U,2),FIELD=$P(X,U,3)
  1. ;get link ien if other than file #2
  1. S LINK=$P($G(^EAS(712,EASAPP,10,EASAEL,2)),U,2)
  1. ;if data location is main file #2, then link is dfn
  1. I FILE=2,(SUBFILE=2!SUBFILE="") S LINK=EASDFN
  1. ;
  1. ;if no link to database, quit
  1. I 'LINK Q -1
  1. ;otherwise setup FM call & use link to get data
  1. I (SUBFILE="")!(SUBFILE=FILE) D
  1. .;data in main file
  1. .S DIQ="ARRAY",DIQ(0)="E",DA=LINK,DR=FIELD,DIC=FILE
  1. .D EN^DIQ1
  1. .S RTR=$G(ARRAY(FILE,LINK,FIELD,"E"))
  1. I SUBFILE'="",SUBFILE'=FILE D
  1. .;data in subfile
  1. .;in this case LINK = file_ien;subfile_ien
  1. .S DIQ="ARRAY",DIQ(0)="E",DA=$P(LINK,";",1),DIC=FILE
  1. .;get field # for subfile
  1. .S DR=$O(^DD(FILE,"SB",SUBFILE,0))
  1. .S DR(SUBFILE)=FIELD,DA(SUBFILE)=$P(LINK,";",2)
  1. .D EN^DIQ1
  1. .S RTR=$G(ARRAY(SUBFILE,$P(LINK,";",2),FIELD,"E"))
  1. Q RTR