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

MDCONUT2.m

Go to the documentation of this file.
  1. MDCONUT2 ; HDSO/RJH - CP Conversion Utility ;31 Oct 2018 2:31 PM
  1. ;;1.0;CLINICAL PROCEDURES;**89**;May 07, 2024;Build 2
  1. ;
  1. ; Integration Control Registration (ICR's):
  1. ; Reference to File 100.01 in ICR #2638
  1. ; Reference to File 123 in ICR #3067
  1. ; Reference to ^GMR(123,"AE" in ICR #5062
  1. ; Reference to File 123.3 in ICR #6926
  1. ; Reference to File 123.5 in ICR #6927
  1. ; Reference to ^MAG(2006.5831 in ICR #6959
  1. ;
  1. ; MD*89/RJH - New routine created to divert the MD PROCONVERT functionality
  1. ; from the MDCONUTL routine in order not to affect the MD
  1. ; CONCONVERT functionality which previously shared the logic.
  1. ; Added prompt to the user for the REQUEST SERVICE within the
  1. ; procedure to convert TO which removes bug in that processing.
  1. ;
  1. Q
  1. ;
  1. EN ; Entry point for this routine
  1. N MDFPRC,MDFPRCD,MDFSVC,MDFSVCD,MDTPRC,MDTPRCD,MDTSVC,MDTSVCD,MDCOUNT,MDCP
  1. N MDFDA,MDSTS,MDSTSD,MDDT,MDIEN,MDPRT,STOP,FROM
  1. S (MDCOUNT,STOP)=0
  1. ;
  1. D INTRO
  1. F FROM=1,0 Q:STOP D GETPR(FROM)
  1. Q:STOP
  1. D CONVERT
  1. Q
  1. ;
  1. INTRO ;
  1. W !!,"This utility will get all pending, active, and scheduled"
  1. W !,"procedures of a selected REQUEST SERVICES and convert them to"
  1. W !,"the selected REQUEST SERVICES in the selected GMRC procedure."
  1. W !
  1. W !,"Note that procedures currently setup with DICOM (in the CLINICAL "
  1. W !,"SPECIALTY DICOM & HL7 file) cannot be converted to CP with this"
  1. W !,"utility. DICOM procedures will need to discontinued and reordered."
  1. W !
  1. Q
  1. ;
  1. GETPR(FROM) ; Get the user-selected procedure
  1. N DIC,X,Y,DTOUT,DUOUT
  1. S DIC="^GMR(123.3,",DIC(0)="AEMNQ",DIC("A")="Select a GMRC Procedure to convert "_$S(FROM:"FROM: ",1:"TO: ")
  1. D ^DIC I Y<1!($D(DTOUT))!($D(DUOUT)) S STOP=1 Q
  1. I FROM D Q
  1. . I $$GET1^DIQ(123.3,+Y,.04)]"" D Q
  1. .. W !!,"This procedure is already a Clinical Procedure - Cannot convert. Quitting...",!
  1. .. S STOP=1
  1. .. Q
  1. . S MDFPRC=+Y,MDFPRCD=$P(Y,U,2)
  1. . D GETRS(FROM)
  1. . Q
  1. ;
  1. Q:STOP
  1. S MDTPRC=+Y,MDTPRCD=$P(Y,U,2)
  1. D GETRS(FROM)
  1. Q
  1. ;
  1. GETRS(FROM) ; Get the Related Service from #123.32
  1. N DIC,X,Y,DTOUT,DUOUT
  1. S DIC="^GMR(123.5,",DIC(0)="AEMNQ"
  1. ; Next line - screen to only allow service related to selected procedure
  1. S DIC("S")="I ($D(^GMR(123.3,"_$S(FROM:"MDFPRC",1:"MDTPRC")_",2,""B"",+Y)))"
  1. D ^DIC I Y<1!($D(DTOUT))!($D(DUOUT)) S STOP=1 Q
  1. I FROM D Q
  1. . I $D(^MAG(2006.5831,"C",+Y,MDFPRC)) D Q
  1. .. W !!,"Procedure/Service setup for DICOM - Cannot convert. Quitting...",!
  1. .. S STOP=1
  1. .. Q
  1. . S MDFSVC=+Y,MDFSVCD=$P(Y,U,2)
  1. . Q
  1. ;
  1. Q:STOP
  1. S MDTSVC=+Y,MDTSVCD=$P(Y,U,2)
  1. Q
  1. ;
  1. CONVERT ; Convert the requested data
  1. S MDCP=$$GET1^DIQ(123.3,+MDTPRC_",",.04,"I")
  1. I 'MDCP D GETCP Q:STOP
  1. ;
  1. W !!,"We will proceed to convert ",MDFPRCD," in ",MDFSVCD
  1. W !,"to ",MDTPRCD," procedures in ",MDTSVCD,!
  1. ;
  1. ; ^GMR(123,"AE",RequestService,OrderStatus,ReverseDate,IEN)
  1. S MDSTS=""
  1. F S MDSTS=$O(^GMR(123,"AE",MDFSVC,MDSTS)) Q:'MDSTS D
  1. . S MDSTSD=$$GET1^DIQ(100.01,MDSTS,.01,"E")
  1. . I MDSTSD'="PENDING",MDSTSD'="ACTIVE",MDSTSD'="SCHEDULED" Q
  1. . S MDDT=0
  1. . F S MDDT=$O(^GMR(123,"AE",MDFSVC,MDSTS,MDDT)) Q:MDDT="" D
  1. .. S MDIEN=0
  1. .. F S MDIEN=$O(^GMR(123,"AE",MDFSVC,MDSTS,MDDT,MDIEN)) Q:'MDIEN D
  1. ... S MDPRT=$$GET1^DIQ(123,MDIEN,4,"E")
  1. ... I MDPRT'=MDFPRCD Q
  1. ... S MDFDA(123,MDIEN_",",1)=+MDTSVC ; To Service
  1. ... S MDFDA(123,MDIEN_",",1.01)=+MDCP ; Clinical Procedure
  1. ... S MDFDA(123,MDIEN_",",4)=+MDTPRC_";"_"GMR(123.3," ; Procedure/Request Type
  1. ... S MDFDA(123,MDIEN_",",13)="P" ; Request Type
  1. ... L +^GMR(123,MDIEN):1 I '$T Q
  1. ... D FILE^DIE("","MDFDA")
  1. ... L -^GMR(123,MDIEN)
  1. ... S MDCOUNT=MDCOUNT+1 W !," Record # ",MDIEN," converted."
  1. ... Q
  1. .. Q
  1. . Q
  1. ;
  1. W !!,"Total records converted = ",MDCOUNT,!
  1. Q
  1. ;
  1. GETCP ; Get/define a clinical procedure for the target/TO procedure
  1. N DIC,X,Y,DTOUT,DUOUT
  1. W !,"Missing Clinical Procedure Definition in ",$$GET1^DIQ(123.3,+MDTPRC,.01),!
  1. S DIC="^MDS(702.01,",DIC(0)="AEMNQ"
  1. D ^DIC I Y<1!($D(DTOUT))!($D(DUOUT)) S STOP=1 Q
  1. S MDCP=+Y
  1. S MDFDA(123.3,MDTPRC_",",.04)=+MDCP
  1. L +^GMR(123.3,MDTPRC):1 I '$T D Q
  1. . W !!,"Unable to lock the "_MDTPRCD_" record. Quitting..."
  1. . S STOP=1
  1. . Q
  1. ;
  1. D FILE^DIE("","MDFDA") K MDFDA
  1. L -^GMR(123.3,MDTPRC)
  1. Q