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

RORUTL09.m

Go to the documentation of this file.
  1. RORUTL09 ;HCIOFO/SG - LIST ITEM UTILITIES ; 4/26/05 10:46am
  1. ;;1.5;CLINICAL CASE REGISTRIES;;Feb 17, 2006
  1. ;
  1. Q
  1. ;
  1. ;***** RETURNS CODE AND TEXT OF THE ITEM IN THE FILE #799.1
  1. ;
  1. ; ITEMIEN IEN of the item
  1. ; [.TEXT] Text of the item is returned via this parameter
  1. ;
  1. ; Return Values:
  1. ; <0 Error code
  1. ; "" Code is not available
  1. ; >0 Code of the item
  1. ;
  1. ITEMCODE(ITEMIEN,TEXT) ;
  1. S TEXT="" Q:ITEMIEN'>0 ""
  1. Q:'$D(^ROR(799.1,+ITEMIEN,0)) ""
  1. N IENS,RC,RORBUF,RORMSG
  1. S IENS=(+ITEMIEN)_","
  1. D GETS^DIQ(799.1,IENS,".01;.04",,"RORBUF","RORMSG")
  1. Q:$G(DIERR) $$DBS^RORERR("RORMSG",-9,,,799.1,IENS)
  1. S TEXT=$G(RORBUF(799.1,IENS,.01))
  1. Q $G(RORBUF(799.1,IENS,.04))
  1. ;
  1. ;***** RETURNS IEN AND TEXT OF THE ITEM IN THE FILE #799.1
  1. ;
  1. ; TYPE Type of the item
  1. ; REGIEN Registry IEN
  1. ; CODE Code of the item
  1. ; [.TEXT] Text of the item is returned via this parameter
  1. ;
  1. ; Return Values:
  1. ; <0 Error code
  1. ; >0 IEN of the item
  1. ;
  1. ITEMIEN(TYPE,REGIEN,CODE,TEXT) ;
  1. N RC,RORBUF,RORMSG,SRCHVAL
  1. S TEXT="",SRCHVAL(1)=+TYPE,SRCHVAL(2)=+REGIEN,SRCHVAL(3)=+CODE
  1. D FIND^DIC(799.1,,"@;.01","QX",.SRCHVAL,2,"KEY",,,"RORBUF","RORMSG")
  1. Q:$G(DIERR) $$DBS^RORERR("RORMSG",-9,,,799.1)
  1. S RC=+$G(RORBUF("DILIST",0))
  1. S:RC=1 TEXT=$G(RORBUF("DILIST","ID",1,.01))
  1. Q $S(RC<1:-80,RC>1:-81,1:+RORBUF("DILIST",2,1))
  1. ;
  1. ;***** RETURNS A LIST OF ITEMS FROM THE FILE #799.1
  1. ;
  1. ; TYPE Type of the items:
  1. ; 3 Lab Group
  1. ; 4 Drug Group
  1. ;
  1. ; REGIEN Registry IEN
  1. ;
  1. ; .ROR8DST Reference to a destination array.
  1. ; Items are returned into this array in the following
  1. ; format: ROR8DST(ItemCode)=ItemIEN^ItemText
  1. ;
  1. ; [CDT] "Current" Date/Time (NOW by default)
  1. ;
  1. ; If this date/time is equal or later that the
  1. ; inactivation date from the item record (only if
  1. ; there is any) then the item is considered inactive
  1. ; and will be skipped.
  1. ;
  1. ; To include both active and inactive items in the
  1. ; list, pass a negative number as the value of this
  1. ; parameter.
  1. ;
  1. ; Return Values:
  1. ; <0 Error code
  1. ; 0 Ok
  1. ;
  1. ITEMLIST(TYPE,REGIEN,ROR8DST,CDT) ;
  1. N CODE,IEN,IENS,INCTVDT,NODE,RC,RORBUF,RORMSG
  1. S NODE=$NA(^ROR(799.1,"KEY",TYPE,REGIEN)) K ROR8DST
  1. S:'$G(CDT) CDT=$$NOW^XLFDT
  1. ;--- Load the active list items
  1. S CODE="",RC=0
  1. F S CODE=$O(@NODE@(CODE)) Q:CODE="" D Q:RC<0
  1. . S IEN=$O(@NODE@(CODE,"")) Q:'IEN
  1. . S IENS=IEN_"," K RORBUF
  1. . ;--- Load text and inactivation date
  1. . D GETS^DIQ(799.1,IENS,".01;1","IE","RORBUF","RORMSG")
  1. . I $G(DIERR) D Q
  1. . . S RC=$$DBS^RORERR("RORMSG",-9,,,799.1,IENS)
  1. . ;--- Skip inactive items
  1. . S INCTVDT=$G(RORBUF(799.1,IENS,1,"I"))
  1. . I INCTVDT>0 Q:CDT'<INCTVDT
  1. . ;--- Create a record in the destination array
  1. . S ROR8DST(CODE)=IEN_U_$G(RORBUF(799.1,IENS,.01,"E"))
  1. Q $S(RC<0:RC,1:0)