IBY664PO ;AITC/VD - Post-Installation for IB patch 664; MAR 31, 2020
 ;;2.0;INTEGRATED BILLING;**664**;MAR 21,1994;Build 29
 ;;Per VA Directive 6402, this routine should not be modified.
 ;
 ;
 Q
PRE ; PRE-INSTALL for IBY664PO
 D DELTRG
 Q
 ;
DELTRG ; delete 2 triggers in #2.312,.01
 ; ICR# 2916 - Is for the use of the DELIX^DDMOD call to delete
 ;             the TRIGGERS in #2.312,.01.
 N IBA
 S IBA(2)="     IB*2*664 Pre-Install .....",IBA(1)=" " D MES^XPDUTL(.IBA) K IBA
 ;
 D DELIX^DDMOD(2.312,.01,4)
 S IBA(2)="     >> ^DD(2.312,.01) Trigger #4 deleted",IBA(1)=" " D MES^XPDUTL(.IBA) K IBA
 ;
 D DELIX^DDMOD(2.312,.01,5)
 S IBA(2)="     >> ^DD(2.312,.01) Trigger #5 deleted",IBA(1)=" " D MES^XPDUTL(.IBA) K IBA
 ;
 S IBA(2)="     IB*2*664 Pre-Install Complete",(IBA(1),IBA(3))=" " D MES^XPDUTL(.IBA) K IBA
 Q
 ;- - - - - - - - - - - - - - - - - - - - - - - - - - - -
 ;
 ;
POST ; POST ROUTINE(S)
 N IBXPD,PRODENV,SITE,SITENAME,SITENUM,XPDIDTOT
 S XPDIDTOT=2
 S SITE=$$SITE^VASITE,SITENAME=$P(SITE,U,2),SITENUM=$P(SITE,U,3)
 ;
 S PRODENV=$$PROD^XUPROD(1)   ; 1=Production Environment, 0=Test Environment
 D MES^XPDUTL("")
 D ADDSOI(1)          ; Add 'Electronic Health Record' to the SOI file (#355.12)
 D SITEREG(2,SITENUM) ; Send site registration message to FSC
 ;
 ; Displays the 'Done' message and finishes the progress bar
 D MES^XPDUTL("")
 D MES^XPDUTL("POST-Install for IB*2.0*664 Completed.")
 Q
 ;============================
ADDSOI(IBXPD) ; Add 'ELECTRONIC HEALTH RECORD' to the SOI file.
 N DA,DIK,IBCNT,IBERR,IBIEN,NEWSOI,OLDSOI
 D BMES^XPDUTL(" STEP "_IBXPD_" of "_XPDIDTOT)
 D MES^XPDUTL("-------------")
 D MES^XPDUTL("Adding ELECTRONIC HEALTH RECORD as a new Source of Information")
 D MES^XPDUTL("in the Source of Information File (#355.12) ... ")
 ;
 S NEWSOI(.01)=21,NEWSOI(.02)="ELECTRONIC HEALTH RECORD",NEWSOI(.03)="EHR"
 ;
 S IBCNT=21
 I $D(^IBE(355.12,IBCNT)) D  Q   ; An SOI already exists in record #21.
 . N PCCNT
 . F PCCNT=.01:.01:.03 S OLDSOI(PCCNT)=$$GET1^DIQ(355.12,IBCNT,PCCNT,"I")
 . ;
 . I OLDSOI(.02)="ELECTRONIC HEALTH RECORD",OLDSOI(.03)="EHR" D  Q  ;'EHR' already exists.
 . . D MES^XPDUTL("")
 . . D MES^XPDUTL("ELECTRONIC HEALTH RECORD (EHR) entry was not installed.")
 . . D MES^XPDUTL("It already exists in the Source Of Information file (#355.12).")
 . ;
 . ; Delete pre-existing SOI record #21 because it is not the EHR SOI.
 . S DA=IBCNT S DIK="^IBE(355.12," D ^DIK
 . S IBIEN=$$ADD^IBDFDBS(355.12,,.NEWSOI,.IBERR,IBCNT)
 . I IBERR D  Q
 . . D BMES^XPDUTL("")
 . . D BMES^XPDUTL("*** ERROR ADDING "_NEWSOI(.02)_" CODE TO THE SOURCE OF INFORMATION TABLE (#355.12) (#355.12) - Log a Service Ticket! ***")
 . D BMES^XPDUTL("")
 . D BMES^XPDUTL("Replaced record #21 ("_OLDSOI(.03)_") - "_OLDSOI(.02)_" with the new")
 . D BMES^XPDUTL("ELECTRONIC HEALTH RECORD (EHR) entry in the Source Of Information file")
 . D BMES^XPDUTL("(#355.12).")
 . ;
 . I PRODENV D   ; Send an email to the eInsurance Rapid Response Team.
 . . N MSG,SUBJ,XMINSTR,XMTO
 . . S SUBJ="IB*2*644 - EHR replaces existing SOI #"_$P(SITE,U,3)_" "_$P(SITE,U,2)  ; Approved by eBiz on 5/5/2020 @ USD&P
 . . S SUBJ=$E(SUBJ,1,65)
 . . S MSG(1)="On "_$$FMTE^XLFDT($$NOW^XLFDT)_" at Site # "_SITENUM_" - "_SITENAME_","
 . . S MSG(2)="the installation of patch IB*2.0*664 added the new EHR - ELECTRONIC HEALTH RECORD"
 . . S MSG(3)="entry to the Source Of Information file (#355.12) by removing the non-standardized"
 . . S MSG(4)="entry # 21 for "_OLDSOI(.03)_" - "_OLDSOI(.02)_"."
 . . S MSG(5)=""
 . . S XMTO("VHAeInsuranceRapidResponse@domain.ext")=""
 . . ;
 . . S XMINSTR("FROM")="VistA-eInsurance"
 . . D SENDMSG^XMXAPI(DUZ,SUBJ,"MSG",.XMTO,.XMINSTR)
 ;
 S IBIEN=$$ADD^IBDFDBS(355.12,,.NEWSOI,.IBERR,IBCNT)
 I IBERR D  Q
 . D BMES^XPDUTL("")
 . D BMES^XPDUTL("*** ERROR ADDING "_NEWSOI(.02)_" CODE TO THE SOURCE OF INFORMATION TABLE (#355.12) (#355.12) - Log a Service Ticket! ***")
 D MES^XPDUTL("Source of Information: ELECTRONIC HEALTH RECORD added successfully")
 Q
 ;
SITEREG(IBXPD,SITENUM) ; send site registration message to FSC
 D BMES^XPDUTL(" STEP "_IBXPD_" of "_XPDIDTOT)
 D MES^XPDUTL("-------------")
 D MES^XPDUTL("Send eIV site registration message to FSC ... ")
 ;
 I '$$PROD^XUPROD(1) D MES^XPDUTL("N/A - Not a production account - No site registration message sent") G SITEREGQ
 I SITENUM=358 D MES^XPDUTL("Current Site is MANILA - NO eIV site registration message sent") G SITEREGQ
 D ^IBCNEHLM
 D MES^XPDUTL("eIV site registration message was successfully sent")
 ;
SITEREGQ ;
 Q
 ;
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HIBY664PO   4629     printed  Sep 23, 2025@20:11:23                                                                                                                                                                                                    Page 2
IBY664PO  ;AITC/VD - Post-Installation for IB patch 664; MAR 31, 2020
 +1       ;;2.0;INTEGRATED BILLING;**664**;MAR 21,1994;Build 29
 +2       ;;Per VA Directive 6402, this routine should not be modified.
 +3       ;
 +4       ;
 +5        QUIT 
PRE       ; PRE-INSTALL for IBY664PO
 +1        DO DELTRG
 +2        QUIT 
 +3       ;
DELTRG    ; delete 2 triggers in #2.312,.01
 +1       ; ICR# 2916 - Is for the use of the DELIX^DDMOD call to delete
 +2       ;             the TRIGGERS in #2.312,.01.
 +3        NEW IBA
 +4        SET IBA(2)="     IB*2*664 Pre-Install ....."
           SET IBA(1)=" "
           DO MES^XPDUTL(.IBA)
           KILL IBA
 +5       ;
 +6        DO DELIX^DDMOD(2.312,.01,4)
 +7        SET IBA(2)="     >> ^DD(2.312,.01) Trigger #4 deleted"
           SET IBA(1)=" "
           DO MES^XPDUTL(.IBA)
           KILL IBA
 +8       ;
 +9        DO DELIX^DDMOD(2.312,.01,5)
 +10       SET IBA(2)="     >> ^DD(2.312,.01) Trigger #5 deleted"
           SET IBA(1)=" "
           DO MES^XPDUTL(.IBA)
           KILL IBA
 +11      ;
 +12       SET IBA(2)="     IB*2*664 Pre-Install Complete"
           SET (IBA(1),IBA(3))=" "
           DO MES^XPDUTL(.IBA)
           KILL IBA
 +13       QUIT 
 +14      ;- - - - - - - - - - - - - - - - - - - - - - - - - - - -
 +15      ;
 +16      ;
POST      ; POST ROUTINE(S)
 +1        NEW IBXPD,PRODENV,SITE,SITENAME,SITENUM,XPDIDTOT
 +2        SET XPDIDTOT=2
 +3        SET SITE=$$SITE^VASITE
           SET SITENAME=$PIECE(SITE,U,2)
           SET SITENUM=$PIECE(SITE,U,3)
 +4       ;
 +5       ; 1=Production Environment, 0=Test Environment
           SET PRODENV=$$PROD^XUPROD(1)
 +6        DO MES^XPDUTL("")
 +7       ; Add 'Electronic Health Record' to the SOI file (#355.12)
           DO ADDSOI(1)
 +8       ; Send site registration message to FSC
           DO SITEREG(2,SITENUM)
 +9       ;
 +10      ; Displays the 'Done' message and finishes the progress bar
 +11       DO MES^XPDUTL("")
 +12       DO MES^XPDUTL("POST-Install for IB*2.0*664 Completed.")
 +13       QUIT 
 +14      ;============================
ADDSOI(IBXPD) ; Add 'ELECTRONIC HEALTH RECORD' to the SOI file.
 +1        NEW DA,DIK,IBCNT,IBERR,IBIEN,NEWSOI,OLDSOI
 +2        DO BMES^XPDUTL(" STEP "_IBXPD_" of "_XPDIDTOT)
 +3        DO MES^XPDUTL("-------------")
 +4        DO MES^XPDUTL("Adding ELECTRONIC HEALTH RECORD as a new Source of Information")
 +5        DO MES^XPDUTL("in the Source of Information File (#355.12) ... ")
 +6       ;
 +7        SET NEWSOI(.01)=21
           SET NEWSOI(.02)="ELECTRONIC HEALTH RECORD"
           SET NEWSOI(.03)="EHR"
 +8       ;
 +9        SET IBCNT=21
 +10      ; An SOI already exists in record #21.
           IF $DATA(^IBE(355.12,IBCNT))
               Begin DoDot:1
 +11               NEW PCCNT
 +12               FOR PCCNT=.01:.01:.03
                       SET OLDSOI(PCCNT)=$$GET1^DIQ(355.12,IBCNT,PCCNT,"I")
 +13      ;
 +14      ;'EHR' already exists.
                   IF OLDSOI(.02)="ELECTRONIC HEALTH RECORD"
                       IF OLDSOI(.03)="EHR"
                           Begin DoDot:2
 +15                           DO MES^XPDUTL("")
 +16                           DO MES^XPDUTL("ELECTRONIC HEALTH RECORD (EHR) entry was not installed.")
 +17                           DO MES^XPDUTL("It already exists in the Source Of Information file (#355.12).")
                           End DoDot:2
                           QUIT 
 +18      ;
 +19      ; Delete pre-existing SOI record #21 because it is not the EHR SOI.
 +20               SET DA=IBCNT
                   SET DIK="^IBE(355.12,"
                   DO ^DIK
 +21               SET IBIEN=$$ADD^IBDFDBS(355.12,,.NEWSOI,.IBERR,IBCNT)
 +22               IF IBERR
                       Begin DoDot:2
 +23                       DO BMES^XPDUTL("")
 +24                       DO BMES^XPDUTL("*** ERROR ADDING "_NEWSOI(.02)_" CODE TO THE SOURCE OF INFORMATION TABLE (#355.12) (#355.12) - Log a Service Ticket! ***")
                       End DoDot:2
                       QUIT 
 +25               DO BMES^XPDUTL("")
 +26               DO BMES^XPDUTL("Replaced record #21 ("_OLDSOI(.03)_") - "_OLDSOI(.02)_" with the new")
 +27               DO BMES^XPDUTL("ELECTRONIC HEALTH RECORD (EHR) entry in the Source Of Information file")
 +28               DO BMES^XPDUTL("(#355.12).")
 +29      ;
 +30      ; Send an email to the eInsurance Rapid Response Team.
                   IF PRODENV
                       Begin DoDot:2
 +31                       NEW MSG,SUBJ,XMINSTR,XMTO
 +32      ; Approved by eBiz on 5/5/2020 @ USD&P
                           SET SUBJ="IB*2*644 - EHR replaces existing SOI #"_$PIECE(SITE,U,3)_" "_$PIECE(SITE,U,2)
 +33                       SET SUBJ=$EXTRACT(SUBJ,1,65)
 +34                       SET MSG(1)="On "_$$FMTE^XLFDT($$NOW^XLFDT)_" at Site # "_SITENUM_" - "_SITENAME_","
 +35                       SET MSG(2)="the installation of patch IB*2.0*664 added the new EHR - ELECTRONIC HEALTH RECORD"
 +36                       SET MSG(3)="entry to the Source Of Information file (#355.12) by removing the non-standardized"
 +37                       SET MSG(4)="entry # 21 for "_OLDSOI(.03)_" - "_OLDSOI(.02)_"."
 +38                       SET MSG(5)=""
 +39                       SET XMTO("VHAeInsuranceRapidResponse@domain.ext")=""
 +40      ;
 +41                       SET XMINSTR("FROM")="VistA-eInsurance"
 +42                       DO SENDMSG^XMXAPI(DUZ,SUBJ,"MSG",.XMTO,.XMINSTR)
                       End DoDot:2
               End DoDot:1
               QUIT 
 +43      ;
 +44       SET IBIEN=$$ADD^IBDFDBS(355.12,,.NEWSOI,.IBERR,IBCNT)
 +45       IF IBERR
               Begin DoDot:1
 +46               DO BMES^XPDUTL("")
 +47               DO BMES^XPDUTL("*** ERROR ADDING "_NEWSOI(.02)_" CODE TO THE SOURCE OF INFORMATION TABLE (#355.12) (#355.12) - Log a Service Ticket! ***")
               End DoDot:1
               QUIT 
 +48       DO MES^XPDUTL("Source of Information: ELECTRONIC HEALTH RECORD added successfully")
 +49       QUIT 
 +50      ;
SITEREG(IBXPD,SITENUM) ; send site registration message to FSC
 +1        DO BMES^XPDUTL(" STEP "_IBXPD_" of "_XPDIDTOT)
 +2        DO MES^XPDUTL("-------------")
 +3        DO MES^XPDUTL("Send eIV site registration message to FSC ... ")
 +4       ;
 +5        IF '$$PROD^XUPROD(1)
               DO MES^XPDUTL("N/A - Not a production account - No site registration message sent")
               GOTO SITEREGQ
 +6        IF SITENUM=358
               DO MES^XPDUTL("Current Site is MANILA - NO eIV site registration message sent")
               GOTO SITEREGQ
 +7        DO ^IBCNEHLM
 +8        DO MES^XPDUTL("eIV site registration message was successfully sent")
 +9       ;
SITEREGQ  ;
 +1        QUIT 
 +2       ;