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

SCDXUTL.m

Go to the documentation of this file.
  1. SCDXUTL ;ALB/JLU;Utility routine for ambcare project;4/26/96
  1. ;;5.3;Scheduling;**44,78,132**;5/1/96
  1. ;
  1. DATE(DATE) ;this entry point will accept a date and return whether the new or old Scheduling Visits file limitations are to be used.
  1. ;INPUTS - a date in FM format to be compared to the ambcare start
  1. ; date parameter,
  1. ;OUTPUTS - 1 for using the new structure
  1. ; 0 for using the old structure
  1. ;
  1. N PAR,ANS
  1. S PAR=$P($G(^SD(404.91,1,"AMB")),U,2) ;get parameter date
  1. I 'PAR S ANS=0 G QT
  1. I DATE<PAR S ANS=0 G QT ;if date passed in older than parameter us old
  1. S ANS=1
  1. QT Q ANS
  1. ;
  1. FMDATE() ;this entry point returns the FM date from the parameter of
  1. ;whether to use the new or old structure.
  1. Q $P($G(^SD(404.91,1,"AMB")),U,2)
  1. ;
  1. CLOSED(DATE) ;this entry point accepts a date, compares it to the close out
  1. ;date and returns whether the close out period is up.
  1. ;INPUTS - a date in FM format to be compared to the close out date
  1. ; parameter.
  1. ;OUTPUTS - 1 for close out period is over
  1. ; 0 for still being able to close out
  1. ;
  1. N PAR,ANS
  1. S PAR=$P($G(^SD(404.91,1,"AMB")),U,3) ;gets close out parameter
  1. I 'PAR S ANS=0 G CQT
  1. I DATE<PAR S ANS=0 G CQT ;if date is after close out date parameter 1.
  1. S ANS=1
  1. CQT Q ANS
  1. ;
  1. CLOSEFM() ;this entry point returns the close out date parameter in FM format.
  1. Q $P($G(^SD(404.91,1,"AMB")),U,3)
  1. ;
  1. INPATENC(PTR,PTR2) ;ALB/JRP - Determine if an Outpatient Encounter
  1. ; is for an inpatient appointment
  1. ;
  1. ;Input : PTR - Pointer to one of the following files:
  1. ; * TRANSMITTED OUTPATIENT ENCOUNTER file (#409.73)
  1. ; * OUTPATIENT ENCOUNTER file (#409.68)
  1. ; * DELETED OUTPATIENT ENCOUNTER file (#409.74)
  1. ; PTR2 - Denotes which file PTR points to
  1. ; 0 = TRANSMITTED OUTPATIENT ENCOUNTER file (Default)
  1. ; 1 = OUTPATIENT ENCOUNTER file
  1. ; 2 = DELETED OUTPATIENT ENCOUNTER file
  1. ;Output : 0 - Encounter is not an inpatient appointment
  1. ; 1 - Encounter is an inpatient appointment
  1. ;Notes : 0 is returned if a valid pointer is not passed or the
  1. ; entry in the TRANSMITTED OUTPATIENT ENCOUNTER file does
  1. ; not point to a valid entry in the OUTPATIENT ENCOUNTER
  1. ; file or DELETED OUTPATIENT ENCOUNTER file
  1. ;
  1. ;Check input
  1. S PTR=+$G(PTR)
  1. Q:('PTR) 0
  1. S PTR2=+$G(PTR2)
  1. S:((PTR2<0)!(PTR2>2)) PTR2=0
  1. I ('PTR) Q:('$D(^SD(409.73,PTR,0))) 0
  1. I (PTR2=1) Q:('$D(^SCE(PTR,0))) 0
  1. I (PTR2=2) Q:('$D(^SD(409.74,PTR,0))) 0
  1. ;Declare variables
  1. N ZERONODE,STATPTR,STATUS
  1. ;Passed pointer to TRANSMITTED OUTPATIENT ENCOUNTER file
  1. ; Convert to pointer to [DELETED] OUTPATIENT ENCOUNTER file
  1. ; Quit if it can't be converted
  1. I ('PTR2) D Q:('PTR) 0
  1. .S ZERONODE=$G(^SD(409.73,PTR,0))
  1. .S PTR=+$P(ZERONODE,"^",2)
  1. .;Entry is for an outpatient encounter
  1. .I (PTR) S PTR2=1 Q
  1. .;Entry is for a deleted outpatient encounter
  1. .S PTR=+$P(ZERONODE,"^",3)
  1. .S PTR2=2
  1. ;Get zero node of [deleted] encounter
  1. S ZERONODE=$G(^SCE(PTR,0))
  1. S:(PTR2=2) ZERONODE=$G(^SD(409.74,PTR,1))
  1. ;Get pointer to appointment status
  1. S STATPTR=+$P(ZERONODE,"^",12)
  1. Q:('STATPTR) 0
  1. ;Get zero node of appointment status
  1. S ZERONODE=$G(^SD(409.63,STATPTR,0))
  1. ;Get abbreviation for appointment status
  1. S STATUS=$P(ZERONODE,"^",2)
  1. ;Inpatient appointments have an abbreviation of 'I'
  1. Q:(STATUS="I") 1
  1. ;Not an inpatient appointment
  1. Q 0
  1. ;
  1. DATECHK() ;this function call returns whether to require diag/prov based
  1. ;on the date function call and whether the post init has run.
  1. ;there are no inout variables.
  1. ;
  1. ;a 1 if after 10/1 or the post init has been run to require diag etc.
  1. ;a 0 if not to require yet
  1. ;
  1. N DATE,ANS
  1. S ANS=$$DATE(DT) I ANS G DATECHKQ
  1. I $P(^SD(404.91,1,"AMB"),U,7) S ANS=1 G DATECHKQ
  1. S ANS=0
  1. DATECHKQ Q ANS
  1. ;
  1. OCCA(CLN) ;This function call returns whether or not the clinic is
  1. ;considered an occasion of service, based upon file 409.45.
  1. ;
  1. ;CLN is the clinic in question
  1. ;
  1. ;a 1 if this clinic is an occasion of service clinic
  1. ;a 0 if not
  1. ;
  1. N SCP,SC,ANS
  1. I '$D(^SC(CLN,0)) S ANS=0 G OCCAQ
  1. S SCP=$P(^SC(CLN,0),U,7)
  1. I 'SCP S ANS=0 G OCCAQ
  1. I '$D(^DIC(40.7,SCP,0)) S ANS=0 G OCCAQ
  1. S SC=$P(^DIC(40.7,SCP,0),U,2)
  1. I 'SC S ANS=0 G OCCAQ
  1. I '$O(^SD(409.45,"B",SC,"")) S ANS=0 G OCCAQ
  1. I "117^118^119^120^121^123^124^125^126^128^152^165^170^999"[SC S ANS=0 G OCCAQ
  1. S ANS=1
  1. OCCAQ Q ANS