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

DGENQRY.m

Go to the documentation of this file.
  1. DGENQRY ;ALB/CJM - API for ENROLLMENT QUERIES; 11/17/00 12:07pm ; 12/6/00 5:32pm
  1. ;;5.3;REGISTRATION;**147,222,232,314**;Aug 13,1993
  1. ;
  1. QRY(DFN) ;
  1. ;Description: Used to implment the automatic querying of HEC for
  1. ;enrollment/eligibility data.
  1. ;
  1. ;Input:
  1. ; DGQRY - this array should contain values for all the subscripts
  1. ; defined for the DGQRY array. (pass by reference)
  1. ;
  1. ;Output:
  1. ; Function Value - If successful, returns the ien of the newly created
  1. ; record, otherwise returns 0.
  1. ;
  1. N STATUS
  1. Q:'$G(DFN) 0
  1. Q:'$$VET^DGENPTA(DFN) 0
  1. Q:$$PENDING^DGENQRY(DFN) 0
  1. S STATUS=$$STATUS^DGENA(DFN)
  1. ; Purple Heart added status 21
  1. Q:((STATUS=1)!(STATUS=2)!(STATUS=9)!(STATUS=15)!(STATUS=16)!(STATUS=17)!(STATUS=18)!(STATUS=21)) 0
  1. Q $$SEND^DGENQRY1(DFN)
  1. ;
  1. LOCK(DFN) ;
  1. ;Description: Locks a record in the ENROLLMENT QUERY file.
  1. ;Input:
  1. ; DFN - ien of record in PATIENT file.
  1. ;Output:
  1. ; Function Value - 1 if successful, 0 otherwise.
  1. ;
  1. I $G(DFN) L +^DGEN(27.12,DFN):3
  1. Q $T
  1. ;
  1. UNLOCK(DFN) ;
  1. ;Description: Releases a lock set by $$LOCK.
  1. ;Input:
  1. ; DFN - ien of record in the PATIENT file.
  1. ;Output: None
  1. ;
  1. I $G(DFN) L -^DGEN(27.12,DFN)
  1. Q
  1. ;
  1. PENDING(DFN) ;
  1. ;Description: Used to determine if, for a given patient, there is
  1. ;an enrollment query pending (STATUS=TRANSMITTED).
  1. ;
  1. N DGQRY,PENDING
  1. S PENDING=0
  1. I $$GET^DGENQRY($$FINDLAST($G(DFN)),.DGQRY) I 'DGQRY("STATUS") S PENDING=1
  1. Q PENDING
  1. ;
  1. FINDMSG(MSGID) ;
  1. ;Description: Used to find a record in the ENROLLMENT QUERY LOG file,
  1. ;give the unique message id assigned to the query by the HL7 package.
  1. ;
  1. ;Input:
  1. ; MSGID - the unique id assigned to the query by the HL7 package and stored in the ENROLLMENT QUERY LOG as the MESSAGE ID field.
  1. ;
  1. ;Output:
  1. ; Function Value - If successful, returns the ien of the record in the file, otherwise returns 0 on failure.
  1. Q:($G(MSGID)="") 0
  1. Q $O(^DGEN(27.12,"C",MSGID,0))
  1. ;
  1. FINDLAST(DFN) ;
  1. ;
  1. ;Description: Finds the last query sent for a patient.
  1. ;Input:
  1. ; DFN - ien of record in the PATIENT file, identifies the patient to
  1. ; find the query for.
  1. ;Output:
  1. ; Function Value - If successful, returns the ien of the record in the
  1. ; file, otherwise returns 0 on failure.
  1. ;
  1. Q:'$G(DFN) 0
  1. N TIME
  1. S TIME=$O(^DGEN(27.12,"ADT",DFN,9999999.999999),-1)
  1. Q:'TIME 0
  1. Q $O(^DGEN(27.12,"ADT",DFN,TIME,0))
  1. ;
  1. GET(IEN,DGQRY) ;
  1. ;Description: Used to obtain a record in the ENROLLMENT QUERY LOG file
  1. ;The values are returned in the PLOG() array.
  1. ;
  1. ;Input:
  1. ; IEN -of a record in the ENROLLMENT QUERY LOG file.
  1. ;
  1. ;Output:
  1. ; Function Value - 1 on success, 0 on failure.
  1. ; DGQRY() array, pass by reference. Subscripts are
  1. ; "DFN" - PATIENT field
  1. ; "SENT" - DT/TM SENT field
  1. ; "STATUS" - STATUS field
  1. ; "MSGID" - MESSAGE ID field
  1. ; "RESPONSE" - DT/TM RESPONSE
  1. ; "RESPONSE ID" - MSG ID OF RESPONSE
  1. ; "NOTIFY" - NOTIFY field
  1. ; "FIRST" - FIRST DT/TM field
  1. ;
  1. ;
  1. N NODE,SUCCESS
  1. K DGQRY
  1. S SUCCESS=1
  1. I '$G(IEN) S SUCCESS=0
  1. S NODE=$S(SUCCESS:$G(^DGEN(27.12,IEN,0)),1:"")
  1. S DGQRY("DFN")=$P(NODE,"^")
  1. S DGQRY("SENT")=$P(NODE,"^",2)
  1. S DGQRY("STATUS")=$P(NODE,"^",3)
  1. S DGQRY("MSGID")=$P(NODE,"^",5)
  1. S DGQRY("RESPONSE")=$P(NODE,"^",6)
  1. S DGQRY("RESPONSEID")=$P(NODE,"^",7)
  1. S DGQRY("NOTIFY")=$P(NODE,"^",8)
  1. S DGQRY("FIRST")=$P(NODE,"^",9)
  1. S DGQRY("ERROR")=$P($G(^DGEN(27.12,IEN,10)),"^")
  1. Q SUCCESS
  1. ;
  1. LOG(DGQRY) ;
  1. ;Description: Creates a record in the ENROLLMENT QUERY LOG file from the
  1. ;values contained in the DGQRY() array. Note: this function does not
  1. ;lock the ENROLLMENT QUERY LOG file for the patient. It should be
  1. ;locked before calling this function.
  1. ;
  1. ;Input:
  1. ; DGQRY - this array should contain values for all the subscripts
  1. ; defined for the DGQRY array. (pass by reference)
  1. ;
  1. ;Output:
  1. ; Function Value - If successful, returns the ien of the newly created
  1. ; record, otherwise returns 0.
  1. ;
  1. N DATA
  1. S DATA(.01)=DGQRY("DFN")
  1. S DATA(.02)=DGQRY("SENT")
  1. S DATA(.03)=DGQRY("STATUS")
  1. S DATA(.05)=DGQRY("MSGID")
  1. S DATA(.06)=DGQRY("RESPONSE")
  1. S DATA(.07)=DGQRY("RESPONSEID")
  1. S DATA(.08)=DGQRY("NOTIFY")
  1. S DATA(.09)=DGQRY("FIRST")
  1. Q $$ADD^DGENDBS(27.12,,.DATA)
  1. ;
  1. DELETE(IEN) ;
  1. ;Description: Deletes the record in the ENROLLMENT QUERY LOG file whose ien=IEN.
  1. ;
  1. ;Input:
  1. ; IEN - the internal entry number of the record.
  1. ;
  1. ;Output:
  1. ; Function Value - 1 on success, 0 on failure.
  1. ;
  1. Q:'$G(IEN) 0
  1. N DIK,DA
  1. S DIK="^DGEN(27.12,"
  1. S DA=IEN
  1. D ^DIK
  1. Q 1
  1. ;
  1. SETADT1(IEN,DFN) ;
  1. ;set logic for the ADT x-ref of the ENROLLMENT QUERY LOG
  1. ;
  1. Q:'DFN
  1. N SENT
  1. S SENT=$P($G(^DGEN(27.12,IEN,0)),"^",2)
  1. Q:'SENT
  1. S ^DGEN(27.12,"ADT",DFN,SENT,IEN)=""
  1. Q
  1. KILLADT1(IEN,DFN) ;
  1. ;kill logic for the ADT x-ref of the ENROLLMENT QUERY LOG
  1. ;
  1. Q:'DFN
  1. N SENT
  1. S SENT=$P($G(^DGEN(27.12,IEN,0)),"^",2)
  1. Q:'SENT
  1. K ^DGEN(27.12,"ADT",DFN,SENT,IEN)
  1. Q
  1. SETADT2(IEN,SENT) ;
  1. ;set logic for the ADT x-ref of the ENROLLMENT QUERY LOG
  1. ;
  1. Q:'SENT
  1. N DFN
  1. S DFN=$P($G(^DGEN(27.12,IEN,0)),"^")
  1. Q:'DFN
  1. S ^DGEN(27.12,"ADT",DFN,SENT,IEN)=""
  1. Q
  1. ;
  1. KILLADT2(IEN,SENT) ;
  1. ;kill logic for the ADT x-ref of the ENROLLMENT QUERY LOG
  1. ;
  1. Q:'SENT
  1. N DFN
  1. S DFN=$P($G(^DGEN(27.12,IEN,0)),"^")
  1. Q:'DFN
  1. K ^DGEN(27.12,"ADT",DFN,SENT,IEN)
  1. Q
  1. ;
  1. SETADS1(IEN,STATUS) ;
  1. ;set logic for the ADS x-ref of the ENROLLMENT QUERY LOG
  1. ;
  1. Q:STATUS
  1. N SENT
  1. S SENT=$P($P($G(^DGEN(27.12,IEN,0)),"^",2),".")
  1. Q:'SENT
  1. S ^DGEN(27.12,"ADS",SENT,IEN)=""
  1. Q
  1. KILLADS1(IEN,STATUS) ;
  1. ;kill logic for the ADS x-ref of the ENROLLMENT QUERY LOG
  1. ;
  1. Q:STATUS
  1. N SENT
  1. S SENT=$P($P($G(^DGEN(27.12,IEN,0)),"^",2),".")
  1. Q:'SENT
  1. K ^DGEN(27.12,"ADS",SENT,IEN)
  1. Q
  1. SETADS2(IEN,SENT) ;
  1. ;set logic for the ADS x-ref of the ENROLLMENT QUERY LOG
  1. ;
  1. S SENT=$P(SENT,".")
  1. Q:'SENT
  1. N STATUS
  1. S STATUS=$P($G(^DGEN(27.12,IEN,0)),"^",3)
  1. Q:STATUS
  1. S ^DGEN(27.12,"ADS",SENT,IEN)=""
  1. Q
  1. ;
  1. KILLADS2(IEN,SENT) ;
  1. ;kill logic for the ADS x-ref of the ENROLLMENT QUERY LOG
  1. ;
  1. S SENT=$P(SENT,".")
  1. Q:'SENT
  1. N STATUS
  1. S STATUS=$P($G(^DGEN(27.12,IEN,0)),"^",3)
  1. Q:STATUS
  1. K ^DGEN(27.12,"ADS",SENT,IEN)
  1. Q
  1. ;
  1. ON(DGON) ;
  1. ;check to see if the ENROLLMENT QUERY ACTIVE? switch is on or off
  1. ;returns 0 if not set to transmit queries to HEC
  1. ;returns 1 if set to transmit queries to HEC
  1. ;
  1. N DGON,DA
  1. S DGON=0
  1. S DA=$O(^IVM(301.9,0))
  1. I DA,$P($G(^IVM(301.9,DA,15)),"^") S DGON=1
  1. Q DGON
  1. ;
  1. TURNON ;put 1 in the new ENROLLMENT QUERY ACTIVE? field (#15) of the
  1. ;IVM SITE PARAMETER file (#301.9)
  1. ;
  1. N DA,DATA
  1. S DA=$O(^IVM(301.9,0))
  1. S DATA(15)=1
  1. I $$UPD^DGENDBS(301.9,DA,.DATA) ;else the update failed
  1. Q
  1. ;
  1. TURNOFF ;put 0 in the new ENROLLMENT QUERY ACTIVE? field (#15) of the
  1. ;IVM SITE PARAMETER file (#301.9)
  1. ;
  1. N DA,DATA
  1. S DA=$O(^IVM(301.9,0))
  1. S DATA(15)=0
  1. I $$UPD^DGENDBS(301.9,DA,.DATA) ;else the update failed
  1. Q