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

IBCNIUR1.m

Go to the documentation of this file.
  1. IBCNIUR1 ;AITC/VAD - Interfacility Ins. Update Report;3-FEB-2021
  1. ;;2.0;INTEGRATED BILLING;**687**; 21-MAR-94;Build 88
  1. ;;Per VA Directive 6402, this routine should not be modified.
  1. ;
  1. ;Variables:
  1. ;IBCNFAC(ien) = Facilities (if IBCNFAC=1, include all)
  1. ;IBCNIRTN = "IBCNIUR1" (routine name for queueing)
  1. ;IBCNIUR("BEGDT") = Begin Date
  1. ;IBCNIUR("ENDDT") = End Date
  1. ;IBCNIUR("IBOUT") = "E"xcel, "R"eport
  1. ;IBCNIUR("PS") = processing status: 1-With, 0-Without
  1. ;IBCNIUR("SD") = "S"ummary or "D"etail
  1. ;IBCNIUR("SORT") = "D"ate or "F"acility
  1. ;IBCNIUR("SR") = "S"ent or "R"eceived
  1. ;
  1. ;ICR #10090 - File 4
  1. ;
  1. Q
  1. ;
  1. EN ;entry point
  1. N %ZIS,I,IBCNFAC,IBCNIUR,IBCNIRTN,IBDFLTDT,IBOUT,IBRPTPS,IBRPTSD,IBRPTSR
  1. N IBRPTSRX,POP,STOP
  1. N ZTDESC,ZTQUEUED,ZTREQ,ZTRTN,ZTSAVE
  1. S STOP=0,IBCNIRTN="IBCNIUR1"
  1. K ^TMP($J,IBCNIRTN)
  1. W @IOF,!,"Interfacility Ins. Update Report",!
  1. ;
  1. P10 ;Summary or Detail
  1. N DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
  1. W !
  1. S DIR(0)="SA^S:Summary;D:Detailed;"
  1. S DIR("A")="Summary or Detailed:// "
  1. S DIR("??")="^D HELPDS^IBCNIUR1"
  1. D ^DIR
  1. I $D(DUOUT)!$D(DTOUT)!(Y=-1) G EXIT
  1. S IBCNIUR("SD")=Y,IBRPTSD=Y
  1. I IBCNIUR("SD")="S" S IBCNFAC=1,IBCNIUR("SORT")=""
  1. ;
  1. P20 ;Received or Sent
  1. N DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
  1. W !!,"To view what your facility sent to other VAMCs choose SENT."
  1. W !,"To view what your facility received from other VAMCs choose RECEIVED.",!
  1. S DIR(0)="SA^S:Sent;R:Received"
  1. S DIR("A")="Report Type - (S)ent or (R)eceived Report// "
  1. S DIR("??")="^D HELPSR^IBCNIUR1"
  1. D ^DIR
  1. I $D(DUOUT)!$D(DTOUT)!(Y=-1) G:$$STOP^IBCNINSU EXIT G P10
  1. S IBCNIUR("SR")=Y,IBRPTSR=Y
  1. W !
  1. ;If the rpt is "Sent", skip Processing Status prompt
  1. I IBCNIUR("SD")="S"!(IBCNIUR("SR")="S") G P30
  1. ;
  1. P25 ;Include or exclude Processing Status
  1. N DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
  1. W !,"To know which records filed to buffer and which did not,"
  1. W !,"select ""YES"" to include processing status.",!
  1. S DIR(0)="Y",DIR("A")="Include processing status"
  1. S DIR("B")="YES",DIR("??")="^D HELPPS^IBCNIUR1"
  1. D ^DIR
  1. I $D(DUOUT)!$D(DTOUT)!(Y=-1) G:$$STOP^IBCNINSU EXIT G P20
  1. S IBCNIUR("PS")=Y,IBRPTPS=Y K DIR
  1. W !
  1. ;
  1. P30 ;Get Default date
  1. S IBRPTSRX=$S(IBRPTSR="S":"SSR",1:"DIR")
  1. S IBDFLTDT=$O(^IBCN(365.19,IBRPTSRX,IBRPTSR,""))
  1. I IBDFLTDT="" S IBDFLTDT=$$NOW^XLFDT ;If no date, use the current date
  1. S IBDFLTDT=IBDFLTDT\1
  1. ;
  1. P35 ;Begin Date
  1. N DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
  1. S DIR(0)="D^::EX"
  1. S DIR("A",1)=$S(IBRPTSR="S":"Sent",1:"Receiving")_" Date Range:"
  1. S DIR("A")=" Earliest Date "_$S(IBRPTSR="R":"Received",1:"Sent")
  1. S DIR("B")=$S(IBDFLTDT:$$FMTE^XLFDT(IBDFLTDT,5),1:"")
  1. D ^DIR
  1. I $D(DUOUT)!$D(DTOUT)!(Y=-1) G:$$STOP^IBCNINSU EXIT G:(IBCNIUR("SD")="S"!(IBCNIUR("SR")="S")) P20 G P25
  1. I Y<IBDFLTDT!(Y>DT) D G P35
  1. . W !,"Invalid date entered."
  1. . W !,"Date must be within the range of ",$$FMTE^XLFDT(IBDFLTDT,5)," and ",$$FMTE^XLFDT(DT,5),"...please re-enter.",!
  1. S IBCNIUR("BEGDT")=Y
  1. ;
  1. P36 ;End date
  1. K DIR("A")
  1. S DIR("A")=" Latest Date "_$S(IBRPTSR="S":"Sent",1:"Received"),DIR("B")="TODAY"
  1. D ^DIR I $D(DUOUT)!$D(DTOUT)!(Y=-1) G:$$STOP^IBCNINSU EXIT G P35
  1. I Y<IBCNIUR("BEGDT") W !," Latest Date must not precede the Earliest Date." G P36
  1. I Y<IBCNIUR("BEGDT")!(Y>DT) D G P36
  1. . W !,"Invalid date entered."
  1. . W !,"Date must be within the range of ",$$FMTE^XLFDT(IBCNIUR("BEGDT"),5)," and ",$$FMTE^XLFDT(DT,5),"...please re-enter.",!
  1. S IBCNIUR("ENDDT")=Y
  1. ;
  1. P40 ;Facility Selection
  1. W !
  1. I IBCNIUR("SD")="D" D INST^IBCNINSL(.IBCNFAC,$S(IBCNIUR("SR")="S":"Destination",1:"Originating")_" Facility")
  1. I $D(DUOUT)!$D(DTOUT) G:$$STOP^IBCNINSU EXIT G P35
  1. ;
  1. P50 ;Report or Excel
  1. N DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
  1. W !
  1. S DIR(0)="SA^E:Excel;R:Report"
  1. S DIR("A")="(E)xcel Format or (R)eport Format: "
  1. S DIR("B")="Report"
  1. D ^DIR I $D(DIRUT) G:$$STOP^IBCNINSU EXIT G:IBCNIUR("SD")="D" P40 G P35
  1. S (IBOUT,IBCNIUR("IBOUT"))=Y
  1. I IBCNIUR("IBOUT")="E" S IBCNIUR("SORT")="D" G P70
  1. ;
  1. P60 ;Sort by Date, Patient or Facility
  1. I IBCNIUR("SD")'="D" G P70 ; If Summary, skip Facility prompt
  1. N DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
  1. W !
  1. S DIR(0)="SA^D:Date "_$S(IBCNIUR("SR")="S":"Sent",1:"Received")_";P:Patient Name;F:Facility "_$S(IBCNIUR("SR")="S":"Destination",1:"Originated From")
  1. S DIR("A",1)="Select one of the following:"
  1. S DIR("A",2)=""
  1. S DIR("A",3)=" D Date "_$S(IBCNIUR("SR")="S":"Sent",1:"Received")
  1. S DIR("A",4)=" P Patient Name"
  1. S DIR("A",5)=" F Facility "_$S(IBCNIUR("SR")="S":"Destination",1:"Originated From")
  1. S DIR("A",6)=""
  1. S DIR("A")="Sort the report by: "
  1. D ^DIR I $D(DIRUT) G:$$STOP^IBCNINSU EXIT G P50
  1. S IBCNIUR("SORT")=Y
  1. ;
  1. P70 ; Proceed to compile the data and generate the output of the rpt
  1. S STOP=0
  1. I '$D(ZTQUEUED) D
  1. . I IBCNIUR("IBOUT")="R" D Q
  1. . . I IBCNIUR("SD")="D" W !,"*** This report is 132 characters wide ***",! ;For DETAIL
  1. . W !,"*** To avoid wrapping, enter '0;256;999' at the 'DEVICE' prompt. ***",!
  1. D DEVICE(IBCNIRTN,.IBCNIUR,.IBCNFAC)
  1. I +STOP,IBCNIUR("IBOUT")="E" G:$$STOP^IBCNINSU EXIT G P50
  1. I +STOP,IBCNIUR("SD")'="D" G:$$STOP^IBCNINSU EXIT G P50
  1. I +STOP,IBCNIUR("SD")="D" G:$$STOP^IBCNINSU EXIT G P60
  1. G EXIT
  1. ; =============================
  1. DEVICE(IBCNIRTN,IBCNIUR,IBCNFAC) ; Device Handler and possible TaskManager calls
  1. ; Input params:
  1. ; IBCNIRTN = Routine name for ^TMP($J,...
  1. ; IBCNIUR = Array passed by ref of the report params
  1. ; IBOUT = "R" for Report format or "E" for Excel format
  1. ;
  1. N POP,ZTDESC,ZTRTN,ZTSAVE
  1. ;
  1. S ZTRTN="COMPILE^IBCNIUR1(.IBCNFAC,.IBCNIUR,"""_IBCNIRTN_""")"
  1. S ZTDESC="IBCNIU - Interfacility Ins. Update Report"
  1. S ZTSAVE("IBCNFAC")=""
  1. S ZTSAVE("IBCNFAC(")=""
  1. S ZTSAVE("IBCNIUR(")=""
  1. S ZTSAVE("IBCNIRTN")=""
  1. S ZTSAVE("IBOUT")=""
  1. D EN^XUTMDEVQ(ZTRTN,ZTDESC,.ZTSAVE)
  1. I POP S STOP=1
  1. Q
  1. ;
  1. HELPDS ;Help for Summary/Detail
  1. W !,"Please enter 'S' for 'Summary' or 'D' for a Detailed Report."
  1. Q
  1. ;
  1. HELPPS ;Help for (W)ith or With(O)ut Processing Status
  1. W !,"Enter 'YES' to include the processing status for the records received."
  1. W !,"This identifies which records filed to the buffer and which did not."
  1. W !,"Enter 'NO' to exclude the processing status on the report."
  1. Q
  1. ;
  1. HELPSR ;Help for (S)ent or (R)eceived Report
  1. W !,"Please enter 'R' for 'Received' or 'S' for 'Sent'."
  1. Q
  1. ;
  1. EXIT ;
  1. K ^TMP($J,IBCNIRTN),IBCNIRTN,IBCNIUR
  1. Q
  1. ;
  1. COMPILE(IBCNFAC,IBCNIUR,IBCNIRTN) ; Compile the data.
  1. N DSENT,FNAME,FSENT,IBBDT,IBEDT,IBOUT,IBRPTPS,IBRPTSD,IBRPTSR,IBSORT
  1. N PNAME,PSENT,SDATE,SITENO,SUBID
  1. S IBBDT=$G(IBCNIUR("BEGDT")) ;Begin Date
  1. S IBEDT=$G(IBCNIUR("ENDDT")) ;End Date
  1. S IBOUT=$G(IBCNIUR("IBOUT")) ;"E"xcel, "R"eport
  1. S IBRPTPS=$G(IBCNIUR("PS")) ;Processing status: 1-With, 0-Without
  1. S IBRPTSD=$G(IBCNIUR("SD")) ;"S"ummary or "D"etail
  1. S IBRPTSR=$G(IBCNIUR("SR")) ;"S"ent or "R"eceived
  1. S IBSORT=$G(IBCNIUR("SORT")) ;"D"ate or "F"acility or "P"atient
  1. S ^TMP($J,IBCNIRTN)=0
  1. ;
  1. I IBRPTSR="R" D GETRECV ;Get RECEIVED data
  1. I IBRPTSR="S" D GETSENT ;Get SENT data
  1. D PRINT^IBCNIUR2
  1. Q
  1. ;
  1. GETRECV ;Get RECEIVED Data
  1. N COB,DATAREC,IIUIENS,IIURCV,IIUVAMC,INSNAM,INSNAME,OVAMC,OVAMCIEN,OVAMCNAM,OVAMCSTA
  1. N PATIEN,PATSSN,PATSSN4,PNAME,RCVDTTM,RDATE,RDTTM,RPROCSTAT,SUBID,VAMCSQ
  1. ;
  1. S RCVDTTM=IBBDT ;Set begin date
  1. F S RCVDTTM=$O(^IBCN(365.19,"DIR","R",RCVDTTM)) Q:RCVDTTM=""!((RCVDTTM\1)>IBEDT) D
  1. .S IIURCV=""
  1. .;Loop thru receiving records by date
  1. .F S IIURCV=$O(^IBCN(365.19,"DIR","R",RCVDTTM,IIURCV)) Q:IIURCV="" D
  1. ..S IIUIENS=IIURCV_","
  1. ..S PATIEN=$$GET1^DIQ(365.19,IIUIENS,.01,"I"),PNAME=$$GET1^DIQ(365.19,IIUIENS,.01) ;Patient IEN & Patient Name
  1. ..S PNAME=$S(IBOUT="R":$E(PNAME,1,25),1:PNAME) ;Truncate for REPORT
  1. ..S PATSSN=$$GET1^DIQ(2,PATIEN_",",.09,"I")
  1. ..;Last 4 of Patient's SSN
  1. ..S PATSSN4=$S($E(PATSSN,$L(PATSSN))="P":$E(PATSSN,$L(PATSSN)-4,$L(PATSSN)),1:$E(PATSSN,$L(PATSSN)-3,$L(PATSSN)))
  1. ..S RDTTM=$$GET1^DIQ(365.19,IIUIENS,2.02,"I"),RDATE=RDTTM\1 ;Received Date/Time
  1. ..S RPROCSTAT=$$GET1^DIQ(365.19,IIUIENS,2.01,"E") ;get the RECEIVER PROCESSING STATUS
  1. ..S RPROCSTAT=$S(IBOUT="R":$E(RPROCSTAT,1,23),1:RPROCSTAT) ;Truncate for REPORT
  1. ..;
  1. ..S IIUVAMC="1,"_IIUIENS ;get the Originating VAMC data
  1. ..S OVAMCIEN=$$GET1^DIQ(365.192,IIUVAMC,.01,"I") ;VAMC IEN
  1. ..I $G(IBCNFAC)'=1,'$D(IBCNFAC(OVAMCIEN)) Q ;** NOT a selected facility
  1. ..S OVAMCNAM=$$GET1^DIQ(365.192,IIUVAMC,.01,"E") ;VAMC name
  1. ..S OVAMCSTA=$$GET1^DIQ(4,OVAMCIEN,99,"E") ;VAMC station # (ICR #10090)
  1. ..S OVAMC=$E(OVAMCNAM,1,$S(+IBRPTPS:11,1:22))_" ("_+OVAMCSTA_")" ;VAMC name & station #
  1. ..I IBOUT="E" S OVAMC=OVAMCNAM_" ("_+OVAMCSTA_")" ;Don't truncate VAMC name/station for EXCEL
  1. ..;
  1. ..;STORE counter data.
  1. ..S $P(^TMP($J,IBCNIRTN),U,1)=$P($G(^TMP($J,IBCNIRTN)),U,1)+1 ;# of transmissions received
  1. ..I '$D(^TMP($J,IBCNIRTN,"VAMCNAME",OVAMC)) D ;A new VAMC
  1. ...S $P(^TMP($J,IBCNIRTN),U,2)=$P(^TMP($J,IBCNIRTN),U,2)+1 ;# of VAMCs
  1. ..S ^TMP($J,IBCNIRTN,"VAMCNAME",OVAMC)=$G(^TMP($J,IBCNIRTN,"VAMCNAME",OVAMC))+1 ;increment # per VAMC
  1. ..I IBRPTSD="S" Q ;If SUMMARY quit
  1. ..;
  1. ..;If DETAIL, gather DETAILED RECEIVED data
  1. ..S INSNAME=$$GET1^DIQ(365.192,IIUVAMC,.03,"E") ;Insurance Company Name
  1. ..S INSNAM=$E(INSNAME,1,$S(+IBRPTPS:25,1:30))
  1. ..I IBOUT="E" S INSNAM=INSNAME ;Don't truncate Ins. name for EXCEL
  1. ..S SUBID=$$GET1^DIQ(365.192,IIUVAMC,1.03) ;Subscriber ID
  1. ..S SUBID=$S(IBOUT="R":$E(SUBID,1,20),1:SUBID) ;Truncate for REPORT
  1. ..S COB=$E($$GET1^DIQ(365.192,IIUVAMC,1.05,"E"),1)
  1. ..;
  1. ..S DATAREC=PNAME_U_PATSSN4_U_INSNAM_U_SUBID_U_COB_U_OVAMC_U_$$FMTE^XLFDT(RDATE,"2Z") ;STORE Originating VAMC info
  1. ..I +IBRPTPS S DATAREC=DATAREC_U_RPROCSTAT ;If including Receiver Processing Status
  1. ..I IBSORT="D" S ^TMP($J,IBCNIRTN,"DATE",RDATE,OVAMC,PNAME_U_PATSSN4_U_PATIEN_U_IIURCV)=DATAREC
  1. ..I IBSORT="F" S ^TMP($J,IBCNIRTN,"FNAME",OVAMC,RDATE,PNAME_U_PATSSN4_U_PATIEN_U_IIURCV)=DATAREC
  1. ..I IBSORT="P" S ^TMP($J,IBCNIRTN,"PNAME",PNAME_U_PATSSN4_U_PATIEN_U_IIURCV,RDATE,OVAMC)=DATAREC
  1. Q
  1. ;
  1. GETSENT ;Get SENT Data
  1. N COB,DATAREC,DVAMC,DVAMCIEN,DVAMCNAM,DVAMCSTA,IIUIENS,IIUSNT,IIUVAMC,IIUVIENS,INSIEN,INSNAM
  1. N PATIEN,PATSSN,PATSSN4,PNAME,SNTDTTM,SDATE,SDTTM,SUBID,VAMCSQ
  1. ;
  1. S SNTDTTM=IBBDT ;Set the begin date
  1. ;
  1. ;Only want transmissions that were successfully SENT
  1. F S SNTDTTM=$O(^IBCN(365.19,"SSR","S",SNTDTTM)) Q:SNTDTTM=""!((SNTDTTM\1)>IBEDT) D
  1. .S IIUSNT=""
  1. .F S IIUSNT=$O(^IBCN(365.19,"SSR","S",SNTDTTM,IIUSNT)) Q:IIUSNT="" D
  1. ..;
  1. ..S IIUIENS=IIUSNT_","
  1. ..;Patient IEN & Patient Name
  1. ..S PATIEN=$$GET1^DIQ(365.19,IIUIENS,.01,"I"),PNAME=$$GET1^DIQ(365.19,IIUIENS,.01)
  1. ..S PNAME=$S(IBOUT="R":$E(PNAME,1,28),1:PNAME) ; Truncate Patient Name for REPORT
  1. ..S PATSSN=$$GET1^DIQ(2,PATIEN_",",.09,"I")
  1. ..;Last 4 of Patient's SSN
  1. ..S PATSSN4=$S($E(PATSSN,$L(PATSSN))="P":$E(PATSSN,$L(PATSSN)-4,$L(PATSSN)),1:$E(PATSSN,$L(PATSSN)-3,$L(PATSSN)))
  1. ..S INSIEN=$$GET1^DIQ(365.19,IIUIENS,1.03,"E") ;Ins. Company IEN
  1. ..S INSNAM=$$GET1^DIQ(2.312,INSIEN_","_PATIEN_",",.01) ;Ins. Company Name
  1. ..S INSNAM=$S(IBOUT="R":$E(INSNAM,1,30),1:INSNAM) ;Truncate Ins. Company Name for REPORT
  1. ..S SUBID=$$GET1^DIQ(365.19,IIUIENS,1.06) ;Subscriber ID
  1. ..S SUBID=$S(IBOUT="R":$E(SUBID,1,20),1:SUBID) ;Truncate for REPORT
  1. ..S COB=$E($$GET1^DIQ(365.19,IIUIENS,1.07,"E"),1)
  1. ..;
  1. ..S IIUVIENS=0
  1. ..F S IIUVIENS=$O(^IBCN(365.19,"SSR","S",SNTDTTM,IIUSNT,IIUVIENS)) Q:'(+IIUVIENS) D ;Process each VAMC that was SENT to.
  1. ...S IIUVAMC=IIUVIENS_","_IIUIENS ;Get the Destination VAMC data
  1. ...I $$GET1^DIQ(365.191,IIUVAMC,.02,"I")'="S" Q ;Only want "S"ENT records
  1. ...S DVAMCIEN=$$GET1^DIQ(365.191,IIUVAMC,.01,"I") ;VAMC IEN
  1. ...I $G(IBCNFAC)'=1,'$D(IBCNFAC(DVAMCIEN)) Q ;**NOT a selected facility
  1. ...S DVAMCNAM=$$GET1^DIQ(365.191,IIUVAMC,.01,"E") ;VAMC name
  1. ...S DVAMCSTA=$$GET1^DIQ(4,DVAMCIEN,99,"E") ;VAMC station #
  1. ...S DVAMC=$S(IBOUT="R":$E(DVAMCNAM,1,22),1:DVAMCNAM)_" ("_+DVAMCSTA_")" ;VAMC name & station #
  1. ...S SDTTM=$$GET1^DIQ(365.191,IIUVAMC,.03,"I"),SDATE=SDTTM\1 ;Sent Date/Time
  1. ...;
  1. ...;If STORE counter data
  1. ...S $P(^TMP($J,IBCNIRTN),U,1)=$P($G(^TMP($J,IBCNIRTN)),U,1)+1 ;# of transmissions sent
  1. ...I '$D(^TMP($J,IBCNIRTN,"VAMCNAME",DVAMC)) D ;A new VAMC
  1. ....S $P(^TMP($J,IBCNIRTN),U,2)=$P(^TMP($J,IBCNIRTN),U,2)+1 ;# of VAMCs
  1. ...S ^TMP($J,IBCNIRTN,"VAMCNAME",DVAMC)=$G(^TMP($J,IBCNIRTN,"VAMCNAME",DVAMC))+1 ;increment # per VAMC
  1. ...I IBRPTSD="S" Q ;If SUMMARY quit
  1. ...;
  1. ...;If DETAIL, gather DETAILED SENT data
  1. ...S DATAREC=PNAME_U_PATSSN4_U_INSNAM_U_SUBID_U_COB_U_DVAMC_U_$$FMTE^XLFDT(SDATE,"2Z")
  1. ...I IBSORT="D" S ^TMP($J,IBCNIRTN,"DATE",SDATE,DVAMC,PNAME_U_PATSSN4_U_PATIEN_U_IIUSNT)=DATAREC
  1. ...I IBSORT="F" S ^TMP($J,IBCNIRTN,"FNAME",DVAMC,SDATE,PNAME_U_PATSSN4_U_PATIEN_U_IIUSNT)=DATAREC
  1. ...I IBSORT="P" S ^TMP($J,IBCNIRTN,"PNAME",PNAME_U_PATSSN4_U_PATIEN_U_IIUSNT,SDATE,DVAMC)=DATAREC
  1. Q