Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: BMCMM

BMCMM.m

Go to the documentation of this file.
BMCMM ; IHS/OIT/FCJ - RCIS - SEND MAILMAN MESSAGE ;     [ 09/12/2006  11:50 AM ]
 ;;4.0;REFERRED CARE INFO SYSTEM;**2**;JAN 09, 2006;Build 101
 ;
 ;IHS/ITSC/FCJ SEND MESSAGE TO GROUPS OR 
 ;     REF PROVIDER AND PROVIDER ONLY
 ;     WILL LIST ANY PREVIOUS MESSAGE SENT AND
 ;     ALSO STORE HISTORY OF MSG SENT IN RCIS MESSAGE FILE
 ;     CALLED AFTER INITIAL ENTRY OF REF AND FROM MODIFY
 ;     OPTIONS 14 AND 15
 ;     Only BO notes are sent on the group message which is called
 ;     during adding a new ref and using modify option 14
 ;BMC*4.0*2 8/2/05 IHS/OIT/FCJ ADDED TST;CALLING FROM API AND EP
 ;     Added Case Com to message;Added type of referral and parameter
 ;     to identify patient to subject line
 ;
 ;
ENMM ;EP;MESSAGE for NEW REF AND MODIFICATIONS
 NEW Y,DIC
 Q:'$G(BMCDFN)
 Q:'$G(BMCRDATE)
MSG ;TEST FOR EXISTING MESSAGES ALREADY SENT
 I $D(^BMCMSG("C",BMCRIEN)) D
 .W !!,"A Message has already been sent for this referral:"
 .S BMCMSG=0 W !?3,"DATE",?25,"SENT BY",?55,"GROUP/PROV"
 .F  S BMCMSG=$O(^BMCMSG("C",BMCRIEN,BMCMSG)) Q:BMCMSG'?1N.N  D
 ..S Y=$P(^BMCMSG(BMCMSG,0),U) D DD^%DT
 ..W !?3,Y,?25,$P(^VA(200,$P(^BMCMSG(BMCMSG,0),U,4),0),U)
 ..S BMCGRP=0 F  S BMCGRP=$O(^BMCMSG(BMCMSG,1,BMCGRP)) Q:BMCGRP'?1N.N  D
 ...S BMCGRP1=$P(^BMCMSG(BMCMSG,1,BMCGRP,0),U)
 ...W ?55,$P(^XMB(3.8,BMCGRP1,0),U),!
 ..S BMCPER=0 F  S BMCPER=$O(^BMCMSG(BMCMSG,2,BMCPER)) Q:BMCPER'?1N.N  D
 ...S BMCPER1=$P(^BMCMSG(BMCMSG,2,BMCPER,0),U)
 ...W ?55,$P(^VA(200,BMCPER1,0),U),!
 E  W !!,"A Message has NOT been sent for this referral."
 S DIR(0)="Y",DIR("A")="Do you wish to send a message",DIR("B")="Y"
 D ^DIR K DIR I $D(DIRUT)!'Y G EXT
 I BMCMODE="M",BMCDTYPE=15 D MPER,MSGPRV
 E  D MGRP,MSGGRP
 D SND
 G EXT Q
MGRP ;SELECT MAIL GROUPS TO SEND MESSAGE TO
 ;ENTER THE GROUP TO SEND IT TO AND ADD ENTRY TO THE RCIS MESSAGE FILE
 S BMCGRP="BMC",DIR(0)="S^",Y=0
 F  S BMCGRP=$O(^XMB(3.8,"B",BMCGRP)) Q:$E(BMCGRP,1,3)'="BMC"  D
 .S BMCGRP1=0 S BMCGRP1=$O(^XMB(3.8,"B",BMCGRP,BMCGRP1))
 .S Y=Y+1,BMCGRP(Y)=BMCGRP_U_BMCGRP1
 I Y=0 W !,"THERE ARE NOT ANY RCIS MAIL GROUPS SET UP.",!,"If you would like to set up a mail group, use Mail Groups Option under the",!,"RCIS Management Menu." Q
 F I=1:1:Y W !?5,I_".  "_$P(BMCGRP(I),U)
 S DIR("A")="To select recipient group(s) enter a list or range of numbers"
 S DIR(0)="L^1:"_Y
 D ^DIR I $D(DIRUT) W !?5,"***MESSAGE WAS NOT SENT***" G EXT
 K XMB,XMY
 F I=1:1 Q:$P(Y,",",I)'?1N.N  S XMY("G."_$P(BMCGRP($P(Y,",",I)),U))="",BMCGRPS($P(BMCGRP($P(Y,",",I)),U,2))=""
 Q
MPER ;SETS PRIM PROV AND REF PROV TO AUTO SEND MESSAGE TO
 S BMCPPRV=$P(^AUPNPAT(BMCDFN,0),U,14)
 S BMCRPRV=$P(^BMCREF(BMCRIEN,0),U,6)
 K XMB,XMY
 I 'BMCPPRV,'BMCRPRV W !,"Primary Care Provider and Referring Provider are not definned.",!?5,"***MESSAGE WAS NOT SENT***" G EXT
 F BMCPER=BMCPPRV,BMCRPRV I BMCPER D
 .S XMY(BMCPER)=""
 Q
MSGGRP ;EP CALL BY BMCAPIA1;GROUP MESSAGE
 S Y=$P(^BMCREF(BMCRIEN,0),U,4)
 S XMZ=""
 ;REF IF OPTION SET AND USER ANSWERS YES....
 S XMB="BMC REFERRAL ALERT"  ;LABEL NEW Message
 S XMB(1)=BMCREC("PAT NAME")
 S XMB(1.1)=$S($P($G(^BMCPARM(DUZ(2),4100)),U,7)="Y":XMB(1),1:"")
 S XMB(2)=BMCREC("REF DATE")
 S XMB(3)=BMCRNUMB
 S XMB(4)=""
 S XMB(5)=$$VAL^XBDIQ1(90001,BMCRIEN,1201)
 S XMB(6)=$$FACREF^BMCRLU(BMCRIEN)
 S XMB(7)=$$VAL^XBDIQ1(90001,BMCRIEN,1301)
 S XMB(8)=$$VAL^XBDIQ1(90001,BMCRIEN,.32)
 ;BMC*4.0*2 8/2/05 IHS/OIT/FCJ Added DOS to Message
 S XMB(8)=XMB(8)_"       Date of Service: "_$$AVDOS^BMCRLU(BMCRIEN,"E")
 S Y=$P(^BMCREF(BMCRIEN,0),U,6)
 S:Y XMB(4)=$P(^VA(200,Y,0),U)
 S XMB(9)=$$VAL^XBDIQ1(90001,BMCRIEN,.04)
 D COMMENTS
 Q
MSGPRV ;PRIM PROV AND REF PHY MESSAGE
 S Y=$P(^BMCREF(BMCRIEN,0),U,4),BMCHRN="",BMCSP=""
 F I=1:1:30 S BMCSP=BMCSP_" "
 S XMZ=""
 S XMB="BMC PROV REF ALERT" ;LABEL NEW Message
 S XMB(1)=BMCREC("PAT NAME")
 I $P(^BMCREF(BMCRIEN,0),U,5)'="" D
 .S I=$P(^BMCREF(BMCRIEN,0),U,5)
 .S BMCHRN=$P($G(^AUPNPAT(BMCDFN,41,I,0)),U,2)
 S XMB(2)=BMCRNUMB,XMB(3)=BMCHRN
 S XMB(4)="" S:BMCPPRV XMB(4)=XMB(4)_$P(^VA(200,BMCPPRV,0),U)
 S XMB(5)=$$DOB^AUPNPAT(BMCDFN,"E")
 S XMB(6)=$$FACREF^BMCRLU(BMCRIEN)
 S XMB(7)=$$AVDOS^BMCRLU(BMCRIEN,"E")
 S XMB(8)=$$VAL^XBDIQ1(90001,BMCRIEN,.04)
 D COMMENTS Q
COMMENTS ;IHS/ITSC/FCJ ADDED BO COM FR RCIS COMMENTS FILE,LIFO DISPLAY
 S XMTEXT="^XTMP(""BMCMSG"","_$J_","
 I $D(^BMCCOM("AD",BMCRIEN)) D
 .S BMCL=0,BMCL2=1
 .F  S BMCL=$O(^BMCCOM("AD",BMCRIEN,BMCL)) Q:BMCL'?1N.N  D
 ..S BMCCTYP=$P(^BMCCOM(BMCL,0),U,5)
 ..I BMCMODE="M",BMCDTYPE=14 Q:(BMCCTYP="M")!(BMCCTYP="D")
 ..I BMCMODE="A" Q:BMCCTYP'="B"
 ..I $D(^BMCCOM(BMCL,1)) D
 ...S I=$S(BMCCTYP="C":"Case Review",BMCCTYP="D":"Discharge",BMCCTYP="M":"Medical HX/Findings",1:"Business/CHS")
 ...S ^XTMP("BMCMSG",$J,BMCL2)=I_" Comments  Date: "_$$FMTE^XLFDT($P(^BMCCOM(BMCL,0),U),"5D")_"  By: "_$$VAL^XBDIQ1(90001.03,BMCL,.04)
 ...S BMCL1=0
 ...F  S BMCL1=$O(^BMCCOM(BMCL,1,BMCL1)) Q:BMCL1'?1N.N  D
 ....S BMCL2=BMCL2+1
 ....S ^XTMP("BMCMSG",$J,BMCL2)=^BMCCOM(BMCL,1,BMCL1,0)
 ..S BMCL2=BMCL2+1
 Q
SND ;SEND MESSAGE
 D EN^XMB
 ;BMC*4.0*2 8/2/05 IHS/OIT/FCJ ADDED TST;CALLING FROM API
 ;I $D(XMB) W !?5,"***ERROR: NO MESSAGE SENT***" G EXT
 I $D(XMB) W:$G(BMCAPIA)="" !?5,"***ERROR: NO MESSAGE SENT***" G EXT
 ;W !?5,"***MESSAGE SENT***"
 W:$G(BMCAPIA)="" !?5,"***MESSAGE SENT***"
ADD ;IF MESSAGE SENT ADD TO RCIS MESSAGE FILE
 S (DIE,DIC)="^BMCMSG(",DIC(0)="L"
 D NOW^%DTC S X=%
 S DIC("DR")=".02////"_BMCRIEN_";.03////"_BMCRNUMB_";.04////"_DUZ_";.05////REFERRAL ALERT"
 D ^DIC S DA=+Y Q:Y<1
 I BMCMODE="M",BMCDTYPE=15 D APER Q
AGRP ;ADD GROUPS MESSAGE WAS SENT TO    
 S DA(1)=+Y,(DIE,DIC)=DIC_DA(1)_",1,",DA=1
 I '$D(^BMCMSG(DA(1),1)) S ^BMCMSG(DA(1),1,0)="^90001.571P^^"
 D ^DIC
 S BMCGRP=0  F  S BMCGRP=$O(BMCGRPS(BMCGRP))  Q:BMCGRP'?1N.N  D
 .S DR=".01////"_BMCGRP
 .D ^DIE
 .S $P(^BMCMSG(DA(1),1,0),U,3,4)=DA_U_DA
 .S DA=DA+1
 Q
APER ;ADD PERSON MESSAGE WAS SENT TO
 S DA(1)=+Y,(DIE,DIC)=DIC_DA(1)_",2,",DA=1
 I '$D(^BMCMSG(DA(1),2)) S ^BMCMSG(DA(1),2,0)="^90001.572P^^"
 D ^DIC
 F BMCPER=BMCPPRV,BMCRPRV I BMCPER D  Q:BMCPPRV=BMCRPRV
 .S DR=".01////"_BMCPER
 .D ^DIE
 .S $P(^BMCMSG(DA(1),2,0),U,3,4)=DA_U_DA
 .S DA=DA+1
 Q
EXT K XMB,XMY,XMZ,DIR,DIC,DIE,DA,DR
 K BMCMSG,BMCGRP,BMCGRPS,BMCGRP1,BMCL,BMCL1,BMCL2,BMCLDT,BMCCTYP,BMCTMP
 K BMCPER,BMCPER1,^XTMP("BMCMSG",$J)
 Q