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

BLRLINK3.m

Go to the documentation of this file.
BLRLINK3 ; IHS/HQT/MJL - CONT. OF BLR - IHS LABORATORY VISIT CREATION ; 13-Oct-2017 14:04 ; MKK
 ;;5.2;IHS LABORATORY;**1010,1011,1014,1015,1018,1021,1022,1024,1025,1027,1028,1029,1030,1031,1033,1034,1037,1039,1041**;NOV 01, 1997;Build 23
 ;
EP ; EP
 S BLRVFILE="9000010"_$S(BLRSS="CH":".09",BLRSS="MI":".25",BLRSS="BB":".31",1:"??")
 I BLRVFILE["??" S BLRERR=1,BLRBUL=2,BLRPCC="Unknown Test Subscript - link not yet implemented" Q
 ;
 S BLRVGL=$$GETGREF(BLRVFILE)
 D VBUILD Q:BLRERR
 D VEDIT
 Q
 ;
VBUILD ; EP create APCDALVR array which is the array containing the elements to be passed to PCC
 ;--- BEGIN cmi/anch/maw REF LAB -- LR*5.2*1021
 I $G(^BLRTXLOG("BVER",BLRIEN))]"" D  Q  ;cmi/maw don't move to pcc if held for verification, ref lab
 . S BLRERR=1,BLRBUL=0
 . S BLRPCC="Result being held for verification"
 ;--- END cmi/anch/maw end REF LAB -- LR*5.2*1021
 ;
 ;----- BEGIN IHS/OIT/MKK MODIFICATIONS LR*5.2*1022
 ; Make sure CLINIC STOP CODE of LABORATORY SERVICES is used, if it exists
 NEW LABCLIN,OUT
 D FIND^DIC(40.7,"","","","LABORATORY SERVICES","","","","","OUT")
 S LABCLIN=+$G(OUT("DILIST",2,1))
 I LABCLIN>0 D
 . Q:$D(APCDALVR("APCDTCLN"))           ; If and Only If APCDALVR("APCDCLN")=""  -- IHS/MSC/MKK - LR*5.2*1031
 . ; S APCDALVR("APCDTCLN")="`"_LABCLIN
 . ; ----- BEGIN IHS/MSC/MKK - LR*5.2*1039
 . NEW LOGSTOP
 . S LOGSTOP=+$$GET1^DIQ(9009022,BLRLOGDA,109,"I")
 . S APCDALVR("APCDTCLN")="`"_$S(LOGSTOP:LOGSTOP,1:LABCLIN)
 . ; ----- END IHS/MSC/MKK - LR*5.2*1039
 ;----- END IHS/OIT/MKK MODIFICATIONS LR*5.2*1022
 ;
 S APCDALVR("APCDTCSF")=BLRSTAT
 S APCDALVR("APCDTLAB")=$S(BLRTLAB="":BLRTNAM,1:"`"_BLRTLAB)
 S APCDALVR("APCDTORD")=BLRORD
 S APCDALVR("APCDTCDT")=BLRCDT
 S APCDALVR("APCDTODT")=BLRODT
 S APCDALVR("APCDTACC")=BLRACC
 ;
 ; send parent ien of V file entry for children of panel
 S:BLRPAREN'="" APCDALVR("APCDTPNT")="`"_$P($G(^BLRTXLOG(BLRPAREN,1)),U,5)
 ;ADDED FOR LOINC PROJECT
 S:$G(APCDALVR("APCDTPNT"))="`" APCDALVR("APCDTPNT")=""  ;ITSC/IHS/TPF 03/04/02 ADDED FOR LOINC
 S APCDALVR("APCDTLNC")="`"_$G(BLRLOINC)
 ;
 ;----- BEGIN LR*5.2*1028;08/18/10;IHS/OIT/MPW - IHS LOINC/UCUM MODIFICATIONS
 ; N XXX,LRIEN,BLRUNIT,SIEN
 N XXX,LRIEN,SIEN            ; IHS/MSC/MKK - LR*5.2*1033
 S XXX=$G(BLRVAL(0)),LRIEN=+$P(XXX,U,6)
 I LRIEN,$P(^LAB(60,LRIEN,0),U,5)="" S APCDALVR("APCDTLNC")="`"_$P($G(^LAB(60,LRIEN,9999999)),U,2)
 ; K XXX,LRIEN,BLRUNIT,SIEN
 K XXX,LRIEN,SIEN            ; IHS/MSC/MKK - LR*5.2*1033
 ;----- END LR*5.2*1028 - IHS LOINC/UCUM MODIFICATIONS - IHS/OIT/MPW
 ;
 D:+$L($G(BLRCOMDT))<1 GETCOMPD(BLRLOGDA,BLRACC,$S(BLRTLAB="":BLRTNAM,1:BLRTLAB),.BLRCOMDT)     ; IHS/OIT/MKK - LR*5.2*1031
 ;
 S APCDALVR("APCDTRDT")=$G(BLRCOMDT)
 S APCDALVR("APCDTCLS")="`"_$G(BLRCOLSA)
 S:$G(APCDALVR("APCDTLNC"))="`" APCDALVR("APCDTLNC")=""
 S:APCDALVR("APCDTCLS")="`" APCDALVR("APCDTCLS")=""
 ;END LOINC STUFF
 ;
 S APCDALVR("APCDTCOS")=BLRCOST
 S APCDALVR("APCDTBIL")=BLRBILL
 S APCDALVR("APCDTCPS")=BLRCPTST
 S APCDALVR("APCDTSDI")=BLRSDI
 ;
 ;[LR*5.2*1028;08/18/10;IHS/OIT/MPW]S:$G(BLRUNIT)'="" APCDALVR("APCDTUNI")=BLRUNIT
 I $G(BLRUNIT)'="",'$D(APCDALVR("APCDTUNI")) S APCDALVR("APCDTUNI")=BLRUNIT
 ;
 S APCDALVR("APCDTRFL")=BLRRFL
 S APCDALVR("APCDTRFH")=BLRRFH
 ;
 ;S APCDALVR("APCDTRES")=$E(BLRRES,1,10)
 D:$G(BLRRES)'="" CHSETCOD^BLRLINK4   ; IHS/MSC/MKK - LR*5.2*1031
 S APCDALVR("APCDTRES")=$E(BLRRES,1,30)  ;cmi/maw 3/25/03 changed for ref lab
 ;S APCDALVR("APCDTRES")=BLRRES   ;IHS/ITSC/TPF 03/25/02 WHY A LIMIT OF 10?
 ;THIS IS OLD COMMENT STUFF
 ;I $D(BLRCOM(1)) S APCDALVR("APCDTLC1")=BLRCOM(1)
 ;I $D(BLRCOM(2)) S APCDALVR("APCDTLC2")=BLRCOM(2)
 ;I $D(BLRCOM(3)) S APCDALVR("APCDTLC3")=BLRCOM(3)
 ;
 ;create micro or Blood Bank specific elements in the APCDALVR array
 I BLRSS="MI" D  ;IHS/DIR TUC/FJE 12/08/98
 . S APCDALVR("APCDTORG")=$S(BLRORG="":BLRORGN,1:"`"_BLRORG),APCDALVR("APCDTANT")=$S(BLRANT="":BLRANTN,1:"`"_BLRANT) ; IHS/DIR TUC/FJE 12/08/98
 . S:$G(BLRCOLSP)="" BLRCOLSP=$P($G(^LAB(60,+$G(BLRTEST),0)),"^",9)                                                 ; IHS/MSC/MKK - LR*5.2*1031
 . ;S APCDALVR("APCDTCOL")=$S($G(BLCOLSP)="":$G(BLCOLSP),1:"`"_BLRCOLSP) S:+BLRCOMPD APCDALVR("APCDTCMD")=BLRCOMPD   ; IHS/DIR TUC/FJE 12/08/98
 . S APCDALVR("APCDTCOL")=$S($G(BLCOLSP)'="":$G(BLCOLSP),1:"`"_BLRCOLSP) S:+BLRCOMPD APCDALVR("APCDTCMD")=BLRCOMPD   ; IHS/ITSC/TPF CHINLE FIX 08/16/02
 ;
 D:BLRSS="CH" ADDORDL^BLRLNKU2(BLRLOGDA,.APCDALVR)    ; IHS/MSC/MKK - LR*5.2*1039 - Add in Ordering Location for CH tests if missing
 ;
 S:BLRSS="BB" APCDALVR("APCDTBTN")=BLRBTN,APCDALVR("APCDTANT")=$S(BLRANT="":BLRANTN,1:"`"_BLRANT)
 ;
 S:BLREPRV'="" APCDALVR("APCDTEPR")="`"_BLREPRV
 S:BLROPRV'="" APCDALVR("APCDTPRV")="`"_BLROPRV
 S:BLROPRV="" APCDALVR("APCDTOPR")=$S(BLROPNM="":BLREPNM,1:BLROPNM)
 S:BLRSITE'="" APCDALVR("APCDTSTE")="`"_BLRSITE
 I BLRCPT,$D(^BLRCPT(BLRCPT,0)) S:BLRCPT'="" APCDALVR("APCDTCPT")="`"_BLRCPT ;FJE 1/25/2000
 I BLRVIEN'="" S BLRMOD=1,APCDALVR("APCDLOOK")=BLRVIEN ; do mod
 Q
 ;
VEDIT ; EP update V file entries
 ; ----- BEGIN IHS/MSC/MKK - LR*5.2*1031
 NEW REFLABF              ; REFerence LAB Flag
 ;
 S REFLABF=0              ; Initialize to FALSE
 ; ----- END IHS/MSC/MKK - LR*5.2*1031
 ;
 I BLRSTAT="D" S DIK=BLRVGL,DA=BLRVIEN D CALLDIK^BLRNLINK Q  ;;results null - do delete
 S BLRTRAN=1
 ;M ^BLRAPCD=APCDALVR
 ; S APCDALVR("APCDTABN")=$S('$D(BLRMOD):BLRABNL,BLRABNL'="":BLRABNL,BLRVIEN="":"",$P($G(@(BLRVGL_"BLRVIEN,0)")),U,5)'="":"@",1:"") ;must be deleted if result value changes
 ;
 S APCDALVR("APCDTABN")=$S('$D(BLRMOD):$G(BLRABNL),BLRVIEN="":"",$P($G(@(BLRVGL_"BLRVIEN,11)")),U,9)="R":"@",$G(BLRABNL)'="":BLRABNL,1:"")  ; IHS/MSC/MKK - LR*5.2*1031 - code will delete flag if result value changes
 ;
 ; S APCDALVR("APCDATMP")=$S($D(BLRMOD):"[APCDALVR "_BLRVFILE_" (MOD)]",1:"[APCDALVR "_BLRVFILE_" (ADD)]") D ^APCDALVR
 ; ----- BEGIN IHS/OIT/MKK LR*5.2*1024 MODIFICATIONS
 ;   Several entries in the APCDALVR array were being cleared, so they are now being
 ;   double-checked BEFORE the call to APCDALVR.
 S APCDALVR("APCDATMP")=$S($D(BLRMOD):"[APCDALVR "_BLRVFILE_" (MOD)]",1:"[APCDALVR "_BLRVFILE_" (ADD)]")
 I $G(APCDALVR("APCDDATE"))="" S APCDALVR("APCDDATE")=$G(BLRCD)
 I $G(APCDALVR("APCDLOC"))="" S APCDALVR("APCDLOC")=$G(BLR("SITE"))
 I $G(APCDALVR("APCDPAT"))="" S APCDALVR("APCDPAT")=$G(BLRVADFN)
 I $G(APCDALVR("APCDCAT"))="" S APCDALVR("APCDCAT")=$G(BLRVCAT)
 I $G(APCDALVR("APCDTYPE"))="" S APCDALVR("APCDTYPE")=$S($P($G(^APCCCTRL(BLR("SITE"),0)),U,4)'="":$P($G(^(0)),U,4),1:"I")
 ;
 ; ----- BEGIN IHS/OIT/MKK - LR*5.2*1027
 I $G(APCDALVR("APCDTLPV"))=""&($G(BLRLPOV)'="") D
 . NEW IHSLPOV
 . I $G(BLRLPOV)["^" S IHSLPOV=$P(BLRLPOV,"^",2)
 . S:$G(IHSLPOV)="" IHSLPOV="`"_$P(BLRLPOV,"^")
 . ; I +$$ICDDX^ICDCODE($P(IHSLPOV,"`",2))<1 S IHSLPOV=$P(IHSLPOV,"`",2)    ; IHS/MSC/MKK - LR*5.2*1031
 . ; I +$$ICDDX^ICDCODE($TR($P(IHSLPOV,"`",2),$C(34)))<1 S IHSLPOV=$P(IHSLPOV,"`",2)    ; IHS/MSC/MKK - LR*5.2*1033 -- Make certain no quotes are passed to the ICDCODE routine.
 . I +$$ICDDX^ICDEX($P(IHSLPOV,"`",2),,,"I")<1 S IHSLPOV=$P(IHSLPOV,"`",2)              ; IHS/MSC/MKK - LR*5.2*1034 -- Use AICD 4.0 function
 . S APCDALVR("APCDTLPV")=IHSLPOV
 ; ----- END IHS/OIT/MKK - LR*5.2*1027
 ;
 ;APCDTLPV
 ;----- BEGIN IHS/OIT/MKK MODIFICATIONS LR*5.2*1025
 ; USER LAST UPDATE field in Visit file is populated by the DUZ.
 ; Temporarily change the DUZ, if possible
 NEW OLDDUZ,USER,TSTR
 M OLDDUZ=DUZ
 ; I +$G(BLRLOGDA)>0 S USER=$P($G(^BLRTXLOG(BLRLOGDA,20)),"^",6)
 ; I +$G(USER)>0 S TSTR="DUZ"_"=USER"  S @TSTR
 ;----- END IHS/OIT/MKK MODIFICATIONS LR*5.2*1025
 ;
 ;----- BEGIN IHS/OIT/MKK MODIFICATIONS LR*5.2*1027
 D RESETDUZ^BLRPCCVC
 ; S APCDALVR("APCDTEPR")="`"_DUZ      ; IHS/OIT/MKK - LR*5.2*1029 - Line commented out
 ;----- END IHS/OIT/MKK MODIFICATIONS LR*5.2*1027
 ;
 I $G(APCDALVR("BLRLINK"))="" S APCDALVR("BLRLINK")=1
 ;
 ; D HL7REFLR   ; IHS/OIT/MKK - LR*5.2*1027 -- Make sure Ref Lab Reference Ranges used, if they exist
 D HL7REFLR^BLRLINK4(.REFLABF)    ; IHS/MSC/MKK - LR*5.2*1031 -- External Routine
 ;
 ; D CHKPCCRU   ; IHS/OIT/MKK - LR*5.2*1030
 ;
 ; ----- BEGIN IHS/MSC/MKK - LR*5.2*1031
 I 'REFLABF D
 . D CHKPCCRU^BLRLINK4
 . D CHKREFA^BLRLINK4
 . D LOTZERO^BLRLINK4(.APCDALVR)
 ; ----- END IHS/MSC/MKK - LR*5.2*1031
 ;
 ; D RESETLOI        ; IHS/MSC/MKK - LR*5.2*1031 -- Have to reset LOINC each time
 D RESETLOI^BLRLNKU1    ; IHS/MSC/MKK - LR*5.2*1041
 ;
 D RESETPOV^BLRLINK4    ; IHS/MSC/MKK - LR*5.2*1033 -- Make Certain Lab POV valid
 ;
 ; ----- BEGIN IHS/MSC/MKK - LR*5.2*1033
 D
 . NEW ICDNAME
 . S ICDNAME=$$GET1^DIQ(80,+$P($G(APCDALVR("APCDTICD")),"`",2),.01)
 . I ICDNAME=".9999"!(ICDNAME="ZZZ.999") K APCDALVR("APCDTICD")
 ; ----- END IHS/MSC/MKK - LR*5.2*1033
 ;
 D RESETABN   ; IHS/MSC/MKK - LR*5.2*1041 - Set ABNORMAL flag to value in the Lab Data file every time
 ;
 D ^APCDALVR
 ;
 ; ----- END IHS/OIT/MKK LR*5.2*1024 MODIFICATIONS
 ;
 D MSNOMED^BLRLINK4     ; IHS/MSC/MKK - LR*5.2*1033 -- Make Certain VLAB SNOMED field is set
 ;
 ;----- BEGIN IHS/OIT/MKK MODIFICATIONS LR*5.2*1025
 S TSTR="DUZ"_"=OLDDUZ"
 ; S @TSTR                          ; Change DUZ back
 M @TSTR                          ; Change DUZ back -- LR*5.2*1027
 ;----- END IHS/OIT/MKK MODIFICATIONS LR*5.2*1025
 ;
 I '$D(APCDALVR("APCDAFLG")) D
 .S:'BLRVIEN BLRVIEN=$G(APCDALVR("APCDADFN"))
 .I 'BLRVIEN,$D(@(BLRVGL_"""ALR"",APCDALVR(""APCDVSIT""),BLRACC,BLRTLAB)")) S BLRVIEN=$O(@(BLRVGL_"""ALR"",APCDALVR(""APCDVSIT""),BLRACC,BLRTLAB,0)"))
 .K DIE,DA,DR
 .S DIE="^BLRTXLOG(",DA=BLRIEN,DR="104///^S X="_BLRVFILE_";105///^S X=BLRVIEN"
 .D ^DIE
 .K BLRCMSG  ;IHS/ITSC/TPF 02/17/2004 ADDED TO CLEAR ERRO MESSAGE FOR COMMENTS LR*5.2*1018 RESULT OF "No V Lab Entry" message showing up in Tuba City EHR alpha testing
 .I $O(BLRCOM("")) D
 ..S BLRCMSG=$$LABC^APCDALVR(BLRVIEN,.BLRCOM)  ;maw comments
 .. K BLRCOM  ; IHS/MSC/MKK - LR*5.2*1041 - Make sure array is cleared after it's stored once.
 .I $G(BLRCMSG)]"" S BLRBUL=2,BLRERR=1,BLRPCC=$P($G(BLRCMSG),U,2)  ;maw
 .K BLRCMSG  ;IHS/ITSC/TPF 02/17/2004 ADDED TO CLEAR ERRO MESSAGE FOR COMMENTS
 .Q
 .S BLRBUL=2,BLRPCC="Another user is editing this TX file entry..."_BLRIEN S BLRERR=1
 .W:'BLRQUIET !,"Another user is editing this TX file entry..."_BLRIEN,! S BLRERR=1
 ;	
 I $G(APCDALVR("APCDAFLG"))=1 S BLRBUL=2,BLRPCC="Invalid template for result display"_" FLG = 1" W:'BLRQUIET !,BLRPCC,!
 ;
 D ^BLRLINKP:$G(APCDALVR("APCDAFLG"))=2
 ;
 K APCDALVR
 Q
 ;
GETGREF(BLRX) ; EP
 Q $G(^DIC(BLRX,0,"GL"))
 ;
 ; If Complete Date variable is null, but there is a complete date, reset it
GETCOMPD(BLRLOGDA,LRAS,F60IEN,COMPDATE) ; EP
 NEW LRAA,LRAD,LRAN,LOGCOMPD,PTR,RESULTDT
 ;
 ; ----- BEGIN IHS/MSC/MKK - LR*5.2*1039
 Q:+$G(BLRLOGDA)<1
 Q:$L(LRAS)<1
 Q:+$G(F60IEN)<1
 Q:BLRSTAT'="R"    ; Has to have status of "RESULTED"
 ;
 ; If COMPLETE DATE in 9009022, use it
 S RESULTDT=$$GET1^DIQ(9009022,BLRLOGDA,1309,"I")
 I RESULTDT S COMPDATE=RESULTDT  Q
 ;
 Q:$$RDINF63^BLRLNKU2(BLRLOGDA,LRAS,F60IEN,.COMPDATE)    ; IHS/MSC/MKK - LR*5.2*1039
 ; ----- END IHS/MSC/MKK - LR*5.2*1039
 ;
 Q:$$GETACCCP^BLRUTIL3(LRAS,.LRAA,.LRAD,.LRAN)<1
 ;
 ; Check Accession file for COMPLETE DATE
 S PTR=+$O(^LRO(68,LRAA,1,LRAD,1,LRAN,4,"B",F60IEN,0))
 Q:PTR<1
 ;
 S RESULTDT=+$P($G(^LRO(68,LRAA,1,LRAD,1,LRAN,4,PTR,0)),"^",5)
 Q:RESULTDT<1
 ;
 S COMPDATE=RESULTDT
 ;
 ; If Complete Date not in ^BLRTXLOG, set it
 S:+$P($G(^BLRTXLOG(BLRLOGDA,13)),"^",9)<1 $P(^BLRTXLOG(BLRLOGDA,13),"^",9)=RESULTDT
 Q
 ; ----- END IHS/MSC/MKK - LR*5.2*1031
 ;
 ; ----- BEGIN IHS/MSC/MKK - LR*5.2*1041
RESETABN ; EP - For "CH" tests only, make sure "Abnormal" Flag is the same as the one in the LAB DATA file
 NEW (APCDALVR,BLRACCN,BLRTLAB,BLRTEST,DILOCKTM,DISYS,DT,DTIME,DUZ,IO,IOBS,IOF,IOM,ION,IOS,IOSL,IOST,IOT,IOXY,U,XPARSYS,XQXFLG)
 ;
 Q:+$G(BLRTLAB)<1               ; Skip if no test variable
 Q:$L($G(BLRACCN))<1            ; Skip if no Accession string
 ;
 S X=$$GETACCCP^BLRUTIL3(BLRACCN,.LRAA,.LRAD,.LRAN)
 Q:LRAA<1!(LRAD<1)!(LRAN<1)
 ;
 S LRSS=$$GET1^DIQ(68,LRAA,.02,"I")
 Q:LRSS'="CH"
 ;
 S LRAAIEN=LRAN_","_LRAD_","_LRAA
 S LRDFN=$$GET1^DIQ(68.02,LRAAIEN,.01,"I")
 Q:LRDFN<1
 ;
 S LRAT=BLRTLAB
 S BLRDATAN=$$GET1^DIQ(60,LRAT,400,"I")
 Q:BLRDATAN<1
 ;
 S LRIDT=$$GET1^DIQ(68.02,LRAAIEN,13.5,"I")
 Q:LRIDT<1
 ; 
 S LRDATABN=$P($G(^LR(LRDFN,LRSS,LRIDT,BLRDATAN)),U,2)
 S APCDALVR("APCDTABN")=$S($L(LRDATABN):LRDATABN,1:"@")
 Q
 ; ----- END IHS/MSC/MKK - LR*5.2*1041