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

BMCRPC2.m

Go to the documentation of this file.
BMCRPC2 ;IHS/CAS/AU - GUI REFERRED CARE INFO SYSTEM (2/4) ;     
 ;;4.0;REFERRED CARE INFO SYSTEM;**7,8,12**;JAN 09, 2006;Build 101
 ;
 ;GDIT/HS/BEE 10/19/17 - p12 CR#8106: Put in code to set up correct OPTION USED
 ;GDIT/HS/BEE 10/19/17 - p12 CR#8779: Send correct provider to V REFERRAL
 ;GDIT/HS/BEE 10/19/17 - p12 - Address XINDEX/SAC issues
 ;
 ; RPC code for RCIS GUI Application
 ; Routines contains code for adding/updating data into RCIS files
SETREFRL(RSLT,RFDT,PTIEN,TYPE,IORO,ICDCAT,CPTCAT,PURPOS,PRORTY,TYPEX,VSTS,NOTESCHD,HXCMT,RQPR,SCHWIDAY,ICSRP,IFSHT,IHLSM,IHSPH,IEKG,ILBRP,IPCC,IPRNL,ITUBL,ICLNT,IXRYR,IXRYF,TMIEN,SITE,BCMT,PRVDR,LOC,VST,RPNM,SNMDCT,SNMDPT,PROB,SNMDST,OTHRTYP) ;
 K ^TMP($J)
 ;GDIT/HS/BEE 10/19/17 - p12 CR#8106:Added OXQY0
 ;GDIT/HS/BEE 10/19/17 - p12 - XINDEX finding:Added SECNSFX,Y
 ;N OUT,FDA,ERR1,X,REFNMBR,REFSTATS,RQSTFAC,PRIMPYR,CHSSTATS,CASEMGR,RS,BMCPDRG,BMCECOST,BMCIHSCT,BMCINLOS,ADTLINFO,YEAR,NREFIEN,PRIMREF,EXPSCHDT,VREFIEN
 N OUT,FDA,ERR1,X,REFNMBR,REFSTATS,RQSTFAC,PRIMPYR,CHSSTATS,CASEMGR,RS,BMCPDRG,BMCECOST,BMCIHSCT,BMCINLOS,ADTLINFO,YEAR,NREFIEN,PRIMREF,EXPSCHDT,VREFIEN,OXQY0,SECNSFX,Y
 S ADTLINFO=0 ;;ADDITIONAL INFO flag
 ;; convert date to internal fileman format 
 I $G(DUZ(2))="" S RSLT="~`0^Site selection is Mandatory" Q RSLT
 S YEAR=$$GET1^DIQ(90001.31,$G(DUZ(2))_",",.02)
 ;I ($E(DT,2,3)'=$G(YEAR)) S RSLT="~`0^RCIS SITE PARAMETER file REFERRAL YEAR does not match current FISCAL YEAR" Q RSLT
 I $G(YEAR)="" S RSLT="~`0^RCIS SITE PARAMETER file REFERRAL YEAR field missing or invalid." Q RSLT
 I $P(RFDT,"^",2)'=""  D
 . S PRIMREF=$P(RFDT,"^",2)
 . S RFDT=$P(RFDT,"^",1)
 . I $G(PTIEN)="" S PTIEN=$$GET1^DIQ(90001,PRIMREF_",",.03,"I")
 I $P($G(SCHWIDAY),"^",2)'="" D
 . S EXPSCHDT=$P($P($G(SCHWIDAY),"^",2),"@",1)
 . D DT^DILF("",EXPSCHDT,.EXPSCHDT) I EXPSCHDT="-1" S EXPSCHDT=""
 . ;GDIT/HS/BEE 10/19/17 - p12 - Fixed SAC issue - changed $REPLACE to $TR()
 . ;I $G(EXPSCHDT)'="" S EXPSCHDT=$G(EXPSCHDT)_"."_$REPLACE($P($P($G(SCHWIDAY),"^",2),"@",2),":","")
 . I $G(EXPSCHDT)'="" S EXPSCHDT=$G(EXPSCHDT)_"."_$TR($P($P($G(SCHWIDAY),"^",2),"@",2),":","")
 ;;. . S SCHWIDAY=$P($G(SCHWIDAY),"^",1)
 S SCHWIDAY=$P($G(SCHWIDAY),"^",1)
 D DT^DILF("",RFDT,.RFDT) I RFDT="-1" S RSLT="~`0^Referral Date is not in mm/dd/yyyy fromat" Q RSLT
 ;; check for duplication of record
 I PTIEN'>0 S RSLT="~`0^Patient Ien not provided" Q RSLT
 ;I $D(^BMCREF("AA",PTIEN,RFDT)) S RSLT="~`0^A referral already exists for this patient on this date" Q RSLT
 S REFSTATS="A" ;; Setting status to ACTIVE
 S PRIMPYR="1"  ;; Setting Primary Payor to 'IHS'
 S:'$G(RQPR) RQPR=DUZ   ;; default to logged in user ien
 S RQSTFAC=DUZ(2) ;;default to facility where user is logged onto
 S CHSSTATS="P"  ;; Setting CHS APPROVAL STATUS to 'PENDING'
 S CASEMGR=$$GET1^DIQ(90001.31,RQSTFAC_",",.12,"I") ;;set default case manager if not provided
 S X=$$REFN^BMC  ;;generate Referral Number - will return 13 digit number in variable X
 Q:'X
 X $P(^DD(90001,.02,0),U,5,99) ;; Perform input transport check
 S REFNMBR=$G(X)
 I $G(PRIMREF)'=""  D
 . S REFNMBR=$$GET1^DIQ(90001,PRIMREF_",",.02,"") ;;
 . I PTIEN="" S PTIEN=$$GET1^DIQ(90001,PRIMREF_",",.03,"I")
 . N Y1,Y2,Y3
 . ;; Copied from BMCADDS routine - Begin  - to calculate suffix and visits
 . S (Y1,Y2,Y3)=0
 . I '$D(^BMCREF("S",REFNMBR)) S Y1=0
 . E  S Y="" F  S Y=$O(^BMCREF("S",REFNMBR,Y)) Q:Y=""  D
 . . S Y3=$E(Y,2,$L(Y)),Y2=Y2+1
 . . S:Y3>Y1 Y1=Y3
 . S Y1=Y1+1,Y2=Y2+1,SECNSFX="A"_Y1
 . ;VISTS REMAINING
 . S VSTS=($P(^BMCREF(PRIMREF,11),U,11)-Y2)
 . S:VSTS<0 VSTS=0
 . ;; Copied code from BMCADDS routine - End
 . K Y1,Y2,Y3
 I ((RFDT="")!(PTIEN="")!(RQSTFAC="")!(IORO="")!(PURPOS="")!(PRORTY="")!(VSTS="")!($G(SNMDCT)="")!(SNMDPT="")) S RSLT="~`0^Required field missing" Q RSLT
 S:$D(TMIEN) TMIEN=""
 S:'$D(TYPE) TYPE=""
 S:'$D(TYPEX) TYPEX=""
 S:'$D(OTHRTYP) OTHRTYP=""
 S:'$D(ICDCAT) ICDCAT=""
 S:'$D(CPTCAT) CPTCAT=""
 I $G(PRIMREF)'=""  D
 . S FDA(90001,"+1,",101)=SECNSFX
 . S FDA(90001,"+1,",102)=PRIMREF
 S FDA(90001,"+1,",.01)=RFDT
 S FDA(90001,"+1,",.02)=REFNMBR
 S FDA(90001,"+1,",.03)=PTIEN
 S FDA(90001,"+1,",.04)=TYPE
 S FDA(90001,"+1,",.05)=RQSTFAC
 S FDA(90001,"+1,",.14)=IORO
 S FDA(90001,"+1,",.06)=RQPR
 S FDA(90001,"+1,",.11)=PRIMPYR
 S:ICDCAT'="" FDA(90001,"+1,",.12)=ICDCAT
 S:CPTCAT'="" FDA(90001,"+1,",.13)=CPTCAT
 S FDA(90001,"+1,",1201)=PURPOS
 S FDA(90001,"+1,",.32)=PRORTY
 I ((TYPE="C")) S FDA(90001,"+1,",.07)=$S(TYPEX'="":TYPEX,TYPEX="":$$FIND1^DIC(9999999.11,"","BQX","UNSPECIFIED","B"),1:"") ;;CHS - Vendor
 I ((TYPE="C")&(OTHRTYP'="")) S FDA(90001,"+1,",.09)=OTHRTYP ;;CHS - Vendor and Other can be set at the same time
 I ((TYPE="O")&(OTHRTYP'="")) S FDA(90001,"+1,",.09)=OTHRTYP ;;OTHER - RCIS Specific provider
 I ((TYPE="O")) S FDA(90001,"+1,",.07)=$S(TYPEX'="":TYPEX,TYPEX="":$$FIND1^DIC(9999999.11,"","BQX","UNSPECIFIED","B"),1:"") ;;CHS - Vendor and Other can be set at the same time
 I ((TYPE="N")&(TYPEX'="")) S FDA(90001,"+1,",.23)=TYPEX ;;IN-HOUSE - Clinic Stop
 I ((TYPE="I")&(TYPEX'="")) S FDA(90001,"+1,",.08)=TYPEX ;;IHS (Another facility) - Location (TO IHS FACILITY)
 S:VSTS'="" FDA(90001,"+1,",1111)=VSTS
 S:CHSSTATS'="" FDA(90001,"+1,",1112)=CHSSTATS
 S:NOTESCHD'="" FDA(90001,"+1,",1301)=NOTESCHD
 S:CASEMGR'="" FDA(90001,"+1,",.19)=CASEMGR
 S:SCHWIDAY'="" FDA(90001,"+1,",1302)=SCHWIDAY ;;Schedule With In days
 S:$G(EXPSCHDT)'="" FDA(90001,"+1,",1105)=$G(EXPSCHDT) ;;Expected Schedule DOS
 S:"YN"[IPCC FDA(90001,"+1,",401)=IPCC ;;INCLUDE PCC VISIT FORM
 S:"YN"[ICLNT FDA(90001,"+1,",402)=ICLNT ;;INCLUDE SPECIALTY CLINIC NOTES
 S:"YN"[IPRNL FDA(90001,"+1,",403)=IPRNL ;;INCLUDE PRENATAL RECORD(S)
 S:"YN"[ITUBL FDA(90001,"+1,",404)=ITUBL ;;INCLUDE SIGNED TUBAL CONSENT
 S:"YN"[IFSHT FDA(90001,"+1,",405)=IFSHT ;;INCLUDE FACE SHEET
 S:"YN"[IHLSM FDA(90001,"+1,",406)=IHLSM ;;INCLUDE HEALTH SUMMARY
 S:"YN"[IEKG FDA(90001,"+1,",407)=IEKG ;;INCLUDE MOST RECENT EKG
 S:"YN"[IHSPH FDA(90001,"+1,",408)=IHSPH ;;INCLUDE HISTORY AND PHYSICAL
 S:"YN"[IXRYR FDA(90001,"+1,",409)=IXRYR ;;INCLUDE X-RAY / REPORT
 S:"YN"[IXRYF FDA(90001,"+1,",410)=IXRYF ;;INCLUDE X-RAY FILM
 S:"YN"[ICSRP FDA(90001,"+1,",411)=ICSRP ;;INCLUDE CONSULTATION REPORT
 S:"YN"[ILBRP FDA(90001,"+1,",412)=ILBRP ;;INCLUDE MOST RECENT LAB REPORT
 S:IPCC_ICLNT_IPRNL_ITUBL_IFSHT_IHLSM_IEKG_IHSPH_IXRYR_IXRYF_ICSRP_ILBRP["Y" ADTLINFO=1
 S FDA(90001,"+1,",.34)=ADTLINFO
 S FDA(90001,"+1,",.15)=REFSTATS
 S FDA(90001,"+1,",.25)=DUZ
 S FDA(90001,"+1,",.26)=DT
 S FDA(90001,"+1,",.27)=DT
 S FDA(90001,"+1,",1304)="P"
 S:$G(VST)'="" FDA(90001,"+1,",1309)=$G(VST)
 I TMIEN>0 D  ;;If Template was used for this 'Add Referral'; fetch extra info for that template
 .S BMCPDRG=$$GET1^DIQ(90001.32,TMIEN_",",.21,"I") S:BMCPDRG'="" FDA(90001,"+1,",.21)=BMCPDRG
 .S BMCECOST=$$GET1^DIQ(90001.32,TMIEN_",",1101,"") S:BMCECOST'="" FDA(90001,"+1,",1101)=BMCECOST
 .S BMCIHSCT=$$GET1^DIQ(90001.32,TMIEN_",",1103,"") S:BMCIHSCT'="" FDA(90001,"+1,",1103)=BMCIHSCT
 .S BMCINLOS=$$GET1^DIQ(90001.32,TMIEN_",",1109,"") S:BMCINLOS'="" FDA(90001,"+1,",1109)=BMCINLOS
 N FDAIEN S FDAIEN=""
 ;GDIT/HS/BEE 10/19/17 - p12 CR#8106;Replace next line with three lines, XQY0 is already defined
 ;D UPDATE^DIE("","FDA","FDAIEN","ERR1")
 S OXQY0=$G(XQY0),XQY0="CIAV VUECENTRIC"
 D UPDATE^DIE("","FDA","FDAIEN","ERR1")
 S XQY0=OXQY0  ;Return to original value
 ;End of CR#8106 changes
 I $D(ERR1("DIERR")) S RSLT="~`0^Error adding referral: "_$G(ERR1("DIERR","1","TEXT",1)) Q RSLT
 ;S ^TMP("FAR4",1)="SNOW 980"_"^PAT "_$G(PTIEN)_"^VST "_$G(VST)_"^REF IEN "_$G(FDAIEN(1))_"^DATE "_DT_"."_$REPLACE($ZT($H),":","")_"^PROV "
 ;_$G(PRVDR)_"^LOC "_$G(LOC)_"^ PROV"_$G(PRVDR)_"^ REF PROV "_$G(RPNM)_"^LOC "_$G(LOC)_"^DUZ "_$G(DUZ)_"^B COmments"_$G(BCMT)
 ;S ^TMP("FAR4",1)="980"_"^"_$G(PTIEN)_"^"_$G(VST)_"^"_$G(FDAIEN(1))_"^"_DT_"."_$REPLACE($ZT($H),":","")_"^"_$G(PRVDR)_"^"_$G(LOC)_"^"_$G(PRVDR)_"^"_$G(RQPR)_"^"_$G(LOC)_"^"_$G(DUZ)
 S NREFIEN=$G(FDAIEN(1))
 ;GDIT/HS/BEE 10/19/17 - p12 CR#8779: Change to pass requesting provider into call, set outside provider to null
 ;S VREFIEN=$$CRENVREF^BMCRPC4(.OUT,SNMDCT,SNMDPT,PTIEN,$G(VST),$G(PROB),NREFIEN,$$NOW^XLFDT,PRVDR,LOC,PRVDR,"",RPNM,LOC,$$NOW^XLFDT,DUZ)
 S VREFIEN=$$CRENVREF^BMCRPC4(.OUT,SNMDCT,SNMDPT,PTIEN,$G(VST),$G(PROB),NREFIEN,$$NOW^XLFDT,RPNM,LOC,PRVDR,"","",LOC,$$NOW^XLFDT,DUZ)  ;GDIT/HS/BEE 10/19/17 - p12 CR#8779
 I $G(SNMDST)'="" D CRENSCT^BMCRPC3("",NREFIEN,$G(SNMDST))
 I ($G(NREFIEN)'="")&($G(VREFIEN)'="")&('$D(ERR1("DIERR")))  D
 .K FDA,ERR1
 .N FDA,ERR1
 .S FDA(90001,NREFIEN_",",1303)=$G(VREFIEN)
 .D FILE^DIE("","FDA","ERR1")
 I $D(ERR1("DIERR")) S RSLT="~`0^Error updating V Referral IEN:"_$G(ERR1("DIERR","1","TEXT",1)) Q RSLT
 ;
 ;
 D SENDALRT^BMCRPC3(NREFIEN) ;; EP-ALERT FOR PHYS
 D SENDXM^BMCRPC3(NREFIEN,"A") ;; Send mailman message
 D STATIC^BMCRPC3(PTIEN,NREFIEN) ;; fill in EXP (5101 - 5114) fields in RCIS REF file...
 I $D(HXCMT) D
 .I HXCMT'="" D SETMEDHX^BMCRPC3(.RS,HXCMT,PTIEN,NREFIEN,"M")
 I $D(BCMT) D
 .I BCMT'="" D SETMEDHX^BMCRPC3(.RS,BCMT,PTIEN,NREFIEN,"B")
 I $P($G(RS),"^")="~`0" S RSLT=RS Q RSLT
 S RSLT="~`1^"_NREFIEN
 Q RSLT
 ;
UPDREFRL(RSLT,REFIEN,TYPE,INOROUT,ICDCAT,CPTCAT,PURPOSE,PRIORITY,TYPEEXT,VISITS,NOTESCHD,HXCMNTS,SCHWIDAY,ICSRP,IFSHT,IHLSM,IHSPH,IEKG,ILBRP,IPCC,IPRNL,ITUBL,ICLNT,IXRYR,IXRYF,BCMNTS,OTHRTYP,SNMDCT,PROB,SNMDST) ;;update referral data
 K ^TMP($J)
 N OUT,FDA,ERR1,PATIEN,ADTLINFO,EXPSCHDT,VREFIEN
 ;S ^TMP("FAR12",2)=REFIEN_"~"_SCHWIDAY
 S ADTLINFO=0 ;;ADDITIONAL INFO flag
 I '$D(REFIEN) S RSLT="~`0^Referral Ien is not provided" Q RSLT
 I REFIEN'>0 S RSLT="~`0^Referral Ien is not provided" Q RSLT
 S:'$D(TYPE) TYPE=""
 S:'$D(TYPEEXT) TYPEEXT=""
 S:'$D(OTHRTYP) OTHRTYP=""
 S:'$D(ICDCAT) ICDCAT=""
 S:'$D(CPTCAT) CPTCAT=""
 I $P($G(SCHWIDAY),"^",2)'="" D
 . S EXPSCHDT=$P($P($G(SCHWIDAY),"^",2),"@",1)
 . D DT^DILF("",EXPSCHDT,.EXPSCHDT) I EXPSCHDT="-1" S EXPSCHDT=""
 . ;GDIT/HS/BEE 10/19/17 - p12 - Fixed SAC issue - changed $REPLACE to $TR()
 . ;I $G(EXPSCHDT)'="" S EXPSCHDT=$G(EXPSCHDT)_"."_$REPLACE($P($P($G(SCHWIDAY),"^",2),"@",2),":","")
 . I $G(EXPSCHDT)'="" S EXPSCHDT=$G(EXPSCHDT)_"."_$TR($P($P($G(SCHWIDAY),"^",2),"@",2),":","")
 . S SCHWIDAY=$P($G(SCHWIDAY),"^",1)
 S SCHWIDAY=$P($G(SCHWIDAY),"^",1)
 S:TYPE'="" FDA(90001,REFIEN_",",.04)=TYPE
 S:INOROUT'="" FDA(90001,REFIEN_",",.14)=INOROUT
 S:ICDCAT'="" FDA(90001,REFIEN_",",.12)=ICDCAT
 S:CPTCAT'="" FDA(90001,REFIEN_",",.13)=CPTCAT
 S:PURPOSE'="" FDA(90001,REFIEN_",",1201)=PURPOSE
 S:PRIORITY'="" FDA(90001,REFIEN_",",.32)=PRIORITY
 I (TYPE="C") D  ;; CHS - Set Vendor - leave specific provider as is - delete To IHS FAC and Clinic Stop
 .S FDA(90001,REFIEN_",",.23)="@",FDA(90001,REFIEN_",",.08)="@",FDA(90001,REFIEN_",",.07)="@",FDA(90001,REFIEN_",",.09)="@"
 .S FDA(90001,REFIEN_",",.07)=$S(TYPEEXT'="":TYPEEXT,TYPEEXT="":$$FIND1^DIC(9999999.11,"","BQX","UNSPECIFIED","B"),1:"")
 .S:(OTHRTYP'="") FDA(90001,REFIEN_",",.09)=OTHRTYP
 I (TYPE="O") D  ;; OTHER - set Specific provider - leave Vendor as is - delete To IHS FAC and Clinic Stop
 .S FDA(90001,REFIEN_",",.23)="@",FDA(90001,REFIEN_",",.08)="@",FDA(90001,REFIEN_",",.07)="@",FDA(90001,REFIEN_",",.09)="@"
 .S FDA(90001,REFIEN_",",.07)=$S(TYPEEXT'="":TYPEEXT,TYPEEXT="":$$FIND1^DIC(9999999.11,"","BQX","UNSPECIFIED","B"),1:"")
 .S:(OTHRTYP'="") FDA(90001,REFIEN_",",.09)=OTHRTYP
 I (TYPE="N") D  ;; IN-HOUSE - set Clinic Stop - delete Specific provider - Vendor - To IHS FAC
 .S FDA(90001,REFIEN_",",.07)="@",FDA(90001,REFIEN_",",.09)="@",FDA(90001,REFIEN_",",.08)="@",FDA(90001,REFIEN_",",.23)="@"
 .S:(TYPEEXT'="") FDA(90001,REFIEN_",",.23)=TYPEEXT
 I (TYPE="I") D  ;IHS(Another facility)-Set Location(FACILITY)-delete SpecificProvider-Vendor-ClinicStop
 .S FDA(90001,REFIEN_",",.07)="@",FDA(90001,REFIEN_",",.09)="@",FDA(90001,REFIEN_",",.23)="@",FDA(90001,REFIEN_",",.08)="@"
 .S:(TYPEEXT'="") FDA(90001,REFIEN_",",.08)=TYPEEXT
 S:VISITS'="" FDA(90001,REFIEN_",",1111)=VISITS
 S:NOTESCHD'="" FDA(90001,REFIEN_",",1301)=NOTESCHD
 S:SCHWIDAY'="" FDA(90001,REFIEN_",",1302)=SCHWIDAY ;; Schedule With In days
 S:$G(EXPSCHDT)'="" FDA(90001,REFIEN_",",1105)=$G(EXPSCHDT) ;;Expected Schedule DOS
 S:$G(EXPSCHDT)="" FDA(90001,REFIEN_",",1105)="@" ;;Expected Schedule DOS
 S:"YN"[IPCC FDA(90001,REFIEN_",",401)=IPCC ;; INCLUDE PCC VISIT FORM
 S:"YN"[ICLNT FDA(90001,REFIEN_",",402)=ICLNT ;; INCLUDE SPECIALTY CLINIC NOTES
 S:"YN"[IPRNL FDA(90001,REFIEN_",",403)=IPRNL ;;INCLUDE PRENATAL RECORD(S)
 S:"YN"[ITUBL FDA(90001,REFIEN_",",404)=ITUBL ;;INCLUDE SIGNED TUBAL CONSENT
 S:"YN"[IFSHT FDA(90001,REFIEN_",",405)=IFSHT ;;INCLUDE FACE SHEET
 S:"YN"[IHLSM FDA(90001,REFIEN_",",406)=IHLSM ;;INCLUDE HEALTH SUMMARY
 S:"YN"[IEKG FDA(90001,REFIEN_",",407)=IEKG ;; INCLUDE MOST RECENT EKG
 S:"YN"[IHSPH FDA(90001,REFIEN_",",408)=IHSPH ;; INCLUDE HISTORY AND PHYSICAL
 S:"YN"[IXRYR FDA(90001,REFIEN_",",409)=IXRYR ;;INCLUDE X-RAY / REPORT
 S:"YN"[IXRYF FDA(90001,REFIEN_",",410)=IXRYF ;; INCLUDE X-RAY FILM
 S:"YN"[ICSRP FDA(90001,REFIEN_",",411)=ICSRP ;;INCLUDE CONSULTATION REPORT
 S:"YN"[ILBRP FDA(90001,REFIEN_",",412)=ILBRP ;;INCLUDE MOST RECENT LAB REPORT
 S:IPCC_ICLNT_IPRNL_ITUBL_IFSHT_IHLSM_IEKG_IHSPH_IXRYR_IXRYF_ICSRP_ILBRP["Y" ADTLINFO=1
 S FDA(90001,REFIEN_",",.34)=ADTLINFO
 S FDA(90001,REFIEN_",",.27)=DT ;; Date last updated - set to current system date
 D FILE^DIE("","FDA","ERR1")
 I $D(ERR1("DIERR")) S RSLT="~`0^Error updating referral:"_$G(ERR1("DIERR","1","TEXT",1)) Q RSLT
 K ^BMCREF(REFIEN,22)
 I $G(SNMDST)'="" D CRENSCT^BMCRPC3("",REFIEN,$G(SNMDST))
 S VREFIEN=$$GET1^DIQ(90001,REFIEN_",",1303,"I") ;
 ;S ^TMP("1221")=$G(VREFIEN)_"^"_$G(SNMDCT)_"^"_$G(DUZ)_"^"_$G(PROB)
 I $G(VREFIEN)'="" S RSLT=$$UPENVREF^BMCRPC4(VREFIEN,$G(SNMDCT),$G(DUZ),$G(PROB))
 I $G(VREFIEN)="" S RSLT="~`1^"
 I $G(RSLT)'="~`1^" Q RSLT
 D SENDXM^BMCRPC3(REFIEN,"M") ;;Send mailman message
 I $D(HXCMNTS) D
 .I HXCMNTS'="" S PATIEN=$$GET1^DIQ(90001,REFIEN_",",.03,"I") D SETMEDHX^BMCRPC3(.RS,HXCMNTS,PATIEN,REFIEN,"M")
 I $D(BCMNTS) D
 .I BCMNTS'="" S PATIEN=$$GET1^DIQ(90001,REFIEN_",",.03,"I") D SETMEDHX^BMCRPC3(.RS,BCMNTS,PATIEN,REFIEN,"B")
 I $P($G(RS),"^")="~`0" S RSLT=RS Q RSLT
 S RSLT="~`1"
 Q RSLT
 ;
CHKYEAR(RSLT,SITE) ;BMC CHK YEAR SITE PARAM
 ;S SITE="2011 DEMO HOSPITAL"
 I $G(DUZ(2))="" S RSLT="0" Q RSLT
 S YEAR=$$GET1^DIQ(90001.31,$G(DUZ(2))_",",.02)
 I $G(YEAR)="" S RSLT="0" Q RSLT
 S RSLT=$G(YEAR)
 Q RSLT
 ;