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

SDUTL2.m

Go to the documentation of this file.
  1. SDUTL2 ;ALB/CAW - Misc. utilities ; 6/28/07 11:48am
  1. ;;5.3;Scheduling;**20,71,132,149,175,193,220,258,380,516**;Aug 13, 1993;Build 3
  1. ;
  1. ;
  1. FYNUNK(SD) ; return YES, NO, UNKNOWN
  1. ; input: SD=internal piece
  1. ; output: [returned] Y=YES, N=NO, U=UNKNOWN
  1. Q $S(SD="Y":"YES",SD="N":"NO",SD="U":"UNKNOWN",1:"")
  1. ;
  1. FMT(DFN) ; return current status of means test in external form
  1. ; input: DFN=ifn of patient
  1. ; ouput: [returned] MT^SMT^LST
  1. ; MT=external format of current status
  1. ; SMT=shortened format of current staus
  1. ; LST=date of last test
  1. ;
  1. N X,Y
  1. S X=$$LST^DGMTU(DFN)
  1. S Y=$P(X,U,4),Y=$S(Y["B":"CAT "_Y,Y["A":"COPAY EX",Y["C":"COPAY REQ",Y["G":"GMT COPAY REQ",Y["R":"REQ",Y["P":"PEND ADJ",Y["N":"NOT REQ",1:"")
  1. Q $P(X,U,3)_U_Y_U_$P(X,U,2)
  1. ;
  1. FCO(DFN) ; return current status of copay test in external form
  1. ; input: DFN=ifn of patient
  1. ; ouput: [returned] COT^SCOT^LST
  1. ; COT=external format of current status
  1. ; SCOT=shortened format of current staus
  1. ; LST=date of last test
  1. ;
  1. N X,Y
  1. S X=$$LST^DGMTU(DFN,"",2)
  1. S Y=$P(X,U,4),Y=$S(Y["E":"EXEMPT",Y["M":"NON-EXEMPT",Y["I":"INCOMPLETE",Y["L":"NO LONGER APPL.",1:"")
  1. Q $P(X,U,3)_U_Y_U_$P(X,U,2)
  1. ;
  1. XMY(GROUP,SDUZ,SDPOST) ; -- set up XMY for mail group members
  1. ; input: GROUP := mail group efn [required]
  1. ; SDUZ := send to current user [ 0|no ; 1|yes] [optional]
  1. ; SDPOST := send to postmaster if XMY is undefined
  1. ; [ 0|no ; 1|yes] [optional]
  1. ; output: XMY := array of users
  1. ; XMDUZ := message sender set postmaster
  1. ;
  1. N I K XMY
  1. I '$D(SDUZ) N SDUZ S SDUZ=1
  1. I '$D(SDPOST) N SDPOST S SDPOST=1
  1. S XMY("G."_$P($G(^XMB(3.8,GROUP,0)),U))=""
  1. I SDUZ,DUZ S XMY(DUZ)=""
  1. ; makes sure it gets sent to someone
  1. I '$D(XMY),SDPOST S XMY(.5)=""
  1. ; make postmaster the sender so it will show up as new to DUZ
  1. S XMDUZ=.5
  1. Q
  1. ;
  1. SCREEN(Y,SDDT) ; -- screen called when entering a provider in the
  1. ; DEFAULT PROVIDER field (#16) or PROVIDER field (#.01) of the PROVIDER
  1. ; multiple (#2600) in the HOSPITAL LOCATION file (#44).
  1. ;
  1. ; Selects active providers with an active entry in the NEW PERSON
  1. ; file (#200) for PERSON CLASS.
  1. ;
  1. ; INPUT: Y = ien of file 200
  1. ; SDDT = today's date
  1. ; OUTPUT: 1 to select; 0 to not select
  1. ;
  1. ; begin patch *516*
  1. ; DBIA #2349 - ACTIVE PROVIDER will be used for validation.
  1. ; The INACTIVE DATE (#53.4) field will no longer be used.
  1. ; New input selection logic...
  1. ; The TERMINATION DATE (#9.2) and the PERSON CLASS (#8932.1) fields
  1. ; will be used to determine if selection is active in the
  1. ; NEW PERSON (#200) file for a given date.
  1. ;
  1. ;S:'+$G(SDDT) SDDT=DT I '+$G(Y) Q 0
  1. ;N SDINACT,SDT,SDY S SDY=0
  1. ; check if provider active
  1. ;S SDINACT=$G(^VA(200,+Y,"PS"))
  1. ;Q:'$S(SDINACT']"":1,'+$P(SDINACT,"^",4):1,DT<+$P(SDINACT,"^",4):1,1:0) SDY
  1. ;S SDT=+$P($G(^VA(200,+Y,0)),U,11)
  1. ;Q:$S('SDT:0,(SDT<DT):1,1:0) 0
  1. ;I $$GET^XUA4A72(Y,SDDT)>0 S SDY=1
  1. ;
  1. I '+$G(Y) Q 0
  1. N SDY
  1. S:'+$G(SDDT) SDDT=DT
  1. S SDY=0,SDDT=$P(SDDT,".")
  1. I $$ACTIVPRV^PXAPI(+Y,SDDT) S SDY=1 ;DBIA #2349
  1. ; end patch *516*
  1. Q SDY
  1. ;
  1. HELP(SDDT) ; -- executable help called when entering a provider in the
  1. ; DEFAULT PROVIDER field (#16) or PROVIDER field (#.01) of the PROVIDER
  1. ; multiple (#2600) in the HOSPITAL LOCATION file (#44), the PROVIDER
  1. ; (#.01) field of the V PROVIDER file (#9000010.06), or in the
  1. ; PROVIDER prompt of the Check-out screen. display active providers
  1. ; with an active entry in the NEW PERSON file (#200) for PERSON CLASS.
  1. ;
  1. ; INPUT: SDDT = today's date
  1. ; OUTPUT: display of active providers with an active entry in the NEW
  1. ; PERSON file (#200) for PERSON CLASS
  1. ;
  1. S:'+$G(SDDT) SDDT=DT
  1. N D,DO,DIC,X
  1. S X="??",DIC="^VA(200,",DIC(0)="EQ",D="B"
  1. S DIC("S")="I $$SCREEN^SDUTL2(Y,SDDT)"
  1. D IX^DIC
  1. Q
  1. ;
  1. SCAN(SDINDEX,SDBEG,SDEND,SDCB,SDFN,SDIR) ; -- api to invoke scan
  1. N SDQID
  1. D OPEN^SDQ(.SDQID)
  1. D INDEX^SDQ(.SDQID,SDINDEX,"SET")
  1. IF SDINDEX="PATIENT/DATE"!(SDINDEX="PATIENT") D PAT^SDQ(.SDQID,SDFN,"SET")
  1. IF SDINDEX="PATIENT/DATE"!(SDINDEX="DATE/TIME") D DATE^SDQ(.SDQID,SDBEG,SDEND,"SET")
  1. D SCANCB^SDQ(.SDQID,SDCB,"SET")
  1. D ACTIVE^SDQ(.SDQID,"TRUE","SET")
  1. D SCAN^SDQ(.SDQID,SDIR)
  1. D CLOSE^SDQ(.SDQID)
  1. SCANQ Q
  1. ;
  1. MHCLIN(SDCL,SDSC) ;;Determines if Mental health Clinic requiring GAF
  1. ;;This will be a supported call
  1. ;;Determines whether the clinic passed is a Mental Health clinic that requires Gaf
  1. ;;Input - SDCL = Clinic IEN
  1. ;; SDSC = DSS Stop Code [Optional]
  1. ;; For Visit File entries where the Clinic IEN is not available
  1. ;; but the DSS identifier is.
  1. ;;
  1. ;;Output - 1 = Mental health clinic requiring a Gaf
  1. ;; 0 = Not a clinic requiring a Gaf
  1. N SDNOGAF,SDSTOP,SDCS,SDMH
  1. S SDNOGAF="526,527,528,530,533,536,537,542,545,546,565,566,573,574,579"
  1. ;; Get either the Clinic IEN or the Clinic Stop code
  1. I $G(SDCL) D
  1. . S SDSTOP=$P($G(^SC(SDCL,0)),"^",7)
  1. E D
  1. . S SDSTOP=$G(SDSC)
  1. ;
  1. S SDCS=$P($G(^DIC(40.7,+SDSTOP,0)),"^",2),SDMH=$S(SDNOGAF[SDCS:0,$E(SDCS)=5:1,1:0)
  1. Q SDMH
  1. ;
  1. NEWGAF(DFN) ;;Determine if new GAF Score needed
  1. ;;This will be a supported call
  1. ;;Determines if a new Gaf is required for a patient and retrieves previous Gaf data
  1. ;; If patient is deceased, returns a 0, no new GAF required
  1. ;;
  1. ;;Input - Patient IEN
  1. ;;Output:
  1. ;; piece 1 = -1 if New Gaf needed and no previous data
  1. ;; = 1 if New Gaf needed and previous data exists
  1. ;; = 0 if no New Gaf needed and previous exists
  1. ;; piece 2 = previous Gaf score
  1. ;; piece 3 = previous Gaf date
  1. ;; piece 4 = previous Gaf Providers IEN
  1. ;;
  1. N SDGAF,SDGAFDT,VADM
  1. ;
  1. S SDGAF=$$RET^YSGAF(DFN)
  1. ;; Check for deceased patient.
  1. D DEM^VADPT
  1. Q:+$G(VADM(6)) "0^"_SDGAF_"^1"
  1. D KVAR^VADPT
  1. ;
  1. Q:SDGAF=-1 -1
  1. S X1=$P(SDGAF,"^",2),X2=90 D C^%DTC
  1. Q $S(DT>X:1,1:0)_"^"_SDGAF
  1. ;
  1. GAFCM() ;;
  1. N DIR,DIRUT
  1. S DIR("A",1)="But a new GAF Score is needed for this patient!"
  1. S DIR("A")="Are you sure you want to bypass the check out screen? "
  1. S DIR("B")="No",DIR(0)="YA" W ! D ^DIR
  1. Q +$G(Y)
  1. COLLAT(SDEC) ;Determines if patient has a collateral eligibility status
  1. ;
  1. ; INPUT: SDEC = patient eligibility status
  1. ;
  1. ; OUTPUT: 1 = collateral patient
  1. ; 0 = non-collateral patient
  1. ;
  1. Q:$G(SDEC)="" 0
  1. I $$GET1^DIQ(8,SDEC,8,"I")=13 Q 1
  1. Q 0
  1. ;
  1. ELSTAT(DA) ;Retrieve patient eligibility status
  1. ;
  1. ; INPUT: DA = patient IEN
  1. ;
  1. ; OUTPUT:
  1. ; Function Value - returns the internal entry number for patient's
  1. ; eligibility status.
  1. ;
  1. Q:$G(DA)="" ""
  1. Q $$GET1^DIQ(2,DA,.361,"I")
  1. SCREST(SCIEN,TYP,DIS) ;check stop code restriction in file 40.7 for a clinic.
  1. ; INPUT: SCIEN = IEN of Stop Code
  1. ; TYP = Stop Code Type, Primary (P) or Secondary (S)
  1. ; DIS = Message Display, 1 - Display or 0 No Display
  1. ;
  1. ; OUTPUT: 1 if no error, or 0^error message
  1. ;
  1. N SCN,RTY,CTY,RDT,STR,STYP
  1. S DIS=$G(DIS,0),STYP="("_$S(TYP="P":"Prim",1:"Second")_"ary)"
  1. I +SCIEN<1 S STR="Invalid Clinic Stop Code "_STYP_"." D MSG Q "0^"_STR
  1. S CTY=$S(TYP="P":"^P^E^",1:"^S^E^")
  1. S SCN=$G(^DIC(40.7,SCIEN,0)),RTY=$P(SCN,U,6),RDT=$P(SCN,U,7)
  1. I RTY="" D Q "0^"_STR
  1. .S STR="Clinic's Stop Code "_$P(SCN,U,2)_" has no restriction type "_STYP_"." D MSG
  1. I CTY'[("^"_RTY_"^") D D MSG Q "0^"_STR
  1. .S STR="Clinic's Stop Code "_$P(SCN,U,2)_" cannot be "_$S(TYP="P":"Prim",1:"Second")_"ary."
  1. I RDT>DT D D MSG Q "0^"_STR
  1. .S STR="Clinic's Stop Code "_$P(SCN,U,2)_" cannot be used. Restriction date is "_$$FMTE^XLFDT(RDT,"1F")_" "_STYP_"."
  1. Q 1
  1. MSG ;display error message to screen
  1. I DIS,$E($G(IOST))="C" W !?5,STR
  1. Q
  1. CLNCK(CLN,DSP) ;Check clinic for valid stop code restriction.
  1. ; INPUT: CLN = IEN of Clinic
  1. ; DSP = Error Message Display, 1 - Display or 0 No Display
  1. ;
  1. ; OUTPUT: 1 if no error or 0^error message
  1. N PSC,SSC,ND0,VAL
  1. S DSP=$G(DSP,0)
  1. I CLN="" D Q "0^"_"Invalid Clinic."
  1. .I DSP,$E($G(IOST))="C" W !?5,"Invalid Clinic."
  1. I $G(^SC(CLN,0))="" D Q "0^"_"Clinic not define or has no zero node."
  1. .I DSP,$E($G(IOST))="C" W !?5,"Clinic not define or has no zero node."
  1. S ND0=^SC(CLN,0),PSC=$P(ND0,U,7),SSC=$P(ND0,U,18),DSP=$G(DSP,0)
  1. I $P(ND0,U,3)'="C" Q 1 ;not a Clinic
  1. S VAL=$$SCREST(PSC,"P",DSP)
  1. Q:'VAL VAL Q:SSC="" 1
  1. S VAL=$$SCREST(SSC,"S",DSP)
  1. Q VAL