MPIFQUE5 ;SF/TNV-Process the RESULT from CMOR COMPARISON request ;FEB 20, 1998
;;1.0; MASTER PATIENT INDEX VISTA ;**1,6,11**;30 Apr 99
;
; Integration Agreements Utilized:
;
; EXC^RGHLLOG IA #2796
; START^RGHLLOG IA #2796
; STOP^RGHLLOG IA #2796
;
; This routine will process the message from the CMOR site to change
; the CMOR as a result of a change cmor request
;
EN ; Entry point for process the update of CMOR
N U,LINE,IKI,ERROR,RGL,RGLOG
S U="^"
D START^RGHLLOG()
;
N MPII,U,LINE,ERROR,PARENT,COUNT,NDATE,IKI,MPIFFS,MPIFSFS,MPIFREAP,RGLOG
F MPII=1:1 X HLNEXT Q:HLQUIT'>0 D
. S LINE=HLNODE
. I $P(LINE,HL("FS"))["MSH" D MSH
. I $P(LINE,HL("FS"))["PV1" D PV1
. I $P(LINE,HL("FS"))["PID" D PID
I $G(ERROR)]"" D ACK Q ; Any problems before changing the CMOR
I ($G(SITE)]"")&($G(DFN)]"") D CHANGE
I $G(SITE)=""!($G(DFN)="") D
.S ERROR="Missing new CMOR or Patient to be changed"
.D EXC^RGHLLOG(219,ERROR_" for change CMOR request HL7 msg "_$G(HL("MID")))
D ACK
Q
;
MSH ; Process MSH segment
I $P(LINE,HL("FS"),16)="AL" S ACK="YES"
I $P(LINE,HL("FS"),16)="ER" S ACK="ERROR"
Q
;
PV1 ; Process PV1 segment
S SITE=$P(LINE,HL("FS"),4)
I SITE="" S ERROR="Missing CMOR site number in Change CMOR message for ICN "_ICN_" HL7 msg# "_$G(HL("MID")) D EXC^RGHLLOG(221,ERROR)
Q
NTE ; Process NTE segment
S SITE=$P(LINE,HL("FS"),8)
I SITE="" S ERROR="Missing CMOR site number in Change CMOR message for ICN "_ICN_" HL7 msg# "_$G(HL("MID")) D EXC^RGHLLOG(221,ERROR)
Q
;
PID ; Process PID segment
S ICN=+$P(LINE,HL("FS"),3) ; get ICN out.
I ICN<1 S ERROR="Missing Patient ICN in Change CMOR message HL7 msg# "_$G(HL("MID")) D EXC^RGHLLOG(219,ERROR) Q
S DFN=$$IEN^MPIFNQ(ICN) ; get DFN of this patient
I DFN="" S ERROR="ICN "_ICN_" not found from Change CMOR message HL7 msg# "_$G(HL("MID")) D EXC^RGHLLOG(219,ERROR) Q
Q
;
CHANGE ; Process the change CMOR to the new CMOR site (YOUR SITE NOW)
S DIC="^DIC(4,",DIC(0)="QMOZX",X=SITE D ^DIC K DIC ; Figure out
I Y=-1 S ERROR="CMOR Site name is not on file for Station Number "_SITE_" processing Change CMOR msg for ICN "_ICN D EXC^RGHLLOG(211,ERROR,DFN) Q ; the CMOR site
S CHANGE=$$CHANGE^MPIF001(+DFN,+Y) ; name and change
I +CHANGE=-1 S ERROR="Unable to update CMOR for site "_SITE_". For DFN "_DFN_" Processing CHANGE CMOR message "_HLMTIEN D EXC^RGHLLOG(211,ERROR,DFN)
Q
;
ACK ; Clean up the partition.
;
D STOP^RGHLLOG()
K X,Y,DFN,ICN,SITE,MPIFREAP,ACK,PARENT,CHANGE
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMPIFQUE5 2615 printed Dec 13, 2024@02:11:32 Page 2
MPIFQUE5 ;SF/TNV-Process the RESULT from CMOR COMPARISON request ;FEB 20, 1998
+1 ;;1.0; MASTER PATIENT INDEX VISTA ;**1,6,11**;30 Apr 99
+2 ;
+3 ; Integration Agreements Utilized:
+4 ;
+5 ; EXC^RGHLLOG IA #2796
+6 ; START^RGHLLOG IA #2796
+7 ; STOP^RGHLLOG IA #2796
+8 ;
+9 ; This routine will process the message from the CMOR site to change
+10 ; the CMOR as a result of a change cmor request
+11 ;
EN ; Entry point for process the update of CMOR
+1 NEW U,LINE,IKI,ERROR,RGL,RGLOG
+2 SET U="^"
+3 DO START^RGHLLOG()
+4 ;
+5 NEW MPII,U,LINE,ERROR,PARENT,COUNT,NDATE,IKI,MPIFFS,MPIFSFS,MPIFREAP,RGLOG
+6 FOR MPII=1:1
XECUTE HLNEXT
if HLQUIT'>0
QUIT
Begin DoDot:1
+7 SET LINE=HLNODE
+8 IF $PIECE(LINE,HL("FS"))["MSH"
DO MSH
+9 IF $PIECE(LINE,HL("FS"))["PV1"
DO PV1
+10 IF $PIECE(LINE,HL("FS"))["PID"
DO PID
End DoDot:1
+11 ; Any problems before changing the CMOR
IF $GET(ERROR)]""
DO ACK
QUIT
+12 IF ($GET(SITE)]"")&($GET(DFN)]"")
DO CHANGE
+13 IF $GET(SITE)=""!($GET(DFN)="")
Begin DoDot:1
+14 SET ERROR="Missing new CMOR or Patient to be changed"
+15 DO EXC^RGHLLOG(219,ERROR_" for change CMOR request HL7 msg "_$GET(HL("MID")))
End DoDot:1
+16 DO ACK
+17 QUIT
+18 ;
MSH ; Process MSH segment
+1 IF $PIECE(LINE,HL("FS"),16)="AL"
SET ACK="YES"
+2 IF $PIECE(LINE,HL("FS"),16)="ER"
SET ACK="ERROR"
+3 QUIT
+4 ;
PV1 ; Process PV1 segment
+1 SET SITE=$PIECE(LINE,HL("FS"),4)
+2 IF SITE=""
SET ERROR="Missing CMOR site number in Change CMOR message for ICN "_ICN_" HL7 msg# "_$GET(HL("MID"))
DO EXC^RGHLLOG(221,ERROR)
+3 QUIT
NTE ; Process NTE segment
+1 SET SITE=$PIECE(LINE,HL("FS"),8)
+2 IF SITE=""
SET ERROR="Missing CMOR site number in Change CMOR message for ICN "_ICN_" HL7 msg# "_$GET(HL("MID"))
DO EXC^RGHLLOG(221,ERROR)
+3 QUIT
+4 ;
PID ; Process PID segment
+1 ; get ICN out.
SET ICN=+$PIECE(LINE,HL("FS"),3)
+2 IF ICN<1
SET ERROR="Missing Patient ICN in Change CMOR message HL7 msg# "_$GET(HL("MID"))
DO EXC^RGHLLOG(219,ERROR)
QUIT
+3 ; get DFN of this patient
SET DFN=$$IEN^MPIFNQ(ICN)
+4 IF DFN=""
SET ERROR="ICN "_ICN_" not found from Change CMOR message HL7 msg# "_$GET(HL("MID"))
DO EXC^RGHLLOG(219,ERROR)
QUIT
+5 QUIT
+6 ;
CHANGE ; Process the change CMOR to the new CMOR site (YOUR SITE NOW)
+1 ; Figure out
SET DIC="^DIC(4,"
SET DIC(0)="QMOZX"
SET X=SITE
DO ^DIC
KILL DIC
+2 ; the CMOR site
IF Y=-1
SET ERROR="CMOR Site name is not on file for Station Number "_SITE_" processing Change CMOR msg for ICN "_ICN
DO EXC^RGHLLOG(211,ERROR,DFN)
QUIT
+3 ; name and change
SET CHANGE=$$CHANGE^MPIF001(+DFN,+Y)
+4 IF +CHANGE=-1
SET ERROR="Unable to update CMOR for site "_SITE_". For DFN "_DFN_" Processing CHANGE CMOR message "_HLMTIEN
DO EXC^RGHLLOG(211,ERROR,DFN)
+5 QUIT
+6 ;
ACK ; Clean up the partition.
+1 ;
+2 DO STOP^RGHLLOG()
+3 KILL X,Y,DFN,ICN,SITE,MPIFREAP,ACK,PARENT,CHANGE
+4 QUIT