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

RANMUSE2.m

Go to the documentation of this file.
  1. RANMUSE2 ;HISC/SWM-Nuclear Medicine Usage reports ;9/3/97 14:37
  1. ;;5.0;Radiology/Nuclear Medicine;**65,47**;Mar 16, 1998;Build 21
  1. ;
  1. ;Supported IA #10061 reference to DEM^VADPT
  1. ;
  1. SET ; There are 2 parts: set local arrays and ^tmp()
  1. ;
  1. ; part 1 -- raseqd(),raseqi(),ranumd(),ranumi() so to reduce
  1. ; div and img-typ names to a single number, and so to reduce
  1. ; the length of the ^tmp() string
  1. ; raseqd("division name")=sequence number for alpha sort order
  1. ; raseqi("imaging type name")=sequence number for alpha sort order
  1. ; ranumd(sequence number for alpha sort order)="division name"
  1. ; ranumi(sequence number for alpha sort order)="imaging type name"
  1. ;
  1. S RA1=0 F S RA1=$O(^RA(79,RA1)) Q:'RA1 S RA2=$P($G(^(RA1,0)),U) S:RA2 RASEQD($P($G(^DIC(4,+RA2,0)),U))=""
  1. S RA1="",RA2=1 F S RA1=$O(RASEQD(RA1)) Q:RA1="" S RASEQD(RA1)=RA2,RANUMD(RA2)=RA1,RA2=RA2+1
  1. ;
  1. S RA1=0 F S RA1=$O(^RA(79.2,RA1)) Q:'RA1 S RA2=$P($G(^(RA1,0)),U) S:RA2]"" RASEQI(RA2)=""
  1. S RA1="",RA2=1 F S RA1=$O(RASEQI(RA1)) Q:RA1="" S RASEQI(RA1)=RA2,RANUMI(RA2)=RA1,RA2=RA2+1
  1. ;
  1. ; part 2 -- ^TMP($J,"RA",div,imgtyp,S3,S4,patnam,caseno)
  1. ; S3 = sort field 3, either radiopharm/whoadmin or examdttm
  1. ; S4 = sort field 4, either examdttm or radiopharm/whoadmin
  1. ;
  1. ; Loop thru ^RADPTN("AB" to select recs within requested date range
  1. ;
  1. S RA0=RADTBEG-.0001
  1. S1 S RA0=$O(^RADPTN("AB",RA0)) Q:RA0="" Q:RA0>RADTEND S RA1=0
  1. S2 S RA1=$O(^RADPTN("AB",RA0,RA1)) G:RA1="" S1
  1. S RAN0=$G(^RADPTN(RA1,0)) G:RAN0="" S2
  1. S RADFN=$P(RAN0,U) G:RADFN="" S2
  1. S RADTI=9999999.9999-$P(RAN0,U,2) G:RADTI="" S2
  1. S RACNI=$O(^RADPT(RADFN,"DT",RADTI,"P","B",$P(RAN0,U,3),0)) G:RACNI="" S2
  1. D EXTRACT
  1. G S2
  1. EXTRACT ;
  1. S P02=$G(^RADPT(RADFN,"DT",RADTI,0)) Q:P02=""
  1. S P03=$G(^RADPT(RADFN,"DT",RADTI,"P",RACNI,0)) Q:P03=""
  1. S RADIVNAM=$P($G(^DIC(4,+$P(P02,U,3),0)),U)
  1. Q:'$D(^TMP($J,"RA D-TYPE",RADIVNAM)) ; div not selected
  1. S RAIMGNAM=$P($G(^RA(79.2,+$P(P02,U,2),0)),U)
  1. Q:'$D(^TMP($J,"RA I-TYPE",RAIMGNAM)) ; img typ not selected
  1. S RA2=0
  1. F1 S RA2=$O(^RADPTN(RA1,"NUC",RA2)) Q:RA2'=+RA2
  1. S RANUC=^RADPTN(RA1,"NUC",RA2,0)
  1. S RACN=$P(RAN0,U,3)
  1. S RADIOPH=$$EN1^RAPSAPI(+$P(RANUC,U),.01) ; Radiopharm Name
  1. I 'RAINPUT,RATITLE["Usage",'$D(^TMP($J,"RA EITHER",RADIOPH)) G F1 ;radioph not selectd
  1. S RAWHO=$P($G(^VA(200,+$P(RANUC,U,9),0)),U) ; who administered dose
  1. I RATITLE["Admin",RAWHO="" G F1 ;who admin dose is unknown
  1. I 'RAINPUT,RATITLE["Admin",'$D(^TMP($J,"RA EITHER",RAWHO)) G F1 ;who not selectd
  1. S RAXMDTM=$P(RAN0,U,2) ; exam date/time
  1. S RAPRC0=$G(^RAMIS(71,+$P(P03,U,2),0)) ; procedure 0-node
  1. S RAPRCNAM=$P(RAPRC0,U) ; procedure name
  1. S DFN=RADFN D DEM^VADPT
  1. S RAPATNAM=$P(VADM(1),U) ; patient name
  1. S RASSN=$P(VADM(2),U,2) ; ssn
  1. K VADM
  1. S RADOSE=$P(RANUC,U,7) ; dose administered
  1. S RADRAWN=$P(RANUC,U,4) ; activity drawn
  1. I 'RADOSE,'RADRAWN G F1 ; dose admin and drawn both null/zero
  1. ; ien of procedure sub-record with matching radiopharm
  1. ; if user changes default radiopharm entry, or
  1. ; adds a radiopharm that's not defined in file 71 default radiopharm,
  1. ; the high and low values would be unknown
  1. S RANUC1=$O(^RAMIS(71,+$P(P03,U,2),"NUC","B",+$P(RANUC,U),0))
  1. ; 0-node of procedure sub-record with matching radiopharm
  1. S:RANUC1 RANUC1=^RAMIS(71,+$P(P03,U,2),"NUC",+RANUC1,0)
  1. S RAHIGH=$P(RANUC1,U,5) ; high adult dose
  1. S RALOW=$P(RANUC1,U,6) ; low adult dose
  1. S RASTERSK=""
  1. I RADOSE>0,RALOW>0,RADOSE<RALOW S RASTERSK="*"
  1. I RADOSE>0,RAHIGH>0,RADOSE>RAHIGH S RASTERSK="*"
  1. D S3S4
  1. S ^TMP($J,"RA",RASEQD(RADIVNAM),RASEQI(RAIMGNAM),S3,S4,$E(RAPATNAM,1,15),RACN,RADIOPH)=RASSN_U_RADRAWN_U_RADOSE_U_RAHIGH_U_RALOW_U_RAWHO_U_RASTERSK_U_RAPRCNAM
  1. I '$D(^TMP($J,"RASUM",$S(RASORT:S3,1:S4),RACN,RASSN)) S ^(RASEQI(RAIMGNAM))=$G(^TMP($J,"RATUNIQ",RASEQD(RADIVNAM),RASEQI(RAIMGNAM)))+1,^(RASEQD(RADIVNAM))=$G(^TMP($J,"RATUNIQ",RASEQD(RADIVNAM)))+1
  1. S RAEITHER=$S(RATITLE["Usage":RADIOPH,1:RAWHO)
  1. I '$D(^TMP($J,"RASUM",$S(RASORT:S3,1:S4),RACN,RASSN,RAEITHER)) S ^(RAEITHER)=$G(^TMP($J,"RATUNIQ",RASEQD(RADIVNAM),RASEQI(RAIMGNAM),RAEITHER))+1,^(RAEITHER)=$G(^TMP($J,"RATUNIQ",RASEQD(RADIVNAM),RAEITHER))+1
  1. S ^(RASSN)=$G(^TMP($J,"RASUM",$S(RASORT:S3,1:S4),RACN,RASSN))+1
  1. S ^(RAEITHER)=$G(^TMP($J,"RASUM",$S(RASORT:S3,1:S4),RACN,RASSN,RAEITHER))+1
  1. ; img typ totals
  1. S:RASTERSK="*" ^(RAEITHER)=$G(^TMP($J,"RATOUTSD",RASEQD(RADIVNAM),RASEQI(RAIMGNAM),RAEITHER))+1
  1. S ^(RAEITHER)=$G(^TMP($J,"RATDRAWN",RASEQD(RADIVNAM),RASEQI(RAIMGNAM),RAEITHER))+RADRAWN
  1. S ^(RAEITHER)=$G(^TMP($J,"RATDOSE",RASEQD(RADIVNAM),RASEQI(RAIMGNAM),RAEITHER))+RADOSE
  1. ; "ratradio" is used for either radiopharm or who-admin-dose
  1. S ^(RAEITHER)=$G(^TMP($J,"RATRADIO",RASEQD(RADIVNAM),RASEQI(RAIMGNAM),RAEITHER))+1
  1. ; division totals
  1. S:RASTERSK="*" ^(RAEITHER)=$G(^TMP($J,"RATOUTSD",RASEQD(RADIVNAM),RAEITHER))+1
  1. S ^(RAEITHER)=$G(^TMP($J,"RATDRAWN",RASEQD(RADIVNAM),RAEITHER))+RADRAWN
  1. S ^(RAEITHER)=$G(^TMP($J,"RATDOSE",RASEQD(RADIVNAM),RAEITHER))+RADOSE
  1. S ^(RAEITHER)=$G(^TMP($J,"RATRADIO",RASEQD(RADIVNAM),RAEITHER))+1
  1. G F1
  1. WRT S RASEQD=""
  1. W1 S RASEQD=$O(^TMP($J,"RA",RASEQD)) Q:RASEQD="" S RASEQI=""
  1. W2 S RASEQI=$O(^TMP($J,"RA",RASEQD,RASEQI)) G:RASEQI="" W1 S S3=""
  1. S:RAPG>0 RAXIT=$$EOS^RAUTL5 Q:$G(RAXIT) D PGHD^RANMUSE3,COLHD^RANMUSE3
  1. W3 S S3=$O(^TMP($J,"RA",RASEQD,RASEQI,S3)) G:S3="" W2 S S4=""
  1. W4 S S4=$O(^TMP($J,"RA",RASEQD,RASEQI,S3,S4)) G:S4="" W3 S RAPATNAM=""
  1. W5 S RAPATNAM=$O(^TMP($J,"RA",RASEQD,RASEQI,S3,S4,RAPATNAM)) G:RAPATNAM="" W4 S RACN=""
  1. W6 S RACN=$O(^TMP($J,"RA",RASEQD,RASEQI,S3,S4,RAPATNAM,RACN)) G:RACN="" W5 S RADIOPH=""
  1. W7 S RADIOPH=$O(^TMP($J,"RA",RASEQD,RASEQI,S3,S4,RAPATNAM,RACN,RADIOPH)) G:RADIOPH="" W6 S RA1=^(RADIOPH)
  1. S RALONGCN=$S(RASORT:S3,1:S4),RALONGCN=$E(RALONGCN,4,7)_$E(RALONGCN,2,3)_"-"_RACN_"@"_$E($P(RALONGCN,".",2)_"000",1,4)
  1. N RASSAN,RACNDSP S RASSAN=$$SSANVAL^RAHLRU1(RADFN,RADTI,RACNI)
  1. S RACNDSP=$S((RASSAN'=""):RASSAN_"@"_$P(RALONGCN,"@",2),1:RALONGCN)
  1. S RASSN=$P(RA1,U),RADRAWN=$P(RA1,U,2),RADOSE=$P(RA1,U,3),RAHIGH=$P(RA1,U,4),RALOW=$P(RA1,U,5),RAWHO=$P(RA1,U,6),RASTERSK=$P(RA1,U,7)
  1. S RAPRCNAM=$P(RA1,U,8)
  1. I ($Y+4)>IOSL!(RAPG=0) S RAXIT=$$EOS^RAUTL5 Q:RAXIT D PGHD^RANMUSE3,COLHD^RANMUSE3
  1. I $$USESSAN^RAHLRU1() W !,RACNDSP,?22,$E(RAPATNAM,1,15),?38,RASSN,?50,$E(RADIOPH,1,14),?56,$J(RADRAWN,10,4),?69,$J(RADOSE,10,4),?79,$J(RALOW,10,4),?89,$J(RAHIGH,10,4),?105,$E(RAPRCNAM,1,15),?121,$E(RAWHO,1,10),?131,RASTERSK
  1. I '$$USESSAN^RAHLRU1() W !,RALONGCN,?16,$E(RAPATNAM,1,15),?32,RASSN,?44,$E(RADIOPH,1,15),?59,$J(RADRAWN,10,4),?69,$J(RADOSE,10,4),?79,$J(RALOW,10,4),?89,$J(RAHIGH,10,4),?100,$E(RAPRCNAM,1,15),?116,$E(RAWHO,1,15),?131,RASTERSK
  1. G W7
  1. S3S4 ; set subscripts 3 and 4
  1. I RATITLE["Usage" D Q
  1. . I RASORT S S4=$E(RADIOPH,1,15),S3=RAXMDTM
  1. . I 'RASORT S S3=$E(RADIOPH,1,15),S4=RAXMDTM
  1. . Q
  1. I RATITLE["Admin" D Q
  1. . I RASORT S S4=$E(RAWHO,1,15),S3=RAXMDTM
  1. . I 'RASORT S S3=$E(RAWHO,1,15),S4=RAXMDTM
  1. . Q
  1. Q