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

BIEXPRT5.m

Go to the documentation of this file.
  1. BIEXPRT5 ;IHS/CMI/MWR - EXPORT IMMUNIZATION RECORDS; OCT 15, 2010
  1. ;;8.5;IMMUNIZATION;**5**;JUL 01,2013
  1. ;;* MICHAEL REMILLARD, DDS * CIMARRON MEDICAL INFORMATICS, FOR IHS *
  1. ;; EXPORT IMMUNIZATION RECORDS: BUILD IMMSERVE EXPORT.
  1. ;; CALLED BY BIEXPRT3.
  1. ;; PATCH 2: Include CVX 20 (DTaP) in translation to -13, so that
  1. ;; DTaP satisfies Tdap. DOSES+42
  1. ;; PATCH 5: Translate new Flu codes to 15 for Immserve. DOSES+54
  1. ;
  1. ;
  1. ;----------
  1. IMMSERV(BIFDT,BIDUZ2,BINF) ;EP
  1. ;---> Called by BIEXPRT3.
  1. ;---> Construct ^BITMP($J,2 nodes for ImmServe exports from the
  1. ;---> ^BITMP($J,1 nodes (gathered in ^BIEXPRT2).
  1. ;---> This prepares the string of Patient Data to be sent to
  1. ;---> Immserve for forecasting.
  1. ;---> Parameters:
  1. ; 1 - BIFDT (opt) Forecast Date (date used to calc Imms due).
  1. ; 2 - BIDUZ2 (opt) User's DUZ(2) for BISITE parameters,
  1. ; which affect forecasting rules.
  1. ; 3 - BINF (opt) Array of Vaccine IEN's that should not be forecast.
  1. ;
  1. ;---> If no Forecast Date passed, set it equal to today.
  1. S:'$G(BIFDT) BIFDT=DT
  1. ;
  1. ;---> If no BIDUZ2, try DUZ(2); otherwise, defaults will be used.
  1. S:'$G(BIDUZ2) BIDUZ2=$G(DUZ(2))
  1. ;
  1. N BIDFN S BIDFN=0
  1. F S BIDFN=$O(^BITMP($J,1,BIDFN)) Q:'BIDFN D
  1. .N BIAGE,BIDOSES,BIMM,BITMP,BITMP1 S BIDOSES=0,BIMM=0,BITMP=""
  1. .;---> Set Patient Age in Years for this Forecast Date.
  1. .S BIAGE=$$AGE^BIUTL1(BIDFN,1,BIFDT)
  1. .F S BIMM=$O(^BITMP($J,1,BIDFN,BIMM)) Q:'BIMM D
  1. ..N BIDATE,Y S BIDATE=0
  1. ..F S BIDATE=$O(^BITMP($J,1,BIDFN,BIMM,BIDATE)) Q:'BIDATE D
  1. ...N BIVIMM,Y S BIVIMM=0
  1. ...F S BIVIMM=$O(^BITMP($J,1,BIDFN,BIMM,BIDATE,BIVIMM)) Q:'BIVIMM D
  1. ....;---> Tack on V Imm IEN for matching ImmServe History.
  1. ....S Y=^BITMP($J,1,BIDFN,BIMM,BIDATE,BIVIMM)_"^"_BIVIMM
  1. ....D DOSES(Y,BIAGE,.BITMP,.BIDOSES)
  1. .;
  1. .;---> Log Errors (Field 1). 1=Do log errors, 0=Do NOT log errors. vvv83
  1. .S BITMP1=+$P($G(^BISITE(+BIDUZ2,0)),U,26)
  1. .;
  1. .;---> Date used for Forecast (Field 2).
  1. .S BITMP1=BITMP1_U_$$NOSLDT^BIUTL5(BIFDT)
  1. .;
  1. .;---> Fields 3-8 ignored by ImmServe.
  1. .S BITMP1=BITMP1_"^0^0^0^0^0^0"
  1. .;
  1. .;---> Forecasting Mode: Minimum vs. Recommended Age (Field 9).
  1. .S BITMP1=BITMP1_U_$$MINAGE^BIUTL2(BIDUZ2)
  1. .;
  1. .;---> Numbered Dose Processing Flag: Ignore Dose Numbers (Field 10).
  1. .S BITMP1=BITMP1_U_"I"
  1. .;
  1. .;---> Invalid/Valid Dose Forecasting Interval: I-Consider Interval (Field 11).
  1. .S BITMP1=BITMP1_U_"I"
  1. .;
  1. .;---> HEP B Series (Vaccine Group) Activation Flag (Field 12).
  1. .S BITMP1=BITMP1_U_$S($D(BINF(4)):0,1:1)
  1. .;
  1. .;---> DTP Series (Vaccine Group) Activation Flag (Field 13).
  1. .S BITMP1=BITMP1_U_$S($D(BINF(1)):0,1:1)
  1. .;
  1. .;---> Td ADULT/Booster Series (V Group) Activation Flag (Field 14).
  1. .S BITMP1=BITMP1_U_$S($D(BINF(8)):0,1:1)
  1. .;
  1. .;---> HIB Series (Vaccine Group) Activation Flag (Field 15).
  1. .S BITMP1=BITMP1_U_$S($D(BINF(3)):0,1:1)
  1. .;
  1. .;---> POLIO Series (Vaccine Group) Activation Flag (Field 16).
  1. .S BITMP1=BITMP1_U_$S($D(BINF(2)):0,1:1)
  1. .;
  1. .;---> MMR Series (Vaccine Group) Activation Flag (Field 17).
  1. .S BITMP1=BITMP1_U_$S($D(BINF(6)):0,1:1)
  1. .;
  1. .;---> HEP A Series (Vaccine Group) Activation Flag (Field 18).
  1. .S BITMP1=BITMP1_U_$S($D(BINF(9)):0,1:1)
  1. .;
  1. .;---> VARICELLA Series (Vaccine Group) Activation Flag (Field 19).
  1. .S BITMP1=BITMP1_U_$S($D(BINF(7)):0,1:1)
  1. .;
  1. .;---> ROTAVIRUS Series (Vaccine Group) Activation Flag (Field 20).
  1. .S BITMP1=BITMP1_U_$S($D(BINF(15)):0,1:1)
  1. .;
  1. .;---> PNEUMO-CONJ Series (Vaccine Group) Activation Flag (Field 21).
  1. .S BITMP1=BITMP1_U_$S($D(BINF(11)):0,1:1)
  1. .;
  1. .;---> INFLUENZA Series (Vaccine Group) Activation Flag (Field 22).
  1. .S BITMP1=BITMP1_U_$S($D(BINF(10)):0,1:1)
  1. .;
  1. .;---> MENINGOCOCAL Series (Vaccine Group) Activation Flag (Field 23).
  1. .S BITMP1=BITMP1_U_$S($D(BINF(16)):0,1:1)
  1. .;
  1. .;---> HPV Series (Vaccine Group) Activation Flag (Field 24).
  1. .S BITMP1=BITMP1_U_$S($D(BINF(17)):0,1:1)
  1. .;
  1. .;---> H1N1 Series (Vaccine Group) Activation Flag (Field 25).
  1. .;---> Imm Program has said to disable H1N1 forecasting.
  1. .S BITMP1=BITMP1_U_0
  1. .;
  1. .;---> Version (Field 26).
  1. .S BITMP1=BITMP1_U_$$RULES^BIUTL2(BIDUZ2)
  1. .;
  1. .;---> Forecasting days/month (Field 27).
  1. .S BITMP1=BITMP1_U_0
  1. .;
  1. .;---> Retrospective Analysis days/month (Field 28).
  1. .S BITMP1=BITMP1_U_0
  1. .;
  1. .;---> Personal ID: Patient Name and Chart# (Field 29)
  1. .S BITMP1=BITMP1_U_$$NAME^BIUTL1(BIDFN)
  1. .S BITMP1=BITMP1_" Chart#: "_$$HRCN^BIUTL1(BIDFN)
  1. .;
  1. .;---> User Note: DFN (Field 30)
  1. .S BITMP1=BITMP1_U_BIDFN
  1. .;
  1. .;---> Date of Birth (Field 31).
  1. .S BITMP1=BITMP1_U_$$NOSLDT^BIUTL5($$DOB^BIUTL1(BIDFN))
  1. .;
  1. .;---> Gender (Field 32).
  1. .S BITMP1=BITMP1_U_$$SEXW^BIUTL1(BIDFN)
  1. .;
  1. .;---> Mother HBsAg Status: P,N,U,A (Field 33).
  1. .S BITMP1=BITMP1_U_$$MOTHER^BIUTL11(BIDFN)
  1. .;
  1. .;---> Build array of contraindicated HL7 Codes for this Patient.
  1. .N BICT D CONTRA^BIUTL11(BIDFN,.BICT)
  1. .;
  1. .;---> Pertussis Indication (Field 34).
  1. .D
  1. ..;---> If patient has contra to DTP or DTaP, pass contra to pertussis.
  1. ..N I,J S J=0 F I=1,11,20 I $D(BICT(I)) S J=1 Q
  1. ..S BITMP1=BITMP1_U_J
  1. .;
  1. .;---> Diphtheria Indication (Field 35).
  1. .D
  1. ..;---> If pt has contra to DT-PEDS or TD-Adult, pass contra to Diph.
  1. ..N I,J S J=0 F I=28,9 I $D(BICT(I)) S J=1 Q
  1. ..S BITMP1=BITMP1_U_J
  1. .;
  1. .;---> Tetanus Indication (Field 36).
  1. .D
  1. ..;---> If pt has contra to TET TOX,
  1. ..;---> pass contra to Tetanus.
  1. ..N I,J S J=0 F I=28,9,35 I $D(BICT(I)) S J=1 Q
  1. ..S BITMP1=BITMP1_U_J
  1. .;
  1. .;---> Hib Indication (Field 37).
  1. .D
  1. ..;---> If pt has contra to any HIB, pass contra to HIB.
  1. ..N I,J S J=0 F I=17,46,47,48,49 I $D(BICT(I)) S J=1 Q
  1. ..S BITMP1=BITMP1_U_J
  1. .;
  1. .;---> HBIG Indication (Field 38).
  1. .S BITMP1=BITMP1_U_$S($D(BICT(30)):1,1:0)
  1. .;
  1. .;---> HepB Indication (Field 39).
  1. .S BITMP1=BITMP1_U_$S($D(BICT(45)):1,1:0)
  1. .;
  1. .;---> OPV Indication (Field 40).
  1. .;---> 2003: ImmServe no longer forecasts OPV.
  1. .;S BITMP1=BITMP1_U_$S($D(BICT(2)):1,$D(BINF(2)):1,1:0)
  1. .S BITMP1=BITMP1_U_0
  1. .;
  1. .;---> IPV Indication (Field 41).
  1. .S BITMP1=BITMP1_U_$S($D(BICT(10)):1,1:0)
  1. .;
  1. .;---> Measles Indication (Field 42).
  1. .S BITMP1=BITMP1_U_$S($D(BICT(5)):1,1:0)
  1. .;
  1. .;---> Mumps Indication (Field 43).
  1. .S BITMP1=BITMP1_U_$S($D(BICT(7)):1,1:0)
  1. .;
  1. .;---> Rubella Indication (Field 44).
  1. .S BITMP1=BITMP1_U_$S($D(BICT(6)):1,1:0)
  1. .;
  1. .;---> Varicella Indication (Field 45).
  1. .S BITMP1=BITMP1_U_$S($D(BICT(21)):1,1:0)
  1. .;
  1. .;---> HepA Indication (Field 46).
  1. .S BITMP1=BITMP1_U_$S($D(BICT(85)):1,1:0)
  1. .;
  1. .;---> Rotavirus Indication (Field 47).
  1. .S BITMP1=BITMP1_U_$S($D(BICT(74)):1,1:0)
  1. .;
  1. .;---> Pneumococcal Indication (Field 48).
  1. .S BITMP1=BITMP1_U_$S($D(BICT(100)):1,1:0)
  1. .;
  1. .;---> Influenza Indication (Field 49).
  1. .S BITMP1=BITMP1_U_$S($D(BICT(88)):1,1:0)
  1. .;
  1. .;---> Meningococcal Indication (Field 50).
  1. .S BITMP1=BITMP1_U_$S($D(BICT(32)):1,1:0)
  1. .;
  1. .;---> HPV Indication (Field 51).
  1. .S BITMP1=BITMP1_U_$S($D(BICT(62)):1,1:0)
  1. .;
  1. .;---> H1N1 Indication (Field 52).
  1. .D
  1. ..;---> If pt has contra to any H1N1, pass contra to H1N1.
  1. ..N I,J S J=0 F I=125,126,127,128 I $D(BICT(I)) S J=1 Q
  1. ..S BITMP1=BITMP1_U_J
  1. .;
  1. .;---> Number of Input Doses (Field 53).
  1. .S BITMP1=BITMP1_U_BIDOSES
  1. .;
  1. .;---> Allow for Maximum Global Length to be as small as 255.
  1. .;---> This gets picked up in +63^BIEXPRT4.
  1. .S BITMP=BITMP1_BITMP
  1. .S ^BITMP($J,2,BIDFN,1,1,1)=$E(BITMP,1,250)
  1. .S:$L(BITMP)>250 ^BITMP($J,2,BIDFN,1,1,1,1)=$E(BITMP,251,500)
  1. .S:$L(BITMP)>500 ^BITMP($J,2,BIDFN,1,1,1,2)=$E(BITMP,501,750)
  1. .S:$L(BITMP)>750 ^BITMP($J,2,BIDFN,1,1,1,3)=$E(BITMP,751,1000)
  1. .S:$L(BITMP)>1000 ^BITMP($J,2,BIDFN,1,1,1,4)=$E(BITMP,1001,1250)
  1. .S:$L(BITMP)>1250 ^BITMP($J,2,BIDFN,1,1,1,5)=$E(BITMP,1251,1500)
  1. .S:$L(BITMP)>1500 ^BITMP($J,2,BIDFN,1,1,1,6)=$E(BITMP,1501,1750)
  1. .S:$L(BITMP)>1750 ^BITMP($J,2,BIDFN,1,1,1,7)=$E(BITMP,1751,2000)
  1. Q
  1. ;
  1. ;----------
  1. DOSES(Y,BIAGE,BITMP,BIDOSES) ;EP
  1. ;---> Add data (5 Immserve fields) for one dose to BITMP.
  1. ;---> Parameters:
  1. ; 1 - Y (req) Data for one visit, stored in ^BITMP($J,1,BIDFN...
  1. ; Date^HL7 Code^Dose Override^V Imm IEN.
  1. ; 2 - BIAGE (req) Patient Age in years (for translating Td).
  1. ; 3 - BITMP (ret) Data returned for one "Input Dose" to ImmServe.
  1. ; Dose Note (V Imm IEN)^HL7 Code^Dose Number^Date of Dose
  1. ; ^Dose Override.
  1. ; 4 - BIDOSES (ret) Total number of doses being collected to
  1. ; pass to ImmServe.
  1. ;
  1. Q:$G(Y)=""
  1. S:$G(BITMP)="" BITMP=""
  1. S:$G(BIDOSES)="" BIDOSES=0
  1. ;
  1. ;---> Quit if no Dose HL7 Code or if NULL.
  1. Q:"NULL"[$P(Y,U,2)
  1. ;
  1. ;************************
  1. ;---> Temp fix for Kinrix until v8.31.
  1. ;
  1. ;********** PATCH 1, v8.3.1, Dec 30,2008, IHS/CMI/MWR
  1. ;---> Next line commented out; KINFIX call no longer necessary (Immserve updated).
  1. ;---> But retain this call in case a future vaccine combo needs to be interpreted
  1. ;---> ahead of an Immserve update.
  1. ;
  1. ;I $P(Y,U,2)=130 D KINFIX(Y) Q
  1. ;
  1. ;---> Temp fix for Kinrix until v8.31.
  1. ;************************
  1. ;
  1. ;---> Dose Note - ^V Imm IEN (Field 52).
  1. S BITMP=BITMP_U_$P(Y,U,4)
  1. ;
  1. ;---> Dose HL7/CVX Code (Field 53) * * * ALL OUTGOING TRANSLATIONS HERE * * *
  1. D
  1. .;---> If this is an Adult Td Booster and patient age>7, send -10 to ImmServe.
  1. .I $P(Y,U,2)=9!($P(Y,U,2)=113) I BIAGE>6 S BITMP=BITMP_U_-10 Q
  1. .;
  1. .;---> If this is Tdap, send -13 to ImmServe.
  1. .;
  1. .;********** PATCH 2, v8.5, MAY 15,2012, IHS/CMI/MWR
  1. .;---> Include CVX 20 (DTaP) in translation to -13, so that DTaP satisfies Tdap.
  1. .;---> During Beta Test decision was made to abandon this for now, due to
  1. .;---> complications. However, Tdap CVX 115 translated to -13 on 7yrs and older.
  1. .I $P(Y,U,2)=115 I BIAGE>6 S BITMP=BITMP_U_-13 Q
  1. .;I $P(Y,U,2)=115!($P(Y,U,2)=20) I BIAGE>6 S BITMP=BITMP_U_-13 Q
  1. .;**********
  1. .;
  1. .;********** PATCH 2, v8.4.2, Oct 15,2010, IHS/CMI/MWR
  1. .;---> Translate new Flu CVX Codes 140 & 141 to 15 until Immserve can accommodate.
  1. .;---> If this is a new Flu, send 15.
  1. .;
  1. .;********** PATCH 5, v8.5, JUL 01,2013, IHS/CMI/MWR
  1. .;---> Recognize new Flu Codes.
  1. .;I ($P(Y,U,2)=140)!($P(Y,U,2)=141) S BITMP=BITMP_U_15 Q
  1. .N Z S Z=($P(Y,U,2))
  1. .I (Z=149)!(Z=150)!(Z=151)!(Z=153)!(Z=155)!(Z=158) S BITMP=BITMP_U_15 Q
  1. .;**********
  1. .;
  1. .;---> No translation of this dose.
  1. .S BITMP=BITMP_U_$P(Y,U,2)
  1. ;
  1. ;---> Dose Number--or "Series Number" (Field 54).
  1. ;---> New Version 8.x+ no longer tracks dose numbers (Field 54, 55, 56).
  1. S BITMP=BITMP_"^0^0^0"
  1. ;
  1. ;---> Date of Dose Administration--Visit Date (Field 57).
  1. S BITMP=BITMP_U_$P(Y,U)
  1. ;
  1. ;---> Dose Override: (Field 58).
  1. ;---> 0=Exclude if violates screening rules
  1. ;---> 1=Include even if violates screening rules
  1. ;---> 2=Exclude per user input (invalidated by user, e.g., expired vaccine).
  1. D
  1. .;---> Interpret Dose Override for ImmServe.
  1. .N X S X=(+$P(Y,U,3))
  1. .D:X
  1. ..I X=9 S X=1 Q
  1. ..S X=2
  1. .S BITMP=BITMP_U_X
  1. ;
  1. ;---> Keep count of doses.
  1. S BIDOSES=BIDOSES+1
  1. Q
  1. ;
  1. ;
  1. KINFIX(Y) ;EP
  1. ;---> TO ACCOMODATE IMMSERVE NOT RECOGNIZING KINRIX.
  1. ;---> DELETE THIS SECTION WITH NEW IMMSERVE, IMM V8.31.
  1. N BIX F BIX=10,20 D
  1. .;
  1. .;---> Dose Note - ^V Imm IEN (Field 52).
  1. .S BITMP=BITMP_U_$P(Y,U,4)
  1. .;
  1. .S BITMP=BITMP_U_BIX
  1. .;
  1. .;---> Dose Number--or "Series Number" (Field 54).
  1. .;---> New Version 8.x+ no longer tracks dose numbers (Field 54, 55, 56).
  1. .S BITMP=BITMP_"^0^0^0"
  1. .;
  1. .;---> Date of Dose Administration--Visit Date (Field 57).
  1. .S BITMP=BITMP_U_$P(Y,U)
  1. .;
  1. .;---> Dose Override: (Field 58).
  1. .;---> 0=Exclude if violates screening rules
  1. .;---> 1=Include even if violates screening rules
  1. .;---> 2=Exclude per user input (invalidated by user, e.g., expired vaccine).
  1. .D
  1. ..;---> Interpret Dose Override for ImmServe.
  1. ..N X S X=(+$P(Y,U,3))
  1. ..D:X
  1. ...I X=9 S X=1 Q
  1. ...S X=2
  1. ..S BITMP=BITMP_U_X
  1. .;
  1. .;---> Keep count of doses.
  1. .S BIDOSES=BIDOSES+1
  1. Q