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

GMTSU.m

Go to the documentation of this file.
  1. GMTSU ;SLC/JER,KER - Health Summary Utilities ;Jul 21, 2023@12:36
  1. ;;2.7;Health Summary;**27,28,31,35,37,43,47,56,144**;Oct 20, 1995;Build 17
  1. ;
  1. ; External References
  1. ; DBIA 10096 ^%ZOSF("TEST")
  1. ; DBIA 2934 ^A7RCP (NDBI Global)
  1. ; DBIA 10103 $$FMTE^XLFDT
  1. ; DBIA 10103 $$FMTHL7^XLFDT
  1. ; DBIA 10103 $$HL7TFM^XLFDT
  1. ; DBIA 10061 OERR^VADPT
  1. ; DBIA 10104 $$UP^XLFSTR
  1. ; DBIA 10026 ^DIR
  1. ; DBIA 2052 FILE^DID
  1. ; DBIA 10022 %XY^%RCR
  1. ; DBIA 2055 $$VFIELD^DILFD
  1. ; DBIA 2052 $$GET1^DID
  1. ;
  1. PROK(X,Y) ; Routine and Patch # OK (in UCI)
  1. N GMTS,GMTSI,GMTSO S X=$G(X),Y=$G(Y) Q:'$L(X) 0 Q:Y'=""&(+Y=0)
  1. S Y=+Y,GMTS=$$ROK(X) Q:'GMTS 0 Q:+Y=0 1 S GMTSO=0,GMTS=$T(@("+2^"_X)),GMTS=$P($P(GMTS,"**",2),"**",1)
  1. F GMTSI=1:1:$L(GMTS,",") S:+($P(GMTS,",",GMTSI))=Y GMTSO=1 Q:GMTSO=1
  1. S X=GMTSO Q X
  1. ROK(X) ; Routine OK (in UCI) (NDBI)
  1. S X=$G(X) Q:'$L(X) 0 Q:$L(X)>8 0 X ^%ZOSF("TEST") Q:$T 1 Q 0
  1. NDBI(X) ; National Database Integration site 1 = yes 0 = no
  1. N R,G S X="A7RDUP" X ^%ZOSF("TEST") S R=$T,G=$S($D(^A7RCP):1,1:0),X=R+G,X=$S(X=2:1,1:0) Q X
  1. ;
  1. CPT(X) ; Use CPT Modifiers Needs GMTSEG Array
  1. S X=+($G(X)) N GMTSN,GMTSC,GMTSM,GMTSA,GMTSI S GMTSN=$G(GMTSEG(X)) S GMTSC=+($P(GMTSN,"^",2)) Q:'GMTSC 0
  1. S GMTSM=$S($P(GMTSN,"^",9)="N":0,$P(GMTSN,"^",9)="":1,1:1) Q:'GMTSM 0
  1. S GMTSA=$S(+($$CMU(+GMTSC))>0:1,1:0) Q:'GMTSA 0
  1. Q 1
  1. CMU(X) ; Component Uses CPT Modifiers
  1. N GMTSA,GMTSN,GMTSI S X=$G(X) Q:'$L(X) 0 S GMTSI=+X,GMTSA=$O(^GMT(142.1,"C",X,0)),GMTSN=$O(^GMT(142.1,"D",X,0)) S:GMTSI=0&(+GMTSA>0) GMTSI=GMTSA S:GMTSI=0&(+GMTSN>0) GMTSI=GMTSN
  1. Q:+GMTSI=0 0 S GMTSA=$S($P($G(^GMT(142.1,+GMTSI,0)),"^",14)="Y":1,1:0) Q:'GMTSA 0
  1. Q 1
  1. ;
  1. ; Dates and Time
  1. ED(X) ; Health Summary External Date
  1. S X=$G(X) Q:'$L(X) "" D REGDT4 Q X
  1. EDT(X) ; Health Summary External Date and Time
  1. S X=$G(X) Q:'$L(X) "" D REGDTM4 Q X
  1. REGDT ; Receives X FM date and returns X in MM/DD/YY format
  1. S X=$TR($$FMTE^XLFDT(X,"2DZ"),"@"," ") Q
  1. REGDT4 ; Receives X FM date and returns X in MM/DD/YYYY format
  1. S X=$TR($$FMTE^XLFDT(X,"5DZ"),"@"," ") Q
  1. REGDTM ; Receives X FM date and returns X in MM/DD/YY TT:TT
  1. S X=$TR($$FMTE^XLFDT(X,"2ZM"),"@"," ") Q
  1. REGDTM4 ; Receives X FM date and returns X in MM/DD/YYYY TT:TT
  1. S X=$TR($$FMTE^XLFDT(X,"5ZM"),"@"," ") Q
  1. SIDT ; Receives X FM date and returns X in DD MMM YY
  1. N MON,MM S X=$P(X,".") S:'X X="" Q:'$L(X)
  1. S MON="JAN^FEB^MAR^APR^MAY^JUN^JUL^AUG^SEP^OCT^NOV^DEC"
  1. S MM=$E(X,4,5),MM=$S(MM:$P(MON,U,+MM),1:"")
  1. S X=$E(X,6,7)_" "_MM_" "_$E(X,2,3) Q
  1. MTIM ; Convert Time from X=2890313.1304 to X=13:04
  1. S X=$P(X,".",2) Q:'$L(X) S X=$S(X:$E(X,1,2)_$E("00",0,2-$L($E(X,1,2)))_":"_$E(X,3,4)_$E("00",0,2-$L($E(X,3,4))),1:"")
  1. Q
  1. ;
  1. HF(X) ; Host File - Used to distinguish from Host Files that
  1. ; are intended for Printers and Host Files for other
  1. ; purposes (windows/files)
  1. ;
  1. ; 1 - if Device Type is HFS and not a TCP/IP Printer
  1. ; 0 - if Device Type is not HFS or device is a Printer
  1. ;
  1. ; Check Device
  1. ; Check Host File Server
  1. Q:$G(IOT)'="HFS" 0
  1. ; Check ORWINDEV (Post OR*3.0*85)
  1. N GMTS85 S GMTS85=$$PROK("ORWRP",85)
  1. Q:+($G(GMTS85))>0&(+($G(ORWINDEV))>0) 0
  1. ; Host File for GUI Scrollable Window
  1. Q:$E($G(ION),1,14)["OR WORKSTATION" 1
  1. ; TCP/IP Printer
  1. Q:$G(IO)["$PRT"!($G(IO)["PRN|") 0
  1. ; Windows Printer
  1. Q:$E($G(ION),1,14)["OR WINDOWS HFS" 0
  1. ; Host Files (file or unspecifed printer)
  1. S X=0 S:$G(ION)["HOST FILE" X=1
  1. S:$E($G(IOST),1,5)["P-OTH" X=1
  1. Q X
  1. ;
  1. FMHL7DTM ; Convert X - int date/time to HL7 CCYYMMDDHHMM-HHHH
  1. S X=$$FMTHL7^XLFDT(+($G(X))) Q
  1. HL7FMDTM ; Convert X - HL7 CCYYMMDDHHMM-HHHH to int date/time local
  1. S X=$$HL7TFM^XLFDT($G(X),"L") Q
  1. ;
  1. DEM ; Gets Demographic Data from VADPT
  1. ;
  1. ; Input DFN
  1. ;
  1. ; Output GMTSPNM Patient Name
  1. ; GMTSSN Social Security Number
  1. ; GMTSDOB Date of Birth
  1. ; SEX Sex
  1. ; GMTSWARD Ward
  1. ; GMTSRB Bed
  1. ; GMTSAGE Age
  1. ; VADM() Demographic Array
  1. ; VAIN() Inpatient Array
  1. ; GMTSPHDR() Report Header Array
  1. ;
  1. K VAHOW D OERR^VADPT S GMTSPNM=VADM(1),GMTSSN=$S($D(VA("PID")):VA("PID"),1:$P(VADM(2),"^",2))
  1. S GMTSAGE=$S(+VADM(4)>0:+VADM(4),1:99),SEX=$P(VADM(5),"^")
  1. S GMTSWARD=$P(VAIN(4),"^",2),GMTSRB=VAIN(5)
  1. S X=$P(VADM(3),"^") D REGDT4 S GMTSDOB=X K VA,GMTSPHDR N DOB,LWARDRB,NMSSN,NMSSNE,WARDRB,WARDRBE,WARDRBS
  1. S NMSSN=GMTSPNM_" "_GMTSSN,NMSSNE=$L(NMSSN)+2,WARDRB=GMTSWARD_" "_GMTSRB
  1. S LWARDRB=$L(WARDRB),WARDRBS=40-(LWARDRB/2),WARDRBE=WARDRBS+LWARDRB
  1. S DOB="DOB: "_GMTSDOB,GMTSPHDR("NMSSN")=NMSSN,GMTSPHDR("WARDRB")=WARDRB
  1. S GMTSPHDR("WARDRBS")=WARDRBS,GMTSPHDR("DOB")=DOB,GMTSPHDR("DOBS")=64
  1. I (NMSSNE'<WARDRBS)!(WARDRBE'<64) S GMTSPHDR("TWO")=1
  1. Q
  1. ;
  1. NAME(X,Y,L) ; Format name
  1. ;
  1. ; Input
  1. ; X Internal Entry Number of NEW PERSON file 200
  1. ; Y Flag to specify the first name format
  1. ; 0 for First Name Initial (only)
  1. ; 1 for First Name
  1. ; L Maximum Length of Name
  1. ;
  1. ; Output Last,First (name/initial) to specified length
  1. ;
  1. N RAWNM,LAST,FIRST,ALPHA,PSN,CH,IEN,FNF,LEN
  1. S IEN=+($G(X)),FNF=+($G(Y)),LEN=+($G(L))
  1. S RAWNM=$$UNAM^GMTSU2(+IEN) S:LEN=0 LEN=$L(RAWNM)
  1. S RAWNM=$S($L(RAWNM):RAWNM,1:"UNKNOWN")
  1. S LAST=$P(RAWNM,","),FIRST=$P(RAWNM,",",2),ALPHA=0
  1. I $L(FIRST) D
  1. . F PSN=1:1 S CH=$E(FIRST,PSN) Q:CH="" S:CH?1A ALPHA=PSN Q:ALPHA>0
  1. S:ALPHA>0 FIRST=$E(FIRST,ALPHA,$L(FIRST))
  1. S:'FNF FIRST=$E(FIRST,1)
  1. S X=$S($L(FIRST):LAST_","_FIRST,1:LAST),X=$E(X,1,LEN)
  1. Q X
  1. GETRANGE(FROMDATE,TODATE) ; Select Date Range (from and to dates)
  1. N DIR,X,Y,DIROUT,DUOUT,DTOUT,DIRUT S DIR(0)="DO^:DT",DIR("A")="Enter Beginning Date (MM/DD/YY)" W !
  1. D ^DIR I $D(DIROUT)!$D(DUOUT)!$D(DTOUT)!$D(DIRUT) W ! Q
  1. S FROMDATE=Y I +FROMDATE>0 D
  1. . W " (",$$UP^XLFSTR($$FMTE^XLFDT(+FROMDATE,1)),")"
  1. . N DIR,X,Y S DIR(0)="DO^::EX",DIR("A")="Enter Ending Date (MM/DD/YY)" S DIR("B")="TODAY"
  1. . D ^DIR I $D(DIROUT)!$D(DUOUT)!$D(DTOUT)!$D(DIRUT) K FROMDATE Q
  1. . I Y'>0 K FROMDATE Q
  1. . S TODATE=Y Q:TODATE>FROMDATE!(TODATE=FROMDATE)
  1. . N FRDT S FRDT=FROMDATE,FROMDATE=TODATE,TODATE=FRDT
  1. W !
  1. Q
  1. ;
  1. OED() ; Other Editor - DIC("S")
  1. N COMP,OTHER,OWNER,OWNN,USER,AUSER,NAT S COMP=+($G(DA(1))) Q:'$D(^GMT(142,+COMP,0)) 0
  1. S OWNER=$P($G(^GMT(142,+COMP,0)),"^",3),OWNN=$$UNAM^GMTSU2(OWNER),NAT=+($P($G(^GMT(142,+COMP,"VA")),"^",1)),USER=+($G(DUZ)),AUSER=$$UACT^GMTSU2(+USER),OTHER=+($G(X))
  1. ; If National Component and Uneditable
  1. W:+NAT=2 !!," Nationally exported Health Summary Type (uneditable)",! Q:+NAT=2 0
  1. ; If OWNER is special case (national, uneditable)
  1. W:+OWNER>0&(OWNER<1)&(NAT'=1) !!," OWNER does not allow 'OTHER EDITORS'",! Q:+OWNER>0&(OWNER<1)&(NAT'=1) 0
  1. ; If OWNER is special case (national, editable)
  1. Q:+OWNER>0&(OWNER<1)&(OWNER=USER)&(NAT=1) 1
  1. ; If DUZ is inactive, or not the owner, quit
  1. W:+AUSER=0!(+OWNER=0)!(+OWNER'=+USER) !!," Only the OWNER may assign 'OTHER EDITORS'",! Q:+AUSER=0!(+OWNER=0)!(+OWNER'=+USER) 0
  1. ; If OTHER is inactive user, quit
  1. S AUSER=$$UACT^GMTSU2(OTHER) W:+AUSER=0!(+OTHER'>.999999999) !!," Selected 'OTHER EDITOR' is not an active user",! Q:+AUSER=0!(+OTHER'>.999999999) 0
  1. ; If OTHER=OWNER, quit
  1. W:+OTHER=+OWNER !!," ",OWNN," is the OWNER",! Q:+OTHER=+OWNER 0
  1. Q 1
  1. ;
  1. FCLR(X) ; File Closed Root
  1. S X=$G(X) Q:+X=0 "" N GMTSL S GMTSL=$$FLOC(X),X=$S($E(GMTSL,$L(GMTSL))=",":$P(GMTSL,",")_")",1:$E(GMTSL,1,$L(GMTSL)-1)) Q:'$L(X) "" S:'$D(@X) X=""
  1. Q X
  1. FSFN(X) ; File/Sub-File Name
  1. N FI,FR,%X,%Y S FI=$G(X) Q:+X=0 "" N DIERR,GMTSN,GMTSE D FILE^DID(+FI,"N","NAME","GMTSN","GMTSE")
  1. S X="" S:'$D(DIERR) X=$$UP^XLFSTR($G(GMTSN("NAME"))) Q:$L(X) X
  1. K FR S %X="^DD("_+($G(FI))_",0,""NM"",",%Y="FR(" D %XY^%RCR S X=$$UP^XLFSTR($O(FR(""))) S:+X>0 X="" S:$L(X) X=X_" SUB-FILE" Q X
  1. FNAM(X) ; File Name
  1. S X=$G(X) Q:+X=0 "" N DIERR,GMTSN,GMTSE D FILE^DID(+X,"N","NAME","GMTSN","GMTSE") S X="" S:'$D(DIERR) X=$G(GMTSN("NAME")) Q X
  1. FLOC(X) ; File location
  1. S X=$G(X) Q:+X=0 "" N DIERR,GMTSN,GMTSE D FILE^DID(+X,"N","GLOBAL NAME","GMTSN","GMTSE") S X="" S:'$D(DIERR) X=$G(GMTSN("GLOBAL NAME")) Q X
  1. FHDD(X) ; File has a DD?
  1. S X=+($G(X)) Q:+($G(X))=0 0 S X=$$VFIELD^DILFD(X,.01),X=$S($L(X):1,1:0) Q X
  1. FLDN(X,Y) ; Field Name
  1. Q:+($G(X))=0!(+($G(Y))=0) "" S X=$$GET1^DID(+($G(X)),+($G(Y)),,"LABEL") Q X
  1. FLDS(X,Y) ; Field Set of Codes
  1. Q:+($G(X))=0!(+($G(Y))=0) "" Q:$$GET1^DID(+($G(X)),+($G(Y)),,"TYPE")'="SET" "" S X=$$GET1^DID(+($G(X)),+($G(Y)),,"POINTER") Q X
  1. FLDI(X,Y) ; Field Input Transform
  1. Q:+($G(X))=0!(+($G(Y))=0) "" S X=$$GET1^DID(+($G(X)),+($G(Y)),,"INPUT TRANSFORM") Q X
  1. FORMAT(X,GMTSLABEL,DIWL) ; Format long line(s)
  1. N DIWR,DIWF,GMTSLCNT,GMTSLINE
  1. S DIWR=79,DIWF=""
  1. I $G(GMTSLABEL)'="" D
  1. .S GMTSINDENT=$L(GMTSLABEL)+2,GMTSLCNT=0
  1. .K ^UTILITY($J,"W")
  1. .S X=GMTSLABEL_": "_X
  1. E S DIWF="I"_+$G(GMTSINDENT),GMTSLCNT=+$G(^UTILITY($J,"W",DIWL))
  1. D ^DIWP
  1. I $G(GMTSLABEL)'="",$G(^UTILITY($J,"W",DIWL))>1 D
  1. .K ^TMP("GMTSTEXT",$J)
  1. .S GMTSLINE=1 F S GMTSLINE=$O(^UTILITY($J,"W",DIWL,GMTSLINE)) Q:'+GMTSLINE D
  1. ..S ^TMP("GMTSTEXT",$J,GMTSLINE)=^UTILITY($J,"W",DIWL,GMTSLINE,0)
  1. ..S ^UTILITY($J,"W",DIWL,GMTSLINE,0)=""
  1. .S DIWF="I"_GMTSINDENT,^UTILITY($J,"W",DIWL)=2
  1. .S GMTSLINE=0 F S GMTSLINE=$O(^TMP("GMTSTEXT",$J,GMTSLINE)) Q:'+GMTSLINE D
  1. ..S X=^TMP("GMTSTEXT",$J,GMTSLINE)
  1. ..D ^DIWP
  1. .K ^TMP("GMTSTEXT",$J)
  1. Q
  1. ;
  1. LINE(GMTSCOL) ; Writes wrapped long lines
  1. N GMTSSUB,GMTSLINE
  1. S GMTSCOL=$G(GMTSCOL,0)
  1. S GMTSSUB=$O(^UTILITY($J,"W",""))
  1. I GMTSSUB="" K GMTSINDENT,^UTILITY($J,"W") Q
  1. S GMTSLINE=0 F S GMTSLINE=$O(^UTILITY($J,"W",GMTSSUB,GMTSLINE)) Q:'+GMTSLINE!($D(GMTSQIT)) D
  1. .D CKP^GMTSUP Q:$D(GMTSQIT)
  1. .W !,?GMTSCOL,$$TRIM^XLFSTR(^UTILITY($J,"W",GMTSSUB,GMTSLINE,0),"R")
  1. K GMTSINDENT,^UTILITY($J,"W")
  1. Q
  1. ;