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

VAFHLZCT.m

Go to the documentation of this file.
  1. VAFHLZCT ;ALB/ESD,TDM - Creation of ZCT segment ; 12/9/09 2:10pm
  1. ;;5.3;PIMS;**68,653,1015,1016**;JUN 30, 2012;Build 20
  1. ;
  1. ; This generic extrinsic function transfers information pertaining to
  1. ; a patient's next of kin through the Emergency Contact (ZCT) segment.
  1. ;
  1. ;
  1. EN(DFN,VAFSTR,VAFNUM,VAFTYPE,VAFNAMFT) ;function returns ZCT segment containing emergency contact info.
  1. ;
  1. ; Input:
  1. ; DFN -- Internal entry number of the PATIENT file.
  1. ; VAFSTR -- String of fields requested separated by commas
  1. ; VAFNUM -- Set Id (sequential number-if not passed, set to 1).
  1. ; VAFTYPE -- Contact type to determine type of data returned
  1. ; (1=NOK, 2=2nd NOK, 3=Emer Cont, 4=2nd Emer Cont,
  1. ; 5=Designee).
  1. ; VAFNAMFT -- Flag indicating to format the name field (SEQ-3)
  1. ; to HL7 XPN data type.(1=Format, 0=Do Not Format)
  1. ;
  1. ; Output: String of components forming ZCT segment.
  1. ;
  1. ; ****Also assumes all HL7 variables returned from****
  1. ; INIT^HLTRANS are defined.
  1. ;
  1. N VAFNODE,VAFCNODE,X,X1,VAFY
  1. I '$G(DFN)!($G(VAFSTR)']"") G QUIT
  1. S $P(VAFY,HLFS,9)="",VAFSTR=","_VAFSTR_","
  1. I "^1^2^3^4^5^"'[("^"_$G(VAFTYPE)_"^") S VAFTYPE=1
  1. I $G(VAFNAMFT)<1 S VAFNAMFT=0
  1. S VAFNODE=$P($T(TYPE+VAFTYPE),";;",2),VAFCNODE=$G(^DPT(DFN,VAFNODE))
  1. S $P(VAFY,HLFS,1)=$S($G(VAFNUM):+VAFNUM\1,1:1) ; If Set Id not passed in, set to 1
  1. S $P(VAFY,HLFS,2)=VAFTYPE ; Contact Type
  1. I VAFSTR[",3," D ;Name of Next of Kin
  1. . S X=$P(VAFCNODE,"^",1)
  1. . I VAFNAMFT D
  1. . . S X=$$HLNAME^XLFNAME(X,"",$E(HL("ECH"),1))
  1. . . I X'="",$P(X,$E(HL("ECH"),1),7)'="L" S $P(X,$E(HL("ECH"),1),7)="L"
  1. . S $P(VAFY,HLFS,3)=$S(X]"":X,1:HLQ)
  1. I VAFSTR[",4," S X=$P(VAFCNODE,"^",2),$P(VAFY,HLFS,4)=$S(X]"":X,1:HLQ) ; Relationship to Patient
  1. I VAFSTR[",5," D
  1. . S X1=$G(^DPT(DFN,.22))
  1. . S X=$$ADDR^VAFHLFNC($P(VAFCNODE,"^",3,7)_"^"_$P(X1,"^",$P($T(TYPE+VAFTYPE),";;",3)))
  1. . S $P(VAFY,HLFS,5)=$S(X]"":$P(X,HLFS,1),1:HLQ) ; Next of Kin address
  1. ;
  1. I VAFSTR[",6," S X=$$HLPHONE^HLFNC($P(VAFCNODE,"^",9)),$P(VAFY,HLFS,6)=$S(X]"":X,1:HLQ) ; Home Phone
  1. I VAFSTR[",7," S X=$$HLPHONE^HLFNC($P(VAFCNODE,"^",11)),$P(VAFY,HLFS,7)=$S(X]"":X,1:HLQ) ; Work Phone
  1. S X=$P(VAFCNODE,"^",10) ;Get this piece for next two fields
  1. I VAFSTR[",8," S $P(VAFY,HLFS,8)=$S(VAFTYPE=1!(VAFTYPE=2):$$YN^VAFHLFNC(X),1:HLQ) ; Contact Address Same as NOK?
  1. I VAFSTR[",9," S $P(VAFY,HLFS,9)=$S(VAFTYPE=3!(VAFTYPE=5):$$YN^VAFHLFNC(X),1:HLQ) ; Contact Person Same as NOK?
  1. I VAFSTR[",10," D ; Last Date/Time Updated
  1. . ;Q:((VAFTYPE'=1)&(VAFTYPE'=2)) ; Currently only available for type 1 & 2
  1. . I (VAFTYPE=1)!(VAFTYPE=2) S X=$P($G(^DPT(DFN,.212)),"^",VAFTYPE)
  1. . I (VAFTYPE=3)!(VAFTYPE=4)!(VAFTYPE=5) S X=$P($G(^DPT(DFN,.332)),"^",(VAFTYPE-2))
  1. . S $P(VAFY,HLFS,10)=$S(X'="":$$HLDATE^HLFNC(X),1:HLQ)
  1. QUIT Q "ZCT"_HLFS_$G(VAFY)
  1. TYPE ; Corresponding nodes for emergency contact type and ZIP+4 field piece.
  1. ;;.21;;7
  1. ;;.211;;3
  1. ;;.33;;1
  1. ;;.331;;4
  1. ;;.34;;2