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

SCDXFU04.m

Go to the documentation of this file.
  1. 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
  1. ;
  1. XMIT4DBC(XMITPTR) ;Determine if an entry in the TRANSMITTED OUTPATIENT
  1. ; ENCOUNTER file (#409.73) should be transmitted to the NPCD
  1. ; for database [not workload] credit and/or workload credit
  1. ;
  1. ;Input : XMITPTR - Pointer to entry in Transmitted Outpatient
  1. ; Encounter file
  1. ;Output:
  1. ; 0 - Transmit - NPCD will accept for monthly workload credit,
  1. ; no message generated
  1. ; 1 - Transmit - NPCD will accept for monthly workload credit
  1. ; with a rolling message
  1. ; 2 - Transmit - will accept for yearly workload report
  1. ; 3 - Transmit - for historical accuracy of database only
  1. ; 4 - Don't transmit (NPCD will not accept for database credit)
  1. ;Notes :5 (don't transmit) will be returned on error/bad input
  1. ;
  1. ;Check input
  1. S XMITPTR=+$G(XMITPTR)
  1. Q:('$D(^SD(409.73,XMITPTR,0))) 5
  1. ;Declare variables
  1. N NODE,ENCPTR,DELPTR,ENCDATE
  1. ;Get pointer to [deleted] encounter
  1. S NODE=$G(^SD(409.73,XMITPTR,0))
  1. S ENCPTR=+$P(NODE,"^",2)
  1. S DELPTR=+$P(NODE,"^",3)
  1. ;Get date/time of [deleted] encounter
  1. S:(ENCPTR) NODE=$G(^SCE(ENCPTR,0))
  1. S:('ENCPTR) NODE=$G(^SD(409.74,DELPTR,1))
  1. S ENCDATE=+NODE
  1. Q:('ENCDATE) 5
  1. ;Get the level of acceptance
  1. Q $$OKTOXMIT(ENCDATE)
  1. ;
  1. OKTOXMIT(ENCDATE,COMPDATE) ;Determine if an encounter occurring on a
  1. ; specified date should be transmitted to the National Patient Care
  1. ; Database for database and workload credit. It also determines
  1. ; the acceptance level(message type), later used when generating
  1. ; late activity messages
  1. ;
  1. ;Input (FileMan format):
  1. ;
  1. ; ENCDATE - Date/time Outpatient Encounter occurred on
  1. ; COMPDATE - Date to compare close out dates against;
  1. ; defaults to the current date
  1. ;
  1. ;Output : MessageType
  1. ;
  1. ; MessageType - Indicates what type of message will be generated
  1. ; for Encounter with the submitted ENCDATE.
  1. ; In the same time the message type determines if
  1. ; Encounter can be transmitted. The message type
  1. ; indicates if the specified date/time will be
  1. ; accepted for database/workload credit.
  1. ;
  1. ; A message type is determined in the following order of comparison:
  1. ; Type Transmitted
  1. ; -------------------------------------------------------------
  1. ; 4 - Database closeout date no DBCLOSE
  1. ; 3 - Annual Workload closeout date yes WLCLA
  1. ; 2 - Monthly Workload closeout date yes WLCLOSE
  1. ; 1 - Rolling date yes ROLL
  1. ;
  1. ; 0 - No message yes
  1. ; -1 - Error no
  1. ;
  1. ;Check input / remove time
  1. S ENCDATE=+$G(ENCDATE)\1
  1. Q:(ENCDATE'?7N) "-1"
  1. S COMPDATE=+$G(COMPDATE)\1
  1. S:(COMPDATE'?7N) COMPDATE=$$DT^XLFDT()
  1. ;Declare variables
  1. N CLOSEOUT,DBCLOSE,WLCLOSE,WLCLA,ROLL
  1. N DBCRED,WLCRED,COMP
  1. S (DBCRED,WLCRED)=-1
  1. ;Get close-out dates for month the encounter occurred in
  1. S CLOSEOUT=$$CLOSEOUT(ENCDATE)
  1. S DBCLOSE=$P(CLOSEOUT,U)
  1. S WLCLOSE=$P(CLOSEOUT,U,2)
  1. S WLCLA=$P(CLOSEOUT,U,3)
  1. S ROLL=$P(CLOSEOUT,U,4)
  1. ;Determine LEVEL to determine if an encounter can be transmitted
  1. ;and identify a message to be generated
  1. N LEVEL,X,%H,%T,%Y,YY
  1. S LEVEL=0
  1. S X=COMPDATE D H^%DTC S COMP=%H
  1. F YY=4:-1:1 D Q:LEVEL
  1. .S X=$S(YY=4:DBCLOSE,YY=3:WLCLA,YY=2:WLCLOSE,YY=1:ROLL) D
  1. ..D H^%DTC I COMP>%H S LEVEL=YY
  1. ;Done
  1. Q LEVEL
  1. ;
  1. CLOSEOUT(NPCDMNTH) ;Get National Patient Care Database (NPCD) close-out
  1. ; dates for a given month
  1. ;
  1. ;Input : NPCDMNTH - Encouter Date (FileMan format) to calculate
  1. ; close-out dates
  1. ;Output: DBCL ^ WLCLM ^ WLCLA ^ ROLL
  1. ; or -1 ^ -1 ^ -1 ^ -1^ - Error/bad input
  1. ; DBCL,WLCLM,WLCLA,ROLL are returned in FileMan format.
  1. ;
  1. ;DBCL - Database closeout date
  1. ; Date on which the specified date/time (NPCDMNTH) will no
  1. ; longer be accepted by the NPCD
  1. ;WLCLM - Monthly Workload closeout date
  1. ; Date on which the specified date/time will no longer be
  1. ; accepted by the NPCD for montly workload credit but will
  1. ; be valid for fiscal year credit
  1. ;WLCLA - Annual Workload closeout date
  1. ; Date on which the specified date/time will no longer be
  1. ; accepted for yearly credit but will be sent to NPCD for
  1. ; historical accuracy of the database.
  1. ;ROLL - NPCDMNTH+ROLLD
  1. ; Date representing the date ROLLD days older than the
  1. ; specified date/time.
  1. ;
  1. N DBCL,WLCLM,WLCLA,ROLL,SDY,SDM,SDMM,SDYM,DBCLMD,WLCLMD,WLCLAMD,ROLLD
  1. N X1,X2,X,%H,%T,%Y,TODAY,SDYY
  1. S DBCLMD="0930",WLCLMD=19,WLCLAMD=1019,ROLLD=19
  1. ;
  1. ;Check input / remove time
  1. S NPCDMNTH=+$G(NPCDMNTH)\1
  1. Q:(+NPCDMNTH'?7N) "-1^-1^-1^-1"
  1. ;
  1. ;Declare variables
  1. S SDY=$E(NPCDMNTH,1,3)
  1. S SDM=$E(NPCDMNTH,4,5)
  1. ;
  1. ;Build DBCL
  1. S SDYY=SDY+2 S:SDM>9 SDYY=SDYY+1
  1. S DBCL=SDYY_DBCLMD
  1. ;
  1. ;Build WLCLM
  1. S SDMM=SDM+1,SDYM=SDY
  1. I SDMM=13 S SDMM="01",SDYM=SDY+1
  1. S:$L(SDMM)=1 SDMM="0"_SDMM
  1. S WLCLM=SDYM_SDMM_WLCLMD
  1. ;
  1. ;Build WLCLA
  1. I SDM>9 S SDY=SDY+1
  1. S WLCLA=SDY_WLCLAMD
  1. ;
  1. ;Build ROLL
  1. S X1=NPCDMNTH,X2=ROLLD D C^%DTC S ROLL=X
  1. ;
  1. Q DBCL_U_WLCLM_U_WLCLA_U_ROLL
  1. ;
  1. AECLOSE(NPCDMNTH,DBCLOSE,WLCLOSE) ;Add/edit NPCD close-out dates for
  1. ; entries in the NPCD ENCOUNTER MONTH multiple (field #710) of the
  1. ; SCHEDULING PARAMETERS file (#404.91)
  1. ;
  1. ; This field (#710) is not used starting with SD*5.3*247.
  1. ;
  1. ;Input : NPCDMNTH - Month to add/edit National Patient Care Database
  1. ; close-out dates (FileMan format)
  1. ; DBCLOSE - Date on which the specified date/time will no
  1. ; longer be accepted by the NPCD (FileMan format)
  1. ; WLCLOSE - Date on which the specified date/time will no
  1. ; longer be accepted by the NPCD for workload
  1. ; credit (FileMan format)
  1. ;Output : IEN ^ Added = Success
  1. ; IEN = Pointer to entry in NPCD ENCOUNTER MONTH multiple
  1. ; Added = Flag indicating if new entry was added
  1. ; 1 = Yes 0 = No
  1. ; -1 = Error/bad input
  1. ;Notes : NPCDMNTH will be converted to an NPCD Encounter Month
  1. ; : It is assumed that NPCDMNTH is a valid date
  1. ;
  1. ;Check input / remove time
  1. S NPCDMNTH=$P((+$G(NPCDMNTH)),".",1)
  1. Q:(NPCDMNTH'?7N) -1
  1. S DBCLOSE=$P((+$G(DBCLOSE)),".",1)
  1. Q:(DBCLOSE'?7N) -1
  1. S WLCLOSE=$P((+$G(WLCLOSE)),".",1)
  1. Q:(WLCLOSE'?7N) -1
  1. ;Declare variables
  1. N SCDXFDA,SCDXIEN,SCDXMSG,MNTHPTR,MNTHADD
  1. ;Convert FileMan month to NPCD Encounter Month
  1. S NPCDMNTH=$$FM2NPCD(NPCDMNTH)
  1. Q:(NPCDMNTH=-1) -1
  1. ;Set up call to FileMan Updater (call will find/create entry)
  1. S SCDXFDA(404.9171,"?+1,1,",.01)=NPCDMNTH
  1. S SCDXFDA(404.9171,"?+1,1,",.02)=DBCLOSE
  1. S SCDXFDA(404.9171,"?+1,1,",.03)=WLCLOSE
  1. ;Call FileMan Updater
  1. D UPDATE^DIE("ES","SCDXFDA","SCDXIEN","SCDXMSG")
  1. ;Error
  1. Q:($D(SCDXMSG("DIERR"))) -1
  1. ;Get entry number
  1. S MNTHPTR=+$G(SCDXIEN(1))
  1. ;Determine if new entry was added
  1. S MNTHADD=0
  1. S:($G(SCDXIEN(1,0))="+") MNTHADD=1
  1. ;Done
  1. Q MNTHPTR_"^"_MNTHADD
  1. ;
  1. FM2NPCD(DATE) ;Convert FileMan date/time to NPCD ENCOUNTER MONTH format
  1. ;
  1. ;Input : DATE - Date/time to convert (FileMan format)
  1. ;Output : MM-YYYY - Imprecise month format
  1. ; MM = Month (numeric with leading zero)
  1. ; YYYYY = Year
  1. ; -1 - Error (bad input)
  1. ;Notes : It is assumed that DATE is a valid date
  1. ;
  1. ;Check input
  1. S DATE=+$P($G(DATE),".",1)
  1. Q:(DATE'?7N) -1
  1. ;Return NPCD Encounter Month
  1. Q $E(DATE,4,5)_"-"_(1700+$E(DATE,1,3))
  1. ;
  1. NPCD2FM(NPCDMNTH) ;Convert NPCD ENCOUNTER MONTH format to FileMan date
  1. ;
  1. ;Input : MM-YYYY - Imprecise month format
  1. ; MM = Month (numeric with leading zero)
  1. ; YYYYY = Year
  1. ;Output : DATE - Date/time to convert (FileMan format)
  1. ; -1 - Error (bad input)
  1. ;Notes : It is assumed that NPCDMNTH is a valid imprecise date
  1. ;
  1. ;Check input
  1. S NPCDMNTH=$G(NPCDMNTH)
  1. Q:(NPCDMNTH'?2N1"-"4N) -1
  1. ;Return FileMan date
  1. ;Q ($P(NPCDMNTH,"-",2)-1700)_$P(NPCDMNTH,"-",1)_"00"
  1. ; Y2K Renovation. %DT will return yyymm00 for imprecise date.
  1. N X,Y S X=NPCDMNTH D ^%DT
  1. Q Y