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

VAFCDD01.m

Go to the documentation of this file.
  1. VAFCDD01 ;ALB/JRP,LTL-DATA DICTIONARY UTILITIES ;05-SEP-1996
  1. ;;5.3;Registration;**91,149,1**;Jun 06, 1996
  1. AVAFC(DFN) ;AVAFC* cross reference for PATIENT file (#2)
  1. ;
  1. ;Input : IFN - Pointer to entry in PATIENT file (#2)
  1. ;Output : None
  1. ; VAFCFLG will be set to 1 if the cross reference is
  1. ; not executed because the change is being made from
  1. ; within the Registration process. This notifies
  1. ; Registration that a change was made and that this
  1. ; cross reference should be executed if the Registration
  1. ; process is aborted.
  1. ;
  1. ;Notes : The AVAFC* cross references are used to remember that
  1. ; changes were made to the PATIENT file (#2) outside of
  1. ; the Registration process. Execution of this cross
  1. ; reference will create an entry in the ADT/HL7 PIVOT
  1. ; file (#391.71) and mark it as requiring transmission
  1. ; of an HL7 ADT-A08 message.
  1. ;
  1. ; : Execution of this cross reference can be prevented by
  1. ; setting the local variables: VAFCA08 equal to 1
  1. ; VAFHCA08 equal to 1
  1. ;
  1. ; : If only one of the CA08 variables is set to 1 an entry
  1. ; will be made in the pivot file (#391.71) but the
  1. ; corresponding transmission flag will not be set. In this
  1. ; case setting VAFCA08=1 will prevent the REQUIRES TRANSMISSION
  1. ; flag from being set and setting VAFHCA08=1 will prevent the
  1. ; TRANSMITTED-REQUIRES TRANSMISSION flag from being set.
  1. ; This allows control for sending HL7 and/or HL7v2.3
  1. ;
  1. ;Check input
  1. I +$G(DFN),$D(^DPT(DFN,0))
  1. E Q
  1. ;quit if re-indexing
  1. Q:$D(DIU(0))
  1. ;
  1. N VARPTR,PIVOTNUM ;Declare variables
  1. ;
  1. DO K VAFCF ; do HL7 V2.3 MESSAGING
  1. .;CHECK TURNOFF FLAG
  1. .Q:$D(VAFCA08)
  1. .;IF SEND HL7 V2.3 MESSAGES IN MAS PARAMETER FILE IS SET
  1. .;TO SEND/SUSPEND THEN DO IT, ELSE QUIT
  1. .I '$P($$SEND^VAFHUTL(),"^",2) Q
  1. .;IF in Registration option, save fields edited
  1. .I $$REG() D Q
  1. . . Q:$G(VAFCF)=""
  1. . . S VAFCFLDS(VAFCF)=""
  1. .;IF NOT IN REGISTRATION DO THIS
  1. .D PVT4A08(DFN)
  1. .I PIVOTNUM<0 Q
  1. .; set need to transmit flag
  1. .D XMITFLAG(0,PIVOTNUM)
  1. ;
  1. DO ; do HL7 V2.2 MESSAGING
  1. .Q:$G(VAFHCA08)
  1. .Q:$G(VAFCFLG)
  1. .I $$EN^VAFHREG() S VAFCFLG=1 Q
  1. .I '$$SEND^VAFHUTL() Q
  1. .I +$G(PIVOTNUM)<0 Q ; its already been called and failed quit
  1. .I '$G(PIVOTNUM) D PVT4A08(DFN) ; set ac xref and pivot
  1. .I PIVOTNUM<0 Q
  1. .; set requires transmission-Yes flag
  1. .D SETTFLAG(0,PIVOTNUM)
  1. .;done
  1. QUIT
  1. ;
  1. PVT4A08(DFN) ;Create entry in ADT/HL7 PIVOT file for an ADT-A08 event
  1. ; and mark it for transmission
  1. ;
  1. ;Input : IFN - Pointer to entry in PATIENT file (#2)
  1. ;Output : None
  1. ;Notes : There are no checks to determine if the entry should be
  1. ; created (other than input of a valid DFN)
  1. ;
  1. ;Check input
  1. I +$G(DFN),$D(^DPT(DFN,0))
  1. E QUIT
  1. ;Declare variables don't new for call from top
  1. ;N VARPTR,PIVOTNUM
  1. ;Set variable pointer used by ADT/HL7 PIVOT file
  1. S VARPTR=DFN_";DPT("
  1. ;Create entry
  1. S PIVOTNUM=+$$PIVNW^VAFHPIVT(DFN,$P(DT,"."),4,VARPTR)
  1. Q:(PIVOTNUM<0)
  1. ;EDIT DUZ2 FIELD IN PIVOT FILE - ADDED FOR AGMPI TPF 7/9/2010
  1. S $P(^VAT(391.71,PIVOTNUM,9999999),U)=DUZ(2) ;NOTE: COULD NOT USE A FM CALL TO ADD THIS. IT CAUSED A MESS ON RETURN
  1. ;END NEW
  1. ;Mark entry as requires transmission
  1. I $P($$SEND^VAFHUTL(),"^",2) D XMITFLAG(0,PIVOTNUM)
  1. ;Mark entry as transmitted field YES
  1. I $G(VAFCFLG),$$SEND^VAFHUTL() D SETTFLAG(0,PIVOTNUM)
  1. ;Done
  1. Q
  1. ;
  1. PROCESS() ;
  1. ;This call simply processes the array elements in the VAFCFLDS
  1. ;variable into a string
  1. Q:'$D(VAFCFLDS) -1
  1. N INDEX,RETURN S INDEX="",RETURN=""
  1. F S INDEX=$O(VAFCFLDS(INDEX)) Q:INDEX="" D
  1. . S RETURN=RETURN_INDEX
  1. Q:$G(RETURN)="" -1
  1. Q RETURN
  1. ;
  1. REGEDIT(PIVOTNUM,FIELDS) ;
  1. ;This call is used to generate an HL7 VERSION 2.3 A04 or A08 message
  1. ;from the pivot file the A04 is generated from DGREG00 when a
  1. ;Registration is known to have been completed. The A08 message
  1. ;is generated from DGREG0 when the Registration option was used
  1. ;to edit some fields, but the Registration was never completed.
  1. ;FIELDS variable contains the fields edited during the session.
  1. S DIE="391.71",DA=PIVOTNUM
  1. S DR="2.1///^S X=FIELDS"
  1. D ^DIE
  1. K DIE,DA,DR
  1. Q
  1. TRANSMIT(PIVOTNUM) ;
  1. ;This call is used to simply set the 'Requires Transmission'
  1. ;flag in the pivot file
  1. S DIE="391.71",DA=PIVOTNUM
  1. S DR=".08///^S X=1"
  1. D ^DIE
  1. K DIE,DA,DR
  1. Q
  1. ;
  1. MESSAGE(PIVOTPTR,NUMBER) ;
  1. ;This tag stuffs the message id from hl7 into pivot file
  1. S DIE="391.71",DA=PIVOTPTR
  1. S DR="1.1///^S X=NUMBER"
  1. D ^DIE
  1. K DIE,DA,DR
  1. Q
  1. ;
  1. REG() ;
  1. ;this tag looks at what option the user is in at the time
  1. ;
  1. I $P($G(XQY0),"^")="DG REGISTER PATIENT" Q 1
  1. I $P($G(XQY0),"^")="DGRPT 10-10T REGISTRATION" Q 1
  1. Q 0
  1. ;
  1. HL7A08 ;
  1. I $D(VAFHMRG) D KILL^VAFHUTL2(DFN,VAFHBEF)
  1. ;Registration process was aborted and changes were made
  1. ;to key demographic data. Create an HL7 V2.3 entry in
  1. ;the ADT/HL PIVOT file so that demographic changes will be
  1. ;broadcast. VAFCFLDS is set in routine VAFCDD01. It contains the
  1. ;fields that were edited.
  1. I $D(VAFCFLDS) D
  1. . N PIVOTNUM,IEN,PTR
  1. . S PTR=DFN_";DPT("
  1. . S PIVOTNUM=+$$PIVNW^VAFHPIVT(DFN,DT,4,PTR)
  1. . Q:PIVOTNUM'>0
  1. . S IEN=$O(^VAT(391.71,"D",PIVOTNUM,""))
  1. . Q:IEN'>0
  1. . S VAFCFLDS=$$PROCESS^VAFCDD01()
  1. . I VAFCFLDS'=-1 D
  1. . . D REGEDIT^VAFCDD01(IEN,VAFCFLDS)
  1. . . D TRANSMIT^VAFCDD01(IEN)
  1. K VAFCFLDS
  1. Q
  1. ;
  1. SECA08(DFN) ;PUT ENTRY IN PIVOT FILE WHEN USER FLAGS A PT AS SENSITIVE IN
  1. ;FILE 38.1 THIS IS TRIGGERED OUT OF ROUTINE DGSEC1
  1. N PIVOTNUM,IEN,PTR
  1. S PTR=DFN_";DPT("
  1. S PIVOTNUM=+$$PIVNW^VAFHPIVT(DFN,DT,4,PTR)
  1. Q:PIVOTNUM'>0
  1. S IEN=$O(^VAT(391.71,"D",PIVOTNUM,""))
  1. Q:IEN'>0
  1. ;SET EVENT CODE FIELD TO 97 INDICATING A SENSITIVITY UPDATE
  1. S DIE="391.71",DA=IEN
  1. S DR=".1///^S X=97"
  1. D ^DIE
  1. K DIE,DA,DR
  1. D TRANSMIT^VAFCDD01(IEN)
  1. Q
  1. ;
  1. XMITFLAG(PIVOTPTR,PIVOTNUM,TURNOFF) ;Turn transmission flag for entry
  1. ; in ADT/HL7 PIVOT file on/off
  1. ;
  1. ;Input : PIVOTPTR - Pointer to entry in ADT/HL7 PIVOT file (#391.71)
  1. ; - Use this parameter if the entry number is known
  1. ; - Not required if using PIVOTNUM parameter
  1. ; - Use of this parameter takes precedence over use
  1. ; the PIVOTNUM parameter
  1. ; PIVOTNUM - PIVOT NUMBER value (field #.02) for entry
  1. ; in ADT/HL7 PIVOT file (#391.71)
  1. ; - Use this parameter if the pivot number is known
  1. ; - Not required if using PIVOTPTR parameter
  1. ; TURNOFF - Denotes if REQUIRES TRANSMISSION field (#.08) should
  1. ; be turned on (set to 'YES') or off (set to 'NO')
  1. ; 1 = Turns transmission off
  1. ; 0 = Turns transmission on (default)
  1. ;Output : None
  1. ;
  1. ;Check input
  1. S PIVOTPTR=+$G(PIVOTPTR)
  1. S PIVOTNUM=+$G(PIVOTNUM)
  1. Q:(('PIVOTPTR)&('PIVOTNUM))
  1. S TURNOFF=+$G(TURNOFF)
  1. ;Declare variables
  1. N VALUE,NODE,XREFNUM,DA,X
  1. ;Passed pointer - validate
  1. I (PIVOTPTR) Q:('$D(^VAT(391.71,PIVOTPTR,0)))
  1. ;Passed pivot number - convert to pointer
  1. I ('PIVOTPTR) S PIVOTPTR=+$O(^VAT(391.71,"D",PIVOTNUM,0)) Q:('PIVOTPTR)
  1. ;Set FileMan variables
  1. S DA=PIVOTPTR
  1. S X='TURNOFF
  1. ;If already transmitted, empty field(s) edited, can't do 8th piece ""
  1. ;I $G(VAFCF),'$P($G(^VAT(391.71,DA,0)),U,8),$G(^VAT(391.71,DA,2)) S $P(^VAT(391.71,DA,2),U)=""
  1. ;Hard set field
  1. S $P(^VAT(391.71,DA,0),"^",8)=X
  1. ;Hard set fields edited
  1. S:$G(VAFCF)&($P($G(^VAT(391.71,DA,2)),U)'[$G(VAFCF)) $P(^VAT(391.71,DA,2),U)=$P($G(^VAT(391.71,DA,2)),U)_$G(VAFCF)
  1. ;Execute cross references
  1. S XREFNUM=0
  1. F S XREFNUM=+$O(^DD(391.71,.08,1,XREFNUM)) Q:('XREFNUM) D
  1. .;Execute kill logic
  1. .S NODE=$G(^DD(391.71,.08,1,XREFNUM,2))
  1. .I (NODE'="") X NODE
  1. .;Execute set logic
  1. .S NODE=$G(^DD(391.71,.08,1,XREFNUM,1))
  1. .I (NODE'="") X NODE
  1. Q
  1. ;
  1. SETTFLAG(PIVOTPTR,PIVOTNUM,TURNOFF) ;Turn transmission flag for entry
  1. ; in ADT/HL7 PIVOT file on/off
  1. ;
  1. ;Input : PIVOTPTR - Pointer to entry in ADT/HL7 PIVOT file (#391.71)
  1. ; - Use this parameter if the entry number is known
  1. ; - Not required if using PIVOTNUM parameter
  1. ; - Use of this parameter takes precedence over use
  1. ; the PIVOTNUM parameter
  1. ; PIVOTNUM - PIVOT NUMBER value (field #.02) for entry
  1. ; in ADT/HL7 PIVOT file (#391.71)
  1. ; - Use this parameter if the pivot number is known
  1. ; - Not required if using PIVOTPTR parameter
  1. ; TURNOFF - Denotes if TRANSMITTED field (#.06) should
  1. ; be turned on (set to 'YES') or off (set to 'NO')
  1. ; 1 = Turns transmission off
  1. ; 0 = Turns transmission on (default)
  1. ;Output : None
  1. ;
  1. ;Check input
  1. S PIVOTPTR=+$G(PIVOTPTR)
  1. S PIVOTNUM=+$G(PIVOTNUM)
  1. Q:(('PIVOTPTR)&('PIVOTNUM))
  1. S TURNOFF=+$G(TURNOFF)
  1. ;Declare variables
  1. N VALUE,NODE,XREFNUM,DA,X
  1. ;Passed pointer - validate
  1. I (PIVOTPTR) Q:('$D(^VAT(391.71,PIVOTPTR,0)))
  1. ;Passed pivot number - convert to pointer
  1. I ('PIVOTPTR) S PIVOTPTR=+$O(^VAT(391.71,"D",PIVOTNUM,0)) Q:('PIVOTPTR)
  1. ;Set FileMan variables
  1. S DA=PIVOTPTR
  1. S X='TURNOFF
  1. ;Hard set field
  1. S $P(^VAT(391.71,DA,0),"^",6)=X
  1. ;Execute cross references
  1. S XREFNUM=0
  1. F S XREFNUM=+$O(^DD(391.71,.06,1,XREFNUM)) Q:('XREFNUM) D
  1. .;Execute kill logic
  1. .S NODE=$G(^DD(391.71,.06,1,XREFNUM,2))
  1. .I (NODE'="") X NODE
  1. .;Execute set logic
  1. .S NODE=$G(^DD(391.71,.06,1,XREFNUM,1))
  1. .I (NODE'="") X NODE
  1. Q