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

MAGDHOWP.m

Go to the documentation of this file.
  1. MAGDHOWP ;WOIFO/PMK - Generate VistA Imaging HL7 message for Clinical Procedures Check-in ;04 Sep 2018 10:41 AM
  1. ;;3.0;IMAGING;**208**;Mar 19, 2002;Build 6;Sep 03, 2013
  1. ;; Per VHA Directive 2004-038, this routine should not be modified.
  1. ;; +---------------------------------------------------------------+
  1. ;; | Property of the US Government. |
  1. ;; | No permission to copy or redistribute this software is given. |
  1. ;; | Use of unreleased versions of this software requires the user |
  1. ;; | to execute a written test agreement with the VistA Imaging |
  1. ;; | Development Office of the Department of Veterans Affairs, |
  1. ;; | telephone (301) 734-0100. |
  1. ;; | The Food and Drug Administration classifies this software as |
  1. ;; | a medical device. As such, it may not be changed in any way. |
  1. ;; | Modifications to this software may result in an adulterated |
  1. ;; | medical device under 21CFR820, the use of which is considered |
  1. ;; | to be a violation of US Federal Statutes. |
  1. ;; +---------------------------------------------------------------+
  1. ;;
  1. ;;
  1. ;
  1. ; Supported IA #10000 reference NOW^%DTC subroutine call
  1. ; Supported IA #2056 reference $$GET1^DIQ function call
  1. ; Supported IA #2056 reference GETS^DIQ subroutine call
  1. ; Controlled IA #4110 to read REQUEST/CONSULTATION file (#123)
  1. ; Private IA #6928 to read CP INSTRUMENT file (#702.09)
  1. ; Private IA #6929 to read CP TRANSACTION file (#702)
  1. ; Private IA #6929 to $Order thru "ACON" xfef in ^MDD(702)
  1. ; Private IA #6930 to read CP DEFINITION file (#702.01)
  1. ;
  1. ; CLINPROC is called by MDHL7BH to generate VistA Imaging HL7
  1. ; for a check-in or cancellation of a Clinical Procedure.
  1. ;
  1. CLINPROC(FILE702P,ORDERFLAG) ; entry point from MDHL7BH
  1. ; FILE702P ---- pointer to the clinical procedure in ^MDD(702,FILE702P,...)
  1. ; ORDERFLAG --- 0=cancel, 1=new order
  1. N APTSCHED,CPINVOCATION,DFN,FILE70201P,FILLER2,GMRCIEN,ORC1,ORC5,SDATE,SERVICE
  1. S DFN=$$GET1^DIQ(702,FILE702P,.01,"I")
  1. S GMRCIEN=$$GET1^DIQ(702,FILE702P,.05,"I")
  1. S SERVICE=$$GET1^DIQ(123,GMRCIEN,1,"I")
  1. S SDATE=$$GET1^DIQ(702,FILE702P,.07,"I")
  1. I SDATE[";" S SDATE=$P(SDATE,";",2)
  1. I SDATE="" D NOW^%DTC S SDATE=%
  1. I SDATE<DT D NOW^%DTC S SDATE=%
  1. S APTSCHED("FM DATETIME")=SDATE
  1. S FILE70201P=$$GET1^DIQ(702,FILE702P,.04,"I")
  1. S APTSCHED("CLINIC IEN")=$$GET1^DIQ(702.01,FILE70201P,.05,"I")
  1. S APTSCHED("CLINIC NAME")=$$GET1^DIQ(702.01,FILE70201P,.05,"E")
  1. S FILLER2="GMRC-SCHEDULED" ; over-ride GMRC's status
  1. I ORDERFLAG D ; new CP order check-in
  1. . S (ORC1,ORC5)="OK"
  1. . Q
  1. E D ; cancel CP order
  1. . S (ORC1,ORC5)="CA"
  1. . Q
  1. ;
  1. D TELEREAD(ORC1) ; put CP study on TeleReader Read/Unread list
  1. ;
  1. S CPINVOCATION=1 ; Clinical Procedures HL7 flag
  1. D MSGSETUP^MAGDHOW1(GMRCIEN,SERVICE,ORC1,ORC5,.APTSCHED)
  1. Q
  1. ;
  1. TELEREAD(ORC1) ; add the CP order to the TeleReader Read/Unread list
  1. N DEL,DEL2,HL7ORC
  1. S DEL="|",DEL2="^"
  1. S $P(HL7ORC,DEL)=ORC1
  1. D ^MAGDTR01
  1. Q
  1. ;
  1. OUTPUT(N) ; called by OUTPUT^MAGDHOW2 if CPINVOCATION=1
  1. N FILE70209P,CPDICOM
  1. S FILE70209P=$$GET1^DIQ(702,FILE702P,.11,"I") ; get instrument
  1. S CPDICOM=$$GET1^DIQ(702.09,FILE70209P,.19,"I") ; get CP - DICOM Interoperability
  1. I CPDICOM=2 D ; replace CP's HL7 message with VistA's
  1. . ; Replace the CP HL7 message body in HLA with the VI HL7 message body
  1. . K HLA
  1. . F I=2:1:N S HLA("HLS",I-1)=HL7(I)
  1. . Q
  1. Q
  1. ;
  1. ;
  1. ; CPORDER is called by MAGDHOW4, MAGDHOWC and MAGDHOWS to determine
  1. ; if this a Clinical Procedures order.
  1. ;
  1. ; In addition, MAGDHOW4 is concerned if this is a Clinical Procedures
  1. ; order and get the HL7 Universal Service ID.
  1. ;
  1. ; MAGDHOWC and MAGDHOWS need to know if this is a new/active CP order
  1. ; for one or more bidirectional instruments. If so, MAGDHOWC(which
  1. ; handles GMRC CPRS Consult Request Tracking) and MAGDHOWS(which handles
  1. ; SDAM Appointment Management) will not prematurely generate an HL7
  1. ; message at order release time or when the appointment is scheduled.
  1. ;
  1. ; Instead, the HL7 message will be generated by the CLINPROC subroutine
  1. ; (above) when it is invoked by MDHL7BH for CP check-in.
  1. ;
  1. CPORDER(GMRCIEN,HL7USID) ; entry point from OBR^MAGDHOW4, ENTRY^MAGDHOWC, MAGDHOWS
  1. ; Return Code
  1. ; -1,ERROR -------- error return
  1. ; 0,NOT A CP ----- not a clinical procedure
  1. ; 1,UNIDIRECT ---- clinical procedure with no bidirectional instruments
  1. ; 2,UNFINISHED --- unfinished clinical procedure with bidirectional instruments
  1. ; 3,FINISHED ----- finished clinical procedure with bidirectional instruments
  1. ;
  1. ; MAGHOWC and MAGDHOWS ignore consult & appointment transactions for
  1. ; unfinished CP's ("2,UNFINISHED") and process them for cancelled, completed,
  1. ; and discontinued CP's, CP's with no bidirectional instruments, and non-CP
  1. ; CPRS Consult Request Tracking consults & procedures.
  1. ;
  1. ; MAGDHOW4 needs to get CP's HL7 Universal Service Identifier (HL7USID) and
  1. ; store it in OBR-4 for clinical procedures.
  1. ;
  1. N BIDIRECT,E,I,FILE702P,FILE70201P,FILE70209P,MCODE,STATUS,TAG
  1. ;
  1. S HL7USID="" ; initialize CP's HL7 Universal Service Identifier
  1. ;
  1. ; is this a consult/procedure in Clinical Procedures?
  1. S FILE70201P=$$GET1^DIQ(123,GMRCIEN,1.01,"I") ; get Clinical Procedures definition
  1. ;
  1. I 'FILE70201P Q "0,NOT A CP" ; not a CP
  1. ;
  1. ; look for a bidirectional instrument associated with this CP definition
  1. S BIDIRECT=0 ; initialize bidirectional switch
  1. S I=0 F S I=$O(^MDS(702.01,FILE70201P,.1,I)) Q:'I D Q:BIDIRECT
  1. . S FILE70209P=$$GET1^DIQ(702.011,I_","_FILE70201P,.01,"I") Q:'FILE70209P
  1. . S HL7USID=$$GET1^DIQ(702.09,FILE70209P,.17,"E")
  1. . S BIDIRECT=$$GET1^DIQ(702.09,FILE70209P,.13,"I")
  1. . Q
  1. ;
  1. I 'BIDIRECT Q "1,UNIDIRECT" ; no bidirectional instrument
  1. ;
  1. ; get CP's HL7 Universal Service Identifier from the transaction
  1. ; the transaction is created at check-in; there is none for order release
  1. S FILE702P=$O(^MDD(702,"ACON",GMRCIEN,""),-1) ; get last transaction
  1. I FILE702P D ; CP transaction exists
  1. . S FILE70209P=$$GET1^DIQ(702,FILE702P,.11,"I") Q:'FILE70209P
  1. . S HL7USID=$$GET1^DIQ(702.09,FILE70209P,.17,"E")
  1. . Q
  1. ;
  1. S STATUS=$$GET1^DIQ(123,GMRCIEN,8,"I")
  1. S TAG="IEN"_$TR($J(STATUS,2)," ",0)
  1. S MCODE=$T(@TAG)
  1. Q $S($P(MCODE,";",3)="U":"2,UNFINISHED",1:"3,FINISHED")
  1. ;
  1. ; Table of Order Status (from file #100.01)
  1. ; IEN ;;F=finished, U=unfinished;name
  1. IEN01 ;;F;DISCONTINUED
  1. IEN02 ;;F;COMPLETE
  1. IEN03 ;;U;HOLD
  1. IEN04 ;;U;FLAGGED
  1. IEN05 ;;U;PENDING
  1. IEN06 ;;U;ACTIVE
  1. IEN07 ;;F;EXPIRED
  1. IEN08 ;;U;SCHEDULED
  1. IEN09 ;;U;PARTIAL RESULTS
  1. IEN10 ;;U;DELAYED
  1. IEN11 ;;U;UNRELEASED
  1. IEN12 ;;F;DISCONTINUED/EDIT
  1. IEN13 ;;F;CANCELLED
  1. IEN14 ;;U;LAPSED
  1. IEN15 ;;U;RENEWED
  1. IEN99 ;;F;NO STATUS