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

TIULO1.m

Go to the documentation of this file.
TIULO1 ; SLC/JER - More embedded Objects ;05/31/12  14:33
 ;;1.0;TEXT INTEGRATION UTILITIES;**47,260,265**;Jun 20, 1997;Build 25
 ;
 ;^XLFSTR 10104, ^XLFDT 10103, ^PXRMD(810.9 5599, ^SC("AST" 4482, ^SDAPI^SDAMA301 4433, ^VADPT 10061
 ;^LAB(60,"B" 3853, LR7OR2 3856
 ;
VISDATE(TIU) ; Visit date/time
 N TIUX,TIUY
 S TIUX=$S(+$G(TIU("VISIT")):$P($G(TIU("VISIT")),U,2),$L($G(TIU("VSTR"))):$P($G(TIU("VSTR")),";",2),1:"")
 I TIUX']"" S TIUY="VISIT DATE UNKNOWN" G VISDTX
 S TIUY=$$DATE^TIULS(TIUX,"MM/DD/YY HR:MIN")
VISDTX Q $G(TIUY)
LABS(DFN,TIUTEST,TIUEDT,TIULDT) ; Get Lab Results
 N TIUY,TIUTST,TIUX S TIUTST=+$O(^LAB(60,"B",TIUTEST,0))
 I '+$G(TIUTST) G LABX
 D TEST^LR7OR2(.TIUY,DFN,"",$G(TIUEDT),$G(TIULDT),"",TIUTST)
 S TIUX=$S($D(TIUY)#2:$G(@TIUY@(1)),1:"____")
 I $L(TIUX,U)>1 D
 . S TIUTST=$P(TIUX,U,4)_" "_$P(TIUX,U,6)_" "_$P(TIUX,U,5)_"    ("
 . S TIUTST=TIUTST_$$DATE^TIULS($P(TIUX,U),"MM/DD/CCYY HR:MIN")_")"
 E  S TIUTST=TIUX
 I $D(TIUY)#2 K @TIUY
LABX Q $G(TIUTST)
 ;
HPHONE(DFN) ;Current Home Telephone Number
 N VAPA
 D ADD^VADPT
HPHX Q $G(VAPA(8))
 ;
SADD(DFN) ;Single Line Street Address
 N VAPA,J
 D ADD^VADPT
 S:$D(VAPA(1)) J=VAPA(1) S:$D(VAPA(2)) J=J_"  "_VAPA(2) S:$D(VAPA(3)) J=J_"  "_VAPA(3)
SADX Q J
 ;
CISTZI(DFN) ;City, State, Zip
 N VAPA,J
 D ADD^VADPT
 S:$D(VAPA(4)) J=VAPA(4) S:$D(VAPA(5)) J=J_", "_$P(VAPA(5),U,2) S:$D(VAPA(6)) J=J_", "_VAPA(6)
CSTX Q J
 ;
MSTAPPT(DFN,TARGET) ;Missed MH appointments for past 10 days;; WAT-TIU*1.0*260
 K ^TMP($J,"TIU CLIN LIST"),@TARGET
 N CLINCNT S CLINCNT=1
 N RMLL,RMLLSTP,RMCLINIC,RMCLNCNT
 N TIUARR,SDCOUNT,SDDFN,SDDATE,SDAPPT,SDDATIME,SDCLINIC,APSTATUS,CLINAME
 N LINE,IDX1,ERROR,ENDT,DASH73
 S $P(DASH73,"=",73)="="
 S LINE=0,ERROR=0
 S @TARGET@(LINE,0)="",LINE=LINE+1
 S @TARGET@(LINE,0)="MH Appointments Missed Last 10 Days",LINE=LINE+1
 S @TARGET@(LINE,0)="",LINE=LINE+1
 S RMLL=$O(^PXRMD(810.9,"B","VA-MH NO SHOW APPT CLINICS LL",""))
 S RMCLNCNT=0,IDX1=0,RMCLINIC=""
 I $G(RMLL)="" S SDCOUNT=0 D ERROR Q "~@"_$NA(@TARGET)  ;error and quit if RMLL not found
 F  S IDX1=$O(^PXRMD(810.9,RMLL,40.7,IDX1)) Q:IDX1'>0!(ERROR=1)  D
 .S RMLLSTP=^PXRMD(810.9,RMLL,40.7,IDX1,0)
 .S RMLLSTP=$P($G(RMLLSTP),"^") ;->this is the stop code, now get clinics for this stop code
 .Q:$D(^SC("AST",RMLLSTP))=0
 .F  S RMCLINIC=$O(^SC("AST",RMLLSTP,RMCLINIC)) Q:RMCLINIC=""!(ERROR=1)  D
 ..S ^TMP($J,"TIU CLIN LIST",RMCLINIC)=RMCLINIC
 ;NOW HAVE LIST OF CLINICS TO SEARCH FOR APPOINTMENTS
 ;CALL SDAPI ONCE FOR ALL CLINICS IN THE LIST
 S ENDT=$$FMADD^XLFDT(DT,-10)
 S TIUARR(1)=ENDT_";"_DT
 S TIUARR(2)="^TMP($J,""TIU CLIN LIST""" ;an array of clinic IENs
 S TIUARR(3)="NS;NSR" ;appt status NO SHOW & NO SHOW RESCHEDULED
 S TIUARR(4)=DFN
 S TIUARR("FLDS")="1;2;4;3"
 S TIUARR("SORT")="P"
 S SDCOUNT=$$SDAPI^SDAMA301(.TIUARR)
 I SDCOUNT=0 S @TARGET@(LINE,0)="No Missed Appointments Found",LINE=LINE+1
 I SDCOUNT<0 D ERROR Q "~@"_$NA(@TARGET)
 I SDCOUNT>0 D
 . S @TARGET@(LINE,0)="DATE/TIME"_$J("CLINIC",19)_$J("STATUS",32),LINE=LINE+1
 . S @TARGET@(LINE,0)=DASH73,LINE=LINE+1
 . S SDDFN=0 F  S SDDFN=$O(^TMP($J,"SDAMA301",SDDFN)) Q:SDDFN=""  D
 .. ;get appointment date/time
 .. S SDDATE=0 F  S SDDATE=$O(^TMP($J,"SDAMA301",SDDFN,SDDATE)) Q:SDDATE=""  D
 ... S SDAPPT=$G(^TMP($J,"SDAMA301",SDDFN,SDDATE)) ;appointment data
 ... S SDDATIME=$P($G(SDAPPT),"^",1) ;appointment date/time
 ... S APSTATUS=$P($G(SDAPPT),"^",3),APSTATUS=$P(APSTATUS,";",2)
 ... S CLINAME=$P($G(SDAPPT),"^",2),CLINAME=$P(CLINAME,";",2) ;CLINIC NAME
 ... I $L(CLINAME)<30 S CLINAME=CLINAME_($$REPEAT^XLFSTR(" ",(30-$L(CLINAME))))
 ... S SDDATIME=$$FMTE^XLFDT(SDDATIME,"5ZP")
 ... I $L(SDDATIME)<20 S SDDATIME=SDDATIME_($$REPEAT^XLFSTR(" ",(22-$L(SDDATIME)))) ;WAT/265
 ... I APSTATUS["&" S APSTATUS=$E(APSTATUS,1,17)_"."
 ... I $L(APSTATUS)<18 S APSTATUS=APSTATUS_($$REPEAT^XLFSTR(" ",(18-$L(APSTATUS))))
 ... S @TARGET@(LINE,0)=SDDATIME_CLINAME_$J(APSTATUS,20),LINE=LINE+1
 I SDCOUNT'=0 K ^TMP($J,"SDAMA301")
 Q "~@"_$NA(@TARGET)
 ;
ERROR ;errors returned from SDAPI
 N IDXERR S IDXERR=""
 I $G(RMLL)="" S @TARGET@(LINE,0)="Reminder location list not found. Unable to retrun appointment data",LINE=LINE+1 Q
 F  S IDXERR=$O(^TMP($J,"SDAMA301",IDXERR)) Q:IDXERR'>0  D
 .S @TARGET@(LINE,0)=^TMP($J,"SDAMA301",IDXERR),LINE=LINE+1
 Q