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

GMRCHL7U.m

Go to the documentation of this file.
  1. GMRCHL7U ;SLC/DCM,MA - Utilities assoc. with HL7 messages ; 12/1/20 4:51pm
  1. ;;3.0;CONSULT/REQUEST TRACKING;**1,5,12,21,22,29,66,145,168**;DEC 27, 1997;Build 3
  1. ; Patch #21 added more variables to in line tage EXIT.
  1. ;
  1. ; This routine invokes IA #872(FILE 101 ^ORD(100)), #2053(DIE), #10103(XLFDT), #10101(XQOR)
  1. ;
  1. INIT(MSH) ;break out MSH segment separators and set other needed variables
  1. ;MSH = MSH segment of the HL-7 message
  1. N X
  1. S (SEP1,SEP2,SEP3,SEP4,SEP5)=""
  1. S SEP1=$E(MSH,4),X=$P(MSH,SEP1,2)
  1. S SEP2=$E(X,1),SEP3=$E(X,2),SEP4=$E(X,3),SEP5=$E(X,4)
  1. Q
  1. PID(GMRCPID) ;Get fields from PID segment and set into GMRC variables.
  1. S DFN=$P(GMRCPID,SEP1,4),GMRCPNM=$P(GMRCPID,SEP1,6)
  1. Q
  1. NTE(MSG,GMRCNTE,GMRCNODE,CTRLCODE) ;set NTE segments of HL-7 message into variables and globals
  1. ;MSG = whole HL-7 array.
  1. ;GMRCNTE = Node in array where NTE message begins
  1. ;CTRLCODE = segment 1 of the ORC segment of HL-7 message
  1. ;GMRCNODE = IEN of entry int file ^GMR(123,
  1. N GMRCACT ;not sure why this is newed here
  1. S GMRCAD=$G(GMRCAD),GMRCORNP=$G(GMRCORNP),GMRCFF=$G(GMRCFF),GMRCPA=$G(GMRCPA),GMRCDEV=$G(GMRCDEV)
  1. S GMRCACT=$S(CTRLCODE="CA":19,CTRLCODE="DC":6,CTRLCODE="NW":1,1:$O(^GMR(123.1,"D",CTRLCODE,0)))
  1. S GMRCNTC(1)=$P(MSG(GMRCNTE),SEP1,4)
  1. S LN=0,LN1=2 F S LN=$O(MSG(GMRCNTE,LN)) Q:LN="" S GMRCNTC(LN1)=MSG(GMRCNTE,LN),LN1=LN1+1
  1. K LN,LN1
  1. Q
  1. PV1(GMRCPV1) ;Get fields from PV1 segment of HL-7 message and set into GMRC variables
  1. ;GMRCRB = patients room/bed GMRCWARD=patients ward
  1. ;GMRCSBR = service basis to be rendered (Inpatient or Outpatient)
  1. N X
  1. S X=$P(GMRCPV1,SEP1,3),GMRCSBR=$S(X]"":X,1:"")
  1. S X=$P(GMRCPV1,SEP1,4),GMRCWARD=$S($P(X,SEP2,1)]"":$P(X,SEP2,1),1:""),VISIT=$S($P(GMRCPV1,SEP1,20)]"":$P(GMRCPV1,SEP1,20),1:"")
  1. S GMRCRB=$S($P(X,SEP2,2)]"":$P(X,SEP2,2),1:"")
  1. S:VISIT]"" GMRCVSIT=$$FMDATE^GMRCHL7(VISIT)
  1. Q
  1. ;
  1. REJECT(GMRCMSG,REAS) ;action can't be filed send reject message
  1. N MSH,ORC,I ;GMRCMESS
  1. S I=0 F S I=$O(GMRCMSG(I)) Q:'I D
  1. . I $P(GMRCMSG(I),"|")="PID" S PID=GMRCMSG(I)
  1. . I $P(GMRCMSG(I),"|")="ORC" D
  1. .. N ORFN,GMRCFN,P17,CTRLCD
  1. .. S ORFN=$P(GMRCMSG(I),"|",3),GMRCFN=$P(GMRCMSG(I),"|",4)
  1. .. S CTRLCD=$P(GMRCMSG(I),"|",2)
  1. .. S ORC="ORC|"_$S(CTRLCD="NW":"UA",1:"UD")_"|"_ORFN_"|"_GMRCFN
  1. .. S P17=$S($D(REAS):REAS,1:"UNABLE TO FILE ACTION")
  1. .. S $P(ORC,"|",17)="X^REJECTED^99ORN^^"_P17
  1. S MSH=$$MSH^GMRCHL7
  1. S $P(MSH,SEP1,9)="ORR"
  1. S GMRCMESS(1)=MSH
  1. S GMRCMESS(2)=PID
  1. S GMRCMESS(3)=ORC
  1. D MSG^XQOR("GMRC EVSEND OR",.GMRCMESS)
  1. Q
  1. ;
  1. RETURN(GMRCIEN,GMRCTRLC) ;return IEN of record in ^GMR(123,IEN, to OERR
  1. ;GMRCIEN = internal record number of record in ^GMR(123,
  1. ;GMRCTRLC=Control code from HL-7 Table 119
  1. N MSH,PID,ORC,GMRCORCC
  1. S SEP1="|",GMRCORCC=$S(GMRCTRLC="NW":"OK",GMRCTRLC="DC":"DR",1:"OK")
  1. S MSH=$$MSH^GMRCHL7($G(X)) S $P(MSH,SEP1,9)="ORR"
  1. S PID=$$PID^GMRCHL7(GMRCIEN)
  1. D ORC^GMRCHL7(GMRCIEN,GMRCORCC,"") S ORC=$P(ORC,"|",1,4)
  1. D BLD^GMRCHL7(MSH,PID,"",ORC,"","",,"",GMRCTRLC)
  1. D MSG^XQOR("GMRC EVSEND OR",.GMRCMSG)
  1. Q
  1. FILE(GMRCO,DR) ;File data into ^GMR(123,IEN,40 using ^DIE
  1. N DIE,DA,GMRCACTI
  1. ;GMRCO = IEN of record from file ^GMR(123,
  1. ;DR = DR string required by ^DIE
  1. Q:'$G(GMRCO)
  1. L +^GMR(123,+GMRCO,40):$S($G(DILOCKTM)>0:DILOCKTM,1:5) S:'$D(^GMR(123,+GMRCO,40,0)) ^(0)="^123.02DA^^" ;wat/66 added lock timeout
  1. S (DA,GMRCACTI)=$S($P(^GMR(123,+GMRCO,40,0),"^",3):$P(^(0),"^",3)+1,1:1),DA(1)=+GMRCO
  1. S DIE="^GMR(123,"_GMRCO_",40,"
  1. S $P(^GMR(123,+GMRCO,40,0),"^",3,4)=DA_"^"_DA
  1. D ^DIE
  1. I $D(GMRCNTC) D COMMENT^GMRCHL7B(.GMRCNTC)
  1. I $D(GMRCCMT) D COMMENT^GMRCHL7B(.GMRCCMT)
  1. D ; if record is an IFC build and send update
  1. . I '$D(^GMR(123,GMRCO,12)) Q
  1. . D TRIGR^GMRCIEVT(GMRCO,GMRCACTI)
  1. L -^GMR(123,+GMRCO,40)
  1. Q
  1. EXIT ;Kill variables and exit
  1. K HLQ,J,LN,ND,ND1,ND2,SEP1,SEP2,SEP3,SEP4,SEP5
  1. K GMRCA,GMRCACT,GMRCAD,GMRCAP,GMRCAPP,GMRCATN,GMRCDA,GMRCDEV,GMRCFAC,GMRCFF,GMRCINTR,GMRCMTP,GMRCMSG,GMRCMSH,GMRCNOD,GMRCNTC,GMRCODT,GMRCOID,GMRCORFN,GMRCPA,GMRCPLCR,GMRCPLI,GMRCPNM,GMRCPR,GMRCPRI,GMRCFQ
  1. K GMRCPRDG,GMRCSEND,GMRCSTDT,GMRCSTS,GMRCURGI,GMRCVAL,GMRCVTYP,GMRCWARD,GMRCPRV,GMRCTYPE,GMRCND,GMRCND1,VISIT
  1. K GMRCRB,GMRCPRA,GMRCRFQ,MSH,OBXND,PID,GMRCORPV,GMRCOTXT,GMRCNATO,GMRCERDT,GMRCDSID
  1. K GMRCOFN,GMRCS123,GMRCS38,GMRCCMT
  1. K GMRCTRLC,GMRCSS,GMRCO,GMRCORNP
  1. Q
  1. AUDIT0 ;place activity audit tracking info into global ^GMR(123,IEN,40,
  1. ;GMRCACT=processing activity (from ^GMR(123.1,
  1. ;GMRCDA=date/time file entered GMRCAD=date/time activity took place
  1. ;GMRCORNP=name of provider GMRCFF=forwared from (if forwarded)
  1. ;GMRCPA=provider previously assigned
  1. ;GMRCDEV=device printed to GMRCCMT=comment array from OBX segment
  1. N GMRCDA
  1. S GMRCDA=$$NOW^XLFDT
  1. L +^GMR(123,+GMRCO,40):$S($G(DILOCKTM)>0:DILOCKTM,1:5) S:'$D(^GMR(123,+GMRCO,40,0)) ^GMR(123,+GMRCO,40,0)="^123.02DA^^" ;wat/66 added lock timeout
  1. S GMRCAD=$S($D(GMRCAD):GMRCAD,1:GMRCDA),GMRCORNP=$G(GMRCORNP),GMRCFF=$G(GMRCFF),GMRCPA=$G(GMRCPA),GMRCDEV=$G(GMRCDEV),GMRCPLCR=$G(GMRCPLCR)
  1. ;Use the Control code from CPRS in 123.1 to determine the action.
  1. ;If action undefined, then use "ADDED COMMENT", entry 20.
  1. S GMRCACT=$O(^GMR(123.1,"D",GMRCTRLC,0))
  1. S:'GMRCACT GMRCACT=20
  1. S DR=".01////^S X=GMRCDA;1////^S X=GMRCACT;2////^S X=GMRCAD;3////^S X=GMRCORNP;4////^S X=GMRCPLCR;6////^S X=GMRCFF;7////^S X=GMRCPA;8////^S X=GMRCDEV"
  1. D FILE(GMRCO,DR)
  1. L -^GMR(123,+GMRCO,40)
  1. Q
  1. ALERT(GMRCDFN,GMRCSS,GMRCPR,GMRCFN,GMRCURG,GMRCORA) ;generate an alert when receiving a consult
  1. ;GMRCDFN=patient DFN from file 2
  1. ;GMRCSS=Service
  1. ;GMRCPR=procedure being ordered
  1. ;GMRCFN=File 123 IEN
  1. ;GMRCURG=urgency of request from protocol file
  1. ;GMRCADUZ=array of those who receive alerts
  1. ;GMRCORA=action to take on alert: 27 is for new alert
  1. N GMRCORTX
  1. S GMRCORTX="New consult "_$$ORTX^GMRCAU(+GMRCO)_$S(+GMRCURG:" ("_$P(^ORD(101,+GMRCURG,0),"^",2)_")",1:"")
  1. S:'$D(GMRCORA) GMRCORA=27 S:GMRCORA="" GMRCORA=27
  1. D MSG^GMRCP(GMRCDFN,GMRCORTX,GMRCFN,GMRCORA,.GMRCADUZ,1)
  1. K GMRCADUZ
  1. Q
  1. CHKTXT(GMRCTXT) ;Added by GMRC*3*168
  1. N X1,X2
  1. F X1=1:1:$L(GMRCTXT) D
  1. . S X2=$E(GMRCTXT,X1,X1)
  1. . I X2?.E1C.E S $E(GMRCTXT,X1,X1)=" "
  1. Q GMRCTXT