SCDXFU04 ;ALB/JRP - ACRP FILE UTILITIES FOR CLOSE OUT;15-APR-97 ; 1/24/02 3:44pm
;;5.3;Scheduling;**121,140,247**;Aug 13, 1993
;
XMIT4DBC(XMITPTR) ;Determine if an entry in the TRANSMITTED OUTPATIENT
; ENCOUNTER file (#409.73) should be transmitted to the NPCD
; for database [not workload] credit and/or workload credit
;
;Input : XMITPTR - Pointer to entry in Transmitted Outpatient
; Encounter file
;Output:
; 0 - Transmit - NPCD will accept for monthly workload credit,
; no message generated
; 1 - Transmit - NPCD will accept for monthly workload credit
; with a rolling message
; 2 - Transmit - will accept for yearly workload report
; 3 - Transmit - for historical accuracy of database only
; 4 - Don't transmit (NPCD will not accept for database credit)
;Notes :5 (don't transmit) will be returned on error/bad input
;
;Check input
S XMITPTR=+$G(XMITPTR)
Q:('$D(^SD(409.73,XMITPTR,0))) 5
;Declare variables
N NODE,ENCPTR,DELPTR,ENCDATE
;Get pointer to [deleted] encounter
S NODE=$G(^SD(409.73,XMITPTR,0))
S ENCPTR=+$P(NODE,"^",2)
S DELPTR=+$P(NODE,"^",3)
;Get date/time of [deleted] encounter
S:(ENCPTR) NODE=$G(^SCE(ENCPTR,0))
S:('ENCPTR) NODE=$G(^SD(409.74,DELPTR,1))
S ENCDATE=+NODE
Q:('ENCDATE) 5
;Get the level of acceptance
Q $$OKTOXMIT(ENCDATE)
;
OKTOXMIT(ENCDATE,COMPDATE) ;Determine if an encounter occurring on a
; specified date should be transmitted to the National Patient Care
; Database for database and workload credit. It also determines
; the acceptance level(message type), later used when generating
; late activity messages
;
;Input (FileMan format):
;
; ENCDATE - Date/time Outpatient Encounter occurred on
; COMPDATE - Date to compare close out dates against;
; defaults to the current date
;
;Output : MessageType
;
; MessageType - Indicates what type of message will be generated
; for Encounter with the submitted ENCDATE.
; In the same time the message type determines if
; Encounter can be transmitted. The message type
; indicates if the specified date/time will be
; accepted for database/workload credit.
;
; A message type is determined in the following order of comparison:
; Type Transmitted
; -------------------------------------------------------------
; 4 - Database closeout date no DBCLOSE
; 3 - Annual Workload closeout date yes WLCLA
; 2 - Monthly Workload closeout date yes WLCLOSE
; 1 - Rolling date yes ROLL
;
; 0 - No message yes
; -1 - Error no
;
;Check input / remove time
S ENCDATE=+$G(ENCDATE)\1
Q:(ENCDATE'?7N) "-1"
S COMPDATE=+$G(COMPDATE)\1
S:(COMPDATE'?7N) COMPDATE=$$DT^XLFDT()
;Declare variables
N CLOSEOUT,DBCLOSE,WLCLOSE,WLCLA,ROLL
N DBCRED,WLCRED,COMP
S (DBCRED,WLCRED)=-1
;Get close-out dates for month the encounter occurred in
S CLOSEOUT=$$CLOSEOUT(ENCDATE)
S DBCLOSE=$P(CLOSEOUT,U)
S WLCLOSE=$P(CLOSEOUT,U,2)
S WLCLA=$P(CLOSEOUT,U,3)
S ROLL=$P(CLOSEOUT,U,4)
;Determine LEVEL to determine if an encounter can be transmitted
;and identify a message to be generated
N LEVEL,X,%H,%T,%Y,YY
S LEVEL=0
S X=COMPDATE D H^%DTC S COMP=%H
F YY=4:-1:1 D Q:LEVEL
.S X=$S(YY=4:DBCLOSE,YY=3:WLCLA,YY=2:WLCLOSE,YY=1:ROLL) D
..D H^%DTC I COMP>%H S LEVEL=YY
;Done
Q LEVEL
;
CLOSEOUT(NPCDMNTH) ;Get National Patient Care Database (NPCD) close-out
; dates for a given month
;
;Input : NPCDMNTH - Encouter Date (FileMan format) to calculate
; close-out dates
;Output: DBCL ^ WLCLM ^ WLCLA ^ ROLL
; or -1 ^ -1 ^ -1 ^ -1^ - Error/bad input
; DBCL,WLCLM,WLCLA,ROLL are returned in FileMan format.
;
;DBCL - Database closeout date
; Date on which the specified date/time (NPCDMNTH) will no
; longer be accepted by the NPCD
;WLCLM - Monthly Workload closeout date
; Date on which the specified date/time will no longer be
; accepted by the NPCD for montly workload credit but will
; be valid for fiscal year credit
;WLCLA - Annual Workload closeout date
; Date on which the specified date/time will no longer be
; accepted for yearly credit but will be sent to NPCD for
; historical accuracy of the database.
;ROLL - NPCDMNTH+ROLLD
; Date representing the date ROLLD days older than the
; specified date/time.
;
N DBCL,WLCLM,WLCLA,ROLL,SDY,SDM,SDMM,SDYM,DBCLMD,WLCLMD,WLCLAMD,ROLLD
N X1,X2,X,%H,%T,%Y,TODAY,SDYY
S DBCLMD="0930",WLCLMD=19,WLCLAMD=1019,ROLLD=19
;
;Check input / remove time
S NPCDMNTH=+$G(NPCDMNTH)\1
Q:(+NPCDMNTH'?7N) "-1^-1^-1^-1"
;
;Declare variables
S SDY=$E(NPCDMNTH,1,3)
S SDM=$E(NPCDMNTH,4,5)
;
;Build DBCL
S SDYY=SDY+2 S:SDM>9 SDYY=SDYY+1
S DBCL=SDYY_DBCLMD
;
;Build WLCLM
S SDMM=SDM+1,SDYM=SDY
I SDMM=13 S SDMM="01",SDYM=SDY+1
S:$L(SDMM)=1 SDMM="0"_SDMM
S WLCLM=SDYM_SDMM_WLCLMD
;
;Build WLCLA
I SDM>9 S SDY=SDY+1
S WLCLA=SDY_WLCLAMD
;
;Build ROLL
S X1=NPCDMNTH,X2=ROLLD D C^%DTC S ROLL=X
;
Q DBCL_U_WLCLM_U_WLCLA_U_ROLL
;
AECLOSE(NPCDMNTH,DBCLOSE,WLCLOSE) ;Add/edit NPCD close-out dates for
; entries in the NPCD ENCOUNTER MONTH multiple (field #710) of the
; SCHEDULING PARAMETERS file (#404.91)
;
; This field (#710) is not used starting with SD*5.3*247.
;
;Input : NPCDMNTH - Month to add/edit National Patient Care Database
; close-out dates (FileMan format)
; DBCLOSE - Date on which the specified date/time will no
; longer be accepted by the NPCD (FileMan format)
; WLCLOSE - Date on which the specified date/time will no
; longer be accepted by the NPCD for workload
; credit (FileMan format)
;Output : IEN ^ Added = Success
; IEN = Pointer to entry in NPCD ENCOUNTER MONTH multiple
; Added = Flag indicating if new entry was added
; 1 = Yes 0 = No
; -1 = Error/bad input
;Notes : NPCDMNTH will be converted to an NPCD Encounter Month
; : It is assumed that NPCDMNTH is a valid date
;
;Check input / remove time
S NPCDMNTH=$P((+$G(NPCDMNTH)),".",1)
Q:(NPCDMNTH'?7N) -1
S DBCLOSE=$P((+$G(DBCLOSE)),".",1)
Q:(DBCLOSE'?7N) -1
S WLCLOSE=$P((+$G(WLCLOSE)),".",1)
Q:(WLCLOSE'?7N) -1
;Declare variables
N SCDXFDA,SCDXIEN,SCDXMSG,MNTHPTR,MNTHADD
;Convert FileMan month to NPCD Encounter Month
S NPCDMNTH=$$FM2NPCD(NPCDMNTH)
Q:(NPCDMNTH=-1) -1
;Set up call to FileMan Updater (call will find/create entry)
S SCDXFDA(404.9171,"?+1,1,",.01)=NPCDMNTH
S SCDXFDA(404.9171,"?+1,1,",.02)=DBCLOSE
S SCDXFDA(404.9171,"?+1,1,",.03)=WLCLOSE
;Call FileMan Updater
D UPDATE^DIE("ES","SCDXFDA","SCDXIEN","SCDXMSG")
;Error
Q:($D(SCDXMSG("DIERR"))) -1
;Get entry number
S MNTHPTR=+$G(SCDXIEN(1))
;Determine if new entry was added
S MNTHADD=0
S:($G(SCDXIEN(1,0))="+") MNTHADD=1
;Done
Q MNTHPTR_"^"_MNTHADD
;
FM2NPCD(DATE) ;Convert FileMan date/time to NPCD ENCOUNTER MONTH format
;
;Input : DATE - Date/time to convert (FileMan format)
;Output : MM-YYYY - Imprecise month format
; MM = Month (numeric with leading zero)
; YYYYY = Year
; -1 - Error (bad input)
;Notes : It is assumed that DATE is a valid date
;
;Check input
S DATE=+$P($G(DATE),".",1)
Q:(DATE'?7N) -1
;Return NPCD Encounter Month
Q $E(DATE,4,5)_"-"_(1700+$E(DATE,1,3))
;
NPCD2FM(NPCDMNTH) ;Convert NPCD ENCOUNTER MONTH format to FileMan date
;
;Input : MM-YYYY - Imprecise month format
; MM = Month (numeric with leading zero)
; YYYYY = Year
;Output : DATE - Date/time to convert (FileMan format)
; -1 - Error (bad input)
;Notes : It is assumed that NPCDMNTH is a valid imprecise date
;
;Check input
S NPCDMNTH=$G(NPCDMNTH)
Q:(NPCDMNTH'?2N1"-"4N) -1
;Return FileMan date
;Q ($P(NPCDMNTH,"-",2)-1700)_$P(NPCDMNTH,"-",1)_"00"
; Y2K Renovation. %DT will return yyymm00 for imprecise date.
N X,Y S X=NPCDMNTH D ^%DT
Q Y
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSCDXFU04 8555 printed Dec 13, 2024@02:39:11 Page 2
SCDXFU04 ;ALB/JRP - ACRP FILE UTILITIES FOR CLOSE OUT;15-APR-97 ; 1/24/02 3:44pm
+1 ;;5.3;Scheduling;**121,140,247**;Aug 13, 1993
+2 ;
XMIT4DBC(XMITPTR) ;Determine if an entry in the TRANSMITTED OUTPATIENT
+1 ; ENCOUNTER file (#409.73) should be transmitted to the NPCD
+2 ; for database [not workload] credit and/or workload credit
+3 ;
+4 ;Input : XMITPTR - Pointer to entry in Transmitted Outpatient
+5 ; Encounter file
+6 ;Output:
+7 ; 0 - Transmit - NPCD will accept for monthly workload credit,
+8 ; no message generated
+9 ; 1 - Transmit - NPCD will accept for monthly workload credit
+10 ; with a rolling message
+11 ; 2 - Transmit - will accept for yearly workload report
+12 ; 3 - Transmit - for historical accuracy of database only
+13 ; 4 - Don't transmit (NPCD will not accept for database credit)
+14 ;Notes :5 (don't transmit) will be returned on error/bad input
+15 ;
+16 ;Check input
+17 SET XMITPTR=+$GET(XMITPTR)
+18 if ('$DATA(^SD(409.73,XMITPTR,0)))
QUIT 5
+19 ;Declare variables
+20 NEW NODE,ENCPTR,DELPTR,ENCDATE
+21 ;Get pointer to [deleted] encounter
+22 SET NODE=$GET(^SD(409.73,XMITPTR,0))
+23 SET ENCPTR=+$PIECE(NODE,"^",2)
+24 SET DELPTR=+$PIECE(NODE,"^",3)
+25 ;Get date/time of [deleted] encounter
+26 if (ENCPTR)
SET NODE=$GET(^SCE(ENCPTR,0))
+27 if ('ENCPTR)
SET NODE=$GET(^SD(409.74,DELPTR,1))
+28 SET ENCDATE=+NODE
+29 if ('ENCDATE)
QUIT 5
+30 ;Get the level of acceptance
+31 QUIT $$OKTOXMIT(ENCDATE)
+32 ;
OKTOXMIT(ENCDATE,COMPDATE) ;Determine if an encounter occurring on a
+1 ; specified date should be transmitted to the National Patient Care
+2 ; Database for database and workload credit. It also determines
+3 ; the acceptance level(message type), later used when generating
+4 ; late activity messages
+5 ;
+6 ;Input (FileMan format):
+7 ;
+8 ; ENCDATE - Date/time Outpatient Encounter occurred on
+9 ; COMPDATE - Date to compare close out dates against;
+10 ; defaults to the current date
+11 ;
+12 ;Output : MessageType
+13 ;
+14 ; MessageType - Indicates what type of message will be generated
+15 ; for Encounter with the submitted ENCDATE.
+16 ; In the same time the message type determines if
+17 ; Encounter can be transmitted. The message type
+18 ; indicates if the specified date/time will be
+19 ; accepted for database/workload credit.
+20 ;
+21 ; A message type is determined in the following order of comparison:
+22 ; Type Transmitted
+23 ; -------------------------------------------------------------
+24 ; 4 - Database closeout date no DBCLOSE
+25 ; 3 - Annual Workload closeout date yes WLCLA
+26 ; 2 - Monthly Workload closeout date yes WLCLOSE
+27 ; 1 - Rolling date yes ROLL
+28 ;
+29 ; 0 - No message yes
+30 ; -1 - Error no
+31 ;
+32 ;Check input / remove time
+33 SET ENCDATE=+$GET(ENCDATE)\1
+34 if (ENCDATE'?7N)
QUIT "-1"
+35 SET COMPDATE=+$GET(COMPDATE)\1
+36 if (COMPDATE'?7N)
SET COMPDATE=$$DT^XLFDT()
+37 ;Declare variables
+38 NEW CLOSEOUT,DBCLOSE,WLCLOSE,WLCLA,ROLL
+39 NEW DBCRED,WLCRED,COMP
+40 SET (DBCRED,WLCRED)=-1
+41 ;Get close-out dates for month the encounter occurred in
+42 SET CLOSEOUT=$$CLOSEOUT(ENCDATE)
+43 SET DBCLOSE=$PIECE(CLOSEOUT,U)
+44 SET WLCLOSE=$PIECE(CLOSEOUT,U,2)
+45 SET WLCLA=$PIECE(CLOSEOUT,U,3)
+46 SET ROLL=$PIECE(CLOSEOUT,U,4)
+47 ;Determine LEVEL to determine if an encounter can be transmitted
+48 ;and identify a message to be generated
+49 NEW LEVEL,X,%H,%T,%Y,YY
+50 SET LEVEL=0
+51 SET X=COMPDATE
DO H^%DTC
SET COMP=%H
+52 FOR YY=4:-1:1
Begin DoDot:1
+53 SET X=$SELECT(YY=4:DBCLOSE,YY=3:WLCLA,YY=2:WLCLOSE,YY=1:ROLL)
Begin DoDot:2
+54 DO H^%DTC
IF COMP>%H
SET LEVEL=YY
End DoDot:2
End DoDot:1
if LEVEL
QUIT
+55 ;Done
+56 QUIT LEVEL
+57 ;
CLOSEOUT(NPCDMNTH) ;Get National Patient Care Database (NPCD) close-out
+1 ; dates for a given month
+2 ;
+3 ;Input : NPCDMNTH - Encouter Date (FileMan format) to calculate
+4 ; close-out dates
+5 ;Output: DBCL ^ WLCLM ^ WLCLA ^ ROLL
+6 ; or -1 ^ -1 ^ -1 ^ -1^ - Error/bad input
+7 ; DBCL,WLCLM,WLCLA,ROLL are returned in FileMan format.
+8 ;
+9 ;DBCL - Database closeout date
+10 ; Date on which the specified date/time (NPCDMNTH) will no
+11 ; longer be accepted by the NPCD
+12 ;WLCLM - Monthly Workload closeout date
+13 ; Date on which the specified date/time will no longer be
+14 ; accepted by the NPCD for montly workload credit but will
+15 ; be valid for fiscal year credit
+16 ;WLCLA - Annual Workload closeout date
+17 ; Date on which the specified date/time will no longer be
+18 ; accepted for yearly credit but will be sent to NPCD for
+19 ; historical accuracy of the database.
+20 ;ROLL - NPCDMNTH+ROLLD
+21 ; Date representing the date ROLLD days older than the
+22 ; specified date/time.
+23 ;
+24 NEW DBCL,WLCLM,WLCLA,ROLL,SDY,SDM,SDMM,SDYM,DBCLMD,WLCLMD,WLCLAMD,ROLLD
+25 NEW X1,X2,X,%H,%T,%Y,TODAY,SDYY
+26 SET DBCLMD="0930"
SET WLCLMD=19
SET WLCLAMD=1019
SET ROLLD=19
+27 ;
+28 ;Check input / remove time
+29 SET NPCDMNTH=+$GET(NPCDMNTH)\1
+30 if (+NPCDMNTH'?7N)
QUIT "-1^-1^-1^-1"
+31 ;
+32 ;Declare variables
+33 SET SDY=$EXTRACT(NPCDMNTH,1,3)
+34 SET SDM=$EXTRACT(NPCDMNTH,4,5)
+35 ;
+36 ;Build DBCL
+37 SET SDYY=SDY+2
if SDM>9
SET SDYY=SDYY+1
+38 SET DBCL=SDYY_DBCLMD
+39 ;
+40 ;Build WLCLM
+41 SET SDMM=SDM+1
SET SDYM=SDY
+42 IF SDMM=13
SET SDMM="01"
SET SDYM=SDY+1
+43 if $LENGTH(SDMM)=1
SET SDMM="0"_SDMM
+44 SET WLCLM=SDYM_SDMM_WLCLMD
+45 ;
+46 ;Build WLCLA
+47 IF SDM>9
SET SDY=SDY+1
+48 SET WLCLA=SDY_WLCLAMD
+49 ;
+50 ;Build ROLL
+51 SET X1=NPCDMNTH
SET X2=ROLLD
DO C^%DTC
SET ROLL=X
+52 ;
+53 QUIT DBCL_U_WLCLM_U_WLCLA_U_ROLL
+54 ;
AECLOSE(NPCDMNTH,DBCLOSE,WLCLOSE) ;Add/edit NPCD close-out dates for
+1 ; entries in the NPCD ENCOUNTER MONTH multiple (field #710) of the
+2 ; SCHEDULING PARAMETERS file (#404.91)
+3 ;
+4 ; This field (#710) is not used starting with SD*5.3*247.
+5 ;
+6 ;Input : NPCDMNTH - Month to add/edit National Patient Care Database
+7 ; close-out dates (FileMan format)
+8 ; DBCLOSE - Date on which the specified date/time will no
+9 ; longer be accepted by the NPCD (FileMan format)
+10 ; WLCLOSE - Date on which the specified date/time will no
+11 ; longer be accepted by the NPCD for workload
+12 ; credit (FileMan format)
+13 ;Output : IEN ^ Added = Success
+14 ; IEN = Pointer to entry in NPCD ENCOUNTER MONTH multiple
+15 ; Added = Flag indicating if new entry was added
+16 ; 1 = Yes 0 = No
+17 ; -1 = Error/bad input
+18 ;Notes : NPCDMNTH will be converted to an NPCD Encounter Month
+19 ; : It is assumed that NPCDMNTH is a valid date
+20 ;
+21 ;Check input / remove time
+22 SET NPCDMNTH=$PIECE((+$GET(NPCDMNTH)),".",1)
+23 if (NPCDMNTH'?7N)
QUIT -1
+24 SET DBCLOSE=$PIECE((+$GET(DBCLOSE)),".",1)
+25 if (DBCLOSE'?7N)
QUIT -1
+26 SET WLCLOSE=$PIECE((+$GET(WLCLOSE)),".",1)
+27 if (WLCLOSE'?7N)
QUIT -1
+28 ;Declare variables
+29 NEW SCDXFDA,SCDXIEN,SCDXMSG,MNTHPTR,MNTHADD
+30 ;Convert FileMan month to NPCD Encounter Month
+31 SET NPCDMNTH=$$FM2NPCD(NPCDMNTH)
+32 if (NPCDMNTH=-1)
QUIT -1
+33 ;Set up call to FileMan Updater (call will find/create entry)
+34 SET SCDXFDA(404.9171,"?+1,1,",.01)=NPCDMNTH
+35 SET SCDXFDA(404.9171,"?+1,1,",.02)=DBCLOSE
+36 SET SCDXFDA(404.9171,"?+1,1,",.03)=WLCLOSE
+37 ;Call FileMan Updater
+38 DO UPDATE^DIE("ES","SCDXFDA","SCDXIEN","SCDXMSG")
+39 ;Error
+40 if ($DATA(SCDXMSG("DIERR")))
QUIT -1
+41 ;Get entry number
+42 SET MNTHPTR=+$GET(SCDXIEN(1))
+43 ;Determine if new entry was added
+44 SET MNTHADD=0
+45 if ($GET(SCDXIEN(1,0))="+")
SET MNTHADD=1
+46 ;Done
+47 QUIT MNTHPTR_"^"_MNTHADD
+48 ;
FM2NPCD(DATE) ;Convert FileMan date/time to NPCD ENCOUNTER MONTH format
+1 ;
+2 ;Input : DATE - Date/time to convert (FileMan format)
+3 ;Output : MM-YYYY - Imprecise month format
+4 ; MM = Month (numeric with leading zero)
+5 ; YYYYY = Year
+6 ; -1 - Error (bad input)
+7 ;Notes : It is assumed that DATE is a valid date
+8 ;
+9 ;Check input
+10 SET DATE=+$PIECE($GET(DATE),".",1)
+11 if (DATE'?7N)
QUIT -1
+12 ;Return NPCD Encounter Month
+13 QUIT $EXTRACT(DATE,4,5)_"-"_(1700+$EXTRACT(DATE,1,3))
+14 ;
NPCD2FM(NPCDMNTH) ;Convert NPCD ENCOUNTER MONTH format to FileMan date
+1 ;
+2 ;Input : MM-YYYY - Imprecise month format
+3 ; MM = Month (numeric with leading zero)
+4 ; YYYYY = Year
+5 ;Output : DATE - Date/time to convert (FileMan format)
+6 ; -1 - Error (bad input)
+7 ;Notes : It is assumed that NPCDMNTH is a valid imprecise date
+8 ;
+9 ;Check input
+10 SET NPCDMNTH=$GET(NPCDMNTH)
+11 if (NPCDMNTH'?2N1"-"4N)
QUIT -1
+12 ;Return FileMan date
+13 ;Q ($P(NPCDMNTH,"-",2)-1700)_$P(NPCDMNTH,"-",1)_"00"
+14 ; Y2K Renovation. %DT will return yyymm00 for imprecise date.
+15 NEW X,Y
SET X=NPCDMNTH
DO ^%DT
+16 QUIT Y