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

VENPCC1D.m

Go to the documentation of this file.
VENPCC1D ; IHS/OIT/GIS - HEALTH MAINTENANCE REMINDERS FOR ENCOUNTER FORMS ; 
 ;;2.6;PCC+;;NOV 12, 2007
 ; MOST OF THIS CODE IS NO LONGER USED DUE TO UPDATED HEATH MAINTENANCE REMINDERS IN VER 2.2
 ; 
 ; 
OUT(TITLE,FN,TYPE,DFN) ; EP-OUTPUT FORMATTER FOR HEALTH MAINTENANCE REMINDERS
 I $L(FN),$L(TYPE),$D(^DPT(+$G(DFN),0))
 E  Q ""
 N X
 S X=$$HMR(FN,TYPE,DFN)
 I X="" S:$G(TITLE)'="" FN=TITLE Q "Last "_FN_": Unknown"
 S X=$$FORM($G(TITLE),FN,X)
 Q X
 ; 
IEN(FN,TYPE,DFN) ; EP-CONVERTS DFN TO IEN FOR ANY FILE NAME FOR V FILES
 I $L($G(FN)),$L($G(TYPE)),+$G(DFN)
 E  Q ""
 N DIC,X,Y,%,FIEN,FOR,TIEN,I
 S DIC=1,X=FN,DIC(0)="" D ^DIC I Y=-1 Q ""
 S FIEN=+Y
 S %=$P($G(^DD(FIEN,.01,0)),U,2)
 S FOR=$G(^DIC(FIEN,0,"GL")) I '$L(FOR) Q ""
 F I=1:1 Q:'$L(%)  S X=$E(%) S:X'?1N %=$E(%,2,999) I X S %=+% Q
 I '% Q ""
 S DIC=%,DIC(0)="",X=TYPE S:FN["V IMM" DIC(0)="M" D ^DIC I Y=-1 Q ""
 S TIEN=+Y
 I FN="V MED" G MED
 S X=FOR_"""AA"","_DFN_","_TIEN_",0)"
 S Y=$O(@X) I 'Y Q ""
 S X=FOR_"""AA"","_DFN_","_TIEN_","_Y_",0)"
 S Y=$O(@X)
 Q Y_U_FIEN
 ; 
MED ; EP-FIELD IEN
 N STOP S STOP=""
 S Y=0 F  Q:STOP  S Y=$O(^AUPNVMED("AA",DFN,Y)) Q:'Y  S IEN=0 F  S IEN=$O(^AUPNVMED("AA",DFN,Y,IEN)) Q:'IEN  I $P($G(^AUPNVMED(IEN,0)),U)=TIEN S STOP=IEN Q
 I 'STOP Q ""
 Q STOP_U_FIEN
 ; 
DATE(X) ; EP-RETURN THE DATE GIVEN THE ZERO NODE OF A V FILE
 N VIEN,Y
 S VIEN=$P(X,U,3) I 'VIEN Q ""
 S Y=$P($G(^AUPNVSIT(VIEN,0)),U) I 'Y Q ""
 S Y=Y\1 S Y=$E(Y,4,5)_"/"_$E(Y,6,7)_"/"_$E(Y,2,3)
 Q Y
 ;
HMR(FN,TYPE,DFN) ; EP-RETURN HEALTH MAINTRNANCE REMINDERS
 ; FILE NAME,EVENT NAME,DFN (INPUT)
 ; DATE^RESULT^ABNORMAL FLAG (OUTPUT)^MODIFIER
 I $L($G(FN)),$L($G(TYPE)),+$G(DFN)
 E  Q ""
 N REC,IEN,DATE,%,X,Y,FIEN
 S REC=$$IEN(FN,TYPE,DFN) I '$L(REC) Q ""
 S IEN=+REC,FIEN=$P(REC,U,2)
 I FN="V MED" S X=$G(^AUPNVMED(IEN,0)) I $L(X) D  Q Y ; MEDICATION
 . S DATE=$$DATE(X) I '$L(DATE) S Y="" Q
 . S Y=DATE
 . Q
 I FN="V EXAM" S X=$G(^AUPNVXAM(IEN,0)) I $L(X) D  Q Y ; EXAM
 . S DATE=$$DATE(X) I '$L(DATE) S Y="" Q
 . S %=$P(X,U,4) S %=$S(%="A":"Abnl",%="N":"Nl",1:"")
 . S Y=DATE_"^^"_%
 . Q
 I FN="V LAB" S X=$G(^AUPNVLAB(IEN,0)) I $L(X) D  Q Y ; LAB TEST RESULT
 . S DATE=$$DATE(X) I '$L(DATE) S Y="" Q
 . S Y=DATE_U_$P(X,U,4,5)
 . Q
 I FN="V RADIOLOGY" S X=$G(^AUPNVRAD(IEN,0)) I $L(X) D  Q Y ; RADIOLOGY
 . S DATE=$$DATE(X) I '$L(DATE) S Y="" Q
 . S %=$P(X,U,5) S %=$S(%=0:"Nl",%=1:"Abnl",1:"")
 . S Y=DATE_"^^"_%
 . Q
 I FN="V IMMUNIZATION" S X=$G(^AUPNVIMM(IEN,0)) I $L(X) D  Q Y ; IMMUNIZATION
 . S DATE=$$DATE(X) I '$L(DATE) S Y="" Q
 . S %=$P(X,U,7) S %=$S(%=1:"Do not use!",1:"")
 . S Y=DATE_"^^"_%_U_$P(X,U,4)
 . Q
 I FN="V SKIN TEST" S X=$G(^AUPNVSK(IEN,0)) I $L(X) D  Q Y ; SKIN TEST
 . S DATE=$$DATE(X) I '$L(DATE) S Y="" Q
 . S %=$P(X,U,4) S %=$S(%="P":"Pos",%="N":"Neg",1:"?")
 . S Y=DATE_U_$P(X,U,5)_"mm"_U_%
 . Q
 Q ""
 ;
FORM(TITLE,FN,X) ; PRELIMINARY OUTPUT FORMATTING
 I '$L(X) Q ""
 I '$L(TITLE),'$L(FN) Q ""
 I $L(TITLE) S FN=TITLE
 S FN=FN I $L($P(X,U,4)) S FN=FN_"("_$P(X,U,4)_")"
 S %="Last "_FN_": "_$P(X,U)
 I $P(X,U,2)'="" S %=%_" ("_$P(X,U,2)
 I $P(X,U,3)'="" S %=%_" - "_$P(X,U,3)
 I $P(X,U,2)'="" S %=%_")"
 Q %
 ; 
PAP(DFN) ; EP-GIVEN DFN, RETURN LAST PAP h1
 Q $$OUT("PAP","V LAB","PAP SMEAR",+$G(DFN))
 ;
GLUC(DFN) ; EP-GIVEN DFN, RETURN LAST GLUCOSE h2
 Q $$OUT("GLUCOSE","V LAB","GLUCOSE",+$G(DFN))
 ;
PPD(DFN) ; EP-GIVEN DFN, RETURN THE LAST PPD SKIN TEST h3
 Q $$OUT("PPD","V SKIN TEST","PPD",+$G(DFN))
 ; 
MAMMO(DFN) ; EP-GIVEN A DFN, RETURN THE LAST MAMMOGRAM h4
 N % S %=$O(^APCHSURV("B","MAMMOGRAM",0))
 I %,$L($T(INAC^APCHSMU)),$$INAC^APCHSMU(%),$O(^BWPCD(0))
 E  Q $$OUT("MAMMO","V RADIOLOGY","MAMMOGRAM BILAT",+$G(DFN))
 N IDATE,STOP,PIEN,%,DATE,RES,Y,Z
 S IDATE=0,STOP=""
 F  S IDATE=$O(^BWPCD("AA",DFN,IDATE)) Q:'IDATE  Q: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 "Last MAMMO: Unknown"
 S DATE=$P($G(^BWPCD(STOP,0)),U,3),RES=$P(^(0),U,5)
 I 'DATE Q "Last MAMMO: Unknown"
 S Y=DATE,Y=Y\1 S DATE=$E(Y,4,5)_"/"_$E(Y,6,7)_"/"_$E(Y,2,3)
 I RES S RES=$P($G(^BWDIAG(RES,0)),U) S RES=$S('$L(RES):"",RES["Negative"!(RES["Normal"):"Nl",1:"Abnl")
 S Z="Last MAMMO: "_DATE I $L($G(RES)) S Z=Z_" - "_RES
 Q Z
 ; 
PELVIC(DFN) ; EP-GIVEN DFN, RETURN THE LAST PELVIC EXAM h5
 Q $$OUT("PELVIC","V EXAM","PELVIC EXAM",+$G(DFN))
 ; 
BREAST(DFN) ; EP-GIVEN DFN, RETURN THE LAST BREAST EXAM h6
 Q $$OUT("BREAST EXAM","V EXAM","BREAST EXAM",+$G(DFN))
 ; 
RECTAL(DFN) ; EP-GIVEN DFN, RETURNT THE LAST RECTAL EXAM h7
 Q $$OUT("RECTAL EXAM","V EXAM","RECTAL EXAM",+$G(DFN))
 ; 
PROST(DFN) ; EP-GIVEN DFN, RETURN THE LAST PROSTATE EXAM h8
 Q $$OUT("PROSTATE EXAM","V EXAM","RECTAL EXAM",+$G(DFN))
 ; 
PN(DFN) ; EP-GIVEN DFN, RETURN THE LAST PNEUMOVAX h9
 Q $$OUT("PNEUMOVAX","V IMMUNIZATION","19",+$G(DFN))
 ; 
FLU(DFN) ; EP-GIVEN DFN, RETURN THE LAST FLU SHOT h10
 Q $$OUT("FLU","V IMMUNIZATION","12",+$G(DFN))
 ; 
TD(DFN) ; EP-GIVEN DFN, RETURN THE LAST TETANUS SHOT h11
 Q $$OUT("TD","V IMMUNIZATION","28",+$G(DFN))
 ; 
DPRV(DFN) ; EP-GIVEN DFN, RETURN THE DESIGNATED PROVIDER x29
 N PRV
 S PRV=$P($G(^AUPNPAT(DFN,0)),U,14)
 I PRV,$G(^DD(9000001,.14,0))["VA(200" S PRV=$P($G(^VA(200,+PRV,0)),U) I $L(PRV) S PRV=$P(PRV,",",2)_" "_$P(PRV,",")
 E  S %=U_"DIC("_16_")",PRV=$P($G(@%@(+PRV,0)),U) I $L(PRV) S PRV=$P(PRV,",",2)_" "_$P(PRV,",")
 I PRV="" S PRV="Unknown"
 Q "PCP: "_PRV
 ; 
DPT(DFN) ; EP-GIVEN DFN, RETURN THE LAST DPT h12
 Q $$OUT("DPT","V IMMUNIZATION","1",+$G(DFN))
 ; 
OPV(DFN) ; EP-GIVEN DFN, RETURN THE LAST OPV h13
 Q $$OUT("OPV","V IMMUNIZATION","2",+$G(DFN))
 ; 
POLIO(DFN) ; EP-GIVEN DFN, RETURN THE LAST POLIO VACCINE h14
 Q $$OUT("POLIO","V IMMUNIZATION","10",+$G(DFN))
 ; 
HEPB(DFN) ; EP-GIVEN THE DFN, RETURN THE LAST HEPATITIS B VACCINE h15
 Q $$OUT("HEP-B","V IMMUNIZATION","45",+$G(DFN))
 ; 
MEASL(DFN)  ; EP-GIVEN THE DFN, RETURN THE LAST MEASLES VACCINE h16
 Q $$OUT("MEASLES","V IMMUNIZATION","5",+$G(DFN))
 ; 
RUB(DFN) ; EP-GIVEN DFN, RETURN THE LAST RUBELLA VACCINE h17
 Q $$OUT("RUBELLA","V IMMUNIZATION","6",+$G(DFN))
 ; 
MUM(DFN) ; EP-GIVEN DFN, RETURN THE LAST MUMPS VACCINE h18
 Q $$OUT("MUMPS","V IMMUNIZATION","7",+$G(DFN))
 ; 
MMR(DFN) ; EP-GIVEN DFN, RETURN THE LAST MMR VACCINE h19
 Q $$OUT("MMR","V IMMUNIZATION","3",+$G(DFN))
 ; 
MR(DFN) ; EP-GIVEN DFN, RETURN THE LAST MR VACCINE h20
 Q $$OUT("MR","V IMMUNIZATION","4",+$G(DFN))
 ; 
HFLU47(DFN) ; EP-GIVEN DFN, RETURN THE LAST HFLU47 VAVVINE h21
 Q $$OUT("H-FLU","V IMMUNIZATION","47",+$G(DFN))
 ; 
HFLU48(DFN) ; EP-GIVEN DFN, RETURN THE LAST HFLU48 VACCINE h22
 Q $$OUT("H-FLU","V IMMUNIZATION","48",+$G(DFN))
 ; 
HFLU49(DFN) ; EP-GIVEN DFN, RETURN THE LAST HFLU49 VACCINE h23
 Q $$OUT("H-FLU","V IMMUNIZATION","49",+$G(DFN))
 ; 
HEPA(DFN) ; EP-GIVEN DFN, RETURN THE LAST HEPATITIS A VACCINE h24
 Q $$OUT("HEP-A","V IMMUNIZATION","85",+$G(DFN))
 ; 
CPOX(DFN) ; EP-GIVEN DFN, RETURN THE LAST VARICELLA VACCINE h25
 Q $$OUT("CPOC","V IMMUNIZATION","21",+$G(DFN))
 ; 
DTAP(DFN) ; EP-GIVEN DFN, RETURN THE LAST DTAP VACCINE h26
 Q $$OUT("DTaP","V IMMUNIZATION","20",+$G(DFN))
 ; 
FEMU50(DFN) ; EP-EN UNDER 50
 N AGE,DOB,SEX,X
 S X=$G(^DPT(+$G(DFN),0)) I X="" Q 0
 S SEX=$P(X,U,2),DOB=$P(X,U,3)
 I $L(SEX),DOB
 E  Q 0
 S AGE=(DT-DOB)\10000
 I AGE<50,SEX="F" Q 1
 Q 0
 ; 
FEM40(DFN) ; EP-WOMEN OVER 40
 N AGE,DOB,SEX,X
 S X=$G(^DPT(+$G(DFN),0)) I X="" Q 0
 S SEX=$P(X,U,2),DOB=$P(X,U,3)
 I $L(SEX),DOB
 E  Q 0
 S AGE=(DT-DOB)\10000
 I AGE>39,SEX="F" Q 1
 Q 0
 ;