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

RORSETU2.m

Go to the documentation of this file.
  1. RORSETU2 ;HCIOFO/SG - SETUP UTILITIES (REGISTRY) ; 1/23/06 10:35am
  1. ;;1.5;CLINICAL CASE REGISTRIES;;Feb 17, 2006
  1. ;
  1. Q
  1. ;
  1. ;***** DRAWS THE BOUNDARY BETWEEN HISTORICAL AND REGULAR EXTRACTIONS
  1. ;
  1. ; REGIEN Registry IEN
  1. ; .BNDRYDT Date that represents a boundary between historical
  1. ; data extraction and regular data extracts is returned
  1. ; via this parameter.
  1. ;
  1. ; Return Values:
  1. ; <0 Error code
  1. ; >=0 Statistics
  1. ; ^1: Total number of processed records
  1. ; ^2: Number of records processed with errors
  1. ;
  1. ; The function calculates a date that will be a boundary between
  1. ; historical data extraction and regular data extractions. This date
  1. ; is stored to all records of the registry. Moreover, the date is
  1. ; returned as a value of the second parameter.
  1. ;
  1. BNDRYDT(REGIEN,BNDRYDT) ;
  1. N CNT,DATE,ECNT,IEN,IENS,LD1,PATIEN,RC,ROOT,RORFDA,RORMSG,TMP
  1. S ROOT=$$ROOT^DILFD(798,,1)
  1. ;--- Get the lag period
  1. S LD1=$$GET1^DIQ(798.1,REGIEN_",",15.1,,,"RORMSG")
  1. S RC=$$DBS^RORERR("RORMSG",-9) Q:RC<0 RC
  1. ;--- Calculate the date
  1. S BNDRYDT=$$FMADD^XLFDT($$DT^XLFDT,-$S(LD1>0:LD1,1:1)-1)
  1. ;--- Store the date into the records of the registry
  1. S IEN="",(CNT,ECNT)=0
  1. F S IEN=$O(@ROOT@("AC",REGIEN,IEN)) Q:IEN="" D
  1. . S CNT=CNT+1,IENS=IEN_",",DATE=BNDRYDT
  1. . ;--- Update the record
  1. . S RORFDA(798,IENS,9.1)=DATE
  1. . S RORFDA(798,IENS,9.2)=DATE
  1. . D FILE^DIE(,"RORFDA","RORMSG")
  1. . I $G(DIERR) D S ECNT=ECNT+1 Q
  1. . . S RC=$$DBS^RORERR("RORMSG",-9)
  1. Q $S(RC<0:RC,1:CNT_U_ECNT)
  1. ;
  1. ;***** CHECKS THE LAB SEARCH CRITERION
  1. ;
  1. ; LSNAME Name of the Lab search criterion
  1. ;
  1. ; This function uses the ^TMP("DILIST",$J) global node.
  1. ;
  1. ; Return Values:
  1. ; <0 Error code
  1. ; 0 Ok
  1. ;
  1. LABSRCH(LSNAME) ;
  1. N IEN,IENS,IR,LSICNT,RC,RORMSG,TMP
  1. ;--- Find the definition
  1. S IENS=$$FIND1^DIC(798.9,,"X",LSNAME,"B",,"RORMSG")_","
  1. S RC=$$DBS^RORERR("RORMSG",-9) Q:RC<0 RC
  1. Q:IENS'>0 $$ERROR^RORERR(-54,,,,LSNAME)
  1. ;--- Load the search indicators
  1. D LIST^DIC(798.92,","_IENS,"@;1I",,,,,"B",,,,"RORMSG")
  1. S RC=$$DBS^RORERR("RORMSG",-9) Q:RC<0 RC
  1. ;--- Check the search indicators
  1. S IR="",LSICNT=0
  1. F S IR=$O(^TMP("DILIST",$J,"ID",IR)) Q:IR="" D
  1. . S:$G(^TMP("DILIST",$J,"ID",IR,1))>0 LSICNT=LSICNT+1
  1. ;--- Process the errors (if any)
  1. Q:LSICNT'>0 $$ERROR^RORERR(-55,,,,LSNAME)
  1. Q 0
  1. ;
  1. ;***** PREPARES REGISTRY RECORDS
  1. ;
  1. ; RORREG Registry IEN and registry name separated by the '^'
  1. ; (RegistryIEN^RegistryName).
  1. ;
  1. ; Return Values:
  1. ; <0 Error code
  1. ; 0 Ok
  1. ;
  1. PREPARE(RORREG) ;
  1. ;;Data extraction boundary (historical/regular) has been established.
  1. ;;Parameters of the historical data extraction have been updated.
  1. ;
  1. N DATE,RC,TMP
  1. ;--- Modify records of the registry
  1. S RC=$$BNDRYDT(+RORREG,.DATE) Q:RC<0 RC
  1. S TMP="Processed records: "_+RC_", Errors: "_+$P(RC,U,2)
  1. D LOG^RORLOG(2,$P($T(PREPARE+1),";;",2),,TMP)
  1. ;--- Update the registry parameters of historical data extraction
  1. S RC=$$UPDHDTRP(+RORREG,DATE) Q:RC<0 RC
  1. D LOG^RORLOG(2,$P($T(PREPARE+2),";;",2))
  1. Q 0
  1. ;
  1. ;***** UPDATES REGISTRY PARAMETERS OF THE HISTORICAL DATA EXTRACTION
  1. ;
  1. ; REGIEN Registry IEN
  1. ; HDTEDT Date that represents a boundary between historical
  1. ; data extraction and regular data extracts
  1. ;
  1. ; Return Values:
  1. ; <0 Error code
  1. ; 0 Ok
  1. ;
  1. UPDHDTRP(REGIEN,HDTEDT) ;
  1. N IENS,RC,RORFDA,RORMSG
  1. S IENS=REGIEN_","
  1. ;--- Prepare the data
  1. S RORFDA(798.1,IENS,21.05)=$$NOW^XLFDT ; Timestamp
  1. ;--- Update historical data extraction parameters
  1. D FILE^DIE(,"RORFDA","RORMSG")
  1. S RC=$$DBS^RORERR("RORMSG",-9)
  1. Q $S(RC<0:RC,1:0)