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

SDMHAP1.m

Go to the documentation of this file.
SDMHAP1 ;MAF/ALB - MENTAL HEALTH AD HOC PROACTIVE HIGH RISK REPORT (CONT.;JULY 14, 2010
 ;;5.3;Scheduling;**588**;Aug 13,1993;Build 53
 ;
SET ; Set up the data for the patient
 ;       piece 1 = dfn
 ;       piece 2 = Appointment Date and time
 ;       piece 3 = status N(Noshow) or NA (Noshow with auto rebook)
 ;       piece 4 = PID last 4 of SSN
 ;       piece 5 = clinic ien   ^SC(
 ;       piece 6 = stop code ien ^DIC(40.7
 ;   
 ;
EN ;PRINT OF THE ^TMP 
 N SDXDIV,SDXCLIN,SDXDFN,SDXSTOP,SDXREM,SDXNM,SDCOUNT,SDATE,SDTOTPG,Y
 S (SDXDFN,SDXREM,SDCOUNT)=0
 N SDPAT
 S SDXDIV=""
 F  S SDXDIV=$O(^TMP(NAMSPC1,$J,SDXDIV)) Q:SDXDIV']""!(SDUP)  D
 .I SDTL="CLIN" D
 ..S SDCOUNT=0
 ..S SDXNM=""
 ..F  S SDXNM=$O(^TMP(NAMSPC1,$J,SDXDIV,SDXNM)) Q:SDXNM']""!($G(SDUP))  D
 ...S SDATE=0
 ...F  S SDATE=$O(^TMP(NAMSPC1,$J,SDXDIV,SDXNM,SDATE)) Q:'SDATE!($G(SDUP))  D
 ....S SDXCLIN=""
 ....F  S SDXCLIN=$O(^TMP(NAMSPC1,$J,SDXDIV,SDXNM,SDATE,SDXCLIN)) Q:SDXCLIN']""!($G(SDUP))  D
 .....S SDXSTOP=0
 .....F  S SDXSTOP=$O(^TMP(NAMSPC1,$J,SDXDIV,SDXNM,SDATE,SDXCLIN,SDXSTOP)) Q:'SDXSTOP!($G(SDUP))  D
 ......I $D(^TMP(NAMSPC1,$J,SDXDIV,SDXNM,SDATE,SDXCLIN,SDXSTOP)) D PRT
 Q:SDUP
 I $D(^TMP(NAMSPC1,$J)) S SDTOTPG=1 D HEAD^SDMHAP D TOTAL1^SDMHPRO
 Q
 ;
 ;
PRT ;Print  report
 ;
 I '$D(SDXFLG(SDXDIV)) D HEAD^SDMHAP S SDXFLG(SDXDIV)=1 S:SDTL'="STOP" SDXFLG(SDXDIV,SDXCLIN)=1
 ;I SDTL="STOP" I $D(SDXFLG(SDXDIV)),'$D(SDXFLG(SDXDIV,SDXSTOP,SDXSTOPN)) W !! D HEAD1^SDMHAP S SDXFLG(SDXDIV,SDXSTOP,SDXSTOPN)=1
 N SDXNODE,SDXID,SDXDT,SDXSTAT,SDXSORT1,SDXSORT2,SDXCLIEN,SDDSS,SDXRLL,SDXZERO
 S SDXSORT1=$S(SDTL="MEN":SDXREM,SDTL="STOP":SDXSTOP,1:SDXCLIN)
 S SDXSORT2=$S(SDTL="CLIN":SDXSTOP,1:SDXCLIN)
 I SDTL="MEN" S SDXNODE=$G(^TMP(NAMSPC1,$J,SDXDIV,SDXSORT1,SDXSORT2,SDXNM,SDATE))
 I SDTL'="MEN" S SDXNODE=$G(^TMP(NAMSPC1,$J,SDXDIV,SDXNM,SDATE,SDXSORT1,SDXSORT2))
 S SDXDFN=$P(SDXNODE,"^",1) Q:SDXDFN']""
 S SDXID=$E($P(SDXNODE,"^",4),1,5)
 S SDXDT=$P(SDXNODE,"^",2)
 S SDXSTAT=$P(SDXNODE,"^",3)
 S SDXCLIEN=$P(SDXNODE,"^",5)
 S SDDSS=$P($G(^DIC(40.7,+$P(SDXNODE,"^",6),0)),"^",2)
 I '$D(SDXFLG(SDXDIV)) D HEAD^SDMHAP S SDXFLG(SDXDIV)=1
 S SDXDT=$$FMTE^XLFDT(SDXDT,"5")
 I '$D(SDPAT(SDXDIV,SDXDFN)) D COUNT^SDMHPRO W !,SDCOUNT,?4,$E($P(^DPT(SDXDFN,0),"^",1),1,20),?25,SDXID,?32,SDXDT,?49,$E(SDXCLIN,1,30),! D RET Q:SDUP  I SDCOUNT=$P($G(TOTAL(SDXDIV)),"^",5) S SDCOUNT=0
 I $D(SDPAT(SDXDIV,SDXDFN)) W ?32,SDXDT,?49,$E(SDXCLIN,1,30),! D RET Q:SDUP  I SDCOUNT=$P($G(TOTAL(SDXDIV)),"^",5) S SDCOUNT=0
 S SDPAT(SDXDIV,SDXDFN)=""
 Q
 ;
 ;
FUT ; FUTURE SCHEDULED APPTS.
 ;W !,?5,"Future Scheduled Appointments:  "
 N SDARRAY,SDCOUNT,SDX,X1,X2,X
 S X1=DT,X2=30 D C^%DTC S SDX=X
 S SDARRAY(1)=DT_";"_SDX
 S SDARRAY("SORT")="P"
 S SDARRAY(3)="NT;R"
 S SDARRAY(4)=SDXDFN
 S SDARRAY("FLDS")="1;2;3;4;10;13"
 S SDCOUNT=$$SDAPI^SDAMA301(.SDARRAY)
 I SDCOUNT>0 D  Q:SDUP
 .;Get info on future scheduled appointments and display it
 . N SDFA,SDFNODE,SDFUTDT
 . S SDFA=0 F  S SDFA=$O(^TMP($J,"SDAMA301",SDXDFN,SDFA)) Q:SDFA=""!(SDUP)!($P($G(SDFA),".",1)<$P(SDBEG,".",1))!($P($G(SDFA),".",1)>$P(SDEND,".",1))  D  Q:SDUP
 .. S SDFUTDT=$$FMTE^XLFDT(SDFA,"5P") S SDFNODE=^TMP($J,"SDAMA301",SDXDFN,SDFA) W !,?7,SDFUTDT,?33,$E($P($P(SDFNODE,"^",2),";",2),1,20)
 ..D RET Q:SDUP
 .Q
 I SDCOUNT'>0 D  Q:SDUP
 .W "NO APPOINTMENTS SCHEDULED WITHIN 30 DAYS"
 K ^TMP($J,"SDAMA301")
 Q
PID(DFN) ; Return PID
 ; INPUT  - DFN
 ; OUTPUT - PID or 'UNKNOWN'
 N VA
 D PID^VADPT6
 Q $S(VA("BID")]"":VA("BID"),1:"UNKNOWN")
 ;
 ;
RET ;
 I $E(IOST,1,2)="C-",($Y+6)>IOSL D  Q:SDUP
 . S DIR(0)="E"
 . D ^DIR K DIR
 . I 'Y S SDUP=1 Q
 . K SDXFLG(SDXDIV)
 . D HEAD^SDMHAP S SDXFLG(SDXDIV)=1    ;,SDXFLG(SDXDIV,SDXCLIN)=1,SDXFLG(SDXDIV,SDXSTOP)=1