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

GMRCISEG.m

Go to the documentation of this file.
  1. GMRCISEG ;SLC/JFR - CREATE IFC HL7 SEGMENTS ; Jul 23, 2024@10:17:34
  1. ;;3.0;CONSULT/REQUEST TRACKING;**22,66,154,202,189**;DEC 27, 1997;Build 54
  1. ; $$GET1^DIQ ORC+28,ORC+29,OBXTZ+11
  1. ;#2171 XUAF4, #10103 XLFDT, #10106 HLFNC, #3042 MCAPI, #10112 VASITE, #2541 $$KSP^XUPARAM
  1. ;
  1. Q ;don't enter at top
  1. BUILD(SEG,PCS) ;create any segment from array in PCS using |^&/~
  1. ; SEG = ORC,OBR,etc.
  1. ; PCS = array of data elements to be combined into the segement
  1. ; array is numbered by the "|" piece
  1. N ARR,SEGMNT
  1. S ARR=0,SEGMNT=""
  1. F S ARR=$O(PCS(ARR)) Q:'ARR D
  1. . S $P(SEGMNT,"|",ARR)=PCS(ARR)
  1. . Q
  1. Q SEG_"|"_SEGMNT
  1. ORC(GMRCO,GMRCOC,GMRCOS,GMRCACT) ;build ORC for all but new orders
  1. ;Input:
  1. ; GMRCO = ien from file 123
  1. ; GMRCOC = order control
  1. ; GMRCOS = order status
  1. ; GMRCACT = ien in 40 multiple of particular action
  1. ;
  1. ;Output:
  1. ; ORC segment
  1. ;
  1. I '$D(GMRCO)!('$D(GMRCOC))!('$D(GMRCACT)) Q "ERROR"
  1. N GMRCPCS,SITE,GMRCRP
  1. S GMRCPCS(1)=GMRCOC
  1. I $P($G(^GMR(123,GMRCO,12)),U,5)="P" D
  1. . S GMRCPCS(2)=GMRCO_U_$$STA^XUAF4($$KSP^XUPARAM("INST"))_"^GMRCIFR"
  1. . S GMRCPCS(3)=$P(^GMR(123,GMRCO,0),U,22)_U_$$STA^XUAF4($P(^(0),U,23))
  1. . S GMRCPCS(3)=GMRCPCS(3)_"^GMRCIFC"
  1. I $P($G(^GMR(123,GMRCO,12)),U,5)="F" D
  1. . S GMRCPCS(2)=$P(^GMR(123,GMRCO,0),U,22)_U_$$STA^XUAF4($P(^(0),U,23))
  1. . S GMRCPCS(2)=GMRCPCS(2)_"^GMRCIFR"
  1. . S GMRCPCS(3)=GMRCO_U_$$STA^XUAF4($$KSP^XUPARAM("INST"))_"^GMRCIFC"
  1. S GMRCPCS(5)=$S($D(GMRCOS):GMRCOS,1:"")
  1. I GMRCOC["X" D
  1. .S $P(GMRCPCS(7),U,4)=$$FMTHL7^XLFDT($P(^GMR(123,GMRCO,0),U,24)) ;wat/66
  1. .S $P(GMRCPCS(7),U,6)=$$URG^GMRCIUTL(GMRCO)
  1. S GMRCPCS(9)=$$FMTHL7^XLFDT($P(^GMR(123,GMRCO,40,GMRCACT,0),U,1))
  1. S GMRCPCS(10)=$$HLNAME^GMRCIUTL($P(^GMR(123,GMRCO,40,GMRCACT,0),U,5))
  1. S GMRCRP=$P(^GMR(123,GMRCO,40,GMRCACT,0),U,4) I +GMRCRP D
  1. . S GMRCPCS(12)=$$HLNAME^GMRCIUTL(GMRCRP)
  1. . N GMRCPHN,GMRCPAG
  1. . S GMRCPHN=$$GET1^DIQ(200,GMRCRP,.132)
  1. . S GMRCPAG=$$GET1^DIQ(200,GMRCRP,.138)
  1. . S GMRCPCS(14)=$$HLPHONE^HLFNC(GMRCPHN,GMRCPAG)
  1. S GMRCPCS(15)=$$FMTHL7^XLFDT($P(^GMR(123,GMRCO,40,GMRCACT,0),U,3))
  1. I GMRCOC["X"!(GMRCOC="SC")!(GMRCOC="RE") D
  1. . I GMRCOC="XX" D Q
  1. .. I $P(^GMR(123,GMRCO,40,GMRCACT,0),U,2)=25 D Q
  1. ... S GMRCPCS(16)="FI^FORWARD TO IFC^99GMRC"
  1. .. S GMRCPCS(16)="F^FORWARD^99GMRC"
  1. . I GMRCOC="XO" S GMRCPCS(16)="E^EDIT-RESUBMIT^99GMRC" Q
  1. . I GMRCOC="SC" D Q
  1. .. I GMRCOS="IP" S GMRCPCS(16)="R^RECEIVE^99GMRC"
  1. .. I GMRCOS="SC" S GMRCPCS(16)="SC^SCHEDULE^99GMRC"
  1. . I GMRCOC="RE" D
  1. .. N ACTVT S ACTVT=$P(^GMR(123,GMRCO,40,GMRCACT,0),U,2)
  1. .. I ACTVT=12 S GMRCPCS(16)="D^DISASSOCIATE RESULT^99GMRC"
  1. .. I ACTVT=13 S GMRCPCS(16)="A^ADDENDUM^99GMRC"
  1. .. I ACTVT=4 S GMRCPCS(16)="S^SIGNIFICANT FINDING^99GMRC"
  1. . Q
  1. S SITE=$$SITE^VASITE
  1. I +SITE S GMRCPCS(17)=$P(SITE,U,3)_U_$P(SITE,U,2) ;use loc instead? ;-(
  1. Q $$BUILD^GMRCISEG("ORC",.GMRCPCS)
  1. ;
  1. OBXWP(GMRCO,GMRCOC,GMRCACT,GMRCSEG) ; return a WP field in OBX segs
  1. ; Input:
  1. ; GMRCO =
  1. ; GMRCOC =
  1. ; GMRCACT = activity in 40 mult triggering msg
  1. ; GMRCSEG = GLOBAL array to return results in
  1. ;
  1. ; Output:
  1. ; ARRAY(1)=OBX|1|TX|coding scheme|1|text||||||obs result status
  1. ; ARRAY(2)=OBX|1|TX|coding scheme|2|text||||||obs result status
  1. ;
  1. K ^TMP("GMRCWP",$J)
  1. N GMRCPCS,TCH,OBX11 ; P202 ADD OBX11
  1. D SETTCH2^GMRCIMSG() ;MKN GMRC*3.0*154 Get TCH array
  1. I GMRCOC="NW"!(GMRCOC="XO") D Q
  1. . N SUBS S SUBS=0
  1. . F S SUBS=$O(^GMR(123,GMRCO,20,SUBS)) Q:'SUBS D
  1. .. S GMRCPCS(1)=1,GMRCPCS(2)="TX"
  1. .. S GMRCPCS(3)="2000.02^REASON FOR REQUEST^AS4",GMRCPCS(4)=SUBS
  1. .. S GMRCPCS(5)=$$ENCODE^GMRCHL7E($G(^GMR(123,GMRCO,20,SUBS,0)),.TCH),GMRCPCS(11)="O" ;MKN GMRC*3.0*154 Encode any special characters
  1. .. S ^TMP("GMRCWP",$J,SUBS)=$$BUILD^GMRCISEG("OBX",.GMRCPCS)
  1. . M @GMRCSEG=^TMP("GMRCWP",$J)
  1. . K ^TMP("GMRCWP",$J)
  1. . Q
  1. I '$D(GMRCACT)!('$D(^GMR(123,GMRCO,40,GMRCACT,1))) Q
  1. N CMT,ACTVT
  1. S CMT=0,ACTVT=$P(^GMR(123,GMRCO,40,GMRCACT,0),U,2)
  1. ;GMRC*202 - new OBX workflow for POST OTHER (ADDED COMMENT - ACTVT =20) or POST COMPLETE (COMPLETE/UPDATE - ACTVT=10) actions
  1. ;
  1. ; OBX-11 is comment status. It's "F" for Admin Complete actions, "P" otherwise except if entered post-complete then "C".
  1. ;
  1. S OBX11=$S(ACTVT=10:"F",1:"P") ;F if an admin comp. else "P"
  1. ;
  1. ; Change status to changed (C) if comments added post-complete on IFC involving Cerner.
  1. ;
  1. I $$CNVTD^GMRCIEVT(GMRCO) D ;
  1. . N GMRCACT1 S GMRCACT1=GMRCACT-.000001 F S GMRCACT1=$O(^GMR(123,GMRCO,40,GMRCACT1),-1) Q:'GMRCACT1 I $P(^(GMRCACT1,0),U,2)=10 S OBX11="C" Q ; WTC p189
  1. ;
  1. I $G(PROSTHCS)&((ACTVT=20)!(ACTVT=10)) D OBXPOST Q
  1. ;END GMRC*202
  1. ;
  1. F S CMT=$O(^GMR(123,GMRCO,40,GMRCACT,1,CMT)) Q:'CMT D
  1. . S GMRCPCS(1)=3,GMRCPCS(2)="TX"
  1. . S GMRCPCS(3)="^COMMENTS^",GMRCPCS(4)=CMT ;MKN GMRC*3.0*154 Encode any special characters
  1. . S GMRCPCS(5)=$$ENCODE^GMRCHL7E($G(^GMR(123,GMRCO,40,GMRCACT,1,CMT,0)),.TCH) ;MKN GMRC*3.0*154 Encode any special characters
  1. . S GMRCPCS(11)=OBX11 ; P189 WTC 6/29/2023
  1. . S ^TMP("GMRCWP",$J,CMT)=$$BUILD^GMRCISEG("OBX",.GMRCPCS)
  1. ;
  1. M @GMRCSEG=^TMP("GMRCWP",$J)
  1. K ^TMP("GMRCWP",$J)
  1. Q
  1. ;
  1. OBXRSLT(GMRCO,GMRCACT) ; build an OBX segment to send a TIU doc reference
  1. ; Input:
  1. ; GMRCO = ien from file 123
  1. ; GMRCACT = activity entry in 40 multiple
  1. ;
  1. ; Output:
  1. ; OBX segment
  1. ; e.g. OBX|4|RP|^TIU DOC^VA8925||41320^TIU^660||||||||F
  1. ;
  1. Q:'$D(^GMR(123,GMRCO,40,GMRCACT)) ""
  1. N GMRCPCS,RSLT,GMRCACTV
  1. S GMRCPCS(1)=4,GMRCPCS(2)="RP"
  1. S GMRCPCS(4)=1
  1. S GMRCACTV=$P(^GMR(123,GMRCO,40,GMRCACT,0),U,2)
  1. S RSLT=$P(^GMR(123,GMRCO,40,GMRCACT,0),U,9)
  1. I RSLT["TIU" D
  1. . S GMRCPCS(3)="^TIU DOC^VA8925"
  1. . S GMRCPCS(5)=+RSLT_"^TIU DOCUMENT^"_$$STA^XUAF4($$KSP^XUPARAM("INST"))
  1. I RSLT["MCAR" D
  1. . N MCPRNM S MCPRNM=$P($$SINGLE^MCAPI(RSLT),U)
  1. . S GMRCPCS(3)="^MED RSLT^VA"_+$P(RSLT,"MCAR(",2)
  1. . S GMRCPCS(5)=+RSLT_U_MCPRNM_U_$$STA^XUAF4($$KSP^XUPARAM("INST"))
  1. S GMRCPCS(11)=$S(GMRCACTV=9:"S",GMRCACTV=12:"D",1:"F")
  1. Q $$BUILD^GMRCISEG("OBX",.GMRCPCS)
  1. ;
  1. NTE(GMRCO,GMRCACT,GMRCAR) ;format an NTE seg with DC comment
  1. ; Input:
  1. ; GMRCO = ien from file 123
  1. ; GMRCACT = activity entry in 40 multiple
  1. ; GMRCAR = array in which to pass back NTE segs
  1. ;
  1. ; Output:
  1. ; array of NTE segments containing the comment
  1. ; e.g. NTE|1|L|cancelled by requestor
  1. ;
  1. Q:'$D(^GMR(123,GMRCO,40,GMRCACT,1))
  1. N CMT,GMRCPCS,TCH S CMT=0
  1. D SETTCH2^GMRCIMSG() ;MKN GMRC*3.0*154 Get TCH array
  1. F S CMT=$O(^GMR(123,GMRCO,40,GMRCACT,1,CMT)) Q:'CMT D
  1. . S GMRCPCS(1)=CMT,GMRCPCS(2)="L"
  1. . S GMRCPCS(3)=$$ENCODE^GMRCHL7E($G(^GMR(123,GMRCO,40,GMRCACT,1,CMT,0)),.TCH) ;MKN GMRC*3.0*154 Encode any special characters
  1. . S GMRCAR(CMT)=$$BUILD^GMRCISEG("NTE",.GMRCPCS)
  1. Q
  1. ;
  1. MSA(GMRCAC,GMRCMSG,GMRCERR) ; build MSA for response to placer activity
  1. ; Input:
  1. ; GMRCAC = acknowledgment code (AA or AR)
  1. ; GMRCMSG = message number from incoming msg being responded to
  1. ; GMRCERR = error message if can't accept the activity
  1. ;
  1. ; Output:
  1. ; MSA segment to include with ACK or NAK
  1. ;
  1. N GMRCPCS
  1. S GMRCPCS(1)=GMRCAC
  1. S GMRCPCS(2)=GMRCMSG
  1. S GMRCPCS(3)=$G(GMRCERR)
  1. Q $$BUILD^GMRCISEG("MSA",.GMRCPCS)
  1. ;
  1. OBXTZ() ;build and return an OBX with the current TIME ZONE encoded
  1. ;Input:
  1. ; none
  1. ;
  1. ;Output:
  1. ; OBX segment in the format:
  1. ; OBX|5|CE|^TIME ZONE^VA4.4|1|MST||||||0
  1. N GMRCPCS
  1. S GMRCPCS(1)=5,GMRCPCS(2)="CE" ;WAT/66
  1. S GMRCPCS(3)="^TIME ZONE^VA4.4",GMRCPCS(4)=1
  1. S GMRCPCS(5)=$$GET1^DIQ(4.3,1,1)
  1. Q $$BUILD^GMRCISEG("OBX",.GMRCPCS)
  1. ;
  1. OBXSF(GMRCO) ; build OBX seg for Sig. Find.
  1. ; Input:
  1. ; GMRCO = ien from file 123
  1. ;
  1. ; Output:
  1. ; OBX segment in format:
  1. ; OBX|6|TX|^SIG FINDINGS^|1|S||||||O
  1. ;
  1. I '$L($P(^GMR(123,GMRCO,0),U,19)) Q ""
  1. N GMRCPCS
  1. S GMRCPCS(1)=6,GMRCPCS(2)="TX",GMRCPCS(3)="^SIG FINDINGS^"
  1. S GMRCPCS(4)=1,GMRCPCS(5)=$P(^GMR(123,GMRCO,0),U,19),GMRCPCS(11)="O"
  1. Q $$BUILD^GMRCISEG("OBX",.GMRCPCS)
  1. ;
  1. OBXPOST ;build OBX for Post Other or Post Complete Actions
  1. ;
  1. ;GMRC*2.0*202
  1. ;For Post Other or Post Complete for Prosthetics orders add additional details to
  1. ;the comments - including "Entered" by and the "Order Details"
  1. N GMRCSUBS,GMRCPCS,GMRCCMT,GMRCCMT1
  1. S GMRCSUBS=0,GMRCCMT=0,GMRCCMT1=0
  1. S GMRCPCS(1)=3,GMRCPCS(2)="TX",GMRCPCS(3)="^COMMENTS^"
  1. S GMRCPCS(11)=OBX11 ;OBX11 added as part of GMRC*189 to capture new "C" action
  1. ;loop through the (#40) REQUEST PROCESSING ACTIVITY to build the comments
  1. F S GMRCCMT=$O(^GMR(123,GMRCO,40,GMRCACT,1,GMRCCMT)) Q:'GMRCCMT D
  1. . S GMRCCMT1=GMRCCMT1+1
  1. . S GMRCPCS(4)=GMRCCMT1
  1. . S GMRCPCS(5)=$$ENCODE^GMRCHL7E($G(^GMR(123,GMRCO,40,GMRCACT,1,GMRCCMT,0)),.TCH)
  1. . S ^TMP("GMRCWP",$J,GMRCCMT1)=$$BUILD^GMRCISEG("OBX",.GMRCPCS)
  1. S GMRCCMT1=GMRCCMT1+1,GMRCPCS(4)=GMRCCMT1 S GMRCPCS(5)="ENTERED BY: "_$$GET1^DIQ(200,$P(^GMR(123,GMRCO,40,GMRCACT,0),"^",5),.01)
  1. S ^TMP("GMRCWP",$J,GMRCCMT1)=$$BUILD^GMRCISEG("OBX",.GMRCPCS)
  1. S GMRCCMT1=GMRCCMT1+1,GMRCPCS(4)=GMRCCMT1 S GMRCPCS(5)="DATE ENTERED: "_$$FMTE^XLFDT($P(^GMR(123,GMRCO,40,GMRCACT,0),"^",1))
  1. S ^TMP("GMRCWP",$J,GMRCCMT1)=$$BUILD^GMRCISEG("OBX",.GMRCPCS)
  1. S GMRCCMT1=GMRCCMT1+1,GMRCPCS(4)=GMRCCMT1 S GMRCPCS(5)=" "
  1. S ^TMP("GMRCWP",$J,GMRCCMT1)=$$BUILD^GMRCISEG("OBX",.GMRCPCS)
  1. ;loop through (#20) REASON FOR REQUEST and append to bottom of "COMMENTS"
  1. F S GMRCSUBS=$O(^GMR(123,GMRCO,20,GMRCSUBS)) Q:'GMRCSUBS D
  1. . S GMRCCMT1=GMRCCMT1+1
  1. . S GMRCPCS(4)=GMRCCMT1
  1. . S GMRCPCS(5)=$$ENCODE^GMRCHL7E($G(^GMR(123,GMRCO,20,GMRCSUBS,0)),.TCH)
  1. . S ^TMP("GMRCWP",$J,GMRCCMT1)=$$BUILD^GMRCISEG("OBX",.GMRCPCS)
  1. ;details move to end
  1. M @GMRCSEG=^TMP("GMRCWP",$J)
  1. K ^TMP("GMRCWP",$J)
  1. Q