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

VAFHLZEL.m

Go to the documentation of this file.
  1. VAFHLZEL ;ALB/ESD,KCL,SCK,JRP - Creation of ZEL segment ; 11/23/99
  1. ;;5.3;Registration;**122,160,195,243,342**;Aug 13, 1993
  1. ;
  1. ;
  1. EN(DFN,VAFSTR,VAFNUM) ; This function call has been left for backwards
  1. ; compatability and is superceeded by EN1^VAFHLZEL. This function
  1. ; call is designed to build the HL7 ZEL segment. This segment contains
  1. ; VA-specific patient eligibility data. Because a patient can have
  1. ; more than eligibility, the ZEL segment for the patient's primary
  1. ; eligibility will be the output of the function call and all other
  1. ; eligibilities will be returned in the array VAFZEL. Because this
  1. ; call was not designed to accomodate a segment length greater than
  1. ; 245, sequence numbers 1 to 24 are the only fields supported.
  1. ;
  1. ;Input: DFN - Pointer to PATIENT file (#2)
  1. ; VAFSTR - String of fields requested separated by commas
  1. ; VAFNUM - Eligibility number to determine type of data
  1. ; returned
  1. ; 1 = primary eligibility only
  1. ; 2 = all eligibilities
  1. ; VAFMSTDT - Date to use when getting MST status (optional)
  1. ; Assumes existance of the HL7 enconding characters
  1. ; (HLFS,HLENC,HLQ)
  1. ;
  1. ;Output: The ZEL segment for the patient's primary eligibility
  1. ;
  1. ; VAFZEL(1..N) - If all eligibilities are chosen, an array of
  1. ; string(s) forming the ZEL segments for the patient's
  1. ; other entitled eligibilities.
  1. ;
  1. ;Notes: All fields will be returned with the primary eligibility
  1. ; : Eligibility Code, Long ID, and Short ID will be the only
  1. ; fields returned for other eligibilities
  1. ; : VAFZEL is initialized (KILLed) on entry
  1. ;
  1. N VAFPRIM,X,MAXSEQ
  1. ;Build segment using newer call
  1. D EN1($G(DFN),$G(VAFSTR),$G(VAFNUM),.VAFZEL)
  1. ;Make output backward compatible
  1. S MAXSEQ=25
  1. S VAFPRIM=$P(VAFZEL(1),HLFS,1,MAXSEQ+1)
  1. K VAFZEL(1)
  1. S X=1
  1. F S X=+$O(VAFZEL(X)) Q:'X D
  1. .S VAFZEL(X-1)=$P(VAFZEL(X),HLFS,1,MAXSEQ+1)
  1. .K VAFZEL(X)
  1. Q VAFPRIM
  1. ;
  1. EN1(DFN,VAFSTR,VAFNUM,VAFZEL) ; This procedure call is designed to build the
  1. ; HL7 ZEL segment. This segment contains VA-specific patient
  1. ; eligibility data. Because a patient can have more than eligibility,
  1. ; the ZEL segment(s) will be returned in the array VAFZEL. This call
  1. ; superceeds $$EN^VAFHLZEL because it accomodates a segment length
  1. ; greater than 245.
  1. ;
  1. ;Input: DFN - Pointer to PATIENT file (#2)
  1. ; VAFSTR - String of fields requested separated by commas
  1. ; VAFNUM - Eligibility number to determine type of data
  1. ; returned
  1. ; 1 = primary eligibility only (default)
  1. ; 2 = all eligibilities
  1. ; .VAFZEL - Array to return segment(s) in
  1. ; VAFMSTDT - Date to use when getting MST status (optional)
  1. ; Existance of HL7 enconding characters (HLFS,HLENC,HLQ) assumed
  1. ;
  1. ;Output: VAFZEL(X) = ZEL segment (first 245 characters)
  1. ; VAFZEL(X,Y) = Remaining portion of ZEL segment in 245 chunks
  1. ;
  1. ;Notes: VAFZEL(1) will be the primary eligibility
  1. ; : VAFZEL(2..n) will be other eligibilities
  1. ; : All fields will be returned with the primary eligibility
  1. ; : Eligibility Code, Long ID, and Short ID will be the only
  1. ; fields returned for other eligibilities
  1. ; : Fields will not be split across nodes in VAFZEL()
  1. ; : VAFZEL is initialized (KILLed) on entry
  1. ;
  1. N VAFPELIG,VAFNODE,VAFPRIM,VAFHLZEL,VAFSETID,VAFELPTR,VAFMAXL,X
  1. K VAFZEL
  1. S VAFMAXL=245
  1. I '$G(DFN)!($G(VAFSTR)="") S VAFZEL(1)="ZEL"_HLFS Q
  1. S VAFNUM=$S('$D(VAFNUM):1,VAFNUM'<2:2,1:1)
  1. S VAFSTR=","_VAFSTR_","
  1. ;Build ZEL segment for primary eligibility
  1. S VAFPELIG=$G(^DPT(DFN,.36))
  1. S VAFNODE=$G(^DPT(DFN,"E",+VAFPELIG,0))
  1. S VAFSETID=1 D GETDATA^VAFHLZE1,MAKESEG
  1. ;Only build for primary elig.
  1. Q:VAFNUM=1
  1. ;Build ZEL segments for other eligibilities
  1. S VAFELPTR=0
  1. F S VAFELPTR=$O(^DPT(DFN,"E",VAFELPTR)) Q:'VAFELPTR I VAFELPTR'=+VAFPELIG D
  1. .S VAFNODE=$G(^DPT(DFN,"E",VAFELPTR,0))
  1. .S VAFSETID=VAFSETID+1 D GETDATA^VAFHLZE1,MAKESEG
  1. ;Done
  1. Q
  1. ;
  1. MAKESEG ;Make segment using obtained data
  1. ;Input: Existance of the following variables is assumed
  1. ; VAFSETID = Number denoting Xth repetition of the ZEL segment
  1. ; VAFMAXL = Maximum length of each node (defaults to 245)
  1. ; VAFHLZEL(SeqNum) = Value
  1. ; HL7 encoding characters (HLFS, HLENC, HLQ)
  1. ;
  1. ;Output: VAFZEL(VAFSETID) = ZEL segment (first VAFMAXL characters)
  1. ; VAFZEL(VAFSETID,x) = Remaining portion of ZEL segment in
  1. ; VAFMAXL character chunks (if needed)
  1. ; beginning with a field seperator
  1. ;
  1. ;Notes: VAFZEL(VAFSETID) is initialized (KILLed) on input
  1. ; : Fields will not be split across nodes in VAFZEL()
  1. ;
  1. N SEQ,SPILL,SPILLON,SPOT,LASTSEQ,VAFY
  1. K VAFZEL(VAFSETID)
  1. S VAFZEL(VAFSETID)="ZEL"
  1. S VAFMAXL=+$G(VAFMAXL) S:'VAFMAXL VAFMAXL=245
  1. S VAFY=$NA(VAFZEL(VAFSETID))
  1. S (SPILL,SPILLON)=0
  1. S LASTSEQ=+$O(VAFHLZEL(""),-1)
  1. F SEQ=1:1:LASTSEQ D
  1. .;Make sure maximum length won't be exceeded
  1. .I ($L(@VAFY)+$L($G(VAFHLZEL(SEQ)))+1)>VAFMAXL D
  1. ..;Max length exceeded - start putting data on next node
  1. ..S SPILL=SPILL+1
  1. ..S SPILLON=SEQ-1
  1. ..S VAFY=$NA(VAFZEL(VAFSETID,SPILL))
  1. .;Add to string
  1. .S SPOT=(SEQ+1)-SPILLON
  1. .S $P(@VAFY,HLFS,SPOT)=$G(VAFHLZEL(SEQ))
  1. ;Done
  1. Q