| [613] | 1 | RORX013 ;HOIFO/SG - DIAGNOSIS CODES REPORT ; 6/21/06 3:05pm | 
|---|
|  | 2 | ;;1.5;CLINICAL CASE REGISTRIES;**1**;Feb 17, 2006;Build 24 | 
|---|
|  | 3 | ; | 
|---|
|  | 4 | Q | 
|---|
|  | 5 | ; | 
|---|
|  | 6 | ;***** OUTPUTS THE REPORT HEADER | 
|---|
|  | 7 | ; | 
|---|
|  | 8 | ; PARTAG        Reference (IEN) to the parent tag | 
|---|
|  | 9 | ; | 
|---|
|  | 10 | ; Return Values: | 
|---|
|  | 11 | ;       <0  Error code | 
|---|
|  | 12 | ;       >0  IEN of the HEADER element | 
|---|
|  | 13 | ; | 
|---|
|  | 14 | HEADER(PARTAG) ; | 
|---|
|  | 15 | ;;ICD9LST(#,CODE,DIAG,NP,NC) | 
|---|
|  | 16 | ;;PATIENTS(#,NAME,LAST4,DOD,PTICDL(CODE,DIAG,DATE,SOURCE)) | 
|---|
|  | 17 | ; | 
|---|
|  | 18 | N HEADER,RC | 
|---|
|  | 19 | S HEADER=$$HEADER^RORXU002(.RORTSK,PARTAG) | 
|---|
|  | 20 | Q:HEADER<0 HEADER | 
|---|
|  | 21 | S RC=$$TBLDEF^RORXU002("HEADER^RORX013",HEADER) | 
|---|
|  | 22 | Q $S(RC<0:RC,1:HEADER) | 
|---|
|  | 23 | ; | 
|---|
|  | 24 | ; | 
|---|
|  | 25 | ;***** COMPILES THE "DIAGNOSIS CODE" REPORT | 
|---|
|  | 26 | ; REPORT CODE: 013 | 
|---|
|  | 27 | ; | 
|---|
|  | 28 | ; .RORTSK       Task number and task parameters | 
|---|
|  | 29 | ; | 
|---|
|  | 30 | ; The ^TMP("VSIT",$J) global node is used by this function. | 
|---|
|  | 31 | ; | 
|---|
|  | 32 | ; @RORTMP@( | 
|---|
|  | 33 | ; | 
|---|
|  | 34 | ;   "PAT",              Number of patients | 
|---|
|  | 35 | ;     DFN,              Descriptor | 
|---|
|  | 36 | ;                         ^01: Las 4 digits of SSN | 
|---|
|  | 37 | ;                         ^02: Name | 
|---|
|  | 38 | ;                         ^03: Date of Death | 
|---|
|  | 39 | ;       ICD9IEN,        Earliest Code Descriptor | 
|---|
|  | 40 | ;                         ^01: Date | 
|---|
|  | 41 | ;                         ^02: Source ("I", "O", or "PB") | 
|---|
|  | 42 | ;         "C")          Quantity | 
|---|
|  | 43 | ;         "I")          Inpatient quantity | 
|---|
|  | 44 | ;         "O")          Outpatient quantity | 
|---|
|  | 45 | ;         "PB")         Problem List quantity | 
|---|
|  | 46 | ; | 
|---|
|  | 47 | ;   "ICD",              Totals | 
|---|
|  | 48 | ;                         ^01: Number of ICD-9 codes | 
|---|
|  | 49 | ;                         ^02: Number of different codes | 
|---|
|  | 50 | ;     ICD9IEN,          ICD-9 Descriptor | 
|---|
|  | 51 | ;                         ^01: Code | 
|---|
|  | 52 | ;                         ^02: Diagnosis (current version) | 
|---|
|  | 53 | ;       "C")            Quantity | 
|---|
|  | 54 | ;       "P")            Number of unique patients | 
|---|
|  | 55 | ; | 
|---|
|  | 56 | ; Return Values: | 
|---|
|  | 57 | ;       <0  Error code | 
|---|
|  | 58 | ;        0  Ok | 
|---|
|  | 59 | ; | 
|---|
|  | 60 | ICD9LST(RORTSK) ; | 
|---|
|  | 61 | N ROREDT        ; End date | 
|---|
|  | 62 | N RORICDL       ; Prepared list of ICD-9 codes | 
|---|
|  | 63 | N RORIGRP       ; List of ICD-9 groups | 
|---|
|  | 64 | N RORREG        ; Registry IEN | 
|---|
|  | 65 | N RORSDT        ; Start date | 
|---|
|  | 66 | N RORTMP        ; Closed root of the temporary buffer | 
|---|
|  | 67 | ; | 
|---|
|  | 68 | N ECNT,RC,REPORT,SFLAGS,TMP | 
|---|
|  | 69 | S RORICDL="",(ECNT,RC)=0 | 
|---|
|  | 70 | ;--- Root node of the report | 
|---|
|  | 71 | S REPORT=$$ADDVAL^RORTSK11(RORTSK,"REPORT") | 
|---|
|  | 72 | Q:REPORT<0 REPORT | 
|---|
|  | 73 | ; | 
|---|
|  | 74 | ;--- Get and prepare the report parameters | 
|---|
|  | 75 | S RORREG=$$PARAM^RORTSK01("REGIEN") | 
|---|
|  | 76 | S RC=$$PARAMS(REPORT,.RORSDT,.ROREDT,.SFLAGS)  Q:RC<0 RC | 
|---|
|  | 77 | ; | 
|---|
|  | 78 | ;--- Report header | 
|---|
|  | 79 | S RC=$$HEADER(REPORT)  Q:RC<0 RC | 
|---|
|  | 80 | S RORTMP=$$ALLOC^RORTMP() | 
|---|
|  | 81 | D | 
|---|
|  | 82 | . ;--- Query the registry | 
|---|
|  | 83 | . D TPPSETUP^RORTSK01(70) | 
|---|
|  | 84 | . S RC=$$QUERY^RORX013A(SFLAGS) | 
|---|
|  | 85 | . I RC  Q:RC<0  S ECNT=ECNT+RC | 
|---|
|  | 86 | . ;--- Sort the data | 
|---|
|  | 87 | . D TPPSETUP^RORTSK01(10) | 
|---|
|  | 88 | . S RC=$$SORT^RORX013A() | 
|---|
|  | 89 | . I RC  Q:RC<0  S ECNT=ECNT+RC | 
|---|
|  | 90 | . ;--- Store the results | 
|---|
|  | 91 | . D TPPSETUP^RORTSK01(20) | 
|---|
|  | 92 | . S RC=$$STORE^RORX013C(REPORT) | 
|---|
|  | 93 | . I RC  Q:RC<0  S ECNT=ECNT+RC | 
|---|
|  | 94 | ; | 
|---|
|  | 95 | ;--- Cleanup | 
|---|
|  | 96 | D FREE^RORTMP(RORTMP),FREE^RORTMP(RORICDL) | 
|---|
|  | 97 | K ^TMP("VSIT",$J) | 
|---|
|  | 98 | Q $S(RC<0:RC,ECNT>0:-43,1:0) | 
|---|
|  | 99 | ; | 
|---|
|  | 100 | ;***** OUTPUTS THE PARAMETERS TO THE REPORT | 
|---|
|  | 101 | ; | 
|---|
|  | 102 | ; PARTAG        Reference (IEN) to the parent tag | 
|---|
|  | 103 | ; | 
|---|
|  | 104 | ; [.STDT]       Start and end dates of the report | 
|---|
|  | 105 | ; [.ENDT]       are returned via these parameters | 
|---|
|  | 106 | ; | 
|---|
|  | 107 | ; [.FLAGS]      Flags for the $$SKIP^RORXU005 are | 
|---|
|  | 108 | ;               returned via this parameter | 
|---|
|  | 109 | ; | 
|---|
|  | 110 | ; Return Values: | 
|---|
|  | 111 | ;       <0  Error code | 
|---|
|  | 112 | ;       >0  IEN of the PARAMETERS element | 
|---|
|  | 113 | ; | 
|---|
|  | 114 | PARAMS(PARTAG,STDT,ENDT,FLAGS) ; | 
|---|
|  | 115 | N PARAMS,TMP | 
|---|
|  | 116 | S PARAMS=$$PARAMS^RORXU002(.RORTSK,PARTAG,.STDT,.ENDT,.FLAGS) | 
|---|
|  | 117 | Q:PARAMS<0 PARAMS | 
|---|
|  | 118 | ;--- Process the list of ICD9 codes | 
|---|
|  | 119 | S TMP=$$ICD9LST^RORXU008(.RORTSK,PARAMS,.RORICDL,.RORIGRP) | 
|---|
|  | 120 | Q:TMP<0 TMP | 
|---|
|  | 121 | ;--- | 
|---|
|  | 122 | Q PARAMS | 
|---|