MDCONUT2 ; HDSO/RJH - CP Conversion Utility ;31 Oct 2018 2:31 PM
;;1.0;CLINICAL PROCEDURES;**89**;May 07, 2024;Build 2
;
; Integration Control Registration (ICR's):
; Reference to File 100.01 in ICR #2638
; Reference to File 123 in ICR #3067
; Reference to ^GMR(123,"AE" in ICR #5062
; Reference to File 123.3 in ICR #6926
; Reference to File 123.5 in ICR #6927
; Reference to ^MAG(2006.5831 in ICR #6959
;
; MD*89/RJH - New routine created to divert the MD PROCONVERT functionality
; from the MDCONUTL routine in order not to affect the MD
; CONCONVERT functionality which previously shared the logic.
; Added prompt to the user for the REQUEST SERVICE within the
; procedure to convert TO which removes bug in that processing.
;
Q
;
EN ; Entry point for this routine
N MDFPRC,MDFPRCD,MDFSVC,MDFSVCD,MDTPRC,MDTPRCD,MDTSVC,MDTSVCD,MDCOUNT,MDCP
N MDFDA,MDSTS,MDSTSD,MDDT,MDIEN,MDPRT,STOP,FROM
S (MDCOUNT,STOP)=0
;
D INTRO
F FROM=1,0 Q:STOP D GETPR(FROM)
Q:STOP
D CONVERT
Q
;
INTRO ;
W !!,"This utility will get all pending, active, and scheduled"
W !,"procedures of a selected REQUEST SERVICES and convert them to"
W !,"the selected REQUEST SERVICES in the selected GMRC procedure."
W !
W !,"Note that procedures currently setup with DICOM (in the CLINICAL "
W !,"SPECIALTY DICOM & HL7 file) cannot be converted to CP with this"
W !,"utility. DICOM procedures will need to discontinued and reordered."
W !
Q
;
GETPR(FROM) ; Get the user-selected procedure
N DIC,X,Y,DTOUT,DUOUT
S DIC="^GMR(123.3,",DIC(0)="AEMNQ",DIC("A")="Select a GMRC Procedure to convert "_$S(FROM:"FROM: ",1:"TO: ")
D ^DIC I Y<1!($D(DTOUT))!($D(DUOUT)) S STOP=1 Q
I FROM D Q
. I $$GET1^DIQ(123.3,+Y,.04)]"" D Q
.. W !!,"This procedure is already a Clinical Procedure - Cannot convert. Quitting...",!
.. S STOP=1
.. Q
. S MDFPRC=+Y,MDFPRCD=$P(Y,U,2)
. D GETRS(FROM)
. Q
;
Q:STOP
S MDTPRC=+Y,MDTPRCD=$P(Y,U,2)
D GETRS(FROM)
Q
;
GETRS(FROM) ; Get the Related Service from #123.32
N DIC,X,Y,DTOUT,DUOUT
S DIC="^GMR(123.5,",DIC(0)="AEMNQ"
; Next line - screen to only allow service related to selected procedure
S DIC("S")="I ($D(^GMR(123.3,"_$S(FROM:"MDFPRC",1:"MDTPRC")_",2,""B"",+Y)))"
D ^DIC I Y<1!($D(DTOUT))!($D(DUOUT)) S STOP=1 Q
I FROM D Q
. I $D(^MAG(2006.5831,"C",+Y,MDFPRC)) D Q
.. W !!,"Procedure/Service setup for DICOM - Cannot convert. Quitting...",!
.. S STOP=1
.. Q
. S MDFSVC=+Y,MDFSVCD=$P(Y,U,2)
. Q
;
Q:STOP
S MDTSVC=+Y,MDTSVCD=$P(Y,U,2)
Q
;
CONVERT ; Convert the requested data
S MDCP=$$GET1^DIQ(123.3,+MDTPRC_",",.04,"I")
I 'MDCP D GETCP Q:STOP
;
W !!,"We will proceed to convert ",MDFPRCD," in ",MDFSVCD
W !,"to ",MDTPRCD," procedures in ",MDTSVCD,!
;
; ^GMR(123,"AE",RequestService,OrderStatus,ReverseDate,IEN)
S MDSTS=""
F S MDSTS=$O(^GMR(123,"AE",MDFSVC,MDSTS)) Q:'MDSTS D
. S MDSTSD=$$GET1^DIQ(100.01,MDSTS,.01,"E")
. I MDSTSD'="PENDING",MDSTSD'="ACTIVE",MDSTSD'="SCHEDULED" Q
. S MDDT=0
. F S MDDT=$O(^GMR(123,"AE",MDFSVC,MDSTS,MDDT)) Q:MDDT="" D
.. S MDIEN=0
.. F S MDIEN=$O(^GMR(123,"AE",MDFSVC,MDSTS,MDDT,MDIEN)) Q:'MDIEN D
... S MDPRT=$$GET1^DIQ(123,MDIEN,4,"E")
... I MDPRT'=MDFPRCD Q
... S MDFDA(123,MDIEN_",",1)=+MDTSVC ; To Service
... S MDFDA(123,MDIEN_",",1.01)=+MDCP ; Clinical Procedure
... S MDFDA(123,MDIEN_",",4)=+MDTPRC_";"_"GMR(123.3," ; Procedure/Request Type
... S MDFDA(123,MDIEN_",",13)="P" ; Request Type
... L +^GMR(123,MDIEN):1 I '$T Q
... D FILE^DIE("","MDFDA")
... L -^GMR(123,MDIEN)
... S MDCOUNT=MDCOUNT+1 W !," Record # ",MDIEN," converted."
... Q
.. Q
. Q
;
W !!,"Total records converted = ",MDCOUNT,!
Q
;
GETCP ; Get/define a clinical procedure for the target/TO procedure
N DIC,X,Y,DTOUT,DUOUT
W !,"Missing Clinical Procedure Definition in ",$$GET1^DIQ(123.3,+MDTPRC,.01),!
S DIC="^MDS(702.01,",DIC(0)="AEMNQ"
D ^DIC I Y<1!($D(DTOUT))!($D(DUOUT)) S STOP=1 Q
S MDCP=+Y
S MDFDA(123.3,MDTPRC_",",.04)=+MDCP
L +^GMR(123.3,MDTPRC):1 I '$T D Q
. W !!,"Unable to lock the "_MDTPRCD_" record. Quitting..."
. S STOP=1
. Q
;
D FILE^DIE("","MDFDA") K MDFDA
L -^GMR(123.3,MDTPRC)
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMDCONUT2 4366 printed Dec 13, 2024@01:42:25 Page 2
MDCONUT2 ; HDSO/RJH - CP Conversion Utility ;31 Oct 2018 2:31 PM
+1 ;;1.0;CLINICAL PROCEDURES;**89**;May 07, 2024;Build 2
+2 ;
+3 ; Integration Control Registration (ICR's):
+4 ; Reference to File 100.01 in ICR #2638
+5 ; Reference to File 123 in ICR #3067
+6 ; Reference to ^GMR(123,"AE" in ICR #5062
+7 ; Reference to File 123.3 in ICR #6926
+8 ; Reference to File 123.5 in ICR #6927
+9 ; Reference to ^MAG(2006.5831 in ICR #6959
+10 ;
+11 ; MD*89/RJH - New routine created to divert the MD PROCONVERT functionality
+12 ; from the MDCONUTL routine in order not to affect the MD
+13 ; CONCONVERT functionality which previously shared the logic.
+14 ; Added prompt to the user for the REQUEST SERVICE within the
+15 ; procedure to convert TO which removes bug in that processing.
+16 ;
+17 QUIT
+18 ;
EN ; Entry point for this routine
+1 NEW MDFPRC,MDFPRCD,MDFSVC,MDFSVCD,MDTPRC,MDTPRCD,MDTSVC,MDTSVCD,MDCOUNT,MDCP
+2 NEW MDFDA,MDSTS,MDSTSD,MDDT,MDIEN,MDPRT,STOP,FROM
+3 SET (MDCOUNT,STOP)=0
+4 ;
+5 DO INTRO
+6 FOR FROM=1,0
if STOP
QUIT
DO GETPR(FROM)
+7 if STOP
QUIT
+8 DO CONVERT
+9 QUIT
+10 ;
INTRO ;
+1 WRITE !!,"This utility will get all pending, active, and scheduled"
+2 WRITE !,"procedures of a selected REQUEST SERVICES and convert them to"
+3 WRITE !,"the selected REQUEST SERVICES in the selected GMRC procedure."
+4 WRITE !
+5 WRITE !,"Note that procedures currently setup with DICOM (in the CLINICAL "
+6 WRITE !,"SPECIALTY DICOM & HL7 file) cannot be converted to CP with this"
+7 WRITE !,"utility. DICOM procedures will need to discontinued and reordered."
+8 WRITE !
+9 QUIT
+10 ;
GETPR(FROM) ; Get the user-selected procedure
+1 NEW DIC,X,Y,DTOUT,DUOUT
+2 SET DIC="^GMR(123.3,"
SET DIC(0)="AEMNQ"
SET DIC("A")="Select a GMRC Procedure to convert "_$SELECT(FROM:"FROM: ",1:"TO: ")
+3 DO ^DIC
IF Y<1!($DATA(DTOUT))!($DATA(DUOUT))
SET STOP=1
QUIT
+4 IF FROM
Begin DoDot:1
+5 IF $$GET1^DIQ(123.3,+Y,.04)]""
Begin DoDot:2
+6 WRITE !!,"This procedure is already a Clinical Procedure - Cannot convert. Quitting...",!
+7 SET STOP=1
+8 QUIT
End DoDot:2
QUIT
+9 SET MDFPRC=+Y
SET MDFPRCD=$PIECE(Y,U,2)
+10 DO GETRS(FROM)
+11 QUIT
End DoDot:1
QUIT
+12 ;
+13 if STOP
QUIT
+14 SET MDTPRC=+Y
SET MDTPRCD=$PIECE(Y,U,2)
+15 DO GETRS(FROM)
+16 QUIT
+17 ;
GETRS(FROM) ; Get the Related Service from #123.32
+1 NEW DIC,X,Y,DTOUT,DUOUT
+2 SET DIC="^GMR(123.5,"
SET DIC(0)="AEMNQ"
+3 ; Next line - screen to only allow service related to selected procedure
+4 SET DIC("S")="I ($D(^GMR(123.3,"_$SELECT(FROM:"MDFPRC",1:"MDTPRC")_",2,""B"",+Y)))"
+5 DO ^DIC
IF Y<1!($DATA(DTOUT))!($DATA(DUOUT))
SET STOP=1
QUIT
+6 IF FROM
Begin DoDot:1
+7 IF $DATA(^MAG(2006.5831,"C",+Y,MDFPRC))
Begin DoDot:2
+8 WRITE !!,"Procedure/Service setup for DICOM - Cannot convert. Quitting...",!
+9 SET STOP=1
+10 QUIT
End DoDot:2
QUIT
+11 SET MDFSVC=+Y
SET MDFSVCD=$PIECE(Y,U,2)
+12 QUIT
End DoDot:1
QUIT
+13 ;
+14 if STOP
QUIT
+15 SET MDTSVC=+Y
SET MDTSVCD=$PIECE(Y,U,2)
+16 QUIT
+17 ;
CONVERT ; Convert the requested data
+1 SET MDCP=$$GET1^DIQ(123.3,+MDTPRC_",",.04,"I")
+2 IF 'MDCP
DO GETCP
if STOP
QUIT
+3 ;
+4 WRITE !!,"We will proceed to convert ",MDFPRCD," in ",MDFSVCD
+5 WRITE !,"to ",MDTPRCD," procedures in ",MDTSVCD,!
+6 ;
+7 ; ^GMR(123,"AE",RequestService,OrderStatus,ReverseDate,IEN)
+8 SET MDSTS=""
+9 FOR
SET MDSTS=$ORDER(^GMR(123,"AE",MDFSVC,MDSTS))
if 'MDSTS
QUIT
Begin DoDot:1
+10 SET MDSTSD=$$GET1^DIQ(100.01,MDSTS,.01,"E")
+11 IF MDSTSD'="PENDING"
IF MDSTSD'="ACTIVE"
IF MDSTSD'="SCHEDULED"
QUIT
+12 SET MDDT=0
+13 FOR
SET MDDT=$ORDER(^GMR(123,"AE",MDFSVC,MDSTS,MDDT))
if MDDT=""
QUIT
Begin DoDot:2
+14 SET MDIEN=0
+15 FOR
SET MDIEN=$ORDER(^GMR(123,"AE",MDFSVC,MDSTS,MDDT,MDIEN))
if 'MDIEN
QUIT
Begin DoDot:3
+16 SET MDPRT=$$GET1^DIQ(123,MDIEN,4,"E")
+17 IF MDPRT'=MDFPRCD
QUIT
+18 ; To Service
SET MDFDA(123,MDIEN_",",1)=+MDTSVC
+19 ; Clinical Procedure
SET MDFDA(123,MDIEN_",",1.01)=+MDCP
+20 ; Procedure/Request Type
SET MDFDA(123,MDIEN_",",4)=+MDTPRC_";"_"GMR(123.3,"
+21 ; Request Type
SET MDFDA(123,MDIEN_",",13)="P"
+22 LOCK +^GMR(123,MDIEN):1
IF '$TEST
QUIT
+23 DO FILE^DIE("","MDFDA")
+24 LOCK -^GMR(123,MDIEN)
+25 SET MDCOUNT=MDCOUNT+1
WRITE !," Record # ",MDIEN," converted."
+26 QUIT
End DoDot:3
+27 QUIT
End DoDot:2
+28 QUIT
End DoDot:1
+29 ;
+30 WRITE !!,"Total records converted = ",MDCOUNT,!
+31 QUIT
+32 ;
GETCP ; Get/define a clinical procedure for the target/TO procedure
+1 NEW DIC,X,Y,DTOUT,DUOUT
+2 WRITE !,"Missing Clinical Procedure Definition in ",$$GET1^DIQ(123.3,+MDTPRC,.01),!
+3 SET DIC="^MDS(702.01,"
SET DIC(0)="AEMNQ"
+4 DO ^DIC
IF Y<1!($DATA(DTOUT))!($DATA(DUOUT))
SET STOP=1
QUIT
+5 SET MDCP=+Y
+6 SET MDFDA(123.3,MDTPRC_",",.04)=+MDCP
+7 LOCK +^GMR(123.3,MDTPRC):1
IF '$TEST
Begin DoDot:1
+8 WRITE !!,"Unable to lock the "_MDTPRCD_" record. Quitting..."
+9 SET STOP=1
+10 QUIT
End DoDot:1
QUIT
+11 ;
+12 DO FILE^DIE("","MDFDA")
KILL MDFDA
+13 LOCK -^GMR(123.3,MDTPRC)
+14 QUIT