- DGENUPL7 ;ISA/KWP/CKN/TMK,TDM,LBD - PROCESS INCOMING (Z11 EVENT TYPE) HL7 MESSAGES ; 8/1/11 5:07pm
- ;;5.3;PIMS;**232,367,397,417,379,431,513,628,673,653,742,1015,1016**;JUN 30, 2012;Build 20
- ;Phase II split from DGENUPL
- Z11(MSGIEN,MSGID,CURLINE,DFN,ERRCOUNT) ;
- ;Description: This is used to process a single ORU~Z11 or ORF~Z11 msg.
- ;Input:
- ; MSGIEN - the internal entry number of the HL7 message in the
- ; HL7 MESSAGE TEXT file (772)
- ; MSGID -message control id of HL7 msg in the MSH segment
- ; CURLINE - the subscript of the MSH segment of the current message (pass by reference)
- ; DFN - identifies the patient, is the ien of a record in the PATIENT file.
- ; ERRCOUNT - is a count of the number of messages in the batch that can not be processed (pass by reference)
- ;
- ;Output:
- ; CURLINE - upon leaving the procedure this parameter should be set to the end of the current message. (pass by reference)
- ; ERRCOUNT - set to count of messages that were not processed due to errors encountered (pass by reference)
- ;
- N DGELG,DGENR,DGPAT,DGCDIS,DGOEIF,ERROR,ERRMSG,MSGS,DGELGSUB,DGENUPLD,DGCON,DGNMSE
- N DGNEWVAL,DIV,SUB,OLDELG,OLDPAT,OLDDCDIS,OLDEIF,DGSEC,OLDSEC,DGNTR,DGMST,DGPHINC
- ;
- ;some process is killing these HL7 variables, so need to protect them
- S SUB=HLFS
- S DIV=HLECH
- N HLDA,HLDAN,HLDAP,HLDT,HLDT1,HLECH,HLFS,HLNDAP,HLNDAP0,HLPID,HLQ,HLVER,HLERR,HLMTN,HLSDT
- S HLFS=SUB
- S HLECH=DIV
- S HLQ=""""""
- K DIV,SUB
- ;
- ;drops out of block on error
- D
- .Q:'$$PARSE^DGENUPL1(MSGIEN,MSGID,.CURLINE,.ERRCOUNT,.DGPAT,.DGELG,.DGENR,.DGCDIS,.DGOEIF,.DGSEC,.DGNTR,.DGMST,.DGNMSE)
- .D GETLOCKS^DGENUPL5(DFN)
- .;
- .;Used by cross-references to determine if an upload is in progress.
- .S DGENUPLD="ENROLLMENT/ELIGIBILITY UPLOAD IN PROGRESS"
- .;
- .;Update the PATIENT, ELIGIBILITY, CATASTROPHIC DISABILITY objects in memory
- .Q:'$$UOBJECTS^DGENUPL4(DFN,.DGPAT,.DGELG,.DGCDIS,.DGOEIF,MSGID,.ERRCOUNT,.MSGS,.OLDPAT,.OLDELG,.OLDCDIS,.OLDEIF)
- .S ERROR=0
- .;if the msg contains patient security, process it
- .I $D(DGSEC) D Q:ERROR
- ..S DGSEC("DFN")=DFN
- ..S DGSEC("USER")=.5
- ..I DGSEC("LEVEL")'="" D
- ...I DGSEC("DATETIME")="" S DGSEC("DATETIME")=$$NOW^XLFDT ;DG*5.3*653
- ..;
- ..; check consistency of patient security record
- ..I '$$CHECK^DGENSEC(.DGSEC,.ERRMSG) D Q
- ...S ERROR=1
- ...D ADDERROR^DGENUPL(MSGID,DGPAT("SSN"),ERRMSG,.ERRCOUNT)
- ..;
- ..; upload patient security, consistency checks passed
- ..D SECUPLD^DGENUPL5(DFN,.DGSEC,.OLDSEC)
- .;
- .;if the msg has an enrollment process it
- .I DGENR("STATUS")!DGENR("APP") D Q:ERROR
- ..;use $$PRIORITY to get the eligibility data used to compute priority
- ..I $$PRIORITY^DGENELA4(DFN,.DGELG,.DGELGSUB,DGENR("DATE"),DGENR("APP"))
- ..;
- ..;store the eligibility data in the enrollment record and other missing fields
- ..M DGENR("ELIG")=DGELGSUB
- ..S DGENR("DFN")=DFN
- ..S DGENR("PRIORREC")=""
- ..S DGENR("USER")=.5
- ..S DGENR("DATETIME")=$$NOW^XLFDT
- ..;
- ..;Allow null overwrites of Ineligible data (Ineligible Project):
- ..I $D(DGENR("DATE")),DGENR("DATE")="" S DGENR("DATE")="@"
- ..I $D(DGENR("FACREC")),DGENR("FACREC")="" S DGENR("FACREC")="@"
- ..;
- ..;check the consistency of the enrollment record
- ..I '$$CHECK^DGENA3(.DGENR,.DGPAT,.ERRMSG) D Q
- ...S ERROR=1
- ...D ADDERROR^DGENUPL(MSGID,DGPAT("SSN"),ERRMSG,.ERRCOUNT)
- ..;
- ..; removed EGT consistency check with DG*5.3*628
- ..;Phase II EGT consistency checks (SRS 6.5.1.3)
- ..;Only do the EGT consistency checks for Rejected-Fiscal Year (11),Rejected-Mid Cycle (12),Rejected-Stop enrolling new apps (13),Rejected-Initil App by VAMC (14),Rejected below EGT threshold (22)
- ..;I "^11^12^13^14^22^"[("^"_DGENR("STATUS")_"^"),$$ABOVE^DGENEGT1(DGENR("DFN"),DGENR("PRIORITY"),DGENR("SUBGRP"),"","",1) D Q
- ..;.S ERROR=1
- ..;.S ERRMSG="THE ENROLLMENT RECORD DID NOT PASS THE EGT CONSISTENCY CHECKS."
- ..;.D ADDERROR^DGENUPL(MSGID,DGPAT("SSN"),ERRMSG,.ERRCOUNT)
- ..;
- ..;Allow null overwrites for Ineligible vets (Ineligible Project):
- ..I $G(DGPAT("INELDATE"))'="" S (DGENR("PRIORITY"),DGENR("SUBGRP"))=""
- ..I DGENR("DATE")="@" S DGENR("DATE")=""
- ..I DGENR("FACREC")="@" S DGENR("FACREC")=""
- ..;
- ..D ENRUPLD^DGENUPL8(.DGENR,.DGPAT)
- .;
- .;Store the PATIENT, ELIGIBILITY, & CAT. DISB. objects
- .I $$STORE^DGENPTA1(.DGPAT,,1)
- .I $$STORE^DGENELA1(.DGELG,.DGPAT,.DGCDIS,,1)
- .I $G(DGCDIS("VCD"))'="",$$STORE^DGENCDA2(DFN,.DGCDIS) ;checks first if there is catastrophic disability information
- .;
- .;Call PIMS api to file NTR data.
- .I $D(DGNTR),$$ENRUPD^DGNTAPI1(DFN,.DGNTR)
- .;
- .;Call PIMS api to file MST data.
- .I DGMST("MSTSTAT")'="",DGMST("MSTDT")'="",DGMST("MSTST")'="" D
- ..I $$NEWSTAT^DGMSTAPI(DFN,DGMST("MSTSTAT"),DGMST("MSTDT"),".5",DGMST("MSTST"),0)
- .;
- .;Since HEC is authoritative source, If no OEF/OIF data in Z11, set count to 0 so existing data in VistA will be deleted.
- .I '$D(DGOEIF) S DGOEIF("COUNT")=0
- .;Call PIMS api to file OEF/OIF data.
- .I $D(DGOEIF) D OEIFUPD^DGCLAPI1(DFN,.DGOEIF)
- .;
- .;File the Military Service Episode (MSE) data (DG*5.3*797)
- .I $D(DGNMSE) D UPDMSE^DGMSEUTL(DFN,.DGNMSE)
- .;
- .;if the current enrollment is a local then log patient for transmission
- .I $$SOURCE^DGENA(DFN)=1!$G(DGPHINC) K DGENUPLD,DGPHINC D EVENT^IVMPLOG(DFN)
- .;
- .;create the audit trail
- .I $$AUDIT^DGENUPA1(,MSGID,.OLDPAT,.DGPAT,.OLDELG,.DGELG,.OLDCDIS,.DGCDIS,.DGSEC,.OLDSEC)
- .;send notifications
- .D NOTIFY^DGENUPL3(.DGPAT,.MSGS)
- .;
- .;invoke registration consistency checker
- .D REGCHECK^DGENUPL2(DFN)
- ;
- D UNLOCK^DGENUPL5(DFN)
- Q
- DGENUPL7 ;ISA/KWP/CKN/TMK,TDM,LBD - PROCESS INCOMING (Z11 EVENT TYPE) HL7 MESSAGES ; 8/1/11 5:07pm
- +1 ;;5.3;PIMS;**232,367,397,417,379,431,513,628,673,653,742,1015,1016**;JUN 30, 2012;Build 20
- +2 ;Phase II split from DGENUPL
- Z11(MSGIEN,MSGID,CURLINE,DFN,ERRCOUNT) ;
- +1 ;Description: This is used to process a single ORU~Z11 or ORF~Z11 msg.
- +2 ;Input:
- +3 ; MSGIEN - the internal entry number of the HL7 message in the
- +4 ; HL7 MESSAGE TEXT file (772)
- +5 ; MSGID -message control id of HL7 msg in the MSH segment
- +6 ; CURLINE - the subscript of the MSH segment of the current message (pass by reference)
- +7 ; DFN - identifies the patient, is the ien of a record in the PATIENT file.
- +8 ; ERRCOUNT - is a count of the number of messages in the batch that can not be processed (pass by reference)
- +9 ;
- +10 ;Output:
- +11 ; CURLINE - upon leaving the procedure this parameter should be set to the end of the current message. (pass by reference)
- +12 ; ERRCOUNT - set to count of messages that were not processed due to errors encountered (pass by reference)
- +13 ;
- +14 NEW DGELG,DGENR,DGPAT,DGCDIS,DGOEIF,ERROR,ERRMSG,MSGS,DGELGSUB,DGENUPLD,DGCON,DGNMSE
- +15 NEW DGNEWVAL,DIV,SUB,OLDELG,OLDPAT,OLDDCDIS,OLDEIF,DGSEC,OLDSEC,DGNTR,DGMST,DGPHINC
- +16 ;
- +17 ;some process is killing these HL7 variables, so need to protect them
- +18 SET SUB=HLFS
- +19 SET DIV=HLECH
- +20 NEW HLDA,HLDAN,HLDAP,HLDT,HLDT1,HLECH,HLFS,HLNDAP,HLNDAP0,HLPID,HLQ,HLVER,HLERR,HLMTN,HLSDT
- +21 SET HLFS=SUB
- +22 SET HLECH=DIV
- +23 SET HLQ=""""""
- +24 KILL DIV,SUB
- +25 ;
- +26 ;drops out of block on error
- +27 Begin DoDot:1
- +28 IF '$$PARSE^DGENUPL1(MSGIEN,MSGID,.CURLINE,.ERRCOUNT,.DGPAT,.DGELG,.DGENR,.DGCDIS,.DGOEIF,.DGSEC,.DGNTR,.DGMST,.DGNMSE)
- QUIT
- +29 DO GETLOCKS^DGENUPL5(DFN)
- +30 ;
- +31 ;Used by cross-references to determine if an upload is in progress.
- +32 SET DGENUPLD="ENROLLMENT/ELIGIBILITY UPLOAD IN PROGRESS"
- +33 ;
- +34 ;Update the PATIENT, ELIGIBILITY, CATASTROPHIC DISABILITY objects in memory
- +35 IF '$$UOBJECTS^DGENUPL4(DFN,.DGPAT,.DGELG,.DGCDIS,.DGOEIF,MSGID,.ERRCOUNT,.MSGS,.OLDPAT,.OLDELG,.OLDCDIS,.OLDEIF)
- QUIT
- +36 SET ERROR=0
- +37 ;if the msg contains patient security, process it
- +38 IF $DATA(DGSEC)
- Begin DoDot:2
- +39 SET DGSEC("DFN")=DFN
- +40 SET DGSEC("USER")=.5
- +41 IF DGSEC("LEVEL")'=""
- Begin DoDot:3
- +42 ;DG*5.3*653
- IF DGSEC("DATETIME")=""
- SET DGSEC("DATETIME")=$$NOW^XLFDT
- End DoDot:3
- +43 ;
- +44 ; check consistency of patient security record
- +45 IF '$$CHECK^DGENSEC(.DGSEC,.ERRMSG)
- Begin DoDot:3
- +46 SET ERROR=1
- +47 DO ADDERROR^DGENUPL(MSGID,DGPAT("SSN"),ERRMSG,.ERRCOUNT)
- End DoDot:3
- QUIT
- +48 ;
- +49 ; upload patient security, consistency checks passed
- +50 DO SECUPLD^DGENUPL5(DFN,.DGSEC,.OLDSEC)
- End DoDot:2
- IF ERROR
- QUIT
- +51 ;
- +52 ;if the msg has an enrollment process it
- +53 IF DGENR("STATUS")!DGENR("APP")
- Begin DoDot:2
- +54 ;use $$PRIORITY to get the eligibility data used to compute priority
- +55 IF $$PRIORITY^DGENELA4(DFN,.DGELG,.DGELGSUB,DGENR("DATE"),DGENR("APP"))
- +56 ;
- +57 ;store the eligibility data in the enrollment record and other missing fields
- +58 MERGE DGENR("ELIG")=DGELGSUB
- +59 SET DGENR("DFN")=DFN
- +60 SET DGENR("PRIORREC")=""
- +61 SET DGENR("USER")=.5
- +62 SET DGENR("DATETIME")=$$NOW^XLFDT
- +63 ;
- +64 ;Allow null overwrites of Ineligible data (Ineligible Project):
- +65 IF $DATA(DGENR("DATE"))
- IF DGENR("DATE")=""
- SET DGENR("DATE")="@"
- +66 IF $DATA(DGENR("FACREC"))
- IF DGENR("FACREC")=""
- SET DGENR("FACREC")="@"
- +67 ;
- +68 ;check the consistency of the enrollment record
- +69 IF '$$CHECK^DGENA3(.DGENR,.DGPAT,.ERRMSG)
- Begin DoDot:3
- +70 SET ERROR=1
- +71 DO ADDERROR^DGENUPL(MSGID,DGPAT("SSN"),ERRMSG,.ERRCOUNT)
- End DoDot:3
- QUIT
- +72 ;
- +73 ; removed EGT consistency check with DG*5.3*628
- +74 ;Phase II EGT consistency checks (SRS 6.5.1.3)
- +75 ;Only do the EGT consistency checks for Rejected-Fiscal Year (11),Rejected-Mid Cycle (12),Rejected-Stop enrolling new apps (13),Rejected-Initil App by VAMC (14),Rejected below EGT threshold (22)
- +76 ;I "^11^12^13^14^22^"[("^"_DGENR("STATUS")_"^"),$$ABOVE^DGENEGT1(DGENR("DFN"),DGENR("PRIORITY"),DGENR("SUBGRP"),"","",1) D Q
- +77 ;.S ERROR=1
- +78 ;.S ERRMSG="THE ENROLLMENT RECORD DID NOT PASS THE EGT CONSISTENCY CHECKS."
- +79 ;.D ADDERROR^DGENUPL(MSGID,DGPAT("SSN"),ERRMSG,.ERRCOUNT)
- +80 ;
- +81 ;Allow null overwrites for Ineligible vets (Ineligible Project):
- +82 IF $GET(DGPAT("INELDATE"))'=""
- SET (DGENR("PRIORITY"),DGENR("SUBGRP"))=""
- +83 IF DGENR("DATE")="@"
- SET DGENR("DATE")=""
- +84 IF DGENR("FACREC")="@"
- SET DGENR("FACREC")=""
- +85 ;
- +86 DO ENRUPLD^DGENUPL8(.DGENR,.DGPAT)
- End DoDot:2
- IF ERROR
- QUIT
- +87 ;
- +88 ;Store the PATIENT, ELIGIBILITY, & CAT. DISB. objects
- +89 IF $$STORE^DGENPTA1(.DGPAT,,1)
- +90 IF $$STORE^DGENELA1(.DGELG,.DGPAT,.DGCDIS,,1)
- +91 ;checks first if there is catastrophic disability information
- IF $GET(DGCDIS("VCD"))'=""
- IF $$STORE^DGENCDA2(DFN,.DGCDIS)
- +92 ;
- +93 ;Call PIMS api to file NTR data.
- +94 IF $DATA(DGNTR)
- IF $$ENRUPD^DGNTAPI1(DFN,.DGNTR)
- +95 ;
- +96 ;Call PIMS api to file MST data.
- +97 IF DGMST("MSTSTAT")'=""
- IF DGMST("MSTDT")'=""
- IF DGMST("MSTST")'=""
- Begin DoDot:2
- +98 IF $$NEWSTAT^DGMSTAPI(DFN,DGMST("MSTSTAT"),DGMST("MSTDT"),".5",DGMST("MSTST"),0)
- End DoDot:2
- +99 ;
- +100 ;Since HEC is authoritative source, If no OEF/OIF data in Z11, set count to 0 so existing data in VistA will be deleted.
- +101 IF '$DATA(DGOEIF)
- SET DGOEIF("COUNT")=0
- +102 ;Call PIMS api to file OEF/OIF data.
- +103 IF $DATA(DGOEIF)
- DO OEIFUPD^DGCLAPI1(DFN,.DGOEIF)
- +104 ;
- +105 ;File the Military Service Episode (MSE) data (DG*5.3*797)
- +106 IF $DATA(DGNMSE)
- DO UPDMSE^DGMSEUTL(DFN,.DGNMSE)
- +107 ;
- +108 ;if the current enrollment is a local then log patient for transmission
- +109 IF $$SOURCE^DGENA(DFN)=1!$GET(DGPHINC)
- KILL DGENUPLD,DGPHINC
- DO EVENT^IVMPLOG(DFN)
- +110 ;
- +111 ;create the audit trail
- +112 IF $$AUDIT^DGENUPA1(,MSGID,.OLDPAT,.DGPAT,.OLDELG,.DGELG,.OLDCDIS,.DGCDIS,.DGSEC,.OLDSEC)
- +113 ;send notifications
- +114 DO NOTIFY^DGENUPL3(.DGPAT,.MSGS)
- +115 ;
- +116 ;invoke registration consistency checker
- +117 DO REGCHECK^DGENUPL2(DFN)
- End DoDot:1
- +118 ;
- +119 DO UNLOCK^DGENUPL5(DFN)
- +120 QUIT