GMRCPOST ;SLC/DCM - Post init driver routine ;10/28/98 14:31
;;3.0;CONSULT/REQUEST TRACKING;**1**;DEC 27, 1997
D EN^GMRCPOS1
Q
EN S ND=0 I '$O(^GMR(123.5,ND)) S DIE=123.5,DA=1,DR=".01////^S X=""ALL SERVICES""" D ^DIE K DIE,DA,DR
K ND
Q
SVC(SVCIEN,SVCNAME,EVCODE) ;build HL7 message for conversion
K GMRCMSG
S MSH="MSH|^~\&|CONSULTS|"_$S($G(DUZ(2))]"":DUZ(2),1:+$$SITE^VASITE())_"|||||MFN"
S MFI="MFI|123.5^Request Services^99DD||"_$S(EVCODE="MUD":"REP",1:"UPD")_"|||NE"
S MFE="MFE|"_EVCODE_"|||^^^"_SVCIEN_"^"_SVCNAME_"^99CON"
I $L($O(^GMR(123.5,SVCIEN,2,"B",""))) D
.S ND1="",ND2=0 F S ND1=$O(^GMR(123.5,SVCIEN,2,"B",ND1)) Q:ND1="" S ND2=ND2+1,GMRCARRY(ND2)=ND1
.D ZSY(.GMRCARRY)
.Q
I +$P(^GMR(123.5,SVCIEN,0),"^",2),$P(^(0),"^",2)'=9 S ZCS="ZCS|"_$P(^(0),"^",2)
D BUILD
K MSH,MFI,MFE,GMRCARRY,ZSY,ZCS
Q
;
BUILD ;build the HL-7 array into its export form
S ND=1,MSG="GMRCMSG"
S @(MSG_"("_ND_")")=MSH,ND=ND+1
S @(MSG_"("_ND_")")=MFI,ND=ND+1
S @(MSG_"("_ND_")")=MFE,ND=ND+1
S:$D(ZCS) @(MSG_"("_ND_")")=ZCS,ND=ND+1
S ND1=0 F S ND1=$O(ZSY(ND1)) Q:ND1="" S @(MSG_"("_ND_")")=ZSY(ND1),ND=ND+1
Q
;
MFI(MTP) ;s MFI HL-7 segment
N X
S MFI="MFI|101^Protocol^99DD||"_$S(MTP="MFN":"REP",1:"UPD")_"|||NE"
Q MFI
;
MFE(RSPLVL,ORXDA,GMRCPRNO,PFX) ;set MFE HL=7 segment
N X
S X="MFE|"_RSPLVL_"|||^^^"_ORXDA_"^"_GMRCPRNO_"^99"_$S(PFX="GMRCR ":"PRO",1:"CON")
Q X
;
ZSY(ARRAY) ;set ZSY segment of the HL-7 segment; contains synonyms
S ND1="",ND2=1
F S ND1=$O(ARRAY(ND1)) Q:ND1="" S ZSY(ND2)="ZSY|"_ND2_"|"_ARRAY(ND1)_"|",ND2=ND2+1
K ND1,ND2
Q
;
ITEMS(ELC,RLECODE,ORDA,ORNAME,GMRCARRY,GMRCPRFX) ;entry point to set up HL-7 message to update orderable items file - file 101.43 in Post INIT
S MSH="MSH|^~\&|"_$S(GMRCPRFX="GMRCR ":"PROCEDURES",1:"CONSULTS")_"|"_+$$SITE^VASITE_"|||||"_ELC
S MFI=$$MFI(ELC)
S MFE=$$MFE(RLECODE,ORDA,ORNAME,GMRCPRFX)
D ZSY(.GMRCARRY)
D BUILD
K HLQ,MFE,MSH,MFI,MSG,MSGND,ND,ND1,ND2,ZSY
Q
;
GMRCPOST ;SLC/DCM - Post init driver routine ;10/28/98 14:31
+1 ;;3.0;CONSULT/REQUEST TRACKING;**1**;DEC 27, 1997
+2 DO EN^GMRCPOS1
+3 QUIT
EN SET ND=0
IF '$ORDER(^GMR(123.5,ND))
SET DIE=123.5
SET DA=1
SET DR=".01////^S X=""ALL SERVICES"""
DO ^DIE
KILL DIE,DA,DR
+1 KILL ND
+2 QUIT
SVC(SVCIEN,SVCNAME,EVCODE) ;build HL7 message for conversion
+1 KILL GMRCMSG
+2 SET MSH="MSH|^~\&|CONSULTS|"_$SELECT($GET(DUZ(2))]"":DUZ(2),1:+$$SITE^VASITE())_"|||||MFN"
+3 SET MFI="MFI|123.5^Request Services^99DD||"_$SELECT(EVCODE="MUD":"REP",1:"UPD")_"|||NE"
+4 SET MFE="MFE|"_EVCODE_"|||^^^"_SVCIEN_"^"_SVCNAME_"^99CON"
+5 IF $LENGTH($ORDER(^GMR(123.5,SVCIEN,2,"B","")))
Begin DoDot:1
+6 SET ND1=""
SET ND2=0
FOR
SET ND1=$ORDER(^GMR(123.5,SVCIEN,2,"B",ND1))
IF ND1=""
QUIT
SET ND2=ND2+1
SET GMRCARRY(ND2)=ND1
+7 DO ZSY(.GMRCARRY)
+8 QUIT
End DoDot:1
+9 IF +$PIECE(^GMR(123.5,SVCIEN,0),"^",2)
IF $PIECE(^(0),"^",2)'=9
SET ZCS="ZCS|"_$PIECE(^(0),"^",2)
+10 DO BUILD
+11 KILL MSH,MFI,MFE,GMRCARRY,ZSY,ZCS
+12 QUIT
+13 ;
BUILD ;build the HL-7 array into its export form
+1 SET ND=1
SET MSG="GMRCMSG"
+2 SET @(MSG_"("_ND_")")=MSH
SET ND=ND+1
+3 SET @(MSG_"("_ND_")")=MFI
SET ND=ND+1
+4 SET @(MSG_"("_ND_")")=MFE
SET ND=ND+1
+5 IF $DATA(ZCS)
SET @(MSG_"("_ND_")")=ZCS
SET ND=ND+1
+6 SET ND1=0
FOR
SET ND1=$ORDER(ZSY(ND1))
IF ND1=""
QUIT
SET @(MSG_"("_ND_")")=ZSY(ND1)
SET ND=ND+1
+7 QUIT
+8 ;
MFI(MTP) ;s MFI HL-7 segment
+1 NEW X
+2 SET MFI="MFI|101^Protocol^99DD||"_$SELECT(MTP="MFN":"REP",1:"UPD")_"|||NE"
+3 QUIT MFI
+4 ;
MFE(RSPLVL,ORXDA,GMRCPRNO,PFX) ;set MFE HL=7 segment
+1 NEW X
+2 SET X="MFE|"_RSPLVL_"|||^^^"_ORXDA_"^"_GMRCPRNO_"^99"_$SELECT(PFX="GMRCR ":"PRO",1:"CON")
+3 QUIT X
+4 ;
ZSY(ARRAY) ;set ZSY segment of the HL-7 segment; contains synonyms
+1 SET ND1=""
SET ND2=1
+2 FOR
SET ND1=$ORDER(ARRAY(ND1))
IF ND1=""
QUIT
SET ZSY(ND2)="ZSY|"_ND2_"|"_ARRAY(ND1)_"|"
SET ND2=ND2+1
+3 KILL ND1,ND2
+4 QUIT
+5 ;
ITEMS(ELC,RLECODE,ORDA,ORNAME,GMRCARRY,GMRCPRFX) ;entry point to set up HL-7 message to update orderable items file - file 101.43 in Post INIT
+1 SET MSH="MSH|^~\&|"_$SELECT(GMRCPRFX="GMRCR ":"PROCEDURES",1:"CONSULTS")_"|"_+$$SITE^VASITE_"|||||"_ELC
+2 SET MFI=$$MFI(ELC)
+3 SET MFE=$$MFE(RLECODE,ORDA,ORNAME,GMRCPRFX)
+4 DO ZSY(.GMRCARRY)
+5 DO BUILD
+6 KILL HLQ,MFE,MSH,MFI,MSG,MSGND,ND,ND1,ND2,ZSY
+7 QUIT
+8 ;