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

BWUTL5.m

Go to the documentation of this file.
BWUTL5 ;IHS/ANMC/MWR/HJT - UTIL: ACC#, TITLES, SL/TX DATES;15-Feb-2003 22:14;PLS
 ;;2.0;WOMEN'S HEALTH;**5,8**;MAY 16, 1996
 ;Modified for Y2k Compliance  5/14/1999  IHS/DSD/HJT
 ;;* MICHAEL REMILLARD, DDS * ALASKA NATIVE MEDICAL CENTER *
 ;;  UTILITY: SETVARS, GENERATE ACCESSION#, MENUT, TITLE, CENTERT,
 ;;  COPYLET, UPPERCASE XREF, CDC, SL/TX DATES.
 ;
 ;
SETVARS ;EP
 D XBKVAR
 S:'$D(IOF) IOF="#"
 S:'$D(BWPOP) BWPOP=0
 Q
 ;**************
 ;---> XBKVAR INCORPORATED HERE FOR VA COMPATIBILITY.
XBKVAR ;SET MINIMUM KERNEL VARIABLES;
 ; FROM ;;2.5;XB;;MAR 20, 1991
 ; FROM ;IHS/DSD/JCM 7/6/92 Added Set of DUZ("AG")
 ;
 S U="^"
 I '$D(DUZ(2)),$D(^AUTTSITE(1,0)) S DUZ(2)=+^(0)
 I '$D(DUZ(2)),$D(^AUTTLOC("SITE")) S DUZ(2)=+^(0)
 I '$D(DUZ("AG")) S DUZ("AG")=$S($P($G(^XMB(1,0)),"^",8)]"":$P(^XMB(1,0),"^",8),1:"I") ;IHS/DSD/JCM 7/6/92
 S:'($D(DUZ)#2) DUZ=0 S:'($D(DUZ(0))#2) DUZ(0)="" S:'($D(DUZ(2))#2) DUZ(2)=0
 I '$D(DT) D NOW^%DTC S DT=X
 S:'$D(DTIME) DTIME=999
 K %,%H,%I
 Q
 ;**************
 ;
 ;
ACCSSN(PCDTYPE) ;EP
 ;---> GENERATE ACCESSION# FOR BW PROCEDURE FILE ENTRY.
 ;---> REQUIRED VARIABLE: PCDTYPE=IEN OF PROCEDURE TYPE (#9002086.2)
 N A,C,L,N,P,X
 Q:'$D(PCDTYPE) ""
 Q:'$D(^BWPN(PCDTYPE,0)) ""
 S X=^BWPN(PCDTYPE,0)          ;X=0-NODE OF PROC TYPE
 S P=$P(X,U,4)                 ;P=PREFIX
 S L=$P(X,U,6)                 ;L=LAST ASSIGNED ACCESSION# FOR THIS PROC
 S A=$P(L,"-")                 ;A=ACC YEAR
 S C=$P(L,"-",2)               ;C=COUNTER
 D NOW^%DTC S N=$E(%I(3),2,3)  ;N=YEAR NOW: 94
 I A'=N S C=0
 F  L +^BWPN(PCDTYPE,0):1 Q:$T
 F  S C=C+1 S R=P_N_"-"_C Q:'$D(^BWPCD("B",R))
 S $P(^BWPN(PCDTYPE,0),U,6)=N_"-"_C
 L -^BWPN(PCDTYPE,0)
 Q R  ;R=RESULT(NEW ACCESSION#)
 ;
 ;---> DISPLAY MENU TITLE FROM BW MENU OPTIONS.
 ;---> REQUIRED VARIABLES: TITLE=TEXT TO BE CENTERED AND DISPLAYED.
 ;--->                     DUZ(2)=CURRENT LOCATION TO BE DISPLAYED.
 N BWTTAB,BWFAC,BWUNL,I
 S:'$D(TITLE) TITLE="* NO TITLE SUPPLIED *"
 S TITLE="*  "_TITLE_"  *"
 S BWTTAB=39-($L(TITLE)/2)
 W:$D(IOF) @IOF
 W !?3,"WOMEN'S HEALTH:"
 W ?BWTTAB,TITLE
 W ?60,$E($$INSTTX^BWUTL6(DUZ(2)),1,20)
 S BWUNL="" F I=1:1:$L(TITLE) S BWUNL=BWUNL_"="
 W !?BWTTAB,BWUNL
 Q
 ;
TITLE(TITLE) ;EP
 ;---> DISPLAY A TITLE.
 ;---> REQUIRED VARIABLES: TITLE=TEXT TO BE CENTERED AND DISPLAYED.
 N BWTTAB
 S:'$D(TITLE) TITLE="* NO TITLE SUPPLIED *"
 S TITLE="* * *  WOMEN'S HEALTH: "_TITLE_"  * * *"
 S BWTTAB=39-($L(TITLE)/2)
 W:$D(IOF) @IOF
 W !?BWTTAB,TITLE,!!
 Q
 ;
CENTERT(TEXT) ;EP
 ;---> ADD LEADING SPACES TO CENTER TEXT.
 S:'$D(TEXT) TEXT="* NO TEXT SUPPLIED *"
 N I
 F I=1:1:(39-($L(TEXT)/2)) S TEXT=" "_TEXT
 Q
 ;
UPPER() ;EP
 S X=$TR(X,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
 Q X
 ;
COPYLET ;EP
 ;---> COPY TEXT OF GENERIC SAMPLE LETTER TO ONE OR MORE BW PURPOSES.
 ;---> EDIT NEXT LINE TO INCLUDE IENS OF BW PURPOSES TO BE CHANGED.
 ;F DA=15,16,18,19 D
 S DA=0
 F  S DA=$O(^BWNOTP(DA)) Q:'DA  D
 .K ^BWNOTP(DA,1)
 .S N=0
 .F  S N=$O(^BWLET(1,1,N)) Q:'N  D
 ..S ^BWNOTP(DA,1,N,0)=^BWLET(1,1,N,0)
 .S ^BWNOTP(DA,1,0)=^BWLET(1,1,0)
 Q
 ;
 ;
UPXREF(X,BWGBL) ;EP
 ;---> SET UPPERCASE XREF FOR X.  CALLED FROM MUMPS XREFS ON MIXED CASE
 ;---> FIELDS WHERE AN ALL UPPERCASE LOOKUP IS NEEDED.
 ;---> REQUIRED VARIABLES: BWGBL=GLOBAL ROOT OF FILE, X=TEXT TO BE
 ;---> CROSSREFERENCED IN ALL UPPERCASE, DA=IEN.
 Q:'$D(BWGBL)!('$D(X))
 N BWX S BWX=X,X=$$UPPER
 S @(BWGBL_"""U"",$E(X,1,30),DA)")=""
 S X=BWX K BWGBL
 Q
 ;
KUPXREF(X,BWGBL) ;EP
 ;---> KILL UPPERCASE XREF FOR X.  CALLED FROM MUMPS XREFS ON MIXED CASE
 ;---> FIELDS WHERE AN ALL UPPERCASE LOOKUP IS NEEDED.
 ;---> REQUIRED VARIABLES: BWGBL=GLOBAL ROOT OF FILE, X=TEXT TO BE
 ;---> CROSSREFERENCED IN ALL UPPERCASE, DA=IEN.
 Q:'$D(BWGBL)!('$D(X))
 N BWX S BWX=X,X=$$UPPER
 K @(BWGBL_"""U"",$E(X,1,30),DA)")
 S X=BWX K BWGBL
 Q
 ;
CDC(SITE) ;EP
 ;---> RETURN 1 IF THIS SITE IS EXPORTING DATA TO CDC.
 Q:'$G(SITE) ""
 Q:'$D(^BWSITE(SITE,0)) ""
 Q $P(^BWSITE(SITE,0),U,12)
 ;
AGENCY(SITE) ;EP
 ;---> RETURN TYPE OF AGENCY ("i"=IHS, "s"=STATE, "v"=VA, ETC.).
 ;---> REQUIRED VARIABLE: SITE=DUZ(2)
 ;---> IF SITE NOT PASSED OR PARAMETER NOT SET, IT DEFAULTS TO IHS.
 Q:'$G(SITE) "i"
 Q:'$D(^BWSITE(SITE,0)) "i"
 Q $P(^BWSITE(SITE,0),U,15)
 ;
PNLAB(SITE) ;EP
 ;---> RETURN TEXT FOR PATIENT NUMBER: "Chart#: " OR "   SSN: ".
 I $$AGENCY(SITE)="i" Q "Chart#: "
 Q "   SSN: "
 ;
PNLB(SITE) ;EP
 ;---> RETURN UPPERCASE TEXT FOR PATIENT NUMBER, NO COLON/SPACES.
 I $$AGENCY(SITE)="i" Q "CHART#"
 Q "SSN"
 ;
CDCID(DFN,SITE) ;EP
 ;---> GENERATE A UNIQUE PATIENT INDENTIFIER FOR CDC MDE EXPORT.
 Q:'$$CDC(SITE) ""
 ;---> QUIT IF ONE ALREADY EXISTS FOR THIS PATIENT.
 I $D(^BWP(DFN,0)) Q:$P(^(0),U,20)]"" ""
 N I,Y,Z
 ;---> TAKE FIRST 4 CHARS OF LAST NAME (EXCHG PUNCTUATION FOR ZEROS).
 S Y=$E($P($$NAME^BWUTL1(DFN),","),1,4)
 S Y=$TR(Y," '-.,","00000")
 F I=1:1:(4-$L(Y)) S Y=Y_0
 ;---> TAKE FIRST INITIAL.
 S Z=$E($P($$NAME^BWUTL1(DFN),",",2)) S:Z="" Z=0
 ;---> CONCATENATE IN REVERSE ORDER.
 S Y=$E(Y,4)_$E(Y,3)_$E(Y,2)_$E(Y)_Z
 ;---> CONCATENATE FILEMAN DATE OF BIRTH.
 S Y=Y_$E($$DOB^BWUTL1(DFN),2,7)
 ;---> CONCATENATE LAST 4 DIGITS OF SSN (OR 9999 IF NO SSN).
 S I=$E($$SSN^BWUTL1(DFN),6,9) S:'+I I=9999
 Q Y_I
 ;
CDCEXP(IEN,SITE) ;EP
 ;---> RETURNS 1 IF THIS PROCEDURE AT THIS SITE SHOULD BE FLAGGED FOR
 ;---> EXPORT TO CDC.  IEN=IEN IN BW PROCEDURE TYPE FILE #9002086.2.
 Q:'$G(IEN) ""
 ;---> QUIT IF SITE NOT EXPORTING MDE'S TO CDC.
 Q:'$$CDC(SITE) ""
 Q:'$D(^BWPN(IEN)) ""
 ;---> QUIT IF PROCEDURE SHOULD NOT BE EXPORTED.
 Q:'$P(^BWPN(IEN,0),U,13) ""
 Q 1
 ;
SLDT2(DATE) ;EP
 ;---> CONVERT FILEMAN INTERNAL DATE TO "SLASH" FORMAT: MM/DD/YY.
 ;---> DATE=DATE IN FILEMAN FORMAT.
 Q:'$G(DATE) "NO DATE"
 S DATE=$P(DATE,".")
 Q:$L(DATE)'=7 DATE
 Q:'$E(DATE,4,5) $E(DATE,1,3)+1700
 ;Begin Y2k fix    5/14/1999  IHS/DSD/HJT
 ;Q:'$E(DATE,6,7) $E(DATE,4,5)_"/"_$E(DATE,2,3)
 Q:'$E(DATE,6,7) $E(DATE,4,5)_"/"_($E(DATE,1,3)+1700)  ;Y2000
 ;Q $E(DATE,4,5)_"/"_$E(DATE,6,7)_"/"_$E(DATE,2,3)
 Q $E(DATE,4,5)_"/"_$E(DATE,6,7)_"/"_($E(DATE,1,3)+1700)  ;Y2000
 ;End Y2k fix
 ;
 ;
SLDT1(DATE) ;EP
 ;---> CONVERT FILEMAN INTERNAL DATE TO "SLASH" FORMAT: MM/DD/YY
 ;---> PLUS TIME.
 N Y
 Q:'$D(DATE) "unknown"
 S Y=DATE,DATE=$P(DATE,".")
 Q:'DATE "NO DATE"
 Q:$L(DATE)'=7 DATE
 Q:'$E(DATE,4,5) $E(DATE,1,3)+1700
 ;Begin Y2k fix
 ;Q:'$E(DATE,6,7) $E(DATE,4,5)_"/"_$E(DATE,2,3)
 Q:'$E(DATE,6,7) $E(DATE,4,5)_"/"_($E(DATE,1,3)+1700)  ;Y2000
 D DD^%DT S:Y["@" Y=" @ "_$P($P(Y,"@",2),":",1,2)
 ;Q $E(DATE,4,5)_"/"_$E(DATE,6,7)_"/"_$E(DATE,2,3)_Y
 Q $E(DATE,4,5)_"/"_$E(DATE,6,7)_"/"_($E(DATE,1,3)+1700)_Y  ;Y2000
 ;End Y2k fix
 ;
TXDT(DATE) ;EP
 ;---> CONVERT FILEMAN INTERNAL DATE TO "TEXT" FORMAT: MMM DD,YYYY.
 N Y
 Q:'$D(DATE) "UNKNOWN"
 S Y=DATE D DD^%DT
 I Y[", " S Y=$P(Y,", ")_","_$P(Y,", ",2)
 I Y["@" S Y=$P(Y,"@")_"  "_$P($P(Y,"@",2),":",1,2)
 Q Y