IBCNRMFE ;BHAM ISC/DMK - Receive HL7 e-Pharmacy MFE Segment ;23-OCT-2003
;;2.0;INTEGRATED BILLING;**251,276,550**;21-MAR-94;Build 25
;;Per VA Directive 6402, this routine should not be modified.
;
; Description
;
; Receive HL7 e-Pharmacy MFE Segment
; Master File Entry
;
; Prepare for potential subsequent Z** Segment(s)
;
; Called by IBCNRHLT
;
; Entry point
;
1000 ; Control MFE Segment processing
D INIT
Q
;
INIT ; Initialize MFE Segment variables
K DATA,DATAAP,DATACM,ERROR
N ANAME,FILENO1,KEY
;
S EPHARM=1
S FILENO=FLN
;
S DATE("NOW")=$$NOW^XLFDT()
;
; Record-Level Event Code (action)
; MAC = Activate
; MAD = Add
; MDC = Deactivate
; MDL = Delete
; MUP = Update
S IBCNACT=$G(IBSEG(2))
;
; Primary Key Value ID
S KEY=$P($G(IBSEG(5)),$E(HLECH,1),1)
;
; Convert HL7 special characters if necessary
I KEY[$E(HLECH,3) S KEY=$$TRAN1^IBCNRHLU(KEY)
;
S IEN=$$LOOKUP1^IBCNRFM1(FILENO,KEY)
;
; Error?
; V200 = NCPDP Processor Name Undefined
; V300 = Pharmacy Benefits Manager (PBM) Name Undefined
; V400 = Plan ID Undefined
; V500 = Plan ID Undefined
I FILE["Pharmacy Plan",IEN=-1 S ERROR="V500" Q
I IBCNACT'="MAD",IEN=-1 S ERROR=$S(FILENO=366.01:"V200",FILENO=366.02:"V300",FILENO=366.03:"V400",1:"V500") Q
;
S FIELDNO=3
S FILENO1=FILENO+.1
S ANAME="E-PHARM"
S AIEN=$$LOOKUP1^IBCNRFM1(FILENO1,ANAME)
I AIEN=-1 S AIEN=$$ADD1^IBCNRFM1(FILENO1,ANAME)
I IEN'=-1 S APIEN=$$LOOKUP2^IBCNRFM1(FILENO,IEN,FIELDNO,ANAME)
I IEN=-1 S APIEN=-1
;
; Error?
; V201 = E-PHARM Application Undefined
; V301 = E-PHARM Application Undefined
; V401 = E-PHARM Application Undefined
; V501 = E-PHARM Application Undefined
I IBCNACT'="MAD",APIEN=-1 D Q
. S ERROR=$S(FILENO=366.01:"V201",FILENO=366.02:"V301",FILENO=366.03:"V401",1:"V501")
. I FILE["Pharmacy" S ERROR="V501"
;
; MAC = Activate
I IBCNACT="MAC" D INITMAC
;
; MAD = Add
I IBCNACT="MAD" D INITMAD
;
; MDC = Deactivate
I IBCNACT="MDC" D INITMDC
;
; MDL = Delete
I IBCNACT="MDL" D INITMDL
;
; MUP = Update
I IBCNACT="MUP" D INITMUP
Q
;
INITMAD ; Initialize APPLICATION Subfile variables if MAD (Add) action
; 366.013 NCPDP PROCESSOR APPLICATION Subfile
; 366.023 PHARMACY BENEFITS MANAGER (PBM) APPLICATION Subfile
; 366.033 PLAN APPLICATION Subfile
;
; Process MAD (Add) as MAC (Activate)
D INITMAC
;
; .03 LOCAL ACTIVE?
; Set to INACTIVE for PLAN, all others ACTIVE
S DATAAP(.03)=$S(FILENO=366.03:0,1:1)
;
; .04 USER EDITED LOCAL
S DATAAP(.04)=IDUZ
;
; .05 DATE/TIME LOCAL EDITED
S DATAAP(.05)=DATE("NOW")
;
; .13 DATE/TIME CREATED
S DATAAP(.13)=DATE("NOW")
Q
;
INITMAC ; Initialize APPLICATION Subfile variables if MAC (Activate) action
; 366.013 NCPDP PROCESSOR APPLICATION Subfile
; 366.023 PHARMACY BENEFITS MANAGER (PBM) APPLICATION Subfile
; 366.033 PLAN APPLICATION Subfile
;
; .02 NATIONAL ACTIVE?
S DATAAP(.02)=1
;
; .06 DATE/TIME NATIONAL EDITED
S DATAAP(.06)=DATE("NOW")
;
; .11 DEACTIVATED?
S DATAAP(.11)=0
;
; .12 DATE/TIME DEACTIVATED
S DATAAP(.12)="@"
Q
;
INITMDC ; Initialize APPLICATION Subfile variables if MDC (deactivate) action
; 366.013 NCPDP PROCESSOR APPLICATION Subfile
; 366.023 PHARMACY BENEFITS MANAGER (PBM) APPLICATION Subfile
; 366.033 PLAN APPLICATION Subfile
;
; .02 NATIONAL ACTIVE?
S DATAAP(.02)=0
;
; .06 DATE/TIME NATIONAL EDITED
S DATAAP(.06)=DATE("NOW")
;
; .11 DEACTIVATED?
S DATAAP(.11)=1
;
; .12 DATE/TIME DEACTIVATED
S DATAAP(.12)=DATE("NOW")
Q
;
INITMDL ; Initialize APPLICATION Subfile variables if MDL (Delete) action
; 366.013 NCPDP PROCESSOR APPLICATION Subfile
; 366.023 PHARMACY BENEFITS MANAGER (PBM) APPLICATION Subfile
; 366.033 PLAN APPLICATION Subfile
;
; Process MDL (Delete) as MDC (Deactivate)
D INITMDC
Q
;
INITMUP ; Initialize APPLICATION Subfile variables if MUP (Update) action
; 366.013 NCPDP PROCESSOR APPLICATION Subfile
; 366.023 PHARMACY BENEFITS MANAGER (PBM) APPLICATION Subfile
; 366.033 PLAN APPLICATION Subfile
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HIBCNRMFE 4128 printed Oct 16, 2024@18:16:58 Page 2
IBCNRMFE ;BHAM ISC/DMK - Receive HL7 e-Pharmacy MFE Segment ;23-OCT-2003
+1 ;;2.0;INTEGRATED BILLING;**251,276,550**;21-MAR-94;Build 25
+2 ;;Per VA Directive 6402, this routine should not be modified.
+3 ;
+4 ; Description
+5 ;
+6 ; Receive HL7 e-Pharmacy MFE Segment
+7 ; Master File Entry
+8 ;
+9 ; Prepare for potential subsequent Z** Segment(s)
+10 ;
+11 ; Called by IBCNRHLT
+12 ;
+13 ; Entry point
+14 ;
1000 ; Control MFE Segment processing
+1 DO INIT
+2 QUIT
+3 ;
INIT ; Initialize MFE Segment variables
+1 KILL DATA,DATAAP,DATACM,ERROR
+2 NEW ANAME,FILENO1,KEY
+3 ;
+4 SET EPHARM=1
+5 SET FILENO=FLN
+6 ;
+7 SET DATE("NOW")=$$NOW^XLFDT()
+8 ;
+9 ; Record-Level Event Code (action)
+10 ; MAC = Activate
+11 ; MAD = Add
+12 ; MDC = Deactivate
+13 ; MDL = Delete
+14 ; MUP = Update
+15 SET IBCNACT=$GET(IBSEG(2))
+16 ;
+17 ; Primary Key Value ID
+18 SET KEY=$PIECE($GET(IBSEG(5)),$EXTRACT(HLECH,1),1)
+19 ;
+20 ; Convert HL7 special characters if necessary
+21 IF KEY[$EXTRACT(HLECH,3)
SET KEY=$$TRAN1^IBCNRHLU(KEY)
+22 ;
+23 SET IEN=$$LOOKUP1^IBCNRFM1(FILENO,KEY)
+24 ;
+25 ; Error?
+26 ; V200 = NCPDP Processor Name Undefined
+27 ; V300 = Pharmacy Benefits Manager (PBM) Name Undefined
+28 ; V400 = Plan ID Undefined
+29 ; V500 = Plan ID Undefined
+30 IF FILE["Pharmacy Plan"
IF IEN=-1
SET ERROR="V500"
QUIT
+31 IF IBCNACT'="MAD"
IF IEN=-1
SET ERROR=$SELECT(FILENO=366.01:"V200",FILENO=366.02:"V300",FILENO=366.03:"V400",1:"V500")
QUIT
+32 ;
+33 SET FIELDNO=3
+34 SET FILENO1=FILENO+.1
+35 SET ANAME="E-PHARM"
+36 SET AIEN=$$LOOKUP1^IBCNRFM1(FILENO1,ANAME)
+37 IF AIEN=-1
SET AIEN=$$ADD1^IBCNRFM1(FILENO1,ANAME)
+38 IF IEN'=-1
SET APIEN=$$LOOKUP2^IBCNRFM1(FILENO,IEN,FIELDNO,ANAME)
+39 IF IEN=-1
SET APIEN=-1
+40 ;
+41 ; Error?
+42 ; V201 = E-PHARM Application Undefined
+43 ; V301 = E-PHARM Application Undefined
+44 ; V401 = E-PHARM Application Undefined
+45 ; V501 = E-PHARM Application Undefined
+46 IF IBCNACT'="MAD"
IF APIEN=-1
Begin DoDot:1
+47 SET ERROR=$SELECT(FILENO=366.01:"V201",FILENO=366.02:"V301",FILENO=366.03:"V401",1:"V501")
+48 IF FILE["Pharmacy"
SET ERROR="V501"
End DoDot:1
QUIT
+49 ;
+50 ; MAC = Activate
+51 IF IBCNACT="MAC"
DO INITMAC
+52 ;
+53 ; MAD = Add
+54 IF IBCNACT="MAD"
DO INITMAD
+55 ;
+56 ; MDC = Deactivate
+57 IF IBCNACT="MDC"
DO INITMDC
+58 ;
+59 ; MDL = Delete
+60 IF IBCNACT="MDL"
DO INITMDL
+61 ;
+62 ; MUP = Update
+63 IF IBCNACT="MUP"
DO INITMUP
+64 QUIT
+65 ;
INITMAD ; Initialize APPLICATION Subfile variables if MAD (Add) action
+1 ; 366.013 NCPDP PROCESSOR APPLICATION Subfile
+2 ; 366.023 PHARMACY BENEFITS MANAGER (PBM) APPLICATION Subfile
+3 ; 366.033 PLAN APPLICATION Subfile
+4 ;
+5 ; Process MAD (Add) as MAC (Activate)
+6 DO INITMAC
+7 ;
+8 ; .03 LOCAL ACTIVE?
+9 ; Set to INACTIVE for PLAN, all others ACTIVE
+10 SET DATAAP(.03)=$SELECT(FILENO=366.03:0,1:1)
+11 ;
+12 ; .04 USER EDITED LOCAL
+13 SET DATAAP(.04)=IDUZ
+14 ;
+15 ; .05 DATE/TIME LOCAL EDITED
+16 SET DATAAP(.05)=DATE("NOW")
+17 ;
+18 ; .13 DATE/TIME CREATED
+19 SET DATAAP(.13)=DATE("NOW")
+20 QUIT
+21 ;
INITMAC ; Initialize APPLICATION Subfile variables if MAC (Activate) action
+1 ; 366.013 NCPDP PROCESSOR APPLICATION Subfile
+2 ; 366.023 PHARMACY BENEFITS MANAGER (PBM) APPLICATION Subfile
+3 ; 366.033 PLAN APPLICATION Subfile
+4 ;
+5 ; .02 NATIONAL ACTIVE?
+6 SET DATAAP(.02)=1
+7 ;
+8 ; .06 DATE/TIME NATIONAL EDITED
+9 SET DATAAP(.06)=DATE("NOW")
+10 ;
+11 ; .11 DEACTIVATED?
+12 SET DATAAP(.11)=0
+13 ;
+14 ; .12 DATE/TIME DEACTIVATED
+15 SET DATAAP(.12)="@"
+16 QUIT
+17 ;
INITMDC ; Initialize APPLICATION Subfile variables if MDC (deactivate) action
+1 ; 366.013 NCPDP PROCESSOR APPLICATION Subfile
+2 ; 366.023 PHARMACY BENEFITS MANAGER (PBM) APPLICATION Subfile
+3 ; 366.033 PLAN APPLICATION Subfile
+4 ;
+5 ; .02 NATIONAL ACTIVE?
+6 SET DATAAP(.02)=0
+7 ;
+8 ; .06 DATE/TIME NATIONAL EDITED
+9 SET DATAAP(.06)=DATE("NOW")
+10 ;
+11 ; .11 DEACTIVATED?
+12 SET DATAAP(.11)=1
+13 ;
+14 ; .12 DATE/TIME DEACTIVATED
+15 SET DATAAP(.12)=DATE("NOW")
+16 QUIT
+17 ;
INITMDL ; Initialize APPLICATION Subfile variables if MDL (Delete) action
+1 ; 366.013 NCPDP PROCESSOR APPLICATION Subfile
+2 ; 366.023 PHARMACY BENEFITS MANAGER (PBM) APPLICATION Subfile
+3 ; 366.033 PLAN APPLICATION Subfile
+4 ;
+5 ; Process MDL (Delete) as MDC (Deactivate)
+6 DO INITMDC
+7 QUIT
+8 ;
INITMUP ; Initialize APPLICATION Subfile variables if MUP (Update) action
+1 ; 366.013 NCPDP PROCESSOR APPLICATION Subfile
+2 ; 366.023 PHARMACY BENEFITS MANAGER (PBM) APPLICATION Subfile
+3 ; 366.033 PLAN APPLICATION Subfile
+4 QUIT