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

BLRRLHL2.m

Go to the documentation of this file.
BLRRLHL2 ;IHS/MSC/MKK - BLR HL7 Utilities for Reference Lab, part 2 ; 09-Mar-2015 06:30 ; MKK
 ;;5.2;IHS LABORATORY;**1034,1035**;NOV 01, 1997;Build 5
 ; 
 ; Routines moved here from BLRRLHL because BLRRLHL got too large.
 ; 
 Q
 ;
DX2(PAT) ; EP - Continuation from DX^BLRRLHL
 K DIC,BLRDXS,BLRADX,BLRDXA
 S BLRADX=1
 S DIC="^ICD9("
 ; S DIC("S")="I '$P($G(^(0)),U,9)"
 ;
 ; AICD 4.0 re-did File 80.  There is no longer an INACTIVE FLAG.
 ; STATUS is now a multiple.  Note that STATUS=1 is ACTIVE; STATUS=0 is INACTIVE.
 ; Have to fully specify the global so the $O will work.
 S DIC("S")="I $P($G(^ICD9(Y,66,+$O(^ICD9(Y,66,""A""),-1),0)),""^"",2)"  ; Most Current Status
 ;
 S DIC(0)="AEMQZ",DIC("A")="What is the ICD Diagnosis code for billing: "
 D ^DIC
 I Y<0 D  Q
 . D ADDDX(BLRTSTDA)
 . K BLRADX
 S BLRDXS=$$ICDDX^ICDEX(+Y)
 I $G(BLRDXA(+Y)) D  G ENDDX
 . W !,"You have already selected this Diagnosis"
 ;
 G:$G(BLRDXS)="" ENDDX  ; IHS/MSC/MKK - LR*5.2*1034
 ;
 S BLRDXA(+Y)=1
 S BLRDX(DXCNT)=BLRDXS
 ;
SETDX I '$G(BLRADX) D ADDDX(BLRO) Q
 S BLRRL("DX",DXCNT)=$P(BLRDXS,U,2)
 S BLRRL("DX")=$P(BLRDXS,U,2)
 S DXCNT=DXCNT+1
ENDDX D DX2(BLRRL("PAT"))
 Q
 ;
ADDDX(RO) ;-- add the diagnosis to the test since it is not there, this happens when they want all dx for mult accessions
 ;ihs/cmi/maw added dx type LR*5.2*1034  
 N TDA,DXCNT,ORI,TSTDA
 S TSTDA=$G(BLRTS)
 K BLRRL(TSTDA,"DX")
 K BLRRL(TSTDA,"DXE")
 K BLRRL(TSTDA,"DXT")
 S DXCNT=0
 S ORI=$O(^BLRRLO("B",RO,0))
 S TDA=0 F  S TDA=$O(^BLRRLO(ORI,1,TDA)) Q:'TDA  D
 . N DXS
 . S DXCNT=DXCNT+1
 . ;S DXS=$G(BLRDX(TDA))
 . S DXS=$S($D(^ICDS(0)):$$ICDDX^ICDEX($P($G(^BLRRLO(ORI,1,TDA,0)),U)),1:$$ICDDX^ICDCODE($P($G(^BLRRLO(ORI,1,TDA,0)),U)))
 . S BLRRL("DX",DXCNT)=$P(DXS,U,2)
 . S BLRRL("DX")=$P(DXS,U,2)
 . S BLRRL(TSTDA,"DX",TDA)=$P(DXS,U,2)
 . S BLRRL(TSTDA,"DXE",TDA)=$P(DXS,U,4)
 . S BLRRL(TSTDA,"DXT",TDA)=$S($P(DXS,U,20)'=30:"I9",1:"I10")
 . S BLRRL(TSTDA,"DX")=$P(DXS,U,2)  ;cmi/maw 01/20/2010
 . S BLRRL(TSTDA,"DXE")=$P(DXS,U,4)  ;cmi/maw 01/20/2010
 . S BLRRL(TSTDA,"DXT")=$S($P(DXS,U,20)'=30:"I9",1:"I10")  ;cmi/maw 01/20/2010
 Q
 ;
HLSET(BLRINS) ;-- setup hl7 variables
 S INSCNT=BLRINS
 S BLRRL(BLRTSTDA,"INSE",INSCNT)=$P(AGINS(BLRINS),U)
 S BLRRL("INSE",INSCNT)=$P(AGINS(BLRINS),U)
 S BLRRL(BLRTSTDA,"INSI",INSCNT)=$P(AGINS(BLRINS),U,2)
 ;S BLRRL(BLRTSTDA,"INSCOV")=$P(AGINS(BLRINS),U,4)
 S BLRRL(BLRTSTDA,"INSCOV",INSCNT)=$E($G(BLRRL("BILL TYPE")),1,1)
 S BLRRL(BLRTSTDA,"INSPH",INSCNT)=$P(AGINS(BLRINS),U,7)
 S BLRRL(BLRTSTDA,"INSGRP",INSCNT)=$P(AGINS(BLRINS),U,20)
 S BLRRL(BLRTSTDA,"INSREL",INSCNT)=$S($P(AGINS(BLRINS),U,16):$P($G(^AUTTRLSH($P(AGINS(BLRINS),U,16),0)),U),1:"")
 S BLRRL(BLRTSTDA,"INSRELE",INSCNT)=BLRRL(BLRTSTDA,"INSREL",INSCNT)
 I $G(BLRRL(BLRTSTDA,"INSREL",INSCNT))]"" D
 . I BLRRL(BLRTSTDA,"INSREL",INSCNT)="SELF" S BLRRL(BLRTSTDA,"INSREL",INSCNT)=$S(BLRRL("RLE")["QUEST":2,1:1) Q
 . I BLRRL(BLRTSTDA,"INSREL",INSCNT)="SPOUSE" S BLRRL(BLRTSTDA,"INSREL",INSCNT)=$S(BLRRL("RLE")["QUEST":2,1:2),BLRRL(BLRTSTDA,"INSRELE",INSCNT)="SPOUSE" Q
 . I BLRRL(BLRTSTDA,"INSREL",INSCNT)="HUSBAND" S BLRRL(BLRTSTDA,"INSREL",INSCNT)=$S(BLRRL("RLE")["QUEST":2,1:2),BLRRL(BLRTSTDA,"INSRELE",INSCNT)="SPOUSE" Q
 . I BLRRL(BLRTSTDA,"INSREL",INSCNT)="WIFE" S BLRRL(BLRTSTDA,"INSREL",INSCNT)=$S(BLRRL("RLE")["QUEST":2,1:2),BLRRL(BLRTSTDA,"INSRELE",INSCNT)="SPOUSE" Q
 . S BLRRL(BLRTSTDA,"INSREL",INSCNT)=$S(BLRRL("RLE")["QUEST":8,1:3),BLRRL(BLRTSTDA,"INSRELE",INSCNT)="OTHER" Q
 I $G(BLRRL(BLRTSTDA,"INSREL",INSCNT))="" S BLRRL(BLRTSTDA,"INSREL",INSCNT)=$S(BLRRL("RLE")["QUEST":1,1:1),BLRRL(BLRTSTDA,"INSRELE",INSCNT)="SELF"
 S BLRRL(BLRTSTDA,"INSPOL",INSCNT)=$P(AGINS(BLRINS),U,9)
 S BLRRL(BLRTSTDA,"INSELG",INSCNT)=$P(AGINS(BLRINS),U,5)
 S BLRRL(BLRTSTDA,"INSEXP",INSCNT)=$P(AGINS(BLRINS),U,6)
 S BLRRL(BLRTSTDA,"INSPLN",INSCNT)=$S(BLRRL(BLRTSTDA,"INSE",INSCNT)["MEDICARE":"MC",BLRRL(BLRTSTDA,"INSE",INSCNT)["MEDICAID":"MD",1:"PI")
 S BLRRL(BLRTSTDA,"INSTYP",INSCNT)=$P($G(^AUTNINS(BLRRL(BLRTSTDA,"INSI",INSCNT),2)),U)
 I BLRRL(BLRTSTDA,"INSI",INSCNT)]"" D
 . S BLRRL(BLRTSTDA,"INSID",INSCNT)=$TR($P($G(^AUTNINS(BLRRL(BLRTSTDA,"INSI",INSCNT),2)),U,19),"~")  ;cmi/maw 2/17/2009 changed to piece 10 external group name from external id 2
 . S BLRRL(BLRTSTDA,"INSCNME",INSCNT)=$P($G(^AUTNINS(BLRRL(BLRTSTDA,"INSI",INSCNT),0)),U)  ;insurance company name
 . S BLRRL(BLRTSTDA,"INSADD",INSCNT)=$$INSADD^BLRRLHL(BLRRL(BLRTSTDA,"INSI",INSCNT))
 . S BLRRL(BLRTSTDA,"INSADDE",INSCNT)=$TR($P(BLRRL(BLRTSTDA,"INSADD",INSCNT),U),U," ")_"~"_$TR($P(BLRRL(BLRTSTDA,"INSADD",INSCNT),U,3,99),U," ")
 . S BLRRL(BLRTSTDA,"INSPHO",INSCNT)=$P($G(^AUTNINS(BLRRL(BLRTSTDA,"INSI"),0)),U,6)
 . S BLRRL(BLRTSTDA,"INSTYP",INSCNT)=$P($G(^AUTNINS(BLRRL(BLRTSTDA,"INSI"),2)),U)
 S BLRRL(BLRTSTDA,"INSEMP",INSCNT)=$$GET1^DIQ(2,PAT,.3111)
 S BLRRL(BLRTSTDA,"INSNOI",INSCNT)=$$HLNAME^XLFNAME($P(^DPT(PAT,0),U))
 S BLRRL(BLRTSTDA,"INSNOIE",INSCNT)=$P(^DPT(PAT,0),U)
 S INSCNT=INSCNT+1
 ;end of hl7 lines
 Q
 ;
O01(BHL) ;PEP - Order Message
 ;ihs/cmi/maw - added this sub from BHLEVENT so can be update by lab without GIS patch LR*5.2*1034
 K INDA,INA
 I '$G(BHL("PAT")) Q $$MSG(0)
 S INDA=BHL("PAT")
 S INA("DUZ2")=$S($G(BHL("ALTDUZ2")):BHL("ALTDUZ2"),1:DUZ(2))  ;cmi/maw 4/25/2006 DUZ(2) gets reset by GIS
 ;cmi/maw 4/25/2006 changed below code due to lapcorp inadequacy
 I BHL("RLE")'="LABCORP" S INA("SF")=$G(BHL("CLIENT")) ;maw 3/3/2006 dynamic account number in MSH
 S INA("PID20LABO",1)=$G(BHL("CLIENT"))_"^^^"_$S($E($G(BHL("BILL TYPE")),1,1)="T":$G(BHL("INSTYP")),$E($G(BHL("BILL TYPE")),1,1)="P":"P",1:"C")  ;quest client id
 I BHL("RLE")="LABCORP" S INA("PID20LABO",1)=$G(BHL("CLIENT"))_"^^^"_$S($E($G(BHL("BILL TYPE")),1,1)="T":"T",$E($G(BHL("BILL TYPE")),1,1)="P":"P",1:"C")  ;labcorp client id
 S INA("ORC2LABO")=$G(BHL("UID"))
 S INA("ORC12LABO")=$G(BHL("ORDP"))
 S INA("ORC11LABO")=$$DATE^INHUT($G(BHL("CDT")),1)
 S BHLDA=0 F  S BHLDA=$O(BHL(BHLDA)) Q:'BHLDA  D
 . S INA("ORC2LABO",BHLDA)=$G(BHL("UID"))
 . S INA("ORC11LABO",BHLDA)=$G(BHL(BHLDA,"CDT"))
 . S INA("ORC12LABO",BHLDA)=$G(BHL(BHLDA,"ORDP"))
 . S INA("OBR4LABO",BHLDA)=U_U_U_$G(BHL(BHLDA,"TCNM"))
 . S INA("OBR4LABOL",BHLDA)=$G(BHL(BHLDA,"TCNM"))
 . S INA("OBR7LABO",BHLDA)=$G(BHL(BHLDA,"CDT"))
 . S INA("OBR13LABO",BHLDA)="N"
 . S INA("OBR15LABO",BHLDA)=$G(BHL(BHLDA,"SRC"))
 . S INA("OBR18LC",BHLDA)=$G(BHL(BHLDA,"ORD"))
 . S INA("OBR27LABO",BHLDA)="^^^^^"_$S($G(BHL("URG"))=1:"S",$G(BHL("URG"))=10:"A",1:"R")
 . N IDA
 . S IDA=0 F  S IDA=$O(BHL(BHLDA,"INSE",IDA)) Q:'IDA  D
 .. S INDA("IN1",IDA)=""
 .. S INA("IN13LABO",IDA)=$S($G(BHL("RLE"))="LABCORP":U_$G(BHL(BHLDA,"INSID",IDA)),1:$G(BHL(BHLDA,"INSID",IDA)))
 .. S INA("IN14LABO",IDA)=$G(BHL(BHLDA,"INSE",IDA))
 .. S INA("IN15LABO",IDA)=$G(BHL(BHLDA,"INSADD",IDA))
 .. S INA("IN17LABO",IDA)=$G(BHL(BHLDA,"INSPHO",IDA))
 .. S INA("IN18LABO",IDA)=$G(BHL(BHLDA,"INSGRP",IDA))
 .. S INA("IN111LABO",IDA)=$G(BHL(BHLDA,"INSEMP",IDA))
 .. S INA("IN112LABO",IDA)=$$DATE^INHUT($G(BHL(BHLDA,"INSELG",IDA)),1)
 .. S INA("IN113LABO",IDA)=$$DATE^INHUT($G(BHL(BHLDA,"INSEXP",IDA)),1)
 .. S INA("IN115LABO",IDA)=$G(BHL(BHLDA,"INSPLN",IDA))
 .. S INA("IN116LABO",IDA)=$G(BHL(BHLDA,"INSNOI",IDA))
 .. S INA("IN117LABO",IDA)=$G(BHL(BHLDA,"INSREL",IDA))
 .. S INA("IN119LABO",IDA)=$G(BHL(BHLDA,"INSADD",IDA))
 .. S INA("IN136LABO",IDA)=$G(BHL(BHLDA,"INSPOL",IDA))
 .. S INA("IN147LABO",IDA)=$S($G(BHL(BHLDA,"INSCOV",IDA))]"":$E(BHL(BHLDA,"INSCOV",IDA),1,1),1:"C")
 . S INA("GT13LABO",BHLDA)=$G(BHL(BHLDA,"GT1NM"))
 . S INA("GT15LABO",BHLDA)=$G(BHL(BHLDA,"GT1ADD"))
 . S INA("GT16LABO",BHLDA)=$G(BHL(BHLDA,"GT1PHO"))
 . ;cmi/maw 4/4/2008 end of insurance info
 . ;cmi/maw 4/4/2008 beginning of dx
 . S INA("GT13LABO")=$G(BHL(BHLDA,"GT1NM"))
 . S INA("GT15LABO")=$G(BHL(BHLDA,"GT1ADD"))
 . S INA("GT16LABO")=$G(BHL(BHLDA,"GT1PHO"))
 . ;cmi/maw 4/4/2008 end of insurance info
 . ;cmi/maw 4/4/2008 beginning of dx
 . N DGDA
 . S DGDA=0 F  S DGDA=$O(BHL(BHLDA,"DX",DGDA)) Q:'DGDA  D
 .. S INDA("DG1",DGDA)=""
 .. S INA("DG12LABO",DGDA)=$G(BHL(BHLDA,"DXT",DGDA))
 .. S INA("DG13LABO",DGDA)=$G(BHL(BHLDA,"DX",DGDA))_U_$G(BHL(BHLDA,"DXE",DGDA))_U_$G(BHL(BHLDA,"DXT",DGDA))
 .. I BHL("RLE")'="LABCORP" S INA("DG13LABO",DGDA)=$G(BHL(BHLDA,"DX",DGDA))
 .. S INA("DG14LABO",DGDA)=$G(BHL(BHLDA,"DXE",DGDA))
 .. S INA("DG12LABO")=$G(BHL(BHLDA,"DXT",DGDA))
 .. S INA("DG13LABO")=$G(BHL(BHLDA,"DX",DGDA))_U_$G(BHL(BHLDA,"DXE",DGDA))_U_$G(BHL(BHLDA,"DXT",DGDA))
 .. I BHL("RLE")'="LABCORP" S INA("DG13LABO",DGDA)=$G(BHL(BHLDA,"DX",DGDA))
 .. S INA("DG14LABO")=$G(BHL(BHLDA,"DXE",DGDA))
 . ;cmi/maw 4/4/2008 end of dx 
 . S INDA("ORC",BHLDA)=""
 . S INDA("OBR",BHLDA)=""
 . S BHLCDA=0 F  S BHLCDA=$O(BHL(BHLDA,"COMMENT",BHLCDA)) Q:'BHLCDA  D
 .. S INDA("OBX",BHLCDA)=""
 .. S BHLCOM1=$P(BHL(BHLDA,"COMMENT",BHLCDA),U)
 .. S BHLCOM2=$P(BHL(BHLDA,"COMMENT",BHLCDA),U,2)
 .. S BHLCOM3=$P(BHL(BHLDA,"COMMENT",BHLCDA),U,3)
 .. S INA("OBX3LABO",BHLDA,BHLCDA)=U_U_U_BHLCOM1_U_BHLCOM2
 .. S INA("OBX2LABOL",BHLDA,BHLCDA)="ST"
 .. S INA("OBX3LABOL1",BHLDA,BHLCDA)=BHLCOM1
 .. S INA("OBX3LABOL2",BHLDA,BHLCDA)=BHLCOM2
 .. S INA("OBX14LABO",BHLDA,BHLCDA)=$G(BHL("CDT"))
 .. S INA("OBX5LABO",BHLDA,BHLCDA)=BHLCOM3
 .. S INA("OBX3LABLC3",BHLDA,BHLCDA)=$G(BHL("RLE"))
 S INA("ORC2LABO")=$G(BHL("UID"))
 S INA("ORC11LABO")=$G(BHL("CDT"))
 S INA("ORC12LABO")=$G(BHL("ORDP"))
 S INA("OBR4LABO")=U_U_U_$G(BHL("TCNM"))
 S INA("OBR4LABOL")=$G(BHL("TCNM"))
 S INA("OBR7LABO")=$G(BHL("CDT"))
 S INA("OBR13LABO")="N"
 S INA("OBR27LABO")="^^^^^"_$S($G(BHL("URG"))=1:"S",$G(BHL("URG"))=10:"A",1:"R")
 S INDA("ORC")=""
 S INDA("OBR")=""
 S BHLCDA=0 F  S BHLCDA=$O(BHL("COMMENT",BHLCDA)) Q:'BHLCDA  D
 . S INDA("OBX",BHLCDA)=""
 . S BHLCOM1=$P(BHL("COMMENT",BHLCDA),U)
 . S BHLCOM2=$P(BHL("COMMENT",BHLCDA),U,2)
 . S BHLCOM3=$P(BHL("COMMENT",BHLCDA),U,3)
 . S INA("OBX2LABOL",BHLCDA)="ST"
 . S INA("OBX3LABOL1",BHLCDA)=BHLCOM1
 . S INA("OBX3LABOL2",BHLCDA)=BHLCOM2
 . S INA("OBX14LABO",BHLCDA)=$G(BHL("CDT"))
 . S INA("OBX3LABO",BHLCDA)=U_U_U_BHLCOM1_U_BHLCOM2
 . S INA("OBX5LABO",BHLCDA)=BHLCOM3
 . S INA("OBX3LABLC3",BHLCDA)=$G(BHL("RLE"))
 D ^INHF("HL IHS O01 OUT PARENT",.INDA,.INA)
 Q $$MSG(INHF)
 ;
MSG(BHLMVAR)        ;-- return message defining status
 I BHLMVAR="PAT" S BHLRMSG="Patient Not Passed In, Message Not Created"
 I BHLMVAR="VST" S BHLRMSG="Visit Not Passed In, Message Not Created"
 I BHLMVAR="VLAB" S BHLRMSG="VLAB Not Passed In, Message Not Created"
 I BHLMVAR="MFL" S BHLRMSG="Mstr File Not Passed In, Message Not Created"
 I BHLMVAR=0 S BHLRMSG="Message Not Created, problem with GIS call"
 I BHLMVAR S BHLRMSG=BHLMVAR_U_"Message Created Successfully"
 Q $G(BHLRMSG)
 ;