- MAGGSTI ;WOIFO/GEK - Imaging interface to TIU RPC Calls etc. ; 01 Nov 2001 12:32 PM
- ;;3.0;IMAGING;**7**;Jul 12, 2002
- ;; +---------------------------------------------------------------+
- ;; | Property of the US Government. |
- ;; | No permission to copy or redistribute this software is given. |
- ;; | Use of unreleased versions of this software requires the user |
- ;; | to execute a written test agreement with the VistA Imaging |
- ;; | Development Office of the Department of Veterans Affairs, |
- ;; | telephone (301) 734-0100. |
- ;; | |
- ;; | The Food and Drug Administration classifies this software as |
- ;; | a medical device. As such, it may not be changed in any way. |
- ;; | Modifications to this software may result in an adulterated |
- ;; | medical device under 21CFR820, the use of which is considered |
- ;; | to be a violation of US Federal Statutes. |
- ;; +---------------------------------------------------------------+
- ;;
- Q
- LISTC(ATMP,PROC,MAGDFN,BDT,EDT,NUM,DETAILS) ;Get Short list of TIU notes
- ; given a CLASS in PROC parameter
- ; The compressed listing, 4 columns "Date^Spec^Desc^Img Count^procedure info"
- N MAGX,I,ACT,NODE,TMP
- D CONTEXT^TIUSRVLO(.MAGX,PROC,1,MAGDFN)
- I '$D(@MAGX) Q
- S ACT=+$O(@ATMP@(""),-1)
- S I="" F S I=$O(@MAGX@(I)) Q:I="" D
- . ;
- . S X=$S(DETAILS:$$DETINF(@MAGX@(I)),1:$$CMPINF(@MAGX@(I)))
- . S ACT=ACT+1
- . S @ATMP@(ACT)=X
- I DETAILS S @ATMP@(1)="Date^Title^Images^Author^Status^Visit" ;^|TIUDA^
- Q
- CMPINF(NODE) ;
- N RY
- S RY=$$EXTDT^MAGGSU1($P(NODE,U,3))_U_"TIU"_U_$P(NODE,U,2)_U
- S RY=RY_$$IMGCT($P(NODE,U))_U_$P($P(NODE,U,5),";",2)_U
- S RY=RY_"|TIU^"_$P(NODE,U)
- Q RY
- ;
- DETINF(NODE) ;
- ; The node info from TIUSRVLO is
- ; TIUDA Desc date patient duz;author status
- ; x)=2452^General Note^2910528.1533^HOOD, ROBIN (H2591)^10;MELANIE BUECHLER
- ; service status visit info ? ? ?
- ; ^CARDIOLOGY^completed^Visit: 05/28/91^ ^^0^
- N RY
- ; DATE^DESC^IMGCT^AUTHOR^STATUS^VISIT^|"TIU^"TIUDA^
- S RY=$$EXTDT^MAGGSU1($P(NODE,U,3))_U_$P(NODE,U,2)_U_$$IMGCT($P(NODE,U))_U
- S RY=RY_$P($P(NODE,U,5),";",2)_U_$P(NODE,U,7)_U_$P(NODE,U,8)
- S RY=RY_U_"|TIU"_U_$P(NODE,U)_U
- Q RY
- IMGCT(TIUDA) ; Get count of images for this TIU Document
- ; If more than one group (or image) is pointing to this Document
- ; then return "Group count : total images" i.e. "3:134"
- ;
- N MAGARR,MAGIEN,CT,GCT,ICT,I
- S I="",CT=0,GCT=0
- D GETILST^TIUSRVPL(.MAGARR,TIUDA)
- F S I=$O(MAGARR(I)) Q:'I D
- . S ICT=+$P($G(^MAG(2005,MAGARR(I),1,0)),U,4)
- . S ICT=$S(ICT:ICT,1:1) ;If no group images, set count =1 (single image)
- . S GCT=GCT+1
- . S CT=CT+ICT
- I (GCT>1) Q GCT_":"_CT
- Q CT
- FILE(MAGRY,MAGDA,TIUDA) ; RPC Call to file TIU and Imaging Pointers
- ; TIU API to add image to TIU
- ; TODO; have to validate that the Imaging patient matches the TIU patient.
- D PUTIMAGE^TIUSRVPL(.MAGRY,TIUDA,MAGDA) ;
- I 'MAGRY Q
- ; Now SET the Parent fields in the Image File
- S $P(^MAG(2005,MAGDA,2),U,6,8)=8925_U_TIUDA_U_+MAGRY
- ; DONE.
- S MAGRY="1^Image pointer filed successfully"
- Q
- DATA(MAGRY,TIUDA) ;RPC Call to get TIU data from the TIUDA
- ; Return = TIUDA^Document Type ^Document Date^DFN
- ; returning DFN is new, We'll need IA for it ;TODO
- ;
- S MAGRY=TIUDA_U_$$GET1^DIQ(8925,TIUDA,".01","E")_U_$$GET1^DIQ(8925,TIUDA,"1201","I")_U_$$GET1^DIQ(8925,TIUDA,".02","I")
- ;
- Q
- IMAGES(MAGRY,TIUDA) ;RPC Call to get all images for a given TIU DA
- ; We first get all Image IEN's breaking groups into seperate images
- ; Then get Image Info for each one.
- ; MAGRY - Return array of Image Data entries
- ; MAGRY(0) is 1 ^ message if successful
- ; 0 ^ Error message if error;
- ; TIUDA is IEN in ^TIU(8925
- ;
- ; Call TIU API to get list of Image IEN's
- N MAGARR,CT K ^TMP("MAGGX",$J)
- N MAGZZ
- D GETILST^TIUSRVPL(.MAGARR,TIUDA)
- S CT=0
- K ^TMP("MAGGX",$J)
- ; Now get all images for all groups and single images.
- S I="" F S I=$O(MAGARR(I)) Q:'I S DA=MAGARR(I) D
- . I $O(^MAG(2005,DA,1,0)) D Q
- . . S J=0 F S J=$O(^MAG(2005,DA,1,J)) Q:'J S CT=CT+1,^TMP("MAGGX",$J,CT)=^(J,0)
- . S CT=CT+1
- . S ^TMP("MAGGX",$J,CT)=DA
- ; Now get image info for each image
- ;
- S CT=0,Z=""
- S MAGQUIET=1
- F S Z=$O(^TMP("MAGGX",$J,Z)) Q:Z="" D
- . S CT=CT+1,MAGXX=^TMP("MAGGX",$J,Z)
- . ;GEK 8/24/00 Stoping the Invalid Image IEN's and Deleted Images
- . I '$D(^MAG(2005,MAGXX)) D Q
- . . D INVALID^MAGGTIG(MAGXX,.MSGX) S MAGRY(CT)=MSGX
- . D BOTH^MAGFILEB
- . S MAGRY(CT)="B2^"_MAGFILE
- K MAGQUIET
- S MAGRY(0)=CT_"^"_CT_" Images for the selected TIU NOTE"
- ; PUT THE Image IEN of the last image into the group ien field.
- Q:'CT
- S $P(MAGRY(0),U,3)=TIUDA
- D DATA(.MAGZZ,TIUDA)
- S $P(MAGRY(0),U,4)=$$GET1^DIQ(8925,TIUDA,".02","E")_" "_$P(MAGZZ,U,2)_" "_$$FMTE^XLFDT($P(MAGZZ,U,3),"8")
- ;
- S $P(MAGRY(0),U,5)=$S($P($G(MAGFILE),U):$P(MAGFILE,U),1:MAGXX)
- Q
- ;
- --- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGGSTI 5136 printed Feb 18, 2025@23:29:21 Page 2
- MAGGSTI ;WOIFO/GEK - Imaging interface to TIU RPC Calls etc. ; 01 Nov 2001 12:32 PM
- +1 ;;3.0;IMAGING;**7**;Jul 12, 2002
- +2 ;; +---------------------------------------------------------------+
- +3 ;; | Property of the US Government. |
- +4 ;; | No permission to copy or redistribute this software is given. |
- +5 ;; | Use of unreleased versions of this software requires the user |
- +6 ;; | to execute a written test agreement with the VistA Imaging |
- +7 ;; | Development Office of the Department of Veterans Affairs, |
- +8 ;; | telephone (301) 734-0100. |
- +9 ;; | |
- +10 ;; | The Food and Drug Administration classifies this software as |
- +11 ;; | a medical device. As such, it may not be changed in any way. |
- +12 ;; | Modifications to this software may result in an adulterated |
- +13 ;; | medical device under 21CFR820, the use of which is considered |
- +14 ;; | to be a violation of US Federal Statutes. |
- +15 ;; +---------------------------------------------------------------+
- +16 ;;
- +17 QUIT
- LISTC(ATMP,PROC,MAGDFN,BDT,EDT,NUM,DETAILS) ;Get Short list of TIU notes
- +1 ; given a CLASS in PROC parameter
- +2 ; The compressed listing, 4 columns "Date^Spec^Desc^Img Count^procedure info"
- +3 NEW MAGX,I,ACT,NODE,TMP
- +4 DO CONTEXT^TIUSRVLO(.MAGX,PROC,1,MAGDFN)
- +5 IF '$DATA(@MAGX)
- QUIT
- +6 SET ACT=+$ORDER(@ATMP@(""),-1)
- +7 SET I=""
- FOR
- SET I=$ORDER(@MAGX@(I))
- if I=""
- QUIT
- Begin DoDot:1
- +8 ;
- +9 SET X=$SELECT(DETAILS:$$DETINF(@MAGX@(I)),1:$$CMPINF(@MAGX@(I)))
- +10 SET ACT=ACT+1
- +11 SET @ATMP@(ACT)=X
- End DoDot:1
- +12 ;^|TIUDA^
- IF DETAILS
- SET @ATMP@(1)="Date^Title^Images^Author^Status^Visit"
- +13 QUIT
- CMPINF(NODE) ;
- +1 NEW RY
- +2 SET RY=$$EXTDT^MAGGSU1($PIECE(NODE,U,3))_U_"TIU"_U_$PIECE(NODE,U,2)_U
- +3 SET RY=RY_$$IMGCT($PIECE(NODE,U))_U_$PIECE($PIECE(NODE,U,5),";",2)_U
- +4 SET RY=RY_"|TIU^"_$PIECE(NODE,U)
- +5 QUIT RY
- +6 ;
- DETINF(NODE) ;
- +1 ; The node info from TIUSRVLO is
- +2 ; TIUDA Desc date patient duz;author status
- +3 ; x)=2452^General Note^2910528.1533^HOOD, ROBIN (H2591)^10;MELANIE BUECHLER
- +4 ; service status visit info ? ? ?
- +5 ; ^CARDIOLOGY^completed^Visit: 05/28/91^ ^^0^
- +6 NEW RY
- +7 ; DATE^DESC^IMGCT^AUTHOR^STATUS^VISIT^|"TIU^"TIUDA^
- +8 SET RY=$$EXTDT^MAGGSU1($PIECE(NODE,U,3))_U_$PIECE(NODE,U,2)_U_$$IMGCT($PIECE(NODE,U))_U
- +9 SET RY=RY_$PIECE($PIECE(NODE,U,5),";",2)_U_$PIECE(NODE,U,7)_U_$PIECE(NODE,U,8)
- +10 SET RY=RY_U_"|TIU"_U_$PIECE(NODE,U)_U
- +11 QUIT RY
- IMGCT(TIUDA) ; Get count of images for this TIU Document
- +1 ; If more than one group (or image) is pointing to this Document
- +2 ; then return "Group count : total images" i.e. "3:134"
- +3 ;
- +4 NEW MAGARR,MAGIEN,CT,GCT,ICT,I
- +5 SET I=""
- SET CT=0
- SET GCT=0
- +6 DO GETILST^TIUSRVPL(.MAGARR,TIUDA)
- +7 FOR
- SET I=$ORDER(MAGARR(I))
- if 'I
- QUIT
- Begin DoDot:1
- +8 SET ICT=+$PIECE($GET(^MAG(2005,MAGARR(I),1,0)),U,4)
- +9 ;If no group images, set count =1 (single image)
- SET ICT=$SELECT(ICT:ICT,1:1)
- +10 SET GCT=GCT+1
- +11 SET CT=CT+ICT
- End DoDot:1
- +12 IF (GCT>1)
- QUIT GCT_":"_CT
- +13 QUIT CT
- FILE(MAGRY,MAGDA,TIUDA) ; RPC Call to file TIU and Imaging Pointers
- +1 ; TIU API to add image to TIU
- +2 ; TODO; have to validate that the Imaging patient matches the TIU patient.
- +3 ;
- DO PUTIMAGE^TIUSRVPL(.MAGRY,TIUDA,MAGDA)
- +4 IF 'MAGRY
- QUIT
- +5 ; Now SET the Parent fields in the Image File
- +6 SET $PIECE(^MAG(2005,MAGDA,2),U,6,8)=8925_U_TIUDA_U_+MAGRY
- +7 ; DONE.
- +8 SET MAGRY="1^Image pointer filed successfully"
- +9 QUIT
- DATA(MAGRY,TIUDA) ;RPC Call to get TIU data from the TIUDA
- +1 ; Return = TIUDA^Document Type ^Document Date^DFN
- +2 ; returning DFN is new, We'll need IA for it ;TODO
- +3 ;
- +4 SET MAGRY=TIUDA_U_$$GET1^DIQ(8925,TIUDA,".01","E")_U_$$GET1^DIQ(8925,TIUDA,"1201","I")_U_$$GET1^DIQ(8925,TIUDA,".02","I")
- +5 ;
- +6 QUIT
- IMAGES(MAGRY,TIUDA) ;RPC Call to get all images for a given TIU DA
- +1 ; We first get all Image IEN's breaking groups into seperate images
- +2 ; Then get Image Info for each one.
- +3 ; MAGRY - Return array of Image Data entries
- +4 ; MAGRY(0) is 1 ^ message if successful
- +5 ; 0 ^ Error message if error;
- +6 ; TIUDA is IEN in ^TIU(8925
- +7 ;
- +8 ; Call TIU API to get list of Image IEN's
- +9 NEW MAGARR,CT
- KILL ^TMP("MAGGX",$JOB)
- +10 NEW MAGZZ
- +11 DO GETILST^TIUSRVPL(.MAGARR,TIUDA)
- +12 SET CT=0
- +13 KILL ^TMP("MAGGX",$JOB)
- +14 ; Now get all images for all groups and single images.
- +15 SET I=""
- FOR
- SET I=$ORDER(MAGARR(I))
- if 'I
- QUIT
- SET DA=MAGARR(I)
- Begin DoDot:1
- +16 IF $ORDER(^MAG(2005,DA,1,0))
- Begin DoDot:2
- +17 SET J=0
- FOR
- SET J=$ORDER(^MAG(2005,DA,1,J))
- if 'J
- QUIT
- SET CT=CT+1
- SET ^TMP("MAGGX",$JOB,CT)=^(J,0)
- End DoDot:2
- QUIT
- +18 SET CT=CT+1
- +19 SET ^TMP("MAGGX",$JOB,CT)=DA
- End DoDot:1
- +20 ; Now get image info for each image
- +21 ;
- +22 SET CT=0
- SET Z=""
- +23 SET MAGQUIET=1
- +24 FOR
- SET Z=$ORDER(^TMP("MAGGX",$JOB,Z))
- if Z=""
- QUIT
- Begin DoDot:1
- +25 SET CT=CT+1
- SET MAGXX=^TMP("MAGGX",$JOB,Z)
- +26 ;GEK 8/24/00 Stoping the Invalid Image IEN's and Deleted Images
- +27 IF '$DATA(^MAG(2005,MAGXX))
- Begin DoDot:2
- +28 DO INVALID^MAGGTIG(MAGXX,.MSGX)
- SET MAGRY(CT)=MSGX
- End DoDot:2
- QUIT
- +29 DO BOTH^MAGFILEB
- +30 SET MAGRY(CT)="B2^"_MAGFILE
- End DoDot:1
- +31 KILL MAGQUIET
- +32 SET MAGRY(0)=CT_"^"_CT_" Images for the selected TIU NOTE"
- +33 ; PUT THE Image IEN of the last image into the group ien field.
- +34 if 'CT
- QUIT
- +35 SET $PIECE(MAGRY(0),U,3)=TIUDA
- +36 DO DATA(.MAGZZ,TIUDA)
- +37 SET $PIECE(MAGRY(0),U,4)=$$GET1^DIQ(8925,TIUDA,".02","E")_" "_$PIECE(MAGZZ,U,2)_" "_$$FMTE^XLFDT($PIECE(MAGZZ,U,3),"8")
- +38 ;
- +39 SET $PIECE(MAGRY(0),U,5)=$SELECT($PIECE($GET(MAGFILE),U):$PIECE(MAGFILE,U),1:MAGXX)
- +40 QUIT
- +41 ;