GMRAY25 ;SLC/DAN Post-install routine ;6/8/05  14:33
 ;;4.0;Adverse Reaction Tracking;**25**;Mar 29, 1996
 ;
POST ;Post-install entry point
 D IDENTSS
 D MAIL
 Q
 ;
IDENTSS ;Identify entries that may not have had their signs/symptoms correctly stored, which may also have caused other important datt to not be stored
 N GMRAIEN,GMRA0
 S GMRAIEN=0 F  S GMRAIEN=$O(^GMR(120.8,GMRAIEN)) Q:'+GMRAIEN  D
 .S GMRA0=$G(^GMR(120.8,GMRAIEN,0))
 .Q:$P(GMRA0,U,12)'=""  ;Stop if signed off field has a value
 .Q:$$TESTPAT^VADPT($P(GMRA0,U))  ;Stop if test patient
 .Q:$P($G(^GMR(120.8,GMRAIEN,"ER")),U)  ;Stop if entered in error
 .Q:$P(GMRA0,U,4)<3040101  ;Stop if entry of allergy predates v25 installation
 .S ARRAY($$GET1^DIQ(2,$P(GMRA0,U)_",",.01)_" ("_$E($$GET1^DIQ(2,$P(GMRA0,U)_",",.09),6,9)_")",$P(GMRA0,U,2))="" ;Store pt name and reactant
 Q
 ;
MAIL ;Send message indicating post install is finished
 N XMSUB,XMTEXT,XMDUZ,XMY,XMZ,GMRATXT,CNT,REACTANT,DIFROM,PNAME
 S XMDUZ="PATCH GMRA*4*25 POST-INSTALL",XMY(.5)="" S:$G(DUZ) XMY(DUZ)=""
 S GMRATXT(1)="The post-install routine for patch GMRA*4*25"
 S GMRATXT(2)="finished on "_$$FMTE^XLFDT($$NOW^XLFDT)_"."
 S GMRATXT(3)=""
 S CNT=3
 I $D(ARRAY) D
 .S CNT=CNT+1,GMRATXT(CNT)="The following patients have allergies on file that may be missing"
 .S CNT=CNT+1,GMRATXT(CNT)="important data required for order checking due to an error when the allergy"
 .S CNT=CNT+1,GMRATXT(CNT)="was saved.  If the user selected the space or dashed line from the"
 .S CNT=CNT+1,GMRATXT(CNT)="signs/symptoms box then the allergy would not have been saved correctly and"
 .S CNT=CNT+1,GMRATXT(CNT)="needs to be reviewed for accuracy.  The recommended course of action is to"
 .S CNT=CNT+1,GMRATXT(CNT)="mark the existing allergy as entered in error and then re-enter the allergy"
 .S CNT=CNT+1,GMRATXT(CNT)="information for the patient."
 .S CNT=CNT+1,GMRATXT(CNT)=""
 .S PNAME="" F  S PNAME=$O(ARRAY(PNAME)) Q:PNAME=""  D
 ..S CNT=CNT+1,GMRATXT(CNT)=PNAME
 ..S REACTANT="" F  S REACTANT=$O(ARRAY(PNAME,REACTANT)) Q:REACTANT=""  D
 ...S CNT=CNT+1,GMRATXT(CNT)="  "_REACTANT
 ..S CNT=CNT+1,GMRATXT(CNT)=""
 S XMTEXT="GMRATXT(",XMSUB="PATCH GMRA*4*25 Post Install COMPLETED"
 D ^XMD
 Q
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HGMRAY25   2255     printed  Sep 23, 2025@19:16:57                                                                                                                                                                                                     Page 2
GMRAY25   ;SLC/DAN Post-install routine ;6/8/05  14:33
 +1       ;;4.0;Adverse Reaction Tracking;**25**;Mar 29, 1996
 +2       ;
POST      ;Post-install entry point
 +1        DO IDENTSS
 +2        DO MAIL
 +3        QUIT 
 +4       ;
IDENTSS   ;Identify entries that may not have had their signs/symptoms correctly stored, which may also have caused other important datt to not be stored
 +1        NEW GMRAIEN,GMRA0
 +2        SET GMRAIEN=0
           FOR 
               SET GMRAIEN=$ORDER(^GMR(120.8,GMRAIEN))
               if '+GMRAIEN
                   QUIT 
               Begin DoDot:1
 +3                SET GMRA0=$GET(^GMR(120.8,GMRAIEN,0))
 +4       ;Stop if signed off field has a value
                   if $PIECE(GMRA0,U,12)'=""
                       QUIT 
 +5       ;Stop if test patient
                   if $$TESTPAT^VADPT($PIECE(GMRA0,U))
                       QUIT 
 +6       ;Stop if entered in error
                   if $PIECE($GET(^GMR(120.8,GMRAIEN,"ER")),U)
                       QUIT 
 +7       ;Stop if entry of allergy predates v25 installation
                   if $PIECE(GMRA0,U,4)<3040101
                       QUIT 
 +8       ;Store pt name and reactant
                   SET ARRAY($$GET1^DIQ(2,$PIECE(GMRA0,U)_",",.01)_" ("_$EXTRACT($$GET1^DIQ(2,$PIECE(GMRA0,U)_",",.09),6,9)_")",$PIECE(GMRA0,U,2))=""
               End DoDot:1
 +9        QUIT 
 +10      ;
MAIL      ;Send message indicating post install is finished
 +1        NEW XMSUB,XMTEXT,XMDUZ,XMY,XMZ,GMRATXT,CNT,REACTANT,DIFROM,PNAME
 +2        SET XMDUZ="PATCH GMRA*4*25 POST-INSTALL"
           SET XMY(.5)=""
           if $GET(DUZ)
               SET XMY(DUZ)=""
 +3        SET GMRATXT(1)="The post-install routine for patch GMRA*4*25"
 +4        SET GMRATXT(2)="finished on "_$$FMTE^XLFDT($$NOW^XLFDT)_"."
 +5        SET GMRATXT(3)=""
 +6        SET CNT=3
 +7        IF $DATA(ARRAY)
               Begin DoDot:1
 +8                SET CNT=CNT+1
                   SET GMRATXT(CNT)="The following patients have allergies on file that may be missing"
 +9                SET CNT=CNT+1
                   SET GMRATXT(CNT)="important data required for order checking due to an error when the allergy"
 +10               SET CNT=CNT+1
                   SET GMRATXT(CNT)="was saved.  If the user selected the space or dashed line from the"
 +11               SET CNT=CNT+1
                   SET GMRATXT(CNT)="signs/symptoms box then the allergy would not have been saved correctly and"
 +12               SET CNT=CNT+1
                   SET GMRATXT(CNT)="needs to be reviewed for accuracy.  The recommended course of action is to"
 +13               SET CNT=CNT+1
                   SET GMRATXT(CNT)="mark the existing allergy as entered in error and then re-enter the allergy"
 +14               SET CNT=CNT+1
                   SET GMRATXT(CNT)="information for the patient."
 +15               SET CNT=CNT+1
                   SET GMRATXT(CNT)=""
 +16               SET PNAME=""
                   FOR 
                       SET PNAME=$ORDER(ARRAY(PNAME))
                       if PNAME=""
                           QUIT 
                       Begin DoDot:2
 +17                       SET CNT=CNT+1
                           SET GMRATXT(CNT)=PNAME
 +18                       SET REACTANT=""
                           FOR 
                               SET REACTANT=$ORDER(ARRAY(PNAME,REACTANT))
                               if REACTANT=""
                                   QUIT 
                               Begin DoDot:3
 +19                               SET CNT=CNT+1
                                   SET GMRATXT(CNT)="  "_REACTANT
                               End DoDot:3
 +20                       SET CNT=CNT+1
                           SET GMRATXT(CNT)=""
                       End DoDot:2
               End DoDot:1
 +21       SET XMTEXT="GMRATXT("
           SET XMSUB="PATCH GMRA*4*25 Post Install COMPLETED"
 +22       DO ^XMD
 +23       QUIT