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

BLRAG05.m

Go to the documentation of this file.
  1. BLRAG05 ; IHS/MSC/SAT - LABORATORY ACCESSION GUI RPCS ; 05-Apr-2016 08:52 ; MKK
  1. ;;5.2;IHS LABORATORY;**1031,1034,1039**;NOV 01, 1997;Build 38
  1. ;
  1. ; BLR REF LAB USING LEDI - UL^BLRAG02 = return the value of the 'REF LAB USING LEDI?' field in the BLR MASTER CONTROL file
  1. ; BLR ICD LOOKUP - ICDLKUP^BLRAG07 = ICD code lookup
  1. ; BLR ORDER REASON LKUP - ORL^BLRAG07 = return order reasons from file 100.03
  1. ; BLR PATIENT LOOKUP - PTLK^BLRAG04 = Patient Lookup
  1. ; BLR PRINTERS AVAILABLE - DEVICE^BLRAG10 = return available printers from the DEVICE file
  1. ; BLR USER LOOKUP - NP^BLRAG06 = return entries from the NEW PERSON table 200 that are 'active'
  1. ;
  1. ; BLR ACCESSION - ACC^BLRAG05 = lab accession processor
  1. ; BLR ACCESSION PRINT - ABR^BLRAG02 = reprint accession label or manifest
  1. ; BLR ALL NON-ACCESSIONED - ANA^BLRAG01 = return all non-accessioned lab records
  1. ; BLR ALL-ACCESSIONED - ABD^BLRAG02 = return all accessioned records for given date range
  1. ; BLR COLLECTION INFO - BLC^BLRAG06 = check BLR PT CONFIRM parameter and return insurances for patient
  1. ; BLR DELETE TEST - DELTST^BLRAG08 = Cancel tests - Test are no longer deleted, instead the status is changed to Not Performed.
  1. ; BLR ORDER/TEST STATUS - LROS^BLRAG03 = return order/test status for given patient and date range
  1. ;
  1. ; BLR SHIP CONF - SC^BLRAG09A = select a shipping configuration
  1. ; BLR MANIFEST BUILD - BM^BLRAG09B = build a shipping manifest
  1. ; BLR MANIFEST CLOSE/SHIP - CLSHIP^BLRAG09C = Close/ship a shipping manifest
  1. ; BLR MANIFEST DISPLAY - DISP^BLRAG09G = screen formatted text for manifest display
  1. ; BLR MANIFEST START - SMONLY^BLRAG09C = Start a shipping manifest only, no building
  1. ; BLR MANIFEST TEST ADD - ADDTEST^BLRAG09C= Add tests to an existing manifest\
  1. ; BLR MANIFEST TEST REMOVE - REMVTST^BLRAG09C= Remove a test from manifest - actually flags test as "removed".
  1. ; BLR MANIFEST TESTS TO ADD- TARPC^BLRAG09B = return tests that can be added to a manifest
  1. ;
  1. ;accessioning GUI (from LROE)
  1. ACC(BLRY,BLRTSTL,BLRCDT,BLRCUSR,BLRPTCM,BLRPTCU,BLRRO,BLRUNC,BLRPAC,BLRBT,BLRAGINS,BLRRLCLA,BLRAOE) ; BLR ACCESSION rpc
  1. ; BLRTSTL = (required) The "TEST POINTERS" portion of this data comes
  1. ; element 39 in the return from BLR ALL NON-ACCESSIONED.
  1. ; List of test pointers with ICD9 pointers for each
  1. ; test/procedure being accessioned separated by ^.
  1. ; Each ^ piece is made up of these pipe pieces:
  1. ; TEST POINTERS | [ICD9_IEN:ICD9_IEN:...] ^ ...
  1. ; Test pointers = pointers to the LAB ORDER ENTRY
  1. ; file 69 - DATE:SPECIMEN:TEST
  1. ; ICD9_IEN - pointer to ICD DIAGNOSIS file 80
  1. ; BLRCDT = (required) Specimen Collection Date in external format
  1. ; BLRCUSR = (required) Specimen Collector - pointer to NEW PERSON file 200
  1. ; BLRPTCM = (optional) Method of patient confirmation - free-text up
  1. ; to 80 characters
  1. ; BLRPTCU = (optional) user that performed patient confirmation - pointer
  1. ; to NEW PERSON file 200
  1. ; BLRRO = (optional) 'Continue if Rollover' Flag?
  1. ; 0=(default) return with message if Rollover has
  1. ; not happened or is in progress
  1. ; 1=continue as if user chose to 'continue anyway'
  1. ; BLRUNC = (optional) 'Continue if Uncollected' flag?
  1. ; 0=(default) return with message if not collected
  1. ; 1=continue as if user chose to 'continue anyway'
  1. ; BLRPAC = (optional) 'Continue if previously accessioned' flag
  1. ; 0=(default) return with message if previously accessioned
  1. ; 1=continue as if user chose to 'continue anyway'
  1. ; BLRBT = (optional) Billing Type; P=Patient, C=Client, T=Third Party
  1. ; BLRAGINS = Required if Billing Type = T;
  1. ; INSURANCE_DATA as returned in BLR COLLECTION INFO:
  1. ; INS_NAME^INS_IEN^??^COVERAGE_NUMBER^ELIGIBILITY_DATE^EXP_DATE^
  1. ; INS_FILE_POINTER^POLICY_HOLDER_NAME^POLICY^...
  1. ; BLRRLCLA = reference lab client account number
  1. ; REF LAB CLIENT ACCOUNT NUMBER multiple
  1. ; in BLR MASTER CONTROL
  1. ; BLRAOE = List of Ask At Order Questions separated by pipe |
  1. ; Each pipe piece contains the following ^ pieces:
  1. ; <question prompt> ^ <result code> ^ <free-text answer> ^ <test name> (test name if from the LABORATORY TEST file 60
  1. ;
  1. ; RETURNS:
  1. ; ERROR_ID ^ POINTER ^ ACCESSION_OR_MESSAGE ^ UID ^ TEST_NAME
  1. ; ERROR_ID = 0=clean
  1. ; 1=error against a single record
  1. ; processing will continue for remaining tests
  1. ; 2=general error - nothing filed
  1. ; only 1 record will be in the return array
  1. ; POINTER = is from the list of passed in pointers in BLRTSTL
  1. ; ACCESSION_OR_MESSAGE =
  1. ; a return record will exist for each UID passed in.
  1. ; POINTER is from the list of passed in pointers in BLRTSTL
  1. ; ACCESSION_OR_MESSAGE = Accession # if a clean return of 0
  1. ; ACCESSION_OR_MESSAGE = Text string message for an error=1
  1. ; TEST_UID = Test Unique ID
  1. ; TEST_NAME = Text from the NAME field of LABORATORY TEST file 60
  1. K LRORIFN,LRNATURE,LREND,LRORDRR
  1. ; BLREF = Error flag
  1. K BLRAGI,BLRAGRL,BLREF,BLRAGUI,BLRIFNL,BLRJ,BLRLTMP
  1. K BLREF,BLREFF,BLRMESS,BLRTMP,BLRTST,BLRUIDC,BLRUIDF
  1. S BLRTMP=""
  1. S BLRMESS=""
  1. S BLREF=0
  1. S BLREFF=0
  1. S (BLRGUI,BLRAGUI)=1
  1. D ^XBKVAR S X="ERROR^BLRAG05D",@^%ZOSF("TRAP")
  1. S BLRAGI=0
  1. K ^TMP("BLRAG",$J)
  1. S BLRY="^TMP(""BLRAG"","_$J_")"
  1. S ^TMP("BLRAG",$J,0)="T00020ERROR_ID^T00020POINTERS^T00200ACCESSION_OR_MESSAGE"
  1. S BLRTSTL=$G(BLRTSTL)
  1. S BLRCDT=$G(BLRCDT)
  1. S BLRCUSR=$G(BLRCUSR)
  1. S BLRPTCM=$G(BLRPTCM)
  1. S BLRPTCU=$G(BLRPTCU)
  1. S BLRRO=$G(BLRRO)
  1. S BLRUNC=$G(BLRUNC)
  1. S BLRPAC=$G(BLRPAC)
  1. S BLRBT=$G(BLRBT)
  1. S BLRAGINS=$G(BLRAGINS)
  1. S LRLWC="WC"
  1. S XQY0=^DIC(19,$O(^DIC(19,"B","LROE",0)),0)
  1. I '$G(DUZ(2)) D ERR^BLRAG05D("BLRAG05: You must have a site defined. (NO DUZ(2))") Q
  1. S:$G(BLRRLCLA)="" BLRRLCLA=$P($$CLIENT^BLRAG02(),"|",1)
  1. I $G(BLRRLCLA)="" D ERR^BLRAG05D("BLRAG05: You must have a Client Account Number defined.") Q
  1. S (MSCRLCLA,BLRRLCLA)=$G(BLRRLCLA)
  1. I 0,+$G(BLRRO)'=1,$D(^LAB(69.9,1,"RO")),+$H'=+$P(^("RO"),U) D ERR^BLRAG05D("BLRAG05: ROLLOVER "_$S($P(^("RO"),U,2):"IS RUNNING.",1:"HAS NOT RUN.")_" ACCESSIONING SHOULDN'T BE DONE NOW. Continue anyway?") Q
  1. D BLRTSTL^BLRAG05A(.BLRTSTL) ;make sure all tests for the specimens represented in the input are processed
  1. D ^LRPARAM
  1. ;
  1. S:$G(BLROPT)=""!($G(BLROPT(0))'=$P(XQY0,U)) BLROPT="ITMCOL",BLROPT(0)=$P(XQY0,U) ;IHS/OIRM TUC/AAB 2/1/97
  1. ;
  1. D ^LRPARAM
  1. ;I $G(LREND) S LREND=0 Q
  1. ;
  1. L5 ;
  1. NEXT ;from LROE1
  1. ;convert external dates to FM format
  1. ; collection date
  1. I BLRCDT'="" D
  1. .S X=BLRCDT,%DT="XT" D ^%DT S BLRCDT=Y
  1. .I $$FR^XLFDT($G(BLRCDT)) D ERR^BLRAG05D("BLRAG05: Invalid Collection Date.") S BLREF=1
  1. ;
  1. Q:BLREF=1
  1. ;S BLRCDT=$P(BLRCDT,".",1)
  1. ;verify patient confirmation input
  1. I $$PTC^BLRAGUT() D
  1. .I $G(BLRPTCM)="" D ERR^BLRAG05D("BLRAG05: Patient Confirmation Method is Required.") S BLREF=1 Q
  1. .I $G(BLRPTCU)="" D ERR^BLRAG05D("BLRAG05: Patient Confirmation User is Required.") S BLREF=1 Q
  1. Q:BLREF
  1. ;I $D(LROESTAT) D:$P(LRPARAM,U,14) ^LRCAPV I $G(LREND) K LRLONG,LRPANEL Q
  1. S (LRODT,X,DT)=$$DT^XLFDT(),LRODT0=$$FMTE^XLFDT(DT,5)
  1. S X="T-7",%DT="" D ^%DT S LRTM7=+Y
  1. ;
  1. ;process TESTs
  1. S BLRCNT=0
  1. F BLRJ=1:1:$L(BLRTSTL,U) D
  1. .S BLRRET=""
  1. .S BLREF=0
  1. . ;
  1. . ;
  1. .I 0 D ;'$P($G(^BLRSITE($S($G(BLRALTDZ):BLRALTDZ,1:DUZ(2)),"RL")),U,22) D ;not using LEDI
  1. ..S BLRDT=$P($P($P(BLRTSTL,U,BLRJ),"|",1),":",1)
  1. ..S BLRSP=$P($P($P(BLRTSTL,U,BLRJ),"|",1),":",2)
  1. ..; D REFLABS^BLRAGUT3 ; Store Ref Lab Info into 9009026.3 - IHS/MSC/MKK - LR*5.2*1039
  1. ..S BLRTST=$P($P($P(BLRTSTL,U,BLRJ),"|",1),":",3)
  1. ..;S BLRTSN=$$GET1^DIQ(60,$P($G(^LRO(69,BLRDT,1,BLRSP,2,BLRTST,0)),U,1)_",",.01)
  1. ..S BLRTSN=$$TESTNAME^BLRAGUT(+$P($G(^LRO(69,BLRDT,1,BLRSP,2,BLRTST,0)),U,1)) ;get test name
  1. ..S (BLRTST60,LRTS)=$P($G(^LRO(69,+$G(BLRDT),1,+$G(BLRSP),2,+$G(BLRTST),0)),U,1) ;get test
  1. ..S BLRAGRL=+$G(^BLRSITE(DUZ(2),"RL")) ;get reference lab
  1. ..S BLRAGRLN=$P($G(^BLRRL(BLRAGRL,0)),U,1)
  1. ..I '+$$CODE^BLRRLEVT(BLRAGRL,BLRTST60) S BLRRET="Test "_BLRTSN_" is not defined in the BLR REFERENCE LAB file for reference lab "_BLRAGRLN_"." S BLREF=1
  1. . ;
  1. .D:'BLREF UID($P(BLRTSTL,U,BLRJ),BLRAGINS,.BLREF,.BLRRET)
  1. .S:BLREF BLREFF=1
  1. .S BLRDT=$P($P($P(BLRTSTL,U,BLRJ),"|",1),":",1)
  1. .S BLRSP=$P($P($P(BLRTSTL,U,BLRJ),"|",1),":",2)
  1. .D REFLABS^BLRAGUT3 ; Store Ref Lab Info into 9009026.3 - IHS/MSC/MKK - LR*5.2*1039
  1. .S BLRTST=$P($P($P(BLRTSTL,U,BLRJ),"|",1),":",3)
  1. .S (BLRUID,LRUID)=$P($G(^LRO(69,BLRDT,1,BLRSP,2,BLRTST,.3)),U,1)
  1. .S BLRTSN=$P($G(^LRO(69,BLRDT,1,BLRSP,2,BLRTST,0)),U,1)
  1. .;S BLRTSN=$$GET1^DIQ(60,BLRTSN_",",.01)
  1. .S BLRTSN=$$TESTNAME^BLRAGUT(+BLRTSN)
  1. .S BLRAGI=BLRAGI+1 S BLRTMP("BLRAG",$J,BLRAGI)=+BLREF_U_$P(BLRTSTL,U,BLRJ)_U_BLRRET_U_BLRUID_U_BLRTSN
  1. .;S BLRAGI=BLRAGI+1 S ^TMP("BLRAG",$J,BLRAGI)=+BLREF_U_$P(BLRTSTL,U,BLRJ)_U_BLRRET_U_BLRUID_U_BLRTSN
  1. .S ^TMP("BLRAG",$J,0)=$S(+BLREFF:"T00020ERROR_ID",1:"T00020CLEAN")_"^T00020POINTERS^T00200ACCESSION_OR_MESSAGE"
  1. .S BLRAGI="" F S BLRAGI=$O(BLRTMP("BLRAG",$J,BLRAGI)) Q:BLRAGI="" D
  1. ..S ^TMP("BLRAG",$J,BLRAGI)=BLRTMP("BLRAG",$J,BLRAGI)
  1. ;
  1. D:BLRBT="T" STORDIAG ; Store diagnosis codes if Billing Type = "T" -- IHS/MSC/MKK - LR*5.2*1034
  1. ;
  1. K BLRTMP
  1. Q
  1. ;
  1. UID(BLRPTR,BLRAGINS,BLREF,BLRRET) ; process single UID
  1. ; BLRPTR = pointer to the LAB ORDER ENTRY
  1. ; file 69 - DATE:SPECIMEN:TEST|INSURANCE_DATA
  1. ; BLRDX = Required if Billing Type = T;
  1. ; List of ICD9 ien(s) delimited by colon :
  1. ; pointer to the ICD DIAGNOSIS file 80.
  1. ; BLREF = returned error flag - set to 1 if an error is encountered
  1. ; .BLRRET = <accession #> OR <error message>
  1. D BLRRL^BLRAG05D ; IHS/cmi/maw 9/9/2004 added check for ship manifest
  1. K DIC,LRSND,LRSN
  1. S BLRRET=""
  1. S BLRP69=$P(BLRPTR,"|",1)
  1. S BLRAGDX=$P(BLRPTR,"|",2)
  1. S LRODT=$P(BLRP69,":",1)
  1. S (BLRSN,DA)=$P(BLRP69,":",2)
  1. S BLRTST=$P(BLRP69,":",3)
  1. I '$G(^LRO(69,LRODT,1,DA,2,BLRTST,0)) S BLRRET="BLRAG05: Order pointers do not point to a valid Order Number" S BLREF=1 Q
  1. S LRORD=$P(^LRO(69,LRODT,1,DA,.1),U,1)
  1. I '+$G(LRORD) S BLRRET="BLRAG05: UID does not point to a valid Order Number" S BLREF=1 Q
  1. S M9=0
  1. D BLRRL^BLRAG05D ;cmi/anch/maw 8/4/2004 check for shipping manifest from previous order
  1. I '$D(^LRO(69,"C",LRORD)) S BLRRET="BLRAG05: No order exist with that order number." S BLREF=1 Q
  1. ;
  1. K BLRPTRF
  1. S (BLRC1,BLRC3,BLRPTRC,BLRPTRF,LRNONE,M9)=0
  1. S LRCHK=1
  1. D LROE2^BLRAG05D
  1. ;
  1. S BLRSNOD=$G(^LRO(69,LRODT,1,DA,0))
  1. S:BLRCDT="" BLRCDT=$P(BLRSNOD,U,1)
  1. S:BLRCUSR="" BLRCUSR=$P(BLRSNOD,U,3)
  1. I (BLRCDT="")!(BLRCUSR="") S BLRRET="BLRAG05: "_$S(BLRCDT="":"Collection date/time ",1:"")_$S((BLRCDT="")&(BLRCUSR=""):"and ",1:"")_$S(BLRCUSR="":"Collector ",1:"")_"not defined." S BLREF=1 Q
  1. I LRNONE=2 I 0,$G(BLRPAC)'=1 S BLRRET="BLRAG05: The order has already been"_$S(LRCHK<1:" partially",1:"")_" accessioned." S BLREF=1 Q
  1. I LRNONE=1 S BLRRET="BLRAG05: No order exists with that number." S BLREF=1 Q
  1. I '$$GOT^BLRAG05D(LRORD,LRODT) S BLRRET="BLRAG05: All tests for this order have been canceled." S BLREF=1 Q
  1. ;
  1. TSTART
  1. L +^LRO(69,"C",LRORD):1
  1. I '$T S BLRRET="BLRAG05: Someone else is editing this Order" S BLREF=1 TROLLBACK Q
  1. I '$D(^LRO(69,DT,1,0)) S ^LRO(69,DT,0)=DT,^LRO(69,DT,1,0)="^69.01PA^^",^LRO(69,"B",DT,DT)=""
  1. K %DT
  1. S LRSTATUS="C",%DT("B")=""
  1. S LRCDT=BLRCDT
  1. S LRTIM=+LRCDT
  1. S LRUN=$P(LRCDT,U,2) K LRCDT,LRSN
  1. MORE ; I M9>1 K DIR S DIR("A")="Do you have the entire order",DIR(0)="Y" D ^DIR K DIR S:Y=1 M9=0
  1. ;I M9>1 I $G(BLRMSP)'=1 S BLRRET="BLRAG05: Do you have the entire order" D UNL69ERR^BLRAG05D S BLREF=1 Q
  1. S (BLREF,LRSND)=0
  1. S YYYLRORD=LRORD
  1. S LRSND=DA
  1. S LRSN(LRSND)=LRSND,LRSN=LRSND
  1. S BLRODT=LRODT
  1. S BLRSND=LRSND
  1. K LRAA D Q15^BLRAG05D K LRSN
  1. D TASK^BLRAG05D,UNL69^BLRAG05D
  1. D:$G(YYYLRORD)'="" ORDNSTOR^BLRAAORU(YYYLRORD) K YYYLRORD ; IHS/OIT/MKK - LR*5.2*1030 - Store Ask-At-Order Questions
  1. S BLRTNOD=$G(^LRO(69,LRODT,1,LRSND,2,BLRTST,0))
  1. S BLRAA=$P(BLRTNOD,U,4)
  1. S BLRAD=$P(BLRTNOD,U,3)
  1. S BLRAN=$P(BLRTNOD,U,5)
  1. S:BLRAA'="" BLRRET=$P($G(^LRO(68,+$G(BLRAA),1,+$G(BLRAD),1,+$G(BLRAN),.2)),U,1)
  1. Q
  1. ;
  1. ; ----- BEGIN IHS/MSC/MKK - LR*5.2*1034
  1. STORDIAG ; EP - Store the Diagnosis code(s)
  1. NEW BLRAGI,BLRJ,BLRTSTL,ERRS,F60DESC,F60IEN,F60PTR,FDA,ICDSTR,ICDIEN,LRODT,LRSN,LRTN,ORDERN,ORDIEN,STORIEN,STR1,STR2,UID
  1. ;
  1. S BLRAGI=0
  1. F S BLRAGI=$O(^TMP("BLRAG",$J,BLRAGI)) Q:BLRAGI<1 D
  1. . S STR1=$G(^TMP("BLRAG",$J,BLRAGI))
  1. . Q:+$P(STR1,"^") ; Quit if Error (Piece 1 > 0)
  1. . ;
  1. . S BLRTSTL=$P(STR1,"^",2)
  1. . S ICDSTR=$P(BLRTSTL,"|",2)
  1. . Q:ICDSTR="" ; Quit if no ICD code
  1. . ;
  1. . S STR2=$P(BLRTSTL,"|")
  1. . S LRODT=$P(STR2,":",1),LRSN=$P(STR2,":",2),LRTN=$P(STR2,":",3)
  1. . S ORDERN=$$GET1^DIQ(69.01,LRSN_","_LRODT,9.5,"I")
  1. . Q:ORDERN<1 ; Quit if no Order #
  1. . ;
  1. . D STORF69D^BLRAG05A(LRODT,LRSN,LRTN,ICDSTR) ; IHS/MSC/MKK - LR*5.2*1039
  1. . ;
  1. . S LRDFN=$$GET1^DIQ(69.01,LRSN_","_LRODT,.01,"I")
  1. . S DFN=$$GET1^DIQ(63,LRDFN,.03,"I")
  1. . ;
  1. . S F60PTR=$$GET1^DIQ(69.03,LRTN_","_LRSN_","_LRODT,.01,"I")
  1. . Q:$$REFLAB^BLRUTIL6(DUZ(2),+F60PTR)<1 ; If Test not MAPPED, do NOT put into 9009026.3
  1. . ;
  1. . S X=$$ORD^BLRRLEDI(ORDERN,DFN) ; Create entry in 9009026.3, if necessary
  1. . ;
  1. . S ORDIEN=$$FIND1^DIC(9009026.3,,,ORDERN)
  1. . Q:ORDIEN<1 ; Quit if Order # NOT in 9009026.3
  1. . ;
  1. . S UID=$$GET1^DIQ(69.03,LRTN_","_LRSN_","_LRODT,13)
  1. . ;
  1. . ; Store ICD code(s) and Tests into DIAGNOSIS field
  1. . F ICDCNT=1:1:$L(ICDSTR,":") D
  1. .. K ERRS,FDA
  1. .. S ICDIEN=$P(ICDSTR,":",ICDCNT)
  1. .. ;
  1. .. ; Skip if UNCODED DIAGNOSIS
  1. .. Q:$$GET1^DIQ(80,ICDIEN,.01)=".9999"!($$GET1^DIQ(80,ICDIEN,.01)="ZZZ.999")
  1. .. ;
  1. .. K ERRS,FDA
  1. .. S FDA(9009026.31,"?+1,"_ORDIEN_",",.01)=ICDIEN
  1. .. S:$L(F60PTR) FDA(9009026.31,"?+1,"_ORDIEN_",",1)=F60PTR
  1. .. D UPDATE^DIE(,"FDA",,"ERRS")
  1. Q
  1. ; ----- END IHS/MSC/MKK - LR*5.2*1034