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

VENPCCS2.m

Go to the documentation of this file.
VENPCCS2 ; IHS/OIT/GIS - POPULATE OCX IMMUNIZATIONS OBJECT AND MAIL MERGRE FIELDS ; 16 Nov 2007  10:04 AM
 ;;2.6;PCC+;;NOV 12, 2007
 ;
 ; SUPPORTS IMM PGK VER 7 AND HIGHER
 ; DEAD CODE IN 2.5
 ;
IMM(DFN) ; EP-GET IMMUNIZATION DATA AND RETURN IT IN A FORMATTED STRING
 I '$D(^DPT(+$G(DFN),0)) Q ""
 N STG1,STG2,X,TMP,STG
 S TMP="^TMP(""VEN IMM"","_$J_")" K @TMP
 S X=$T(IMMHX^BIRPC) I '$L(X) Q ""
 S X=$T(IMMFORC^BIRPC) I '$L(X) Q ""
 I $L($T(VER^BILOGO)),$$VER^BILOGO>7.99,$L($T(IMMBI^BIAPCHS)) S STG=$$NEWIMM(DFN) K @TMP Q STG ; ACCOMODATES NEW IMMINUZATION PKG
 D IMMHX^BIRPC(.STG1,DFN)
 D IMMFORC^BIRPC(.STG2,DFN)
ABORT I '$L(STG1),'$L(STG2) Q ""
STG D ANAL(STG1,STG2)
FMT S STG=$$FORMAT
 K @TMP
 I '$G(WFLG) D CLN
 D FORC(STG) ; MAIL MERGE FORECASTING COMPONENT
 Q STG
 ; 
ANAL(STG1,STG2) ; EP-ANALYSIS OF THE HX AND FORCAST STRINGS
 N B,PCE1,PCE2,X,Y,%DT,CPT,CPTIEN,ICLASS,IDATE,IIEN,ILOC,IMM,IR,IRNO,STG,STYPE,VIIEN
 S B="|"
 F PCE1=1:1:$L(STG1,U) S X=$P(STG1,U,PCE1) I X'="" D
 . S ICLASS=$P(X,B,2) I '$L(ICLASS) Q
 . S IMM=$P(X,B,6) I '$L(IMM) Q
 . S VIIEN=+$P(X,B,4) I 'VIIEN Q
 . S ILOC=$P(X,B,5)
 . S STYPE=$P(X,B,6) I '$L(STYPE) S STYPE="OTHER"
 . S IDATE=$P(X,B,7) I IDATE S IDATE=$E(IDATE,1,11),%DT="",X=IDATE D ^%DT
 . I Y'?7N Q
 . S IDATE=$E(Y,4,5)_"/"_$E(Y,6,7)_"/"_(1700+$E(Y,1,3))
 . S %=$G(^AUPNVIMM(VIIEN,0)) S IRNO=$P(%,U,6),IIEN=+% I 'IIEN Q
 . S IR="" I IRNO S %=$P($G(^DD(9000010.11,.06,0)),U,3),%=";"_%,Y=$P(%,(";"_IRNO_":"),2),IR=$P(Y,";") I IR="OTHER" S IR="UNSPECIFIED REACTION"
 . I $L(IR) S @TMP@("IR",ICLASS,IR)="" I $G(WFLG) Q
 . S @TMP@("ORD",STYPE,2,ICLASS,PCE1)=IDATE_"_"_IMM_"_"_ILOC
 . Q
 K STG1
 I $G(WFLG) Q  ; WARNINGS ONLY
 F PCE2=1:1:$L(STG2,U) S X=$P(STG2,U,PCE2) I X'="" D
 . S IMM=$P(X,B,1) I '$L(IMM) Q
 . S IMM=$$STRIP^VENPCCU(IMM)
 . S DUE="Yes"
 . S ICLASS=IMM I IMM?1N1"-"1.E S ICLASS=$P(IMM,"-",2,99)
 . S CPT="",STYPE="OTHER",IIEN=$O(^AUTTIMM("D",ICLASS,0))
 . I IIEN D
 .. S STNO=+$P($G(^AUTTIMM(IIEN,0)),U,9),STYPE=$P($G(^BISERT(STNO,0)),U)
 .. I STYPE="" S STYPE="OTHER"
 .. S CPTIEN=+$P($G(^AUTTIMM(IIEN,0)),U,11),CPT=$P($G(^ICPT(CPTIEN,0)),U)
 .. Q
 . S @TMP@("ORD",STYPE,1,ICLASS,PCE2)=IMM_"~"_DUE_"~"_CPT_"~"
 . Q
 K STG2
 S STYPE="" F  S STYPE=$O(@TMP@("ORD",STYPE)) Q:STYPE=""  S ICLASS="" F  S ICLASS=$O(@TMP@("ORD",STYPE,2,ICLASS)) Q:ICLASS=""  D
 . I '$D(@TMP@("ORD",STYPE,1,ICLASS)) S @TMP@("ORD",STYPE,1,ICLASS,1)=ICLASS_"~No~~"
 . Q
 Q
 ; 
FORMAT() ; EP-FORMAT THE OUTPUT STRINGS
 N WARN,ORD,HX,IIEN,ICLASS,CNT,IIEN,IR,STYPE,CNT1,CNT2,ICLASS
 S WARN="",IIEN=0
 S ICLASS="",CNT=0
 I $G(WFLG),$D(@TMP@("IR")) F  S ICLASS=$O(@TMP@("IR",ICLASS)) Q:ICLASS=""  S IR="" F  S IR=$O(@TMP@("IR",ICLASS,IR)) Q:IR=""  D
 . I 'CNT S CNT=1 S WARN=WARN_$S($L(WARN):"    ",1:"")_"Warnings: "_ICLASS_" CAUSES "_IR Q
 . S WARN=WARN_", "_ICLASS_" CAUSES "_IR
 . Q
 I $G(WFLG) Q WARN ; WARNINGS ONLY
 S STYPE="",ORD=""
 F  S STYPE=$O(@TMP@("ORD",STYPE)) Q:STYPE=""  S ICLASS="" F  S ICLASS=$O(@TMP@("ORD",STYPE,1,ICLASS)) Q:ICLASS=""  D
 .  S CNT1=0 F  S CNT1=$O(@TMP@("ORD",STYPE,1,ICLASS,CNT1)) Q:'CNT1  D
 .. S ORD=ORD_@TMP@("ORD",STYPE,1,ICLASS,CNT1),CNT2=0,CNT=0
 .. F  S CNT2=$O(@TMP@("ORD",STYPE,2,ICLASS,CNT2)) Q:'CNT2  D
 ... I CNT S ORD=ORD_"`"
 ... E  S CNT=1
 ... S ORD=ORD_@TMP@("ORD",STYPE,2,ICLASS,CNT2)
 ... Q
 .. S ORD=ORD_"|"
 .. Q
 . Q
 Q ORD
 ; 
IWARN(DFN) ; EP-RETURN IMMUNIZATION WARNINGS
 Q ""
 ; 
FORC(STG) ; EP-RESET THE HEALTH MAINT REMINDERS FOR IMMUNIZATIONS TO ACCOMODATE THE "FORECAST BOX"
 N I,FSTG,YES,A,B,IMM,CPT,N,TOT,TMP
 S TMP=$NA(^TMP("VEN PRNT",$J,1))
 S YES="~Yes~",FSTG="",STG="|"_STG,N=0
 I STG["Yes" S TOT=$L(STG,YES) F I=1:1:TOT D
 . S A=$P(STG,YES,1) S IMM=$P(A,"|",$L(A,"|"))
 . S B=$P(STG,YES,2,99) S CPT=$P(B,"~")
 . S STG=B
 . I $L(FSTG) S FSTG=FSTG_U
 . S FSTG=FSTG_IMM_" due"
 . I $L(CPT) S FSTG=FSTG_" ("_CPT_")"
 . Q
 F I=9:1:25 S N=N+1,%=$P(FSTG,U,N) I $L(%) S @TMP@("h"_I)=%
 Q
 ; 
CLN ; EP CLEAN OUT IMMUNIZATIONS
 N I,TMP
 S TMP=$NA(^TMP("VEN PRNT",$J,1))
 F I=9:1:25 S @TMP@("h"_I)=""
 Q
 ;
NEWIMM(DFN) ; EP-GET DATA FROM NEW IMMUNIZATION PACKAGE
 N ARR,TYPE,LINE,CNT,ISTG,LAST,X
 D CLN  ; CLEAN OUT IMMUNIZATION WARNINGS AND START OVER WITH NEW DATA
 D IMMBI^BIAPCHS(DFN,.ARR) ; GET THE IMMUNIZATION ARRAY FRO IMM PKG
 K BIDLLP,BIDLLID,BIDLLRUN,BIFDT,BIRESULT,BISITE,%T,%Y,DX,DY,XY
 I '$D(ARR) Q ""  ; MUST HAVE SOME RESULTS
 S TYPE="",LINE=0,CNT=8,ISTG="",LAST="",MCNT=0
 F  S LINE=$O(ARR(LINE)) Q:'LINE  S X=$G(ARR(LINE,0)) I $L(X)>1 D  ; BUILD MAIL MERGE FIELDS AND THE IMMUNIZATION STRING
 . I X["IMMUNIZATION FORECAST" S TYPE="NEWFORC" Q
 . I X["IMMUNIZATION HISTORY" S TYPE="NEWHX" Q
 . X ("D "_TYPE_"(X,LINE)") ; SET IMM HEALTH MAINT REMINDERS FOR BOTH HX AND FORECAST
 . Q
 I $L(ISTG) S ISTG=ISTG_"|"
 Q ISTG
 ; 
NEWFORC(STG,LINE) ; EP-NEW IMMINUZATION FORECASTS
 N X,Y,%,CPT,IIEN,GBL
 S GBL=$NA(^TMP("VEN PRNT",$J,1))
 I STG'[" due " Q
 I STG["past due" S X=$P(STG,"past due") ; GET IMMINUZATION ; PATCHED BY GIS/ITSC
 E  S X=$P(STG,"due") ; PATCHED BY GIS/ITSC
 S X=$$STRIP^VENPCCU(X) ; STRIP OFF BLANKS
 I '$L(X) Q  ; THIS POINT X = NAME OF IMMUNIZATON
 S CNT=CNT+1 I CNT>25 Q
 S IIEN=$O(^AUTTIMM("D",X,0)),CPT="" I 'IIEN Q
 S CPT=$P($G(^AUTTIMM(IIEN,0)),U,11)
 I $L(CPT) S CPT="("_CPT_")"
 S @GBL@("h"_CNT)="__"_X_" due now "_CPT ; REFRESH THE IMM FORCAST MAIL MERGE FIELD
 S @TMP@("DUE",X)="h"_CNT ; TMP ARRAY USED IN THE PEDS FORM
 Q
 ; 
NEWHX(STG,LINE) ; EP-NEW IMM HISTORY
 N WARN,NEXT,IMM,TYPE,DATE,LOC,DUE,X,Y,Z,GBL
 S GBL=$NA(^TMP("VEN PRNT",$J,1))
 S DUE="No"
 S X=$E(STG,1,27) S X=$$STRIP^VENPCCU(X) I '$L(X) Q
 S IMM=X
 S X=$E(STG,28,37) S X=$$STRIP^VENPCCU(X) I X'?2N1"/"2N1"/"2N Q  ; THIS BLOCKS A "Reaction" LINE FROM HX
 S DATE=X
 S X=$E(STG,38,45) S X=$$STRIP^VENPCCU(X)
 S TYPE=X
 S X=$E(STG,46,59) S X=$$STRIP^VENPCCU(X)
 S LOC=X
 I TMP'="IMM" D  Q  ; PEDS FORM HX FROM IMM^VENPCCS2
 . I $D(@TMP@("DUE",IMM)) S DUE="Yes"
 . S Z=DATE_"_"_TYPE_"_"_LOC
 . S ISTG=ISTG_$S(LAST="":"",IMM=LAST:"`",1:"|") ; DELIMITER
 . I IMM'=LAST S ISTG=ISTG_IMM_"~"_DUE_"~~"
 . S ISTG=ISTG_Z,LAST=IMM
 . Q
 I TMP="IMM" D  ; GENL IMM HX FROM IF^VENPCC1C (IMM 8.0 AND HIGHER)
 . S MCNT=MCNT+1
  . I $O(ARR(999),-1)<49,MCNT>1,IMM'=LAST,MCNT<51 S @GBL@("ihx"_MCNT)=" " S MCNT=MCNT+1 ; SPACER LINE
 . I MCNT<51 S @GBL@("ihx"_MCNT)=IMM_" "_DATE_" "_TYPE_" "_LOC ; POPULATE IMM HX LIST
 . S LAST=IMM
 . Q
 S NEXT=$G(ARR(LINE+1,0)) ; MAY NEED TO APPEND IMM FORCAST NOTICE WITH ADVERSE RXN INFO!
 I NEXT'["Reaction" Q  ; CHECK FOR ADVERSE REACTION
 S Y=$G(@TMP@("DUE",IMM)) I '$L(Y) Q  ; GET MM FIELD
 S X=$G(^TMP("VEN PRNT",$J,1,Y)) ; GET MESSAGE
 I $L(X),X'["Rxn: " S X=X_" (Rxn: "_$E($P(NEXT,"Reaction: ",2),1,12)_")"
 S ^TMP("VEN PRNT",$J,1,Y)=X ; APPEND REACTION NOTICE TO END OF DUE NOW NOTICE
 Q
 ;