BIEXPRT5 ;IHS/CMI/MWR - EXPORT IMMUNIZATION RECORDS; OCT 15, 2010
;;8.5;IMMUNIZATION;**5**;JUL 01,2013
;;* MICHAEL REMILLARD, DDS * CIMARRON MEDICAL INFORMATICS, FOR IHS *
;; EXPORT IMMUNIZATION RECORDS: BUILD IMMSERVE EXPORT.
;; CALLED BY BIEXPRT3.
;; PATCH 2: Include CVX 20 (DTaP) in translation to -13, so that
;; DTaP satisfies Tdap. DOSES+42
;; PATCH 5: Translate new Flu codes to 15 for Immserve. DOSES+54
;
;
;----------
IMMSERV(BIFDT,BIDUZ2,BINF) ;EP
;---> Called by BIEXPRT3.
;---> Construct ^BITMP($J,2 nodes for ImmServe exports from the
;---> ^BITMP($J,1 nodes (gathered in ^BIEXPRT2).
;---> This prepares the string of Patient Data to be sent to
;---> Immserve for forecasting.
;---> Parameters:
; 1 - BIFDT (opt) Forecast Date (date used to calc Imms due).
; 2 - BIDUZ2 (opt) User's DUZ(2) for BISITE parameters,
; which affect forecasting rules.
; 3 - BINF (opt) Array of Vaccine IEN's that should not be forecast.
;
;---> If no Forecast Date passed, set it equal to today.
S:'$G(BIFDT) BIFDT=DT
;
;---> If no BIDUZ2, try DUZ(2); otherwise, defaults will be used.
S:'$G(BIDUZ2) BIDUZ2=$G(DUZ(2))
;
N BIDFN S BIDFN=0
F S BIDFN=$O(^BITMP($J,1,BIDFN)) Q:'BIDFN D
.N BIAGE,BIDOSES,BIMM,BITMP,BITMP1 S BIDOSES=0,BIMM=0,BITMP=""
.;---> Set Patient Age in Years for this Forecast Date.
.S BIAGE=$$AGE^BIUTL1(BIDFN,1,BIFDT)
.F S BIMM=$O(^BITMP($J,1,BIDFN,BIMM)) Q:'BIMM D
..N BIDATE,Y S BIDATE=0
..F S BIDATE=$O(^BITMP($J,1,BIDFN,BIMM,BIDATE)) Q:'BIDATE D
...N BIVIMM,Y S BIVIMM=0
...F S BIVIMM=$O(^BITMP($J,1,BIDFN,BIMM,BIDATE,BIVIMM)) Q:'BIVIMM D
....;---> Tack on V Imm IEN for matching ImmServe History.
....S Y=^BITMP($J,1,BIDFN,BIMM,BIDATE,BIVIMM)_"^"_BIVIMM
....D DOSES(Y,BIAGE,.BITMP,.BIDOSES)
.;
.;---> Log Errors (Field 1). 1=Do log errors, 0=Do NOT log errors. vvv83
.S BITMP1=+$P($G(^BISITE(+BIDUZ2,0)),U,26)
.;
.;---> Date used for Forecast (Field 2).
.S BITMP1=BITMP1_U_$$NOSLDT^BIUTL5(BIFDT)
.;
.;---> Fields 3-8 ignored by ImmServe.
.S BITMP1=BITMP1_"^0^0^0^0^0^0"
.;
.;---> Forecasting Mode: Minimum vs. Recommended Age (Field 9).
.S BITMP1=BITMP1_U_$$MINAGE^BIUTL2(BIDUZ2)
.;
.;---> Numbered Dose Processing Flag: Ignore Dose Numbers (Field 10).
.S BITMP1=BITMP1_U_"I"
.;
.;---> Invalid/Valid Dose Forecasting Interval: I-Consider Interval (Field 11).
.S BITMP1=BITMP1_U_"I"
.;
.;---> HEP B Series (Vaccine Group) Activation Flag (Field 12).
.S BITMP1=BITMP1_U_$S($D(BINF(4)):0,1:1)
.;
.;---> DTP Series (Vaccine Group) Activation Flag (Field 13).
.S BITMP1=BITMP1_U_$S($D(BINF(1)):0,1:1)
.;
.;---> Td ADULT/Booster Series (V Group) Activation Flag (Field 14).
.S BITMP1=BITMP1_U_$S($D(BINF(8)):0,1:1)
.;
.;---> HIB Series (Vaccine Group) Activation Flag (Field 15).
.S BITMP1=BITMP1_U_$S($D(BINF(3)):0,1:1)
.;
.;---> POLIO Series (Vaccine Group) Activation Flag (Field 16).
.S BITMP1=BITMP1_U_$S($D(BINF(2)):0,1:1)
.;
.;---> MMR Series (Vaccine Group) Activation Flag (Field 17).
.S BITMP1=BITMP1_U_$S($D(BINF(6)):0,1:1)
.;
.;---> HEP A Series (Vaccine Group) Activation Flag (Field 18).
.S BITMP1=BITMP1_U_$S($D(BINF(9)):0,1:1)
.;
.;---> VARICELLA Series (Vaccine Group) Activation Flag (Field 19).
.S BITMP1=BITMP1_U_$S($D(BINF(7)):0,1:1)
.;
.;---> ROTAVIRUS Series (Vaccine Group) Activation Flag (Field 20).
.S BITMP1=BITMP1_U_$S($D(BINF(15)):0,1:1)
.;
.;---> PNEUMO-CONJ Series (Vaccine Group) Activation Flag (Field 21).
.S BITMP1=BITMP1_U_$S($D(BINF(11)):0,1:1)
.;
.;---> INFLUENZA Series (Vaccine Group) Activation Flag (Field 22).
.S BITMP1=BITMP1_U_$S($D(BINF(10)):0,1:1)
.;
.;---> MENINGOCOCAL Series (Vaccine Group) Activation Flag (Field 23).
.S BITMP1=BITMP1_U_$S($D(BINF(16)):0,1:1)
.;
.;---> HPV Series (Vaccine Group) Activation Flag (Field 24).
.S BITMP1=BITMP1_U_$S($D(BINF(17)):0,1:1)
.;
.;---> H1N1 Series (Vaccine Group) Activation Flag (Field 25).
.;---> Imm Program has said to disable H1N1 forecasting.
.S BITMP1=BITMP1_U_0
.;
.;---> Version (Field 26).
.S BITMP1=BITMP1_U_$$RULES^BIUTL2(BIDUZ2)
.;
.;---> Forecasting days/month (Field 27).
.S BITMP1=BITMP1_U_0
.;
.;---> Retrospective Analysis days/month (Field 28).
.S BITMP1=BITMP1_U_0
.;
.;---> Personal ID: Patient Name and Chart# (Field 29)
.S BITMP1=BITMP1_U_$$NAME^BIUTL1(BIDFN)
.S BITMP1=BITMP1_" Chart#: "_$$HRCN^BIUTL1(BIDFN)
.;
.;---> User Note: DFN (Field 30)
.S BITMP1=BITMP1_U_BIDFN
.;
.;---> Date of Birth (Field 31).
.S BITMP1=BITMP1_U_$$NOSLDT^BIUTL5($$DOB^BIUTL1(BIDFN))
.;
.;---> Gender (Field 32).
.S BITMP1=BITMP1_U_$$SEXW^BIUTL1(BIDFN)
.;
.;---> Mother HBsAg Status: P,N,U,A (Field 33).
.S BITMP1=BITMP1_U_$$MOTHER^BIUTL11(BIDFN)
.;
.;---> Build array of contraindicated HL7 Codes for this Patient.
.N BICT D CONTRA^BIUTL11(BIDFN,.BICT)
.;
.;---> Pertussis Indication (Field 34).
.D
..;---> If patient has contra to DTP or DTaP, pass contra to pertussis.
..N I,J S J=0 F I=1,11,20 I $D(BICT(I)) S J=1 Q
..S BITMP1=BITMP1_U_J
.;
.;---> Diphtheria Indication (Field 35).
.D
..;---> If pt has contra to DT-PEDS or TD-Adult, pass contra to Diph.
..N I,J S J=0 F I=28,9 I $D(BICT(I)) S J=1 Q
..S BITMP1=BITMP1_U_J
.;
.;---> Tetanus Indication (Field 36).
.D
..;---> If pt has contra to TET TOX,
..;---> pass contra to Tetanus.
..N I,J S J=0 F I=28,9,35 I $D(BICT(I)) S J=1 Q
..S BITMP1=BITMP1_U_J
.;
.;---> Hib Indication (Field 37).
.D
..;---> If pt has contra to any HIB, pass contra to HIB.
..N I,J S J=0 F I=17,46,47,48,49 I $D(BICT(I)) S J=1 Q
..S BITMP1=BITMP1_U_J
.;
.;---> HBIG Indication (Field 38).
.S BITMP1=BITMP1_U_$S($D(BICT(30)):1,1:0)
.;
.;---> HepB Indication (Field 39).
.S BITMP1=BITMP1_U_$S($D(BICT(45)):1,1:0)
.;
.;---> OPV Indication (Field 40).
.;---> 2003: ImmServe no longer forecasts OPV.
.;S BITMP1=BITMP1_U_$S($D(BICT(2)):1,$D(BINF(2)):1,1:0)
.S BITMP1=BITMP1_U_0
.;
.;---> IPV Indication (Field 41).
.S BITMP1=BITMP1_U_$S($D(BICT(10)):1,1:0)
.;
.;---> Measles Indication (Field 42).
.S BITMP1=BITMP1_U_$S($D(BICT(5)):1,1:0)
.;
.;---> Mumps Indication (Field 43).
.S BITMP1=BITMP1_U_$S($D(BICT(7)):1,1:0)
.;
.;---> Rubella Indication (Field 44).
.S BITMP1=BITMP1_U_$S($D(BICT(6)):1,1:0)
.;
.;---> Varicella Indication (Field 45).
.S BITMP1=BITMP1_U_$S($D(BICT(21)):1,1:0)
.;
.;---> HepA Indication (Field 46).
.S BITMP1=BITMP1_U_$S($D(BICT(85)):1,1:0)
.;
.;---> Rotavirus Indication (Field 47).
.S BITMP1=BITMP1_U_$S($D(BICT(74)):1,1:0)
.;
.;---> Pneumococcal Indication (Field 48).
.S BITMP1=BITMP1_U_$S($D(BICT(100)):1,1:0)
.;
.;---> Influenza Indication (Field 49).
.S BITMP1=BITMP1_U_$S($D(BICT(88)):1,1:0)
.;
.;---> Meningococcal Indication (Field 50).
.S BITMP1=BITMP1_U_$S($D(BICT(32)):1,1:0)
.;
.;---> HPV Indication (Field 51).
.S BITMP1=BITMP1_U_$S($D(BICT(62)):1,1:0)
.;
.;---> H1N1 Indication (Field 52).
.D
..;---> If pt has contra to any H1N1, pass contra to H1N1.
..N I,J S J=0 F I=125,126,127,128 I $D(BICT(I)) S J=1 Q
..S BITMP1=BITMP1_U_J
.;
.;---> Number of Input Doses (Field 53).
.S BITMP1=BITMP1_U_BIDOSES
.;
.;---> Allow for Maximum Global Length to be as small as 255.
.;---> This gets picked up in +63^BIEXPRT4.
.S BITMP=BITMP1_BITMP
.S ^BITMP($J,2,BIDFN,1,1,1)=$E(BITMP,1,250)
.S:$L(BITMP)>250 ^BITMP($J,2,BIDFN,1,1,1,1)=$E(BITMP,251,500)
.S:$L(BITMP)>500 ^BITMP($J,2,BIDFN,1,1,1,2)=$E(BITMP,501,750)
.S:$L(BITMP)>750 ^BITMP($J,2,BIDFN,1,1,1,3)=$E(BITMP,751,1000)
.S:$L(BITMP)>1000 ^BITMP($J,2,BIDFN,1,1,1,4)=$E(BITMP,1001,1250)
.S:$L(BITMP)>1250 ^BITMP($J,2,BIDFN,1,1,1,5)=$E(BITMP,1251,1500)
.S:$L(BITMP)>1500 ^BITMP($J,2,BIDFN,1,1,1,6)=$E(BITMP,1501,1750)
.S:$L(BITMP)>1750 ^BITMP($J,2,BIDFN,1,1,1,7)=$E(BITMP,1751,2000)
Q
;
;----------
DOSES(Y,BIAGE,BITMP,BIDOSES) ;EP
;---> Add data (5 Immserve fields) for one dose to BITMP.
;---> Parameters:
; 1 - Y (req) Data for one visit, stored in ^BITMP($J,1,BIDFN...
; Date^HL7 Code^Dose Override^V Imm IEN.
; 2 - BIAGE (req) Patient Age in years (for translating Td).
; 3 - BITMP (ret) Data returned for one "Input Dose" to ImmServe.
; Dose Note (V Imm IEN)^HL7 Code^Dose Number^Date of Dose
; ^Dose Override.
; 4 - BIDOSES (ret) Total number of doses being collected to
; pass to ImmServe.
;
Q:$G(Y)=""
S:$G(BITMP)="" BITMP=""
S:$G(BIDOSES)="" BIDOSES=0
;
;---> Quit if no Dose HL7 Code or if NULL.
Q:"NULL"[$P(Y,U,2)
;
;************************
;---> Temp fix for Kinrix until v8.31.
;
;********** PATCH 1, v8.3.1, Dec 30,2008, IHS/CMI/MWR
;---> Next line commented out; KINFIX call no longer necessary (Immserve updated).
;---> But retain this call in case a future vaccine combo needs to be interpreted
;---> ahead of an Immserve update.
;
;I $P(Y,U,2)=130 D KINFIX(Y) Q
;
;---> Temp fix for Kinrix until v8.31.
;************************
;
;---> Dose Note - ^V Imm IEN (Field 52).
S BITMP=BITMP_U_$P(Y,U,4)
;
;---> Dose HL7/CVX Code (Field 53) * * * ALL OUTGOING TRANSLATIONS HERE * * *
D
.;---> If this is an Adult Td Booster and patient age>7, send -10 to ImmServe.
.I $P(Y,U,2)=9!($P(Y,U,2)=113) I BIAGE>6 S BITMP=BITMP_U_-10 Q
.;
.;---> If this is Tdap, send -13 to ImmServe.
.;
.;********** PATCH 2, v8.5, MAY 15,2012, IHS/CMI/MWR
.;---> Include CVX 20 (DTaP) in translation to -13, so that DTaP satisfies Tdap.
.;---> During Beta Test decision was made to abandon this for now, due to
.;---> complications. However, Tdap CVX 115 translated to -13 on 7yrs and older.
.I $P(Y,U,2)=115 I BIAGE>6 S BITMP=BITMP_U_-13 Q
.;I $P(Y,U,2)=115!($P(Y,U,2)=20) I BIAGE>6 S BITMP=BITMP_U_-13 Q
.;**********
.;
.;********** PATCH 2, v8.4.2, Oct 15,2010, IHS/CMI/MWR
.;---> Translate new Flu CVX Codes 140 & 141 to 15 until Immserve can accommodate.
.;---> If this is a new Flu, send 15.
.;
.;********** PATCH 5, v8.5, JUL 01,2013, IHS/CMI/MWR
.;---> Recognize new Flu Codes.
.;I ($P(Y,U,2)=140)!($P(Y,U,2)=141) S BITMP=BITMP_U_15 Q
.N Z S Z=($P(Y,U,2))
.I (Z=149)!(Z=150)!(Z=151)!(Z=153)!(Z=155)!(Z=158) S BITMP=BITMP_U_15 Q
.;**********
.;
.;---> No translation of this dose.
.S BITMP=BITMP_U_$P(Y,U,2)
;
;---> Dose Number--or "Series Number" (Field 54).
;---> New Version 8.x+ no longer tracks dose numbers (Field 54, 55, 56).
S BITMP=BITMP_"^0^0^0"
;
;---> Date of Dose Administration--Visit Date (Field 57).
S BITMP=BITMP_U_$P(Y,U)
;
;---> Dose Override: (Field 58).
;---> 0=Exclude if violates screening rules
;---> 1=Include even if violates screening rules
;---> 2=Exclude per user input (invalidated by user, e.g., expired vaccine).
D
.;---> Interpret Dose Override for ImmServe.
.N X S X=(+$P(Y,U,3))
.D:X
..I X=9 S X=1 Q
..S X=2
.S BITMP=BITMP_U_X
;
;---> Keep count of doses.
S BIDOSES=BIDOSES+1
Q
;
;
KINFIX(Y) ;EP
;---> TO ACCOMODATE IMMSERVE NOT RECOGNIZING KINRIX.
;---> DELETE THIS SECTION WITH NEW IMMSERVE, IMM V8.31.
N BIX F BIX=10,20 D
.;
.;---> Dose Note - ^V Imm IEN (Field 52).
.S BITMP=BITMP_U_$P(Y,U,4)
.;
.S BITMP=BITMP_U_BIX
.;
.;---> Dose Number--or "Series Number" (Field 54).
.;---> New Version 8.x+ no longer tracks dose numbers (Field 54, 55, 56).
.S BITMP=BITMP_"^0^0^0"
.;
.;---> Date of Dose Administration--Visit Date (Field 57).
.S BITMP=BITMP_U_$P(Y,U)
.;
.;---> Dose Override: (Field 58).
.;---> 0=Exclude if violates screening rules
.;---> 1=Include even if violates screening rules
.;---> 2=Exclude per user input (invalidated by user, e.g., expired vaccine).
.D
..;---> Interpret Dose Override for ImmServe.
..N X S X=(+$P(Y,U,3))
..D:X
...I X=9 S X=1 Q
...S X=2
..S BITMP=BITMP_U_X
.;
.;---> Keep count of doses.
.S BIDOSES=BIDOSES+1
Q
BIEXPRT5 ;IHS/CMI/MWR - EXPORT IMMUNIZATION RECORDS; OCT 15, 2010
+1 ;;8.5;IMMUNIZATION;**5**;JUL 01,2013
+2 ;;* MICHAEL REMILLARD, DDS * CIMARRON MEDICAL INFORMATICS, FOR IHS *
+3 ;; EXPORT IMMUNIZATION RECORDS: BUILD IMMSERVE EXPORT.
+4 ;; CALLED BY BIEXPRT3.
+5 ;; PATCH 2: Include CVX 20 (DTaP) in translation to -13, so that
+6 ;; DTaP satisfies Tdap. DOSES+42
+7 ;; PATCH 5: Translate new Flu codes to 15 for Immserve. DOSES+54
+8 ;
+9 ;
+10 ;----------
IMMSERV(BIFDT,BIDUZ2,BINF) ;EP
+1 ;---> Called by BIEXPRT3.
+2 ;---> Construct ^BITMP($J,2 nodes for ImmServe exports from the
+3 ;---> ^BITMP($J,1 nodes (gathered in ^BIEXPRT2).
+4 ;---> This prepares the string of Patient Data to be sent to
+5 ;---> Immserve for forecasting.
+6 ;---> Parameters:
+7 ; 1 - BIFDT (opt) Forecast Date (date used to calc Imms due).
+8 ; 2 - BIDUZ2 (opt) User's DUZ(2) for BISITE parameters,
+9 ; which affect forecasting rules.
+10 ; 3 - BINF (opt) Array of Vaccine IEN's that should not be forecast.
+11 ;
+12 ;---> If no Forecast Date passed, set it equal to today.
+13 IF '$GET(BIFDT)
SET BIFDT=DT
+14 ;
+15 ;---> If no BIDUZ2, try DUZ(2); otherwise, defaults will be used.
+16 IF '$GET(BIDUZ2)
SET BIDUZ2=$GET(DUZ(2))
+17 ;
+18 NEW BIDFN
SET BIDFN=0
+19 FOR
SET BIDFN=$ORDER(^BITMP($JOB,1,BIDFN))
IF 'BIDFN
QUIT
Begin DoDot:1
+20 NEW BIAGE,BIDOSES,BIMM,BITMP,BITMP1
SET BIDOSES=0
SET BIMM=0
SET BITMP=""
+21 ;---> Set Patient Age in Years for this Forecast Date.
+22 SET BIAGE=$$AGE^BIUTL1(BIDFN,1,BIFDT)
+23 FOR
SET BIMM=$ORDER(^BITMP($JOB,1,BIDFN,BIMM))
IF 'BIMM
QUIT
Begin DoDot:2
+24 NEW BIDATE,Y
SET BIDATE=0
+25 FOR
SET BIDATE=$ORDER(^BITMP($JOB,1,BIDFN,BIMM,BIDATE))
IF 'BIDATE
QUIT
Begin DoDot:3
+26 NEW BIVIMM,Y
SET BIVIMM=0
+27 FOR
SET BIVIMM=$ORDER(^BITMP($JOB,1,BIDFN,BIMM,BIDATE,BIVIMM))
IF 'BIVIMM
QUIT
Begin DoDot:4
+28 ;---> Tack on V Imm IEN for matching ImmServe History.
+29 SET Y=^BITMP($JOB,1,BIDFN,BIMM,BIDATE,BIVIMM)_"^"_BIVIMM
+30 DO DOSES(Y,BIAGE,.BITMP,.BIDOSES)
End DoDot:4
End DoDot:3
End DoDot:2
+31 ;
+32 ;---> Log Errors (Field 1). 1=Do log errors, 0=Do NOT log errors. vvv83
+33 SET BITMP1=+$PIECE($GET(^BISITE(+BIDUZ2,0)),U,26)
+34 ;
+35 ;---> Date used for Forecast (Field 2).
+36 SET BITMP1=BITMP1_U_$$NOSLDT^BIUTL5(BIFDT)
+37 ;
+38 ;---> Fields 3-8 ignored by ImmServe.
+39 SET BITMP1=BITMP1_"^0^0^0^0^0^0"
+40 ;
+41 ;---> Forecasting Mode: Minimum vs. Recommended Age (Field 9).
+42 SET BITMP1=BITMP1_U_$$MINAGE^BIUTL2(BIDUZ2)
+43 ;
+44 ;---> Numbered Dose Processing Flag: Ignore Dose Numbers (Field 10).
+45 SET BITMP1=BITMP1_U_"I"
+46 ;
+47 ;---> Invalid/Valid Dose Forecasting Interval: I-Consider Interval (Field 11).
+48 SET BITMP1=BITMP1_U_"I"
+49 ;
+50 ;---> HEP B Series (Vaccine Group) Activation Flag (Field 12).
+51 SET BITMP1=BITMP1_U_$SELECT($DATA(BINF(4)):0,1:1)
+52 ;
+53 ;---> DTP Series (Vaccine Group) Activation Flag (Field 13).
+54 SET BITMP1=BITMP1_U_$SELECT($DATA(BINF(1)):0,1:1)
+55 ;
+56 ;---> Td ADULT/Booster Series (V Group) Activation Flag (Field 14).
+57 SET BITMP1=BITMP1_U_$SELECT($DATA(BINF(8)):0,1:1)
+58 ;
+59 ;---> HIB Series (Vaccine Group) Activation Flag (Field 15).
+60 SET BITMP1=BITMP1_U_$SELECT($DATA(BINF(3)):0,1:1)
+61 ;
+62 ;---> POLIO Series (Vaccine Group) Activation Flag (Field 16).
+63 SET BITMP1=BITMP1_U_$SELECT($DATA(BINF(2)):0,1:1)
+64 ;
+65 ;---> MMR Series (Vaccine Group) Activation Flag (Field 17).
+66 SET BITMP1=BITMP1_U_$SELECT($DATA(BINF(6)):0,1:1)
+67 ;
+68 ;---> HEP A Series (Vaccine Group) Activation Flag (Field 18).
+69 SET BITMP1=BITMP1_U_$SELECT($DATA(BINF(9)):0,1:1)
+70 ;
+71 ;---> VARICELLA Series (Vaccine Group) Activation Flag (Field 19).
+72 SET BITMP1=BITMP1_U_$SELECT($DATA(BINF(7)):0,1:1)
+73 ;
+74 ;---> ROTAVIRUS Series (Vaccine Group) Activation Flag (Field 20).
+75 SET BITMP1=BITMP1_U_$SELECT($DATA(BINF(15)):0,1:1)
+76 ;
+77 ;---> PNEUMO-CONJ Series (Vaccine Group) Activation Flag (Field 21).
+78 SET BITMP1=BITMP1_U_$SELECT($DATA(BINF(11)):0,1:1)
+79 ;
+80 ;---> INFLUENZA Series (Vaccine Group) Activation Flag (Field 22).
+81 SET BITMP1=BITMP1_U_$SELECT($DATA(BINF(10)):0,1:1)
+82 ;
+83 ;---> MENINGOCOCAL Series (Vaccine Group) Activation Flag (Field 23).
+84 SET BITMP1=BITMP1_U_$SELECT($DATA(BINF(16)):0,1:1)
+85 ;
+86 ;---> HPV Series (Vaccine Group) Activation Flag (Field 24).
+87 SET BITMP1=BITMP1_U_$SELECT($DATA(BINF(17)):0,1:1)
+88 ;
+89 ;---> H1N1 Series (Vaccine Group) Activation Flag (Field 25).
+90 ;---> Imm Program has said to disable H1N1 forecasting.
+91 SET BITMP1=BITMP1_U_0
+92 ;
+93 ;---> Version (Field 26).
+94 SET BITMP1=BITMP1_U_$$RULES^BIUTL2(BIDUZ2)
+95 ;
+96 ;---> Forecasting days/month (Field 27).
+97 SET BITMP1=BITMP1_U_0
+98 ;
+99 ;---> Retrospective Analysis days/month (Field 28).
+100 SET BITMP1=BITMP1_U_0
+101 ;
+102 ;---> Personal ID: Patient Name and Chart# (Field 29)
+103 SET BITMP1=BITMP1_U_$$NAME^BIUTL1(BIDFN)
+104 SET BITMP1=BITMP1_" Chart#: "_$$HRCN^BIUTL1(BIDFN)
+105 ;
+106 ;---> User Note: DFN (Field 30)
+107 SET BITMP1=BITMP1_U_BIDFN
+108 ;
+109 ;---> Date of Birth (Field 31).
+110 SET BITMP1=BITMP1_U_$$NOSLDT^BIUTL5($$DOB^BIUTL1(BIDFN))
+111 ;
+112 ;---> Gender (Field 32).
+113 SET BITMP1=BITMP1_U_$$SEXW^BIUTL1(BIDFN)
+114 ;
+115 ;---> Mother HBsAg Status: P,N,U,A (Field 33).
+116 SET BITMP1=BITMP1_U_$$MOTHER^BIUTL11(BIDFN)
+117 ;
+118 ;---> Build array of contraindicated HL7 Codes for this Patient.
+119 NEW BICT
DO CONTRA^BIUTL11(BIDFN,.BICT)
+120 ;
+121 ;---> Pertussis Indication (Field 34).
+122 Begin DoDot:2
+123 ;---> If patient has contra to DTP or DTaP, pass contra to pertussis.
+124 NEW I,J
SET J=0
FOR I=1,11,20
IF $DATA(BICT(I))
SET J=1
QUIT
+125 SET BITMP1=BITMP1_U_J
End DoDot:2
+126 ;
+127 ;---> Diphtheria Indication (Field 35).
+128 Begin DoDot:2
+129 ;---> If pt has contra to DT-PEDS or TD-Adult, pass contra to Diph.
+130 NEW I,J
SET J=0
FOR I=28,9
IF $DATA(BICT(I))
SET J=1
QUIT
+131 SET BITMP1=BITMP1_U_J
End DoDot:2
+132 ;
+133 ;---> Tetanus Indication (Field 36).
+134 Begin DoDot:2
+135 ;---> If pt has contra to TET TOX,
+136 ;---> pass contra to Tetanus.
+137 NEW I,J
SET J=0
FOR I=28,9,35
IF $DATA(BICT(I))
SET J=1
QUIT
+138 SET BITMP1=BITMP1_U_J
End DoDot:2
+139 ;
+140 ;---> Hib Indication (Field 37).
+141 Begin DoDot:2
+142 ;---> If pt has contra to any HIB, pass contra to HIB.
+143 NEW I,J
SET J=0
FOR I=17,46,47,48,49
IF $DATA(BICT(I))
SET J=1
QUIT
+144 SET BITMP1=BITMP1_U_J
End DoDot:2
+145 ;
+146 ;---> HBIG Indication (Field 38).
+147 SET BITMP1=BITMP1_U_$SELECT($DATA(BICT(30)):1,1:0)
+148 ;
+149 ;---> HepB Indication (Field 39).
+150 SET BITMP1=BITMP1_U_$SELECT($DATA(BICT(45)):1,1:0)
+151 ;
+152 ;---> OPV Indication (Field 40).
+153 ;---> 2003: ImmServe no longer forecasts OPV.
+154 ;S BITMP1=BITMP1_U_$S($D(BICT(2)):1,$D(BINF(2)):1,1:0)
+155 SET BITMP1=BITMP1_U_0
+156 ;
+157 ;---> IPV Indication (Field 41).
+158 SET BITMP1=BITMP1_U_$SELECT($DATA(BICT(10)):1,1:0)
+159 ;
+160 ;---> Measles Indication (Field 42).
+161 SET BITMP1=BITMP1_U_$SELECT($DATA(BICT(5)):1,1:0)
+162 ;
+163 ;---> Mumps Indication (Field 43).
+164 SET BITMP1=BITMP1_U_$SELECT($DATA(BICT(7)):1,1:0)
+165 ;
+166 ;---> Rubella Indication (Field 44).
+167 SET BITMP1=BITMP1_U_$SELECT($DATA(BICT(6)):1,1:0)
+168 ;
+169 ;---> Varicella Indication (Field 45).
+170 SET BITMP1=BITMP1_U_$SELECT($DATA(BICT(21)):1,1:0)
+171 ;
+172 ;---> HepA Indication (Field 46).
+173 SET BITMP1=BITMP1_U_$SELECT($DATA(BICT(85)):1,1:0)
+174 ;
+175 ;---> Rotavirus Indication (Field 47).
+176 SET BITMP1=BITMP1_U_$SELECT($DATA(BICT(74)):1,1:0)
+177 ;
+178 ;---> Pneumococcal Indication (Field 48).
+179 SET BITMP1=BITMP1_U_$SELECT($DATA(BICT(100)):1,1:0)
+180 ;
+181 ;---> Influenza Indication (Field 49).
+182 SET BITMP1=BITMP1_U_$SELECT($DATA(BICT(88)):1,1:0)
+183 ;
+184 ;---> Meningococcal Indication (Field 50).
+185 SET BITMP1=BITMP1_U_$SELECT($DATA(BICT(32)):1,1:0)
+186 ;
+187 ;---> HPV Indication (Field 51).
+188 SET BITMP1=BITMP1_U_$SELECT($DATA(BICT(62)):1,1:0)
+189 ;
+190 ;---> H1N1 Indication (Field 52).
+191 Begin DoDot:2
+192 ;---> If pt has contra to any H1N1, pass contra to H1N1.
+193 NEW I,J
SET J=0
FOR I=125,126,127,128
IF $DATA(BICT(I))
SET J=1
QUIT
+194 SET BITMP1=BITMP1_U_J
End DoDot:2
+195 ;
+196 ;---> Number of Input Doses (Field 53).
+197 SET BITMP1=BITMP1_U_BIDOSES
+198 ;
+199 ;---> Allow for Maximum Global Length to be as small as 255.
+200 ;---> This gets picked up in +63^BIEXPRT4.
+201 SET BITMP=BITMP1_BITMP
+202 SET ^BITMP($JOB,2,BIDFN,1,1,1)=$EXTRACT(BITMP,1,250)
+203 IF $LENGTH(BITMP)>250
SET ^BITMP($JOB,2,BIDFN,1,1,1,1)=$EXTRACT(BITMP,251,500)
+204 IF $LENGTH(BITMP)>500
SET ^BITMP($JOB,2,BIDFN,1,1,1,2)=$EXTRACT(BITMP,501,750)
+205 IF $LENGTH(BITMP)>750
SET ^BITMP($JOB,2,BIDFN,1,1,1,3)=$EXTRACT(BITMP,751,1000)
+206 IF $LENGTH(BITMP)>1000
SET ^BITMP($JOB,2,BIDFN,1,1,1,4)=$EXTRACT(BITMP,1001,1250)
+207 IF $LENGTH(BITMP)>1250
SET ^BITMP($JOB,2,BIDFN,1,1,1,5)=$EXTRACT(BITMP,1251,1500)
+208 IF $LENGTH(BITMP)>1500
SET ^BITMP($JOB,2,BIDFN,1,1,1,6)=$EXTRACT(BITMP,1501,1750)
+209 IF $LENGTH(BITMP)>1750
SET ^BITMP($JOB,2,BIDFN,1,1,1,7)=$EXTRACT(BITMP,1751,2000)
End DoDot:1
+210 QUIT
+211 ;
+212 ;----------
DOSES(Y,BIAGE,BITMP,BIDOSES) ;EP
+1 ;---> Add data (5 Immserve fields) for one dose to BITMP.
+2 ;---> Parameters:
+3 ; 1 - Y (req) Data for one visit, stored in ^BITMP($J,1,BIDFN...
+4 ; Date^HL7 Code^Dose Override^V Imm IEN.
+5 ; 2 - BIAGE (req) Patient Age in years (for translating Td).
+6 ; 3 - BITMP (ret) Data returned for one "Input Dose" to ImmServe.
+7 ; Dose Note (V Imm IEN)^HL7 Code^Dose Number^Date of Dose
+8 ; ^Dose Override.
+9 ; 4 - BIDOSES (ret) Total number of doses being collected to
+10 ; pass to ImmServe.
+11 ;
+12 IF $GET(Y)=""
QUIT
+13 IF $GET(BITMP)=""
SET BITMP=""
+14 IF $GET(BIDOSES)=""
SET BIDOSES=0
+15 ;
+16 ;---> Quit if no Dose HL7 Code or if NULL.
+17 IF "NULL"[$PIECE(Y,U,2)
QUIT
+18 ;
+19 ;************************
+20 ;---> Temp fix for Kinrix until v8.31.
+21 ;
+22 ;********** PATCH 1, v8.3.1, Dec 30,2008, IHS/CMI/MWR
+23 ;---> Next line commented out; KINFIX call no longer necessary (Immserve updated).
+24 ;---> But retain this call in case a future vaccine combo needs to be interpreted
+25 ;---> ahead of an Immserve update.
+26 ;
+27 ;I $P(Y,U,2)=130 D KINFIX(Y) Q
+28 ;
+29 ;---> Temp fix for Kinrix until v8.31.
+30 ;************************
+31 ;
+32 ;---> Dose Note - ^V Imm IEN (Field 52).
+33 SET BITMP=BITMP_U_$PIECE(Y,U,4)
+34 ;
+35 ;---> Dose HL7/CVX Code (Field 53) * * * ALL OUTGOING TRANSLATIONS HERE * * *
+36 Begin DoDot:1
+37 ;---> If this is an Adult Td Booster and patient age>7, send -10 to ImmServe.
+38 IF $PIECE(Y,U,2)=9!($PIECE(Y,U,2)=113)
IF BIAGE>6
SET BITMP=BITMP_U_-10
QUIT
+39 ;
+40 ;---> If this is Tdap, send -13 to ImmServe.
+41 ;
+42 ;********** PATCH 2, v8.5, MAY 15,2012, IHS/CMI/MWR
+43 ;---> Include CVX 20 (DTaP) in translation to -13, so that DTaP satisfies Tdap.
+44 ;---> During Beta Test decision was made to abandon this for now, due to
+45 ;---> complications. However, Tdap CVX 115 translated to -13 on 7yrs and older.
+46 IF $PIECE(Y,U,2)=115
IF BIAGE>6
SET BITMP=BITMP_U_-13
QUIT
+47 ;I $P(Y,U,2)=115!($P(Y,U,2)=20) I BIAGE>6 S BITMP=BITMP_U_-13 Q
+48 ;**********
+49 ;
+50 ;********** PATCH 2, v8.4.2, Oct 15,2010, IHS/CMI/MWR
+51 ;---> Translate new Flu CVX Codes 140 & 141 to 15 until Immserve can accommodate.
+52 ;---> If this is a new Flu, send 15.
+53 ;
+54 ;********** PATCH 5, v8.5, JUL 01,2013, IHS/CMI/MWR
+55 ;---> Recognize new Flu Codes.
+56 ;I ($P(Y,U,2)=140)!($P(Y,U,2)=141) S BITMP=BITMP_U_15 Q
+57 NEW Z
SET Z=($PIECE(Y,U,2))
+58 IF (Z=149)!(Z=150)!(Z=151)!(Z=153)!(Z=155)!(Z=158)
SET BITMP=BITMP_U_15
QUIT
+59 ;**********
+60 ;
+61 ;---> No translation of this dose.
+62 SET BITMP=BITMP_U_$PIECE(Y,U,2)
End DoDot:1
+63 ;
+64 ;---> Dose Number--or "Series Number" (Field 54).
+65 ;---> New Version 8.x+ no longer tracks dose numbers (Field 54, 55, 56).
+66 SET BITMP=BITMP_"^0^0^0"
+67 ;
+68 ;---> Date of Dose Administration--Visit Date (Field 57).
+69 SET BITMP=BITMP_U_$PIECE(Y,U)
+70 ;
+71 ;---> Dose Override: (Field 58).
+72 ;---> 0=Exclude if violates screening rules
+73 ;---> 1=Include even if violates screening rules
+74 ;---> 2=Exclude per user input (invalidated by user, e.g., expired vaccine).
+75 Begin DoDot:1
+76 ;---> Interpret Dose Override for ImmServe.
+77 NEW X
SET X=(+$PIECE(Y,U,3))
+78 IF X
Begin DoDot:2
+79 IF X=9
SET X=1
QUIT
+80 SET X=2
End DoDot:2
+81 SET BITMP=BITMP_U_X
End DoDot:1
+82 ;
+83 ;---> Keep count of doses.
+84 SET BIDOSES=BIDOSES+1
+85 QUIT
+86 ;
+87 ;
KINFIX(Y) ;EP
+1 ;---> TO ACCOMODATE IMMSERVE NOT RECOGNIZING KINRIX.
+2 ;---> DELETE THIS SECTION WITH NEW IMMSERVE, IMM V8.31.
+3 NEW BIX
FOR BIX=10,20
Begin DoDot:1
+4 ;
+5 ;---> Dose Note - ^V Imm IEN (Field 52).
+6 SET BITMP=BITMP_U_$PIECE(Y,U,4)
+7 ;
+8 SET BITMP=BITMP_U_BIX
+9 ;
+10 ;---> Dose Number--or "Series Number" (Field 54).
+11 ;---> New Version 8.x+ no longer tracks dose numbers (Field 54, 55, 56).
+12 SET BITMP=BITMP_"^0^0^0"
+13 ;
+14 ;---> Date of Dose Administration--Visit Date (Field 57).
+15 SET BITMP=BITMP_U_$PIECE(Y,U)
+16 ;
+17 ;---> Dose Override: (Field 58).
+18 ;---> 0=Exclude if violates screening rules
+19 ;---> 1=Include even if violates screening rules
+20 ;---> 2=Exclude per user input (invalidated by user, e.g., expired vaccine).
+21 Begin DoDot:2
+22 ;---> Interpret Dose Override for ImmServe.
+23 NEW X
SET X=(+$PIECE(Y,U,3))
+24 IF X
Begin DoDot:3
+25 IF X=9
SET X=1
QUIT
+26 SET X=2
End DoDot:3
+27 SET BITMP=BITMP_U_X
End DoDot:2
+28 ;
+29 ;---> Keep count of doses.
+30 SET BIDOSES=BIDOSES+1
End DoDot:1
+31 QUIT