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

RORRP041.m

Go to the documentation of this file.
  1. RORRP041 ;HCIOFO/SG - RPC: REGISTRY-SPECIFIC LAB RESULTS ; 8/25/05 12:24pm
  1. ;;1.5;CLINICAL CASE REGISTRIES;;Feb 17, 2006
  1. ;
  1. Q
  1. ;
  1. ;***** LOADS AND PROCESSES CD4 AND VIRAL LOAD RESULTS
  1. ;
  1. ; .ROR8DST( Reference to the Lab search descriptor.
  1. ; See the $$LTSEARCH^RORUTL10 for details
  1. ;
  1. ; "RORPTR") Index of the last node in the destination buffer
  1. ;
  1. ; "RORSTATS",
  1. ; Group,
  1. ; "LAST") Latest
  1. ; ^01: Result Value
  1. ; ^02: Date
  1. ; "MAX") Highest
  1. ; ^01: Result Value
  1. ; ^02: Date
  1. ; "MIN") Lowest
  1. ; ^01: Result Value
  1. ; ^02: Date
  1. ;
  1. ; INVDT IEN of the Lab test (inverted date)
  1. ;
  1. ; .RESULT Reference to a local variable, which contains the
  1. ; result in the same format as it is stored into
  1. ; the destination array by default.
  1. ;
  1. ; Return Values:
  1. ; <0 Error code (the search will be aborted)
  1. ; 0 Ok
  1. ; 1 Skip this result
  1. ; 2 Skip this and all remaining results
  1. ;
  1. LOADLT(ROR8DST,INVDT,RESULT) ;
  1. N BUF,GROUP,LTDT,LTVAL,TMP
  1. S LTDT=$P($G(RESULT(1)),U,2) Q:LTDT'>0 1 ; Date of the test
  1. S LTVAL=$$TRIM^XLFSTR($P(RESULT(1),U,3)) ; Result value
  1. S GROUP=+$P($G(RESULT(2)),U,3) Q:GROUP'>0 1 ; Code of the group
  1. ;
  1. ;=== Create and store the segment
  1. S BUF="LTR"_U_$P(RESULT(1),U)
  1. S $P(BUF,U,3,4)=LTDT_U_LTVAL
  1. S $P(BUF,U,5,8)=$P(RESULT(2),U,1,4)
  1. S ROR8DST("RORPTR")=$G(ROR8DST("RORPTR"))+1
  1. S @ROR8DST@(ROR8DST("RORPTR"))=BUF
  1. ;
  1. ;=== Most recent result of the group
  1. D:LTDT>$P($G(ROR8DST("RORSTATS",GROUP,"LAST")),U,2)
  1. . S ROR8DST("RORSTATS",GROUP,"LAST")=LTVAL_U_LTDT
  1. ;
  1. ;=== Numeric results
  1. D:$$NUMERIC^RORUTL05(LTVAL)
  1. . ;--- Lowest result value of the group
  1. . S TMP=+$G(ROR8DST("RORSTATS",GROUP,"MIN"))
  1. . S:'TMP!(LTVAL<TMP) ROR8DST("RORSTATS",GROUP,"MIN")=LTVAL_U_LTDT
  1. . ;--- Highest result value of the group
  1. . S TMP=+$G(ROR8DST("RORSTATS",GROUP,"MAX"))
  1. . S:LTVAL>TMP ROR8DST("RORSTATS",GROUP,"MAX")=LTVAL_U_LTDT
  1. ;
  1. ;=== Success
  1. Q 0
  1. ;
  1. ;***** LOADS THE PATIENT'S REGISTRY-SPECIFIC LAB RESULTS
  1. ; RPC: [ROR PATIENT REGISTRY LABS]
  1. ;
  1. ; .RESULTS Reference to a local variable where the results
  1. ; are returned to.
  1. ;
  1. ; REGIEN Registry IEN
  1. ;
  1. ; PATIEN IEN of the registry patient (DFN)
  1. ;
  1. ; Return Values:
  1. ;
  1. ; A negative value of the first "^"-piece of the RESULTS(0)
  1. ; indicates an error (see the RPCSTK^RORERR procedure for more
  1. ; details).
  1. ;
  1. ; Otherwise, zero is returned in the @RESULTS@(0) and the
  1. ; subsequent nodes of the global array contain the data.
  1. ;
  1. ; @RESULTS@(0) 0
  1. ;
  1. ; @RESULTS@(i) Registry-specific Lab Result
  1. ; ^01: "LTR"
  1. ; ^02: Result IEN (inverted date/time)
  1. ; ^03: Date/time of the test (FileMan)
  1. ; ^04: Result
  1. ; ^05: Test IEN (in file #60)
  1. ; ^06: Test name
  1. ; ^07: Code of the group
  1. ; ^08: Group name
  1. ;
  1. ; @RESULTS@(i) Lab Group Statistics
  1. ; ^01: "LTG"
  1. ; ^02: Code of the group
  1. ; ^03: Group name
  1. ; ^04: Latest result value
  1. ; ^05: Date of the latest result (FileMan)
  1. ; ^06: Lowest result value
  1. ; ^07: Date of the lowest value (FileMan)
  1. ;
  1. LOADPRL(RESULTS,REGIEN,PATIEN) ;
  1. N BUF,GRP,NAME,PTR,RC,RORBUF,RORERRDL,TMP
  1. D CLEAR^RORERR("LOAD^RORRP041",1)
  1. K RESULTS S RESULTS=$$ALLOC^RORTMP() S @RESULTS@(0)=0
  1. ;
  1. ;=== Check the parameters
  1. S RC=0 D I RC<0 D RPCSTK^RORERR(.RESULTS,RC) Q
  1. . ;--- Registry IEN
  1. . I $G(REGIEN)'>0 D Q
  1. . . S RC=$$ERROR^RORERR(-88,,,,"REGIEN",$G(REGIEN))
  1. . S REGIEN=+REGIEN
  1. . ;--- Patient IEN
  1. . I $G(PATIEN)'>0 D Q
  1. . . S RC=$$ERROR^RORERR(-88,,,,"PATIEN",$G(PATIEN))
  1. . S PATIEN=+PATIEN
  1. ;
  1. ;=== Search for registry-specific lab results
  1. S RORBUF=RESULTS
  1. S RORBUF("RORCB")="$$LOADLT^RORRP041"
  1. S RC=$$LTSEARCH^RORUTL10(PATIEN,+REGIEN,.RORBUF)
  1. I RC<0 D RPCSTK^RORERR(.RESULTS,RC) Q
  1. ;
  1. ;=== Store the group statistics
  1. S PTR=+$O(@RESULTS@(""),-1)
  1. S GRP=0
  1. F S GRP=$O(RORBUF("RORSTATS",GRP)) Q:GRP'>0 D
  1. . S TMP=$$ITEMIEN^RORUTL09(3,REGIEN,GRP,.NAME)
  1. . S BUF="LTG"_U_GRP_U_NAME
  1. . S $P(BUF,U,4,5)=$G(RORBUF("RORSTATS",GRP,"LAST"))
  1. . S $P(BUF,U,6,7)=$G(RORBUF("RORSTATS",GRP,"MIN"))
  1. . S PTR=PTR+1,@RESULTS@(PTR)=BUF
  1. Q