RGRSBUL1 ;ALB/RJS,CML-RGRSTEXT BULLETIN ROUTINE (PART 2) ;07/24/98
 ;;1.0;CLINICAL INFO RESOURCE NETWORK;**1,3,19,52**;30 Apr 99;Build 2
 ;
SSNBULL(DFN,ARRAY,NAME,SSN,ICN,CMOR) ;
 ;Entry point generates a bulletin to the RG CIRN DEMOGRAPHIC
 ;ISSUES mail group about an SSN change for a given patient.
 ;
 ;Input:  Required Variables
 ;
 ;   DFN   - IEN in the PATIENT file (#2)
 ;  ARRAY  - Array of data containing sending sites station number
 ;   NAME  - Patient's Name
 ;   SSN   - Patient's SSN
 ;   ICN   - Patient's ICN (Integration Control Number) 
 ;   CMOR  - Patient's CMOR (Coordinating Master of Record)
 ;
 Q:$G(DFN)=""!($G(ARRAY)="")
 N LOCDATA,RGRSTEXT,INDEX,COUNTER
 S RGRSTEXT(1)="The MPI/PD Package has received an SSN change from:"
 S RGRSTEXT(2)=$$INST(@ARRAY@("SENDING SITE"))
 S RGRSTEXT(3)="           "
 S RGRSTEXT(4)="This change has been made in your local data base for:"
 S RGRSTEXT(5)=NAME
 S RGRSTEXT(6)="           "
 S RGRSTEXT(7)="=> Local "_$P($$SITE^VASITE(),"^",2)_" data PRIOR to update:"
 S RGRSTEXT(8)="NAME: "_NAME
 S RGRSTEXT(9)="SSN: "_SSN
 S RGRSTEXT(10)="ICN: "_ICN
 S RGRSTEXT(11)="CMOR: "_CMOR
 S RGRSTEXT(12)="--------------------------------------------------------"
 S RGRSTEXT(13)="=> Update received from "_$P($$INST(@ARRAY@("SENDING SITE"))," -->")_":"
 S RGRSTEXT(14)="SSN: "_@ARRAY@("SSN")
 D BULL2^RGRSBULL("MPI/PD SSN CHANGE - "_NAME,"RGRSTEXT(")
 Q
 ;
NOT2(ARRAY) ;
 ;Entry point generates a bulletin to the RG CIRN DEMOGRAPHIC
 ;ISSUES mail group about invalid subscription information for a given
 ;patient.
 ;
 ;Input:  Required Variables
 ;
 ;  ARRAY  - Array of information regarding the invalid subscription
 ;
 Q:($G(ARRAY)="")
 N RGRSTEXT,INDEX,COUNTER
 S RGRSTEXT(1)="The MPI/PD Package has received a message from:"
 S RGRSTEXT(2)=$$INST(@ARRAY@("SENDING SITE"))
 S RGRSTEXT(3)="This patient has your station as a subscriber, however"
 S RGRSTEXT(4)="the patient was not found in your database."
 S RGRSTEXT(5)="--------------------------------------------------------"
 S RGRSTEXT(6)="Remote Data"
 S RGRSTEXT(7)="           "
 S INDEX=0,COUNTER=8
 F  S INDEX=$O(@ARRAY@("MESSAGE",INDEX)) Q:INDEX']""  D
 . S RGRSTEXT(COUNTER)=@ARRAY@("MESSAGE",INDEX)
 . S COUNTER=COUNTER+1
 D BULL2^RGRSBULL("MPI/PD - PATIENT NOT FOUND","RGRSTEXT(")
 Q
 ;
SENSTIVE(DFN,ARRAY,NAME) ;FIRES WHEN PT. IS FLAGGED AS SENSITIVE AT ANOTHER SITE
 ;Entry point generates a bulletin to the RG CIRN DEMOGRAPHIC
 ;ISSUES mail group when a given patient is flagged as sensitive at
 ;another site.
 ;
 ;Input:  Required Variables
 ;
 ;   DFN  - IEN in the PATIENT file (#2)
 ;  ARRAY - Array of data containing sending sites station number and SSN
 ;  NAME  - Patient's name
 ;  CMOR  - Coordinating Master of Record
 ;
 Q:($G(ARRAY)="")!($G(DFN)="")
 N RGRSTEXT,INDEX,COUNTER,CMOR
 S CMOR=$$CMOR2^MPIF001(DFN) I $P(CMOR,"^")<0 S CMOR="not assigned"
 S RGRSTEXT(1)="The MPI/PD Package has received a message from:"
 S RGRSTEXT(2)=$$INST(@ARRAY@("SENDING SITE"))
 S RGRSTEXT(3)="   "
 S RGRSTEXT(4)="This message indicates that patient "_NAME_" is flagged"
 S RGRSTEXT(5)="as Sensitive at the other facility but is not flagged as"
 S RGRSTEXT(6)="Sensitive at your facility."
 S RGRSTEXT(7)="  "
 S RGRSTEXT(8)="Remote Patient SSN: "_$S(@ARRAY@("SSN")="":"Not Available",1:@ARRAY@("SSN"))
 S RGRSTEXT(9)="Remote User who Flagged the Patient as Sensitive: "_@ARRAY@("SENSITIVITY USER")
 S RGRSTEXT(10)="Date/Time Remote User Flagged Patient Sensitive:  "_$$FMTE^XLFDT(@ARRAY@("SENSITIVITY DATE"))
 S RGRSTEXT(11)="  "
 S RGRSTEXT(12)="CMOR Site: "_CMOR
 D BULL2^RGRSBULL("Remote Sensitivity Indicated","RGRSTEXT(")
 Q
 ;
 ;MPIC_772 - **52; Commented out Remote Date of Death Indicated module.
 ;Only RGADTP2 and RGRSPT called this module; and both have been commented out.
RMTDOD(DFN,ARRAY,NAME,RDOD,LDOD) ;Fires when patient has a Date of Death at another site
 ;Entry point generates a bulletin to the RG CIRN DEMOGRAPHIC
 ;ISSUES mail group when a given patient has a Date of Death at
 ;another site.
 ;
 ;Input:  Required Variables
 ;
 ;  DFN   - IEN in the PATIENT file (#2)
 ;  ARRAY - Array of data containing sending sites station number and SSN
 ;  NAME  - Patient's name
 ;  RDOD  - Date of Death at remote site
 ;  LDOD  - Date of Death at local site
 ;  CMOR  - Coordinating Master of Record
 ;
 ;Q:($G(ARRAY)="")!($G(DFN)="")
 ;Q:(RDOD=LDOD)  ;If remote DOD and local DOD same, QUIT
 ;N CMOR
 ;S CMOR=$$CMOR2^MPIF001(DFN) I $P(CMOR,"^")<0 S CMOR="not assigned"
 ;N RGRSTEXT
 ;S RGRSTEXT(1)="The MPI/PD Package has received a message from:"
 ;S RGRSTEXT(2)=$$INST(@ARRAY@("SENDING SITE"))
 ;S RGRSTEXT(3)="   "
 ;S RGRSTEXT(4)="This message indicates that patient "_NAME
 ;I 'LDOD S RGRSTEXT(5)="has a date of death at the other facility but not at your facility." G RMTMSG
 ;I LDOD,(LDOD'=RDOD) S RGRSTEXT(5)="has a different date of death at the other facility than at your facility."
RMTMSG ;S RGRSTEXT(6)="  "
 ;S RGRSTEXT(7)="Remote Patient SSN: "_$S(@ARRAY@("SSN")="":"Not Available",1:@ARRAY@("SSN"))
 ;S RGRSTEXT(8)="Date of Death from other facility:  "_$$FMTE^XLFDT(RDOD)
 ;I LDOD,(LDOD'=RDOD) S RGRSTEXT(9)="Date of Death at your facility:  "_$$FMTE^XLFDT(LDOD)
 ;S RGRSTEXT(10)="  "
 ;S RGRSTEXT(11)="CMOR site: "_CMOR
 ;D BULL2^RGRSBULL("Remote Date of Death Indicated","RGRSTEXT(")
 Q
 ;
INST(SITENUM) ;
 N RETURN,IEN,DATA,NAME,NUMBER
 S RETURN=""
 Q:$G(SITENUM)="" RETURN
 S IEN=$$LKUP^XUAF4(SITENUM)
 I IEN>0 S DATA=$$NS^XUAF4(IEN)
 I $G(DATA)]"" D 
 . S NAME=$P(DATA,"^",1),NUMBER=$P(DATA,"^",2)
 . S RETURN=NAME_" --> Site Number: "_NUMBER
 Q RETURN
 ;
FORMAT(DATA1,DATA2) ;
 N SPACES,SPACENUM,LENGTH1,LENGTH2,RETURN
 S SPACES="                       "
 S LENGTH1=$L(DATA1),LENGTH2=$L(DATA2)
 I LENGTH1>23 S DATA1=$E(DATA1,1,23) S LENGTH1=23
 I LENGTH2>22 S DATA2=$E(DATA2,1,22)
 S SPACENUM=23-LENGTH1
 S SPACES=$E(SPACES,1,SPACENUM)
 S RETURN=DATA1_SPACES_" "_DATA2
 Q $G(RETURN)
 ;
FREE(DATA) ;
 Q:$G(DATA)="" ""
 Q:$G(DATA)["@" ""
 Q:$G(DATA)=HL("Q") ""
 Q $G(DATA)
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HRGRSBUL1   6190     printed  Sep 23, 2025@19:18:49                                                                                                                                                                                                    Page 2
RGRSBUL1  ;ALB/RJS,CML-RGRSTEXT BULLETIN ROUTINE (PART 2) ;07/24/98
 +1       ;;1.0;CLINICAL INFO RESOURCE NETWORK;**1,3,19,52**;30 Apr 99;Build 2
 +2       ;
SSNBULL(DFN,ARRAY,NAME,SSN,ICN,CMOR) ;
 +1       ;Entry point generates a bulletin to the RG CIRN DEMOGRAPHIC
 +2       ;ISSUES mail group about an SSN change for a given patient.
 +3       ;
 +4       ;Input:  Required Variables
 +5       ;
 +6       ;   DFN   - IEN in the PATIENT file (#2)
 +7       ;  ARRAY  - Array of data containing sending sites station number
 +8       ;   NAME  - Patient's Name
 +9       ;   SSN   - Patient's SSN
 +10      ;   ICN   - Patient's ICN (Integration Control Number) 
 +11      ;   CMOR  - Patient's CMOR (Coordinating Master of Record)
 +12      ;
 +13       if $GET(DFN)=""!($GET(ARRAY)="")
               QUIT 
 +14       NEW LOCDATA,RGRSTEXT,INDEX,COUNTER
 +15       SET RGRSTEXT(1)="The MPI/PD Package has received an SSN change from:"
 +16       SET RGRSTEXT(2)=$$INST(@ARRAY@("SENDING SITE"))
 +17       SET RGRSTEXT(3)="           "
 +18       SET RGRSTEXT(4)="This change has been made in your local data base for:"
 +19       SET RGRSTEXT(5)=NAME
 +20       SET RGRSTEXT(6)="           "
 +21       SET RGRSTEXT(7)="=> Local "_$PIECE($$SITE^VASITE(),"^",2)_" data PRIOR to update:"
 +22       SET RGRSTEXT(8)="NAME: "_NAME
 +23       SET RGRSTEXT(9)="SSN: "_SSN
 +24       SET RGRSTEXT(10)="ICN: "_ICN
 +25       SET RGRSTEXT(11)="CMOR: "_CMOR
 +26       SET RGRSTEXT(12)="--------------------------------------------------------"
 +27       SET RGRSTEXT(13)="=> Update received from "_$PIECE($$INST(@ARRAY@("SENDING SITE"))," -->")_":"
 +28       SET RGRSTEXT(14)="SSN: "_@ARRAY@("SSN")
 +29       DO BULL2^RGRSBULL("MPI/PD SSN CHANGE - "_NAME,"RGRSTEXT(")
 +30       QUIT 
 +31      ;
NOT2(ARRAY) ;
 +1       ;Entry point generates a bulletin to the RG CIRN DEMOGRAPHIC
 +2       ;ISSUES mail group about invalid subscription information for a given
 +3       ;patient.
 +4       ;
 +5       ;Input:  Required Variables
 +6       ;
 +7       ;  ARRAY  - Array of information regarding the invalid subscription
 +8       ;
 +9        if ($GET(ARRAY)="")
               QUIT 
 +10       NEW RGRSTEXT,INDEX,COUNTER
 +11       SET RGRSTEXT(1)="The MPI/PD Package has received a message from:"
 +12       SET RGRSTEXT(2)=$$INST(@ARRAY@("SENDING SITE"))
 +13       SET RGRSTEXT(3)="This patient has your station as a subscriber, however"
 +14       SET RGRSTEXT(4)="the patient was not found in your database."
 +15       SET RGRSTEXT(5)="--------------------------------------------------------"
 +16       SET RGRSTEXT(6)="Remote Data"
 +17       SET RGRSTEXT(7)="           "
 +18       SET INDEX=0
           SET COUNTER=8
 +19       FOR 
               SET INDEX=$ORDER(@ARRAY@("MESSAGE",INDEX))
               if INDEX']""
                   QUIT 
               Begin DoDot:1
 +20               SET RGRSTEXT(COUNTER)=@ARRAY@("MESSAGE",INDEX)
 +21               SET COUNTER=COUNTER+1
               End DoDot:1
 +22       DO BULL2^RGRSBULL("MPI/PD - PATIENT NOT FOUND","RGRSTEXT(")
 +23       QUIT 
 +24      ;
SENSTIVE(DFN,ARRAY,NAME) ;FIRES WHEN PT. IS FLAGGED AS SENSITIVE AT ANOTHER SITE
 +1       ;Entry point generates a bulletin to the RG CIRN DEMOGRAPHIC
 +2       ;ISSUES mail group when a given patient is flagged as sensitive at
 +3       ;another site.
 +4       ;
 +5       ;Input:  Required Variables
 +6       ;
 +7       ;   DFN  - IEN in the PATIENT file (#2)
 +8       ;  ARRAY - Array of data containing sending sites station number and SSN
 +9       ;  NAME  - Patient's name
 +10      ;  CMOR  - Coordinating Master of Record
 +11      ;
 +12       if ($GET(ARRAY)="")!($GET(DFN)="")
               QUIT 
 +13       NEW RGRSTEXT,INDEX,COUNTER,CMOR
 +14       SET CMOR=$$CMOR2^MPIF001(DFN)
           IF $PIECE(CMOR,"^")<0
               SET CMOR="not assigned"
 +15       SET RGRSTEXT(1)="The MPI/PD Package has received a message from:"
 +16       SET RGRSTEXT(2)=$$INST(@ARRAY@("SENDING SITE"))
 +17       SET RGRSTEXT(3)="   "
 +18       SET RGRSTEXT(4)="This message indicates that patient "_NAME_" is flagged"
 +19       SET RGRSTEXT(5)="as Sensitive at the other facility but is not flagged as"
 +20       SET RGRSTEXT(6)="Sensitive at your facility."
 +21       SET RGRSTEXT(7)="  "
 +22       SET RGRSTEXT(8)="Remote Patient SSN: "_$SELECT(@ARRAY@("SSN")="":"Not Available",1:@ARRAY@("SSN"))
 +23       SET RGRSTEXT(9)="Remote User who Flagged the Patient as Sensitive: "_@ARRAY@("SENSITIVITY USER")
 +24       SET RGRSTEXT(10)="Date/Time Remote User Flagged Patient Sensitive:  "_$$FMTE^XLFDT(@ARRAY@("SENSITIVITY DATE"))
 +25       SET RGRSTEXT(11)="  "
 +26       SET RGRSTEXT(12)="CMOR Site: "_CMOR
 +27       DO BULL2^RGRSBULL("Remote Sensitivity Indicated","RGRSTEXT(")
 +28       QUIT 
 +29      ;
 +30      ;MPIC_772 - **52; Commented out Remote Date of Death Indicated module.
 +31      ;Only RGADTP2 and RGRSPT called this module; and both have been commented out.
RMTDOD(DFN,ARRAY,NAME,RDOD,LDOD) ;Fires when patient has a Date of Death at another site
 +1       ;Entry point generates a bulletin to the RG CIRN DEMOGRAPHIC
 +2       ;ISSUES mail group when a given patient has a Date of Death at
 +3       ;another site.
 +4       ;
 +5       ;Input:  Required Variables
 +6       ;
 +7       ;  DFN   - IEN in the PATIENT file (#2)
 +8       ;  ARRAY - Array of data containing sending sites station number and SSN
 +9       ;  NAME  - Patient's name
 +10      ;  RDOD  - Date of Death at remote site
 +11      ;  LDOD  - Date of Death at local site
 +12      ;  CMOR  - Coordinating Master of Record
 +13      ;
 +14      ;Q:($G(ARRAY)="")!($G(DFN)="")
 +15      ;Q:(RDOD=LDOD)  ;If remote DOD and local DOD same, QUIT
 +16      ;N CMOR
 +17      ;S CMOR=$$CMOR2^MPIF001(DFN) I $P(CMOR,"^")<0 S CMOR="not assigned"
 +18      ;N RGRSTEXT
 +19      ;S RGRSTEXT(1)="The MPI/PD Package has received a message from:"
 +20      ;S RGRSTEXT(2)=$$INST(@ARRAY@("SENDING SITE"))
 +21      ;S RGRSTEXT(3)="   "
 +22      ;S RGRSTEXT(4)="This message indicates that patient "_NAME
 +23      ;I 'LDOD S RGRSTEXT(5)="has a date of death at the other facility but not at your facility." G RMTMSG
 +24      ;I LDOD,(LDOD'=RDOD) S RGRSTEXT(5)="has a different date of death at the other facility than at your facility."
RMTMSG    ;S RGRSTEXT(6)="  "
 +1       ;S RGRSTEXT(7)="Remote Patient SSN: "_$S(@ARRAY@("SSN")="":"Not Available",1:@ARRAY@("SSN"))
 +2       ;S RGRSTEXT(8)="Date of Death from other facility:  "_$$FMTE^XLFDT(RDOD)
 +3       ;I LDOD,(LDOD'=RDOD) S RGRSTEXT(9)="Date of Death at your facility:  "_$$FMTE^XLFDT(LDOD)
 +4       ;S RGRSTEXT(10)="  "
 +5       ;S RGRSTEXT(11)="CMOR site: "_CMOR
 +6       ;D BULL2^RGRSBULL("Remote Date of Death Indicated","RGRSTEXT(")
 +7        QUIT 
 +8       ;
INST(SITENUM) ;
 +1        NEW RETURN,IEN,DATA,NAME,NUMBER
 +2        SET RETURN=""
 +3        if $GET(SITENUM)=""
               QUIT RETURN
 +4        SET IEN=$$LKUP^XUAF4(SITENUM)
 +5        IF IEN>0
               SET DATA=$$NS^XUAF4(IEN)
 +6        IF $GET(DATA)]""
               Begin DoDot:1
 +7                SET NAME=$PIECE(DATA,"^",1)
                   SET NUMBER=$PIECE(DATA,"^",2)
 +8                SET RETURN=NAME_" --> Site Number: "_NUMBER
               End DoDot:1
 +9        QUIT RETURN
 +10      ;
FORMAT(DATA1,DATA2) ;
 +1        NEW SPACES,SPACENUM,LENGTH1,LENGTH2,RETURN
 +2        SET SPACES="                       "
 +3        SET LENGTH1=$LENGTH(DATA1)
           SET LENGTH2=$LENGTH(DATA2)
 +4        IF LENGTH1>23
               SET DATA1=$EXTRACT(DATA1,1,23)
               SET LENGTH1=23
 +5        IF LENGTH2>22
               SET DATA2=$EXTRACT(DATA2,1,22)
 +6        SET SPACENUM=23-LENGTH1
 +7        SET SPACES=$EXTRACT(SPACES,1,SPACENUM)
 +8        SET RETURN=DATA1_SPACES_" "_DATA2
 +9        QUIT $GET(RETURN)
 +10      ;
FREE(DATA) ;
 +1        if $GET(DATA)=""
               QUIT ""
 +2        if $GET(DATA)["@"
               QUIT ""
 +3        if $GET(DATA)=HL("Q")
               QUIT ""
 +4        QUIT $GET(DATA)