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

VENPCC1E.m

Go to the documentation of this file.
VENPCC1E ; IHS/OIT/GIS - NEW HEALTH MAINTENANCE REMINDER OUTOPUT ;
 ;;2.6;PCC+;;NOV 12, 2007
 ;
 ; INCLUDES NEW CODE FOR PATIENT REFUSALS IN VER 2.5
 ; 
RAW(APCHSPAT,APCHSTYP) ; EP-GET RAW HMR TEXT
 N APCHSCVD,APCHSBRK,APCHSCKP,APCHSNPG,APCHSBWR,APCHSERR,DDH,%T,%Y,AMQQTAXN,E
 S APCHSCVD="S:Y]"""" Y=+Y,Y=$E(Y,4,5)_""/""_$S($E(Y,6,7):$E(Y,6,7)_""/"",1:"""")_$E(Y,2,3)"
 S APCHSBRK="",APCHSCKP="",APCHSNPG=1
 D SURV^APCHS11
 Q
 ; 
LINE ; EP-INC LINE
 N I,X S I=0
 F  R X:30 Q:$$STATUS^%ZISH!(X["** END ")  D
 . I X="" Q
 . I X["LAST",X["NEXT" Q
 . S I=I+1,@TMP@(I)=X
 . Q
 Q
 ; 
ARR(DFN) ; EP-SAVE SURVEILANNCE INFO IN A TMP ARRAY
 N PATH,TMP,IOST,IOSL,IOM,POP,HSIEN,AGE,%,LINE,FILE
 I '$D(^DPT(+$G(DFN,0),0)) Q
 S %=+$P($G(^DPT(DFN,0)),U,3) I '% Q
 S AGE=(DT-%)\10000
 S HSIEN=$O(^APCHSCTL("B",$S(AGE<12:"PEDIATRIC",1:"ADULT REGULAR"),0)) I '$G(HSIEN) Q
 S PATH=$G(^VEN(7.5,+$$CFG^VENPCCU,3)) I '$L(PATH) Q
 S TMP="^TMP(""VEN SURV"",$J)",FILE="S"_DFN_".TXT" K @TMP
 S IOST="P-PRINTER",IOSL=99999,IOM=80
 S POP=$$OPN^VENPCCP(PATH,FILE,"W","N IO S IO=DEV D RAW^VENPCC1E(DFN,HSIEN)") I POP Q
 S POP=$$OPN^VENPCCP(PATH,FILE,"R","D LINE^VENPCC1E") I POP Q
 D DEL^VENPCCP1(PATH,("S"_DFN_".TXT")) ; CLEAN UP THE TMP FILE
 D ITEM(DFN) ; GETS NEW SURVEILLANCE ITEMS (h26-h50) AND CLEARS OUT OLD ITEMS (h1-h8)
 I $G(DEFEF) D REF(DFN,DEFEF) ; PATIENT REFUSALS
 K @TMP
 Q
 ;
CREF(FILE) ; EP-GIVEN A V FILE NUMBER, RETURN THE CLOSED REF
 N X
 S X=$G(^DIC(FILE,0,"GL")) I X="" Q X
 I $E($RE(X),1)="(" S X=$TR(X,"(","")
 E  S X=$RE(X) S $E(X,1)=")" S X=$RE(X)
 Q X
 ; 
EXDT(DATE,A) ; EP-EXTERNAL DATE TO INTERNAL FM FORMAT.  IF A=1, RETURN DAY ONLY
 N X,Y,%DT
 S X=DATE,%DT="P"
 D ^%DT
 I Y=-1 Q ""
 I A S Y=Y\1
 Q Y
 ; 
LAST(DFN,TYPE,DATE) ; EP-RETURN THE LAST VALUE FOR A PATIENT ON A GIVEN DATE
 I $G(DFN),$L($G(DATE)),$L(TYPE)
 E  Q ""
 N SIEN,FILE,VFILE,LUV,LIEN,%,X,OREF,SDATE,IDATE,DIC,Y,UNITS,TIEN,PCE,CREF,DDH,LDT,%DT,VIEN,RES,SPEC
 S %=$O(^APCHSURV("B",TYPE,0)) I '$D(^VEN(7.96,+%,0)),TYPE'="PRIME MD SCORE" Q "" ; PATCHED BY GIS/OIT 2/25/06 ; PCC+ 2.5 PATCH 3
 S SIEN=$O(^APCHSURV("B",TYPE,0)) I 'SIEN Q ""
 S %=$G(^VEN(7.96,SIEN,0)),FILE=$P(%,U,2),VFILE=$P(%,U,3),UNITS=$P(%,U,4),SPEC=$G(^VEN(7.96,SIEN,2))
 I $L(FILE),$L(VFILE)
 E  Q ""
 S LDT=$$EXDT(DATE,1) I 'LDT Q ""
 S IDATE=9999999-LDT
 I $L(SPEC) X ("S X=$$"_SPEC_"(DFN,IDATE)") Q X
 S LUV="",LIEN=0,DIC(0)="MX",DIC=$G(^DIC(FILE,0,"GL")) I '$L(DIC) Q ""
 F  S LIEN=$O(^VEN(7.96,SIEN,1,LIEN)) Q:'LIEN  D
 . S X=$G(^VEN(7.96,SIEN,1,LIEN,0)) I '$L(X) Q
 . D ^DIC I Y=-1 Q
 . I $L(LUV) S LUV=LUV_U
 . S LUV=LUV_(+Y)
 . Q
 I '$L(LUV) Q ""
 S CREF=$$CREF(VFILE) I '$L(CREF) Q ""
 F PCE=1:1:$L(LUV,U) S TIEN=$P(LUV,U,PCE) I TIEN D  I $L($G(VAL)) Q
 . S VIEN=999999999 F  S VIEN=$O(@CREF@("AA",DFN,TIEN,IDATE,VIEN),-1) Q:'VIEN  D  I $L($G(VAL)) Q
 .. K VAL
 .. I VFILE=9000010.09 D  Q
 ... S VAL=$P($G(^AUPNVLAB(VIEN,0)),U,4),RES=$P($G(^AUPNVLAB(VIEN,0)),U,5)
 ... I TYPE="PAP SMEAR",$G(VAL) S VAL="Class "_VAL
 ... I $L(VAL),$L($G(UNITS)) S VAL=VAL_UNITS
 ... I $L(VAL),$L(RES) S VAL=VAL_" "
 ... I $L(RES) S VAL=VAL_"("_RES_")"
 ... I '$L(VAL) K VAL
 ... Q
 .. I VFILE=9000010.12 D  Q
 ... S VAL=$P($G(^AUPNVSK(VIEN,0)),U,4),X=$P($G(^AUPNVSK(VIEN,0)),U,5)
 ... S RES=$S(X="P":"Pos",X="N":"Neg",X="D":"Doubtful",X="0":"No take",1:"")
 ... I $L(VAL),$L(RES) S VAL=VAL_" "
 ... I $L(RES) S VAL=VAL_"("_RES_")"
 ... I '$L(VAL) K VAL
 ... Q
 .. I VFILE=9000010.13 D  Q
 ... S VAL=$P($G(^AUPNVXAM(VIEN,0)),U,4)
 ... I '$L(VAL) K VAL Q
 ... S VAL=$S(VAL="N":"Nl",VAL="A":"Abnl",1:VAL)
 ... Q
 .. Q
 . I '$L($G(VAL)),$D(^AUPNPREF("AA",DFN,FILE,TIEN,IDATE)) S VAL="REFUSED!" Q
 . Q
 Q $G(VAL)
 ;
ITEM(DFN) ; EP-GET EACH ITEM AND STORE RESULTS
 N LINE,STG,X,TYPE,FORC,VAL,Y,DATE,CNT,%,I,TMP,GBL
 S TMP=$NA(^TMP("VEN PRNT",$J,1))
 S GBL=$NA(^TMP("VEN SURV",$J))
 F I=1:1:8 S @TMP@("h"_I)="" ; CLEAR OLD SURVEILLANCE ITEMS ; PATCHED BY GIS 1/15/04
 S LINE=0,CNT=25
 F  S LINE=$O(@GBL@(LINE)) Q:'LINE  D
 . S STG=$G(@GBL@(LINE)) I '$L(STG) Q
 . S X=$E(STG,1,23),TYPE=$$STRIP(X) I '$L(TYPE) Q
 . ; S %=$O(^APCHSURV("B",TYPE,0)) I '$D(^VEN(7.96,+%,0)),TYPE'="PRIME MD SCORE" Q  ; ITEM MUST EXIST IN VEN SURV FILE ; PATCHED BY GIS/OIT 2/25/06 ; PCC+ 2.5 PATCH 3
 . S X=$E(STG,24,36) S DATE=$$STRIP(X)
 . I DATE?1." "2N1"/"2N1"/"2N S DATE=$TR(DATE," ","") ; PATCHED BY GIS/OIT 2/25/06 ; PCC+ 2.5 PATCH 3 
 . S X=$E(STG,37,99),FORC=$$STRIP(X)
 . I FORC?2N1"/"2N1"/"2N S FORC="Due: "_FORC ; PATCHED BY GIS/OIT 2/25/06 ; PCC+ 2.5 PATCH 3 
 . S VAL=$$LAST(DFN,TYPE,DATE),CNT=CNT+1 I CNT>50 Q
 . S STG=TYPE I $L(DATE) S STG=STG_"  Last: "_DATE
 . I $L(VAL) S STG=STG_" "_VAL ; PATCHED BY GIS/OIT 2/25/06 ; PCC+ 2.5 PATCH 3 
 . I $L(FORC) S STG=STG_"  "_FORC ; PATCHED BY GIS/OIT 2/25/06 ; PCC+ 2.5 PATCH 3 
 . S @TMP@("h"_CNT)=STG
 . Q
 Q
 ;
STRIP(X) ; EP-STRIP BLANKS OFF THE END
 N I,Y
 S X=$RE(X)
 F I=1:1 S Y=$E(X,I) Q:Y'=" "
 Q $RE($E(X,I,999))
 ; 
MAMMO(DFN,IDATE) ; EP-GIVEN A DFN, RETURN THE LAST MAMMOGRAM h4
 N %,X,PIEN,VAL,STOP
 S PIEN=$O(^APCHSURV("B","MAMMOGRAM",0)) I 'PIEN Q "Unknown"
 I $L($T(INAC^APCHSMU)),$$INAC^APCHSMU(%),$O(^BWPCD(0))
 E  Q ""
 S IDATE=0,STOP=""
 S PIEN=0 F  S PIEN=$O(^BWPCD("AA",DFN,IDATE,PIEN)) Q:'PIEN  D  I STOP Q
 . S %=$P($G(^BWPCD(PIEN,0)),U,4)
 . I %'=25,%'=26,%'=28 Q
 . S STOP=PIEN
 . Q
 I 'STOP Q "Unknown"
 S VAL=$P($G(^BWPCD(STOP,0)),U,5)
 I '$L(VAL) Q "Unknown"
 Q VAL
 ; 
REF(DFN,DEFEF) ; EP - PATIENT REFUSALS (h1 - h8)
 I '$O(^AUPNPREF("AA",+$G(DFN),0)) Q  ; NO REFUSALS SO QUIT
 N MAXDT,PTED,FILE,FIEN,IDT,MOS,RIEN,X,STG,CNT,TOT,DAYS,MIDT,DATE,VIEN,WHAT,%,TMP
 S TMP=$NA(^TMP("VEN PRNT",$J,1))
 S STG=$G(^VEN(7.41,DEFEF,15))
 S MOS=$P(STG,U) I MOS=0 Q  ; REFUSALS HAS BEEN TURNED OFF
 I MOS="" S MOS=60
 S DAYS=(MOS*30.5)\1
 S MIDT=9999999-$$FMADD^XLFDT(DT,-DAYS,"","","")
 S PTED=+$P(STG,U,2)
 S FILE=0,CNT=0
 F  S FILE=$O(^AUPNPREF("AA",DFN,FILE)) Q:'FILE  D
 . I 'PTED,FILE=9999999.09 Q  ; PATIENT ED REFUSALS SHOULD BE EXCLUDED
 . S FIEN=0 F  S FIEN=$O(^AUPNPREF("AA",DFN,FILE,FIEN)) Q:'FIEN  D  I CNT=8 Q
 .. S IDT=0 F  Q:IDT>MIDT  S IDT=$O(^AUPNPREF("AA",DFN,FILE,FIEN,IDT)) Q:'IDT  D  I CNT=8 Q
 ... S RIEN=0 F  S RIEN=$O(^AUPNPREF("AA",DFN,FILE,FIEN,IDT,RIEN)) Q:'RIEN  D  I CNT=8 Q
 .... S X=$G(^AUPNPREF(RIEN,0)) I '$L(X) Q
 .... S WHAT=$P(X,U,4)
 .... S %=$P(X,U,3) I '% Q
 .... S DATE=$$FMTE^XLFDT(%,"2D")
 .... S CNT=CNT+1
 .... S @TMP@("h"_CNT)="Refused "_WHAT_" ("_DATE_")"
 .... Q
 ... Q
 .. Q
 . Q
 Q