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

MAGGSIU3.m

Go to the documentation of this file.
  1. MAGGSIU3 ;WOIFO/GEK - Utilities
  1. ;;3.0;IMAGING;**7,8,48**;Jan 11, 2005
  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. ;; | |
  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. Q
  1. LOG(MAGRY,MAGIX,IMAGES,PAT,WRKS,TRKID) ;Utilities for Import API, logging data for tracking and debugging
  1. ; into Imaging Windows Session and Imaging Windows Workstation files.
  1. N WRKSIEN,WRKSN0,USERSRV,MAGSTART,I,SESSIEN,X,Z,DIERR
  1. I '$L($G(WRKS)) S WRKS="NULL WORKSTATION NAME"
  1. S WRKSIEN=0
  1. S SESSIEN=0
  1. S WRKSIEN=$O(^MAG(2006.81,"B",WRKS,""))
  1. I 'WRKSIEN D NEWWRKS^MAGGTAU(WRKS,"",.WRKSIEN) I WRKSIEN<1 S MAGRY="0^Error Creating Workstation Entry." Q 0
  1. ;
  1. S WRKSN0=^MAG(2006.81,WRKSIEN,0) ; '0' node for use later.
  1. S WRKSIEN=+WRKSIEN_","
  1. S MAGGFDA(2006.81,WRKSIEN,.01)=WRKS ; Computer Name
  1. S MAGGFDA(2006.81,WRKSIEN,8)=0 ; Active or not.
  1. S MAGGFDA(2006.81,WRKSIEN,3)="@" ; delete logoff time for this job.
  1. S MAGGFDA(2006.81,WRKSIEN,10)="@" ; delete session pointer
  1. S MAGGFDA(2006.81,WRKSIEN,11)="@" ; reset the session error count.
  1. ;
  1. ;
  1. S MAGGFDA(2006.81,WRKSIEN,12.5)=$P(WRKSN0,U,14)+1 ; total Import Sessions for workstation
  1. ;
  1. S X=$$NOW^XLFDT
  1. S MAGSTART=$E(X,1,12)
  1. I $G(DUZ) D
  1. . S MAGGFDA(2006.81,WRKSIEN,1)=DUZ
  1. . S MAGGFDA(2006.81,WRKSIEN,2)=MAGSTART
  1. ;
  1. D UPDATE^DIE("S","MAGGFDA","MAGXIEN","MAGXERR")
  1. I $D(DIERR) D RTRNERR^MAGGTAU(.MAGRY) Q 0
  1. ;
  1. S MAGRY="1^"
  1. ;
  1. ; SESSION : Now here we have to create a new session entry;
  1. ; //TODO, make a generic call to create a Session entry, this is
  1. ; a duplicate of code in MAGGTAU
  1. D GETS^DIQ(200,DUZ_",","29","I","Z","") ; service/section
  1. S USERSRV=$G(Z(200,DUZ_",",29,"I"))
  1. ;
  1. K MAGGFDA,MAGXERR,MAGXIEN
  1. S MAGGFDA(2006.82,"+1,",.01)=$P(^VA(200,DUZ,0),U,1) ; User
  1. S MAGGFDA(2006.82,"+1,",1)=DUZ ; USER
  1. S MAGGFDA(2006.82,"+1,",2)=MAGSTART ; Session Start Time
  1. S MAGGFDA(2006.82,"+1,",4)=+WRKSIEN ; Workstation
  1. I $D(^DPT(+PAT,0)) S MAGGFDA(2006.82,"+1,",5)=+PAT ; Patient
  1. S MAGGFDA(2006.82,"+1,",7)=+USERSRV ; User's Service/Section pointer
  1. S MAGGFDA(2006.82,"+1,",13)=3 ; 1=normal 2= started by CPRS 3= Import API session.
  1. S MAGGFDA(2006.82,"+1,",8)=$G(TRKID) ; Tracking ID
  1. ;
  1. D UPDATE^DIE("","MAGGFDA","MAGXIEN","MAGXERR")
  1. I $D(DIERR) D RTRNERR^MAGGTAU(.MAGRY) Q 0
  1. S MAGRY="1^"
  1. I '+MAGXIEN(1) S MAGRY="0^" Q 0
  1. S SESSIEN=+MAGXIEN(1)
  1. S MAGRY=SESSIEN_"^Session # "_SESSIEN_" Started."
  1. S MAGGFDA(2006.81,+WRKSIEN_",",10)=SESSIEN
  1. D UPDATE^DIE("","MAGGFDA","MAGXIEN","MAGXERR")
  1. D ACTION^MAGGTAU("IMPORT^",0,SESSIEN) ;
  1. S I="" F S I=$O(MAGIX(I)) Q:I="" D ACTION^MAGGTAU("Data:|"_"("_I_"): "_$TR(MAGIX(I),"^","~"),0,SESSIEN)
  1. S I="" F S I=$O(IMAGES(I)) Q:I="" D ACTION^MAGGTAU("Image:|"_"("_I_"): "_$TR(IMAGES(I),"^","~"),0,SESSIEN)
  1. Q SESSIEN
  1. LOGRES(RES,LOGTM,MAGSESS) ;
  1. N I
  1. S LOGTM=+$G(LOGTM)
  1. I '$G(MAGSESS) Q
  1. D ACTION^MAGGTAU("RESULTS^",1,MAGSESS) ;
  1. S I="" F S I=$O(RES(I)) Q:I="" D ACTION^MAGGTAU("Result:|"_"("_I_"): "_$TR(RES(I),"^","~"),LOGTM,MAGSESS)
  1. Q
  1. INPRC(RET,ARR) ; gek/Duplicate Import check
  1. ; gek/stop duplicates. Import now has a status in the Session File.
  1. ; ^MAG(2006.82,"STATUS",TRKID,SESSION IEN)= status
  1. ; INPRC tells if the Session (by Tracking ID) is in process or not.
  1. ; if In Process, we won't return the data.
  1. ; INPRC will set the status to In Process if not currently in process.
  1. ; P48T1 This function is not called in P48.
  1. ; Possible use in future.
  1. N I,SESS,STAT,TRKID
  1. S TRKID=0
  1. S I="" F S I=$O(ARR(I)) Q:I="" D
  1. . S FLD=$P(ARR(I),"^",1) I (FLD=108)!(FLD="TRKID") D
  1. . . S TRKID=$P(ARR(I),"^",2)
  1. . . Q
  1. . Q
  1. I TRKID="" S RET="0^Null value for Tracking ID." Q 0
  1. S RET="0^This tracking ID: "_TRKID_" isn't being processed"
  1. I '$D(^MAG(2006.82,"E",TRKID)) Q 0
  1. S SESS=$$SES4TRK(TRKID) Q:'SESS 0 ; This tracking ID isn't being processed yet.
  1. S STAT=$$GETSTAT(TRKID,SESS)
  1. I 'STAT D SETSTAT(TRKID,SESS,"-5") Q 0 ; -5 means In Process
  1. ; If in process we return 1
  1. I (+STAT=-5) D Q 1
  1. . S RET="0^Import for Tracking ID: "_TRKID_" has been processed."
  1. Q 0
  1. SES4TRK(TRKID) ; Returns the Session ID for a Tracking ID
  1. Q +$O(^MAG(2006.82,"E",TRKID,""),-1)
  1. ;
  1. GETSTAT(TRKID,SESS) ; Get Status for given Tracking ID and Session ID
  1. Q $G(^MAG(2006.82,"STATUS",TRKID,SESS))
  1. ;
  1. SETSTAT(TRKID,SESS,STAT) ; Set Status for given Tracking ID and Session ID
  1. S ^MAG(2006.82,"STATUS",TRKID,SESS)=STAT
  1. Q