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

BIUTL6.m

Go to the documentation of this file.
  1. BIUTL6 ;IHS/CMI/MWR - UTIL: TEXT FOR POINTERS; MAY 10, 2010
  1. ;;8.5;IMMUNIZATION;**9**;OCT 01,2014
  1. ;;* MICHAEL REMILLARD, DDS * CIMARRON MEDICAL INFORMATICS, FOR IHS *
  1. ;; UTILITY: TEXT FOR PROVIDER, HOSP LOC, INSTIT, OTHER LOC,
  1. ;; TRANSLATIONS, REACTION, CONTRA, SITE HDR, CUR COM TXT.
  1. ;; PATCH 3: Add call to return Imm Date if 1201 Event Date is populated IMMDT
  1. ;; PATCH 9: Allow return of 1201 Event or NULL, by not passing BIVPTR. IMMDT+12
  1. ;
  1. ;
  1. ;----------
  1. USERPOP(BIDFN,BIEDATE) ;EP - Return 1 if Patient is in User Population as of BIEDATE.
  1. ;---> Code from Lori Butcher, CMI, Feb 2010.
  1. ;---> Return 1 if Patient is in User Population; otherwise return 0.
  1. ;---> Parameters:
  1. ; 1 - BIDFN (req) Patient DFN.
  1. ; 2 - BIEDATE (req) Date as of which Patient is an in User Population.
  1. ; User Population = 1 or more qualifying visits in last 3 years.
  1. ;
  1. I '$D(^AUPNPAT(BIDFN,0)) Q 0 ;invalid patient
  1. I '$D(^AUPNVSIT("AC",BIDFN)) Q 0 ;patient has no visits
  1. ;
  1. NEW A,B,E,G,X,BIBDATE
  1. S BIBDATE=$$FMADD^XLFDT(BIEDATE,-1096) ;get beginning date for search, 3 yrs ago (1096 days)
  1. K ^TMP($J,"ALL VISITS")
  1. S A="^TMP($J,""ALL VISITS"","
  1. S B=BIDFN_"^ALL VISITS;DURING "_$$FMTE^XLFDT(BIBDATE)_"-"_$$FMTE^XLFDT(BIEDATE)
  1. S E=$$START1^APCLDF(B,A)
  1. I '$D(^TMP($J,"ALL VISITS",1)) Q 0
  1. S (X,UP)=0
  1. F S X=$O(^TMP($J,"ALL VISITS",X)) Q:((X'=+X)!(UP)) S V=$P(^TMP($J,"ALL VISITS",X),U,5) D
  1. .Q:'$D(^AUPNVSIT(V,0))
  1. .Q:'$P(^AUPNVSIT(V,0),U,9)
  1. .Q:$P(^AUPNVSIT(V,0),U,11)
  1. .Q:'$D(^AUPNVPRV("AD",V)) ;MUST BE A COMPLETE VISIT
  1. .Q:"SAHO"'[$P(^AUPNVSIT(V,0),U,7) ;must be ambulatory, hosp, day surgery or obervation
  1. .Q:"V"[$P(^AUPNVSIT(V,0),U,3) ;can't be a VA type visit
  1. .Q:$P(^AUPNVSIT(V,0),U,6)=""
  1. .S UP=1 ;has at least one visit so in user pop
  1. Q UP
  1. ;
  1. ;
  1. ;----------
  1. ACTCLIN(BIDFN,BIEDATE) ;EP - Return 1 if Patient is Active Clinical User as of BIEDATE.
  1. ;---> Code from Lori Butcher, CMI, Feb 2010.
  1. ;---> Return 1 if Patient is Active Clinical; otherwise return 0.
  1. ;---> Parameters:
  1. ; 1 - BIDFN (req) Patient DFN.
  1. ; 2 - BIEDATE (req) Date as of which Patient is an Active Clinical User.
  1. ; Active Clinical = 2 or more qualifying visits in last 3 years.
  1. ;
  1. I '$D(^AUPNPAT(BIDFN,0)) Q 0 ;invalid patient
  1. I '$D(^AUPNVSIT("AC",BIDFN)) Q 0 ;patient has no visits
  1. ;
  1. NEW A,B,E,G,X,BIBDATE,AC,S,F,BIGPRAYR
  1. S BIBDATE=$$FMADD^XLFDT(BIEDATE,-1096) ;get begin date for search, 3 yrs ago (1096 days)
  1. K ^TMP($J,"ALL VISITS")
  1. ;
  1. ;---> Get IEN of GPRA Control File entry.
  1. S BIGPRAYR=$$GPRAIEN
  1. I 'BIGPRAYR Q 0
  1. ;
  1. S A="^TMP($J,""ALL VISITS"","
  1. S B=BIDFN_"^ALL VISITS;DURING "_$$FMTE^XLFDT(BIBDATE)_"-"_$$FMTE^XLFDT(BIEDATE)
  1. S E=$$START1^APCLDF(B,A)
  1. ;
  1. I '$D(^TMP($J,"ALL VISITS",1)) Q 0
  1. S (X,G,AC,S,F)=0
  1. F S X=$O(^TMP($J,"ALL VISITS",X)) Q:((X'=+X)!(AC)) S V=$P(^TMP($J,"ALL VISITS",X),U,5) D
  1. .Q:'$D(^AUPNVSIT(V,0))
  1. .Q:'$P(^AUPNVSIT(V,0),U,9)
  1. .Q:$P(^AUPNVSIT(V,0),U,11)
  1. .Q:'$D(^AUPNVPRV("AD",V)) ;MUST BE A COMPLETE VISIT
  1. .Q:"SAHO"'[$P(^AUPNVSIT(V,0),U,7) ;must be ambulatory, hosp, day surgery or obervation
  1. .Q:"V"[$P(^AUPNVSIT(V,0),U,3) ;can't be a VA type visit
  1. .Q:$P(^AUPNVSIT(V,0),U,6)=""
  1. .S B=$$CLINIC^APCLV(V,"C") ;get clinic for active clinical check
  1. .Q:B=""
  1. .I 'G,$D(^BGPCTRL(BIGPRAYR,11,"B",B)) S G=V ;must be a primary clinic
  1. .I V'=G,$D(^BGPCTRL(BIGPRAYR,12,"B",B)) S S=1 ;has a secondary type of clinic
  1. .I G,S S AC=1 ;if have both then they are active clinical
  1. .Q
  1. Q AC
  1. ;
  1. ;
  1. ;----------
  1. GPRAIEN() ;EP
  1. ;---> Return GPRA Control File IEN
  1. ;
  1. ;---> Get the most recent GPRA Year Control file entry.
  1. N BIYR,BIGPIEN
  1. S BIYR=$O(^BGPCTRL("B",""),-1)
  1. Q:'BIYR 0
  1. S BIGPIEN=$O(^BGPCTRL("B",BIYR,0))
  1. Q:'BIGPIEN 0
  1. Q:('$G(^BGPCTRL(BIGPIEN,0))) 0
  1. Q BIGPIEN
  1. ;
  1. ;
  1. ;----------
  1. PROV200(X) ;EP
  1. ;---> Given PROVIDER's IEN in File #3, return the IEN in File #200.
  1. ;---> Parameters:
  1. ; 1 - X (req) =IEN in old PROVIDER File #6.
  1. ;
  1. Q:'$G(X) ""
  1. Q $G(^DIC(16,X,"A3"))
  1. ;
  1. ;
  1. ;----------
  1. PROVIDER(X) ;EP
  1. ;---> Code to check whether to return File 6 or File 200 for
  1. ;---> Provider. ** Not used so far. **
  1. ;
  1. Q:'X ""
  1. ;---> IF PCC WANTS A FILE 6 POINTER FOR PROVIDER, RESET X.
  1. I '$P(^AUTTSITE(1,0),U,22) D
  1. .I $P($G(^VA(200,X,0)),U,16) S X=$P(^(0),U,16) Q
  1. .S X=$P($G(^DIC(3,X,0)),U,16)
  1. Q X
  1. ;
  1. ;
  1. ;----------
  1. REACTXT(X) ;EP
  1. ;---> Return text of Reaction to Immunization.
  1. ;---> Parameters:
  1. ; 1 - X (req) =IEN in IMMUNIZATION File #9002084.8.
  1. ;
  1. Q:'$G(X) ""
  1. Q:'$D(^BIREC(X,0)) ""
  1. Q $P(^BIREC(X,0),U)
  1. ;
  1. ;
  1. ;----------
  1. CONTXT(X) ;EP
  1. ;---> Return text of a Contraindication Reason.
  1. ;---> Parameters:
  1. ; 1 - X (req) =IEN in BI TABLE CONTRA REASON File #9002084.81.
  1. ;
  1. Q:'$G(X) ""
  1. Q:'$D(^BICONT(X,0)) ""
  1. Q $P(^BICONT(X,0),U)
  1. ;
  1. ;
  1. ;----------
  1. SKNAME(X) ;EP
  1. ;---> Return text of Skin Test name.
  1. ;---> Parameters:
  1. ; 1 - X (req) =IEN in IMMUNIZATION File #9999999.14.
  1. ;
  1. Q:'$G(X) "NO SKIN TEST"
  1. Q:'$D(^AUTTSK(X,0)) "UNK POINTER"
  1. Q $P(^AUTTSK(X,0),U)
  1. ;
  1. ;
  1. ;----------
  1. SKRESLT(X) ;EP
  1. ;---> Return text of Skin Test Result.
  1. ;---> Parameters:
  1. ; 1 - X (req) = Code for Skin Test Result.
  1. ;
  1. Q:$G(X)="" ""
  1. Q:X="P" "Positive"
  1. Q:X="N" "Negative"
  1. Q:X="D" "Doubtful"
  1. Q:X="O" "No Take"
  1. Q "Unknown"
  1. ;
  1. ;
  1. ;----------
  1. HOSPLC() ;EP
  1. ;---> RETURN TEXT OF HOSPITAL LOCATION NAME.
  1. ;---> REQUIRED VARIABLE: X=IEN IN HOSPITAL LOCATION FILE #44.
  1. Q:'$D(X) ""
  1. Q:'X "UNKNOWN"
  1. Q:'$D(^SC(X,0)) "UNKNOWN POINTER"
  1. Q $P(^SC(X,0),U)
  1. ;
  1. ;
  1. ;----------
  1. INSTIT() ;EP
  1. ;---> RETURN IEN OF INSTITUTION (FACILITY) FILE 4, FOR THIS HOSPITAL
  1. ;---> LOCATION ENTRY IN HOSPITAL LOCATION FILE 44.
  1. ;---> ALSO CONCATENATE "`" TO THE FRONT OF IEN FOR USE IN DR STRINGS.
  1. Q:'$D(X) ""
  1. Q:X="" ""
  1. Q:'$D(^SC(X,0)) ""
  1. Q:$P(^SC(X,0),U,4)']"" ""
  1. Q "`"_$P(^SC(X,0),U,4)
  1. ;
  1. ;
  1. ;----------
  1. INSTTX(FACILITY) ;EP
  1. ;---> Return text of Institution (Facility) Name.
  1. ;---> Parameters:
  1. ; 1 - FACILITY (req) IEN in INSTITUTION File #4.
  1. ;
  1. Q:'$G(FACILITY) ""
  1. Q:'$D(^DIC(4,FACILITY,0)) "Unknown facility"
  1. Q $P(^DIC(4,FACILITY,0),U)
  1. ;
  1. ;
  1. ;----------
  1. LOCABBR(FACILITY) ;EP
  1. ;---> Return text of Institution/Location Abbreviated Name.
  1. ;---> Parameters:
  1. ; 1 - FACILITY (req) IEN in INSTITUTION File #4.
  1. ;
  1. Q:'$G(FACILITY) ""
  1. Q:'$D(^AUTTLOC(FACILITY,0)) "UNKN"
  1. Q $P(^AUTTLOC(FACILITY,0),U,7)
  1. ;
  1. ;
  1. ;----------
  1. INSTTX1(BIVPTR,BIMX,BIIHS) ;EP
  1. ;---> Return text of Other Location if it exists (for this Visit);
  1. ;---> otherwise, return text of IHS Location.
  1. ;---> Parameters:
  1. ; 1 - BIVPTR (req) IEN of Visit in VISIT File.
  1. ; 2 - BIMX (opt) BIMX=1 to return text in mixed case.
  1. ; 3 - BIIHS (opt) BIIHS=1 to force IHS LOCATION (ignore OTHER).
  1. ; BIIHS>1 to force OTHER LOCATION.
  1. ; BIIHS<1 Look first for OTHER LOCATION;
  1. ; if null, then return IHS LOCATION.
  1. ;
  1. Q:'$G(BIVPTR) "No Visit Pointer."
  1. Q:'$D(^AUPNVSIT(BIVPTR,0)) "Visit does not exist."
  1. ;
  1. N Y
  1. S:'$G(BIMX) BIMX=0
  1. S:'$G(BIIHS) BIIHS=0
  1. ;
  1. D
  1. .;---> If this Visit has an OTHER LOCATION and IHS LOCATION
  1. .;---> is not forced, return OUTSIDE LOCATION text.
  1. .I BIIHS<1 I $P($G(^AUPNVSIT(BIVPTR,21)),U)]"" D Q
  1. ..S Y=$P(^AUPNVSIT(BIVPTR,21),U)
  1. .;
  1. .;---> If OTHER LOCATION is forced, return it (even if null).
  1. .I BIIHS>1 S Y=$P($G(^AUPNVSIT(BIVPTR,21)),U) Q
  1. .;
  1. .;---> If IHS Location is forced (or if neither IHS nor OTHER was
  1. .;---> forced, but OTHER is null), return the IHS LOCATION
  1. .;---> (.06 of VISIT File).
  1. .S Y=$P(^AUPNVSIT(BIVPTR,0),U,6)
  1. .I Y<1 S Y="Location not entered." Q
  1. .S Y=$E($$INSTTX(Y),1,20)
  1. ;
  1. Q:BIMX $$T^BITRS(Y)
  1. Q Y
  1. ;
  1. ;
  1. ;----------
  1. OTHERLOC(BIDUZ2,Z) ;PEP - Return IEN of the "OTHER" Location.
  1. ;---> Return IEN of the "OTHER" Location, as selected in the
  1. ;---> BI SITE PARAMETER File. (For use with Outside Locations
  1. ;---> in PCC Visit entries.)
  1. ;---> Parameters:
  1. ; 1 - BIDUZ2 (req) IEN of "OTHER" in LOCATION File.
  1. ; 2 - Z (opt) If Z=1 return text of "OTHER" Location.
  1. ;
  1. N X S:'$G(Z) Z=0
  1. Q:'$G(BIDUZ2) $S(Z:"OTHER NOT DEFINED",1:"")
  1. Q:'$D(^BISITE(BIDUZ2,0)) $S(Z:"SITE PARAMETERS NOT SET.",1:"")
  1. S X=$P(^BISITE(BIDUZ2,0),U,3)
  1. Q:'X $S(Z:"OTHER not set in BI SITE PARAMETERS.",1:"")
  1. Q:'$D(^DIC(4,X,0)) $S(Z:"UNKNOWN FACILITY",1:"")
  1. Q:'Z X
  1. Q $$INSTTX(X)
  1. ;
  1. ;
  1. ;----------
  1. DEFPROV(BIDUZ2) ;EP
  1. ;---> Return 1 if Site Parameter says User should be the Default
  1. ;---> Provider for a new Visit.
  1. ;---> Parameters:
  1. ; 1 - BIDUZ2 (req) User's DUZ(2)
  1. ;
  1. Q +$P($G(^BISITE(+$G(BIDUZ2),0)),U,16)
  1. ;
  1. ;
  1. ;----------
  1. REPHDR(BISITE) ;EP
  1. ;---> Return text of Record/Report Header for this Site.
  1. ;---> This is the free text full name of the site as it should
  1. ;---> appear at the top of records and reports.
  1. ;---> Parameters:
  1. ; 1 - BISITE (req) IEN in BI SITE PARAMETERS File,
  1. ; the user's DUZ(2) (INSTITUTION File #4).
  1. ;
  1. Q:'$G(BISITE) "No Facility IEN passed."
  1. Q:'$D(^BISITE(BISITE,0)) "Report Header not set."
  1. N X S X=$P(^BISITE(BISITE,0),U,6)
  1. S:X="" X=$$INSTTX(BISITE)
  1. Q X
  1. ;
  1. ;
  1. ;----------
  1. CCTX(X) ;EP
  1. ;---> Return text of Current Community Name.
  1. ;---> Parameters:
  1. ; 1 - X (req) IEN in COMMUNITY File #9999999.05.
  1. ;
  1. Q:'$G(X) ""
  1. Q:'$D(^AUTTCOM(X,0)) "BAD POINTER"
  1. Q $P(^AUTTCOM(X,0),U)
  1. ;
  1. ;
  1. ;----------
  1. BENTX(X) ;EP
  1. ;---> Return text of Beneficiary Type.
  1. ;---> Parameters:
  1. ; 1 - X (req) IEN in BENEFICIARY File #9999999.25.
  1. ;
  1. Q:'$G(X) ""
  1. Q:'$D(^AUTTBEN(X,0)) "BAD POINTER"
  1. Q $P(^AUTTBEN(X,0),U)
  1. ;
  1. ;
  1. ;********** PATCH 3, v8.5, SEP 10,2012, IHS/CMI/MWR
  1. ;---> New line accounting for Event Date and Time.
  1. ;----------
  1. IMMDTT(BIVPTR,BI012,BIFORM) ;EP
  1. ;---> Return Immunization Date and Time from V Immunizations file.
  1. ;---> If 1201 Event Date and Time field is populated, return that.
  1. ;---> Parameters:
  1. ; 1 - BIVPTR (req) IEN in VISIT File.
  1. ; 2 - BI012 (opt) 12-node of V IMM File entry.
  1. ; 3 - BIFORM (opt) Date Format: null default=MM/DD/YY, 1=(DD-Mmm-YYYY
  1. ; 2=YYYMMDD
  1. ;
  1. N BIY D
  1. .I $P($G(BI012),U) S BIY=$P(BI012,U) Q
  1. .;--->
  1. .;********** PATCH 9, v8.5, OCT 01,2014, IHS/CMI/MWR
  1. .;---> Allow return of 1201 Event or NULL, by not passing BIVPTR.
  1. .I '$G(BIVPTR) S BIY="" Q
  1. .;
  1. .S BIY=$P($P($G(^AUPNVSIT($G(BIVPTR),0)),U),".")
  1. Q:'BIY ""
  1. ;**********
  1. Q:($G(BIFORM)=2) BIY
  1. Q:($G(BIFORM)=1) $$TXDT1^BIUTL5(BIY,1)
  1. Q $$SLDT2^BIUTL5(BIY,1)
  1. ;---> Old line stored in ^BIEXPDD(29,0)=S Y=$P($G(~AUPNVSIT(+BIVPTR,0)),U),Y=$$TXDT1~BIUTL5(Y,1)
  1. ;**********
  1. ;
  1. ;----------
  1. BIUPTX(X,Y) ;EP
  1. ;---> Return text of Patient Group.
  1. ;---> Parameters:
  1. ; 1 - X (req) Code for Patient Group.
  1. ; 2 - Y (opt) If Y=1 return the long form.
  1. ;
  1. Q:X="r" $S($G(Y):"Registered",1:"Registered Patients (All)")
  1. Q:X="i" $S($G(Y):"Imm Register",1:"Immunization Register Patients (Active)")
  1. Q:X="u" $S($G(Y):"User Population",1:"User Population (1 visit, 3 yrs)")
  1. Q:X="a" $S($G(Y):"Active Users",1:"Active Users (2+ visits, 3 yrs)")
  1. Q $S($G(Y):"Error",1:"Error (Unknown Patient Group)")
  1. ;
  1. ;
  1. ;----------
  1. LOTTX(X,Y) ;EP
  1. ;---> Return text or vaccine of a Lot Number.
  1. ;---> Parameters:
  1. ; 1 - X (req) =IEN in IMMUNIZATION LOT File #9999999.41.
  1. ; 2 - Y (opt) If Y=1, return the Vaccine IEN associated with
  1. ; this Lot Number. If Y=2, return text of Vaccine Name.
  1. ; If Y=3 return default NDC for this Lot Number.
  1. ;
  1. Q:'$G(X) ""
  1. Q:'$D(^AUTTIML(X,0)) ""
  1. ;---> Return Lot Number text.
  1. Q:'$G(Y) $P(^AUTTIML(X,0),U)
  1. I Y=1 Q $P(^AUTTIML(X,0),U,4)
  1. I Y=2 Q $$VNAME^BIUTL2(Z)
  1. I Y=3 Q $P(^AUTTIML(X,0),U,17)
  1. Q ""
  1. ;
  1. ;
  1. ;----------
  1. DETX(X) ;EP
  1. ;---> Return text of a Data Element name.
  1. ;---> Parameters:
  1. ; 1 - X (req) =IEN in BI TABLE DATA ELEMENT File 9002084.91.
  1. ;
  1. Q:'$G(X) ""
  1. Q:'$D(^BIEXPDD(X,0)) ""
  1. Q $P(^BIEXPDD(X,0),U)
  1. ;
  1. ;
  1. ;----------
  1. TEXT1 ;EP
  1. ;;You have selected a "Duplicate Lot Number." This means that this
  1. ;;Lot Number exists at least one other time in the Lot Number file,
  1. ;;and the Immunization visit you are entering cannot be stored until
  1. ;;the duplicate has been resolved.
  1. ;;
  1. ;;Only a person with access to the Immunization Manager's Menu can
  1. ;;resolve duplicate Lot Numbers. Since you do not have this access,
  1. ;;you should contact your Immunization Program Manager or your
  1. ;;Computer Site Manager for support with this problem.
  1. ;;
  1. ;;In the meantime, you can either finish entering the Immunization
  1. ;;visit without a Lot Number, and come back to add the Lot Number to
  1. ;;this visit later, after the duplicate has been resolved.
  1. ;;Or you can simply quit without adding this visit at this time.
  1. ;;
  1. D PRINTX("TEXT1")
  1. Q
  1. ;
  1. ;
  1. ;----------
  1. TEXT2 ;EP
  1. ;;You have selected a "Duplicate Lot Number." This means that this
  1. ;;Lot Number exists at least one other time in the Lot Number file,
  1. ;;and the Immunization visit you are entering cannot be stored until
  1. ;;the duplicate has been resolved.
  1. ;;
  1. ;;Two steps should be taken to resolve duplicate Lot Numbers:
  1. ;;
  1. ;;STEP 1
  1. ;;------
  1. ;;Duplicate Lot Numbers are resolved under the Manager Menu, "Lot
  1. ;;Number Add/Edit" (MGR-->LOT). Go to this option and enter the Lot
  1. ;;Number in question. Two or more choices will be presented. Select
  1. ;;one of the choices to be the valid Lot Number. Edit this Lot Number,
  1. ;;making sure it is Active and that all relevant vaccines are listed
  1. ;;under it.
  1. D PRINTX("TEXT2")
  1. Q
  1. ;
  1. ;
  1. ;----------
  1. TEXT3 ;EP
  1. ;;STEP 2
  1. ;;------
  1. ;;Select and edit each of the duplicate Lot Numbers.
  1. ;;
  1. ;;Edit the Lot Number itself by placing "z" at the beginning
  1. ;;(e.g, 483-116 --> z483-116). If there is a second duplicate, add
  1. ;;"zz" to the beginning of that Lot Number; for a third duplicate,
  1. ;;add "zzz", and so on. The adding of leading "z"s to the duplicates
  1. ;;will make them distinguishable from the valid Lot Number. This
  1. ;;method will also make the old duplicate Lot Numbers recognizable on
  1. ;;pre-existing visits.
  1. ;;
  1. ;;The duplicate Lot Numbers should also be made INACTIVE.
  1. ;;If an old Visit is to be edited and it has one of the old duplicate
  1. ;;Lot Numbers, the old duplicate should be replaced with the current
  1. ;;valid Lot Number (easily recognized by ignoring the leading "z"s).
  1. D PRINTX("TEXT3")
  1. Q
  1. ;
  1. ;
  1. ;----------
  1. PRINTX(BILINL,BITAB) ;EP
  1. Q:$G(BILINL)=""
  1. N I,T,X S T="" S:'$D(BITAB) BITAB=5 F I=1:1:BITAB S T=T_" "
  1. F I=1:1 S X=$T(@BILINL+I) Q:X'[";;" W !,T,$P(X,";;",2)
  1. Q