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