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

RAAPI.m

Go to the documentation of this file.
  1. RAAPI ;HISC/GJC,RTK - API & function utilities ;04/16/07 15:02
  1. ;;5.0;Radiology/Nuclear Medicine;**47**;Mar 16, 1998;Build 21
  1. ;
  1. ;Integration Agreements
  1. ;----------------------
  1. ;$$NS^XUAF4(2171); $$KSP^XUPARAM(2541)
  1. ;
  1. ACCNUM(RADFN,RADTI,RACNI) ; return the site specific accession number
  1. ;internal use for the VistA Radiology application
  1. ;
  1. ;input : RADFN=the DFN of the patient record in the PATIENT (#2) file
  1. ; RADTI=inverse date/time of the exam
  1. ; RACNI=the IEN of the case level record
  1. ;return: sss-mmddyy-case# (site specific accession number)
  1. ;
  1. I RADFN=""!(RADTI="")!(RACNI="") Q "" ;all MUST be defined
  1. N RAC,RAD,RAE S RAE=$G(^RADPT(RADFN,"DT",RADTI,"P",RACNI,0)) ;exam node
  1. S RAC=9999999.9999-RADTI ;RAC=FM internal date/time
  1. S RAD=$E(RAC,4,7)_$E(RAC,2,3)_"-"_+RAE ;mmddyy-case#
  1. Q $E($P($$NS^XUAF4($$KSP^XUPARAM("INST")),U,2),1,3)_"-"_RAD
  1. ;
  1. ACCFIND(Y,RAA) ;
  1. ;
  1. ;input : Y=the accession number in either a 'sss-mmddyy-xxxxx' or
  1. ; 'mmddyy-xxxxx' format
  1. ; : RAA(n)=the array used to return the data in the following
  1. ; format RADFN_^_RADTI_^_RACNI
  1. ;
  1. ;return: n>0 successful, else n<0... 'n' is the number of array
  1. ; elements when successful. When unsuccessful (n<0) 'n' is
  1. ; a specific error dialog which is returned along with the
  1. ; invalid accession number.
  1. ;
  1. ; Examples:
  1. ; -1^"invalid site accession number format"^accession #
  1. ; -2^"invalid accession number format"^accession #
  1. ; -3^"no data associated with this accession number"^accession #
  1. ;
  1. I $L(Y,"-")=3 Q:Y'?3N1"-"6N1"-"1.5N "-1^invalid site accession number format^"_Y
  1. I $L(Y,"-")=2 Q:Y'?6N1"-"1.5N "-2^invalid accession number format^"_Y
  1. N X S X=$S($L(Y,"-")=3:$NA(^RADPT("ADC1")),1:$NA(^RADPT("ADC")))
  1. Q:$O(@X@(Y,0))'>0 "-3^no data associated with this accession number^"_Y
  1. N RADFN,RADTI,RACNI,Z S:$D(U)#2=0 U="^"
  1. S (RADFN,Z)=0 F S RADFN=$O(@X@(Y,RADFN)) Q:'RADFN D
  1. .S RADTI=0 F S RADTI=$O(@X@(Y,RADFN,RADTI)) Q:'RADTI D
  1. ..S RACNI=0 F S RACNI=$O(@X@(Y,RADFN,RADTI,RACNI)) Q:'RACNI D
  1. ...S Z=Z+1,RAA(Z)=RADFN_U_RADTI_U_RACNI
  1. ...Q
  1. ..Q
  1. .Q
  1. Q Z ;success
  1. ;
  1. ACCRPT(Y,RAA) ;return accession number(s) given file #74 pointer value - RTK
  1. ;
  1. ;input : Y=pointer to a record in file #74
  1. ; : RAA(n)=the array used to return the data.
  1. ;
  1. ;return: n>0 successful, n<0 unsuccessful
  1. ;
  1. ; When successful, 'n' is the number of array elements.
  1. ; If n=1 the single accession number is returned in RAA(1)
  1. ; If n>1, the "lead" accession number (for printsets) is
  1. ; returned in RAA(1) and subsequent ones are returned in
  1. ; RAA(2) thru RAA(n)
  1. ; Accession numbers are returned in either "mmddyy-case#" or
  1. ; "sss-mmddyy-case#" format
  1. ; When unsuccessful, n<0, an error message is
  1. ; returned along with the invalid file #74 pointer value.
  1. ;
  1. K RAA N RADCN,RAOTHCS,RARPTIEN,Z S RARPTIEN=Y
  1. I '$D(^RARPT(Y,0)) Q "-1^invalid file #74 pointer value^"_Y
  1. S RADCN=$P($G(^RARPT(RARPTIEN,0)),U,1) ;day-case #
  1. S Z=1,RAA(Z)=RADCN
  1. F RAOTHCS=0:0 S RAOTHCS=$O(^RARPT(RARPTIEN,1,RAOTHCS)) Q:RAOTHCS'>0 D
  1. .S Z=Z+1,RAA(Z)=$P($G(^RARPT(RARPTIEN,1,RAOTHCS,0)),U,1)
  1. Q Z
  1. ;
  1. SIUID() ; called from [RA REGISTER] template, creates the STUDY INSTANCE UID
  1. ; also called directly from RAMAG03C for exams created thru the importer
  1. ; RADFN, RADTI and RACNI are set in RA REGISTER template/RAMAG03C
  1. N RASSAN,RASIUID S RASIUID=""
  1. ; if SSAN exists use it to build RASIUID
  1. S RASSAN=$$SSANVAL^RAHLRU1(RADFN,RADTI,RACNI)
  1. I RASSAN'="" S RASIUID=$$STUDYUID^MAGDRAHL(RADTI,RACNI,RASSAN) Q RASIUID
  1. ; else if RASSAN="" do the lines below to use the legacy acc #
  1. N RAC,RAD,RAE S RAE=$G(^RADPT(RADFN,"DT",RADTI,"P",RACNI,0)) ;exam node
  1. S RAC=9999999.9999-RADTI ;RAC=FM internal date/time
  1. S RAD=$E(RAC,4,7)_$E(RAC,2,3)_"-"_+RAE ;mmddyy-case#
  1. S RASIUID=$$STUDYUID^MAGDRAHL(RADTI,RACNI,RAD)
  1. Q RASIUID
  1. ;
  1. GETSIUID(RADFN,RADTI,RACNI) ; return the value of the exam's SIUID
  1. Q $G(^RADPT(RADFN,"DT",RADTI,"P",RACNI,"SIUID"))
  1. ;
  1. SIUIDFND(Y,RAA) ; return exam data for a given study instance UID
  1. ;input : Y=the study instance UID
  1. ; : RAA(1)=variable to hold the data in the following format:
  1. ; RADFN_^_RADTI_^_RACNI
  1. ;
  1. ;return: n=1 if successful, else n<-1 with error message
  1. ; When successful, n=1 and RAA(1) is returned in above format
  1. ; When unsuccessful 'n' is a specific error dialog
  1. ; which is returned along with the invalid study instance UID:
  1. ; -1^"no data associated with this study instance UID"^siuid
  1. ;
  1. K RAA N RADFN,RADTI,RACNI S RASIUID=Y,Z=0
  1. S RADFN=0 F S RADFN=$O(^RADPT("ASIUID",RASIUID,RADFN)) Q:'RADFN D
  1. .S RADTI=0 F S RADTI=$O(^RADPT("ASIUID",RASIUID,RADFN,RADTI)) Q:'RADTI D
  1. ..S RACNI=0 F S RACNI=$O(^RADPT("ASIUID",RASIUID,RADFN,RADTI,RACNI)) Q:'RACNI D
  1. ...S Z=Z+1,RAA(Z)=RADFN_"^"_RADTI_"^"_RACNI
  1. I Z=0 Q "-1^no data associated with this study instance UID^"_RASIUID
  1. Q Z