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

RORRP016.m

Go to the documentation of this file.
  1. RORRP016 ;HCIOFO/SG - RPC: LIST OF ICD-9 CODES ;6/16/06 2:16pm
  1. ;;1.5;CLINICAL CASE REGISTRIES;**1,10,23,19,30**;Feb 17, 2006;Build 37
  1. ;
  1. ; This routine uses the following IAs:
  1. ;
  1. ; #2051,5388,5773 LIST^DIC (supported)
  1. ; #5747 $$CSI^ICDEX (controlled)
  1. ; #5747 $$VSTD^ICDEX (controlled)
  1. ; #5747 $$VH^ICDEX (controlled)
  1. ; #5747 $$UPDX^ICDEX (controlled)
  1. ; #5747 $$VSTP^ICDEX (controlled)
  1. ; #5699 $$ICDDATA^ICDXCODE (supported)
  1. ; #5699 $$ICDDESC^ICDXCODE (supported)
  1. ;
  1. ;******************************************************************************
  1. ;******************************************************************************
  1. ; --- ROUTINE MODIFICATION LOG ---
  1. ;
  1. ;PKG/PATCH DATE DEVELOPER MODIFICATION
  1. ;----------- ---------- ----------- ----------------------------------------
  1. ;ROR*1.5*19 FEB 2012 K GUPTA Support for ICD-10 Coding System
  1. ;
  1. ;ROR*1.5*30 OCT 2016 M FERRARESE Changing the dispay for "Sex" to "Birth Sex"
  1. ;******************************************************************************
  1. ;******************************************************************************
  1. ;
  1. Q
  1. ;
  1. ;***** RETURNS THE LIST OF ICD CODES (DIAGNOSES OR PROCEDURES)
  1. ; RPC: [ROR LIST ICD]
  1. ;
  1. ; .RORESULT Reference to a local variable where the results
  1. ; are returned to.
  1. ;
  1. ; [DATE] Date for the code set versioning.
  1. ;
  1. ; [PART] The partial match restriction.
  1. ;
  1. ; [FLAGS] Flags that control the execution (can be combined):
  1. ; A Exclude active codes
  1. ; B Backwards. Traverses the index in the opposite
  1. ; direction of normal traversal
  1. ; D Full search by description
  1. ; F Exclude codes applicable to females only
  1. ; I Exclude inactive codes
  1. ; K Search in description keywords
  1. ; M Exclude codes applicable to males only
  1. ; O Return operation/procedure codes from file #80.1
  1. ; instead of diagnosis codes from the file #80
  1. ; P Exclude codes that are not acceptable
  1. ; as primary diagnoses
  1. ;
  1. ; [NUMBER] Maximum number of entries to return. A value of "*"
  1. ; or no value in this parameter designates all entries.
  1. ;
  1. ; [FROM] The index entry(s) from which to begin the list
  1. ; ^01: FromName
  1. ; ^02: FromIEN
  1. ;
  1. ; For example, a FROM value of "51" would list entries
  1. ; following 51. You can use the 2-nd and 3-rd "^"-
  1. ; pieces of the @RORESULT@(0) node to continue the
  1. ; listing in the subsequent procedure calls.
  1. ;
  1. ; NOTE: The FROM value itself is not included in
  1. ; the resulting list.
  1. ;
  1. ; See description of the LIST^DIC for more details about the
  1. ; PART, NUMBER and FROM parameters.
  1. ;
  1. ; [ICDTYPE] TYPE OF ICD SEARCH: ICD9 OR ICD10
  1. ;
  1. ; The ^TMP("RORRP016",$J) global node is used by this procedure.
  1. ;
  1. ; Return Values:
  1. ;
  1. ; A negative value of the first "^"-piece of the @RORESULT@(0)
  1. ; indicates an error (see the RPCSTK^RORERR procedure for more
  1. ; details).
  1. ;
  1. ; Otherwise, number of ICD-9 codes and the value of the FROM
  1. ; parameter for the next procedure call are returned in the
  1. ; @RORESULT@(0) and the subsequent nodes of the global array
  1. ; contain the codes.
  1. ;
  1. ; @RORESULT@(0) Result Descriptor
  1. ; ^01: Number of codes
  1. ; ^02: FromName
  1. ; ^03: FromIEN
  1. ;
  1. ; @RORESULT@(i) ICD
  1. ; ^01: IEN
  1. ; ^02: Diagnosis or operation/procedure
  1. ; ^03: Code
  1. ; ^04: Use only with Birth Sex
  1. ; ^05: Inactive {0|1}
  1. ; ^06: Inactivation Date (FileMan)
  1. ;
  1. ; @RORESULT@(i+1) ICD Description
  1. ;
  1. ICDLIST(RORESULT,DATE,PART,FLAGS,NUMBER,FROM,ICDTYPE) ;
  1. N BUF,RC,RORERRDL,TMP,RORCODSYS
  1. D CLEAR^RORERR("ICDLIST^RORRP016",1)
  1. K RORESULT S RORESULT=$NA(^TMP("RORRP016",$J)) K @RORESULT
  1. ;--- Check the parameters
  1. S PART=$G(PART),FLAGS=$G(FLAGS)
  1. S NUMBER=$S($G(NUMBER)>0:+NUMBER,1:"*")
  1. S ICDTYPE=$G(ICDTYPE)
  1. ;--- Setup the start point
  1. I $G(FROM)'="" D S FROM=$P(FROM,U)
  1. . S:$P(FROM,U,2)>0 FROM("IEN")=+$P(FROM,U,2)
  1. ;--- Compile the list
  1. I FLAGS["O" D
  1. . I ICDTYPE="ICD9" S RORCODSYS="2" I 1
  1. . E I ICDTYPE="ICD10" S RORCODSYS="31"
  1. . ;--- Get the list of operation/procedure codes
  1. . S RC=$$QUERY1(PART,FLAGS,NUMBER,.FROM,RORCODSYS) Q:RC<0
  1. . S RORESULT=$NA(@RORESULT@("DILIST"))
  1. . ;--- Load remaining data and refine the list
  1. . D REFINE1(PART,FLAGS,$G(DATE),RORCODSYS)
  1. E D
  1. . I ICDTYPE="ICD9" S RORCODSYS="1" I 1
  1. . E I ICDTYPE="ICD10" S RORCODSYS="30"
  1. . ;--- Get the list of diagnosis codes
  1. . S RC=$$QUERY(PART,FLAGS,NUMBER,.FROM,RORCODSYS) Q:RC<0
  1. . S RORESULT=$NA(@RORESULT@("DILIST"))
  1. . ;--- Load remaining data and refine the list
  1. . D REFINE(PART,FLAGS,$G(DATE),RORCODSYS)
  1. I RC<0 D RPCSTK^RORERR(.RORESULT,RC) Q
  1. ;--- Success
  1. S TMP=$G(@RORESULT@(0)),BUF=+$P(TMP,U)
  1. S:$P(TMP,U,3) $P(BUF,U,2,3)=$G(FROM)_U_$G(FROM("IEN"))
  1. K @RORESULT@(0) S @RORESULT@(0)=BUF
  1. Q
  1. ;
  1. ;***** QUERIES THE ICD DIAGNOSIS FILE (#80)
  1. QUERY(PART,FLAGS,NR,FROM,CODSYS) ;
  1. N FLDS,RORMSG,SCR,TMP,XREF
  1. ;--- Compile the screen logic (be careful with naked references)
  1. S SCR=""
  1. ;I FLAGS["D" S:PART'="" SCR=SCR_"I $P(D,U,3)["""_PART_""" ",PART=""
  1. ;S:FLAGS["F" SCR=SCR_"I $P(D,U,10)'=""F"" "
  1. ;S:FLAGS["M" SCR=SCR_"I $P(D,U,10)'=""M"" "
  1. ;S:FLAGS["P" SCR=SCR_"I '$P(D,U,4) "
  1. ;S:SCR'="" SCR="S D=$G(^(0)) "_SCR ;Naked Ref: ^ICD9(
  1. S:CODSYS]"" SCR=SCR_"I $$CSI^ICDEX(80,Y)="""_CODSYS_""" "
  1. I FLAGS["D" S:PART'="" SCR=SCR_"I $$UP^XLFSTR($$VSTD^ICDEX(Y))["""_PART_""" ",PART=""
  1. S:FLAGS["F" SCR=SCR_"I $$VSEX^ICDEX(80,Y)'=""F"" "
  1. S:FLAGS["M" SCR=SCR_"I $$VSEX^ICDEX(80,Y)'=""M"" "
  1. S:FLAGS["P" SCR=SCR_"I '$$UPDX^ICDEX(Y) "
  1. ;--- Get the list of codes and some data
  1. ;S FLDS="@;3;.01;9.5I;IXI",TMP="P"_$S(FLAGS["B":"B",1:"")
  1. ;S FLDS="@;.01;9.5I;IXI"
  1. S FLDS="@;.01;IXI"
  1. S TMP="P"_$S(FLAGS["B":"B",1:"")
  1. S XREF=$S(FLAGS["D":"#",FLAGS["K":"D",1:"BA")
  1. D LIST^DIC(80,,FLDS,TMP,NR,.FROM,PART,XREF,SCR,,RORESULT,"RORMSG")
  1. I $G(DIERR) K @RORESULT Q $$DBS^RORERR("RORMSG",-9,,,80)
  1. ;--- Add Diagnosis code to RORESULT using API
  1. D GETDIAG(CODSYS)
  1. ;--- Success
  1. Q 0
  1. ;
  1. ;***** QUERIES THE ICD OPERATION/PROCEDURE FILE (#80.1)
  1. QUERY1(PART,FLAGS,NR,FROM,CODSYS) ;
  1. N FLDS,RORMSG,SCR,TMP,XREF
  1. ;--- Compile the screen logic (be careful with naked references)
  1. S SCR=""
  1. ;I FLAGS["D" S:PART'="" SCR=SCR_"I $P(D,U,4)["""_PART_""" ",PART=""
  1. ;S:FLAGS["F" SCR=SCR_"I $P(D,U,10)'=""F"" "
  1. ;S:FLAGS["M" SCR=SCR_"I $P(D,U,10)'=""M"" "
  1. ;S:SCR'="" SCR="S D=$G(^(0)) "_SCR ;Naked Ref: ^ICD0(
  1. S:CODSYS]"" SCR=SCR_"I $$CSI^ICDEX(80.1,Y)="""_CODSYS_""" "
  1. I FLAGS["D" S:PART'="" SCR=SCR_"I $$UP^XLFSTR($$VSTP^ICDEX(Y))["""_PART_""" ",PART=""
  1. S:FLAGS["F" SCR=SCR_"I $$VSEX^ICDEX(80.1,Y)'=""F"" "
  1. S:FLAGS["M" SCR=SCR_"I $$VSEX^ICDEX(80.1,Y)'=""M"" "
  1. ;--- Get the list of codes and some data
  1. ;S FLDS="@;4;.01;9.5I;IXI",TMP="P"_$S(FLAGS["B":"B",1:"")
  1. ;S FLDS="@;.01;9.5I;IXI"
  1. S FLDS="@;.01;IXI"
  1. S TMP="P"_$S(FLAGS["B":"B",1:"")
  1. S XREF=$S(FLAGS["D":"#",FLAGS["K":"D",1:"BA")
  1. D LIST^DIC(80.1,,FLDS,TMP,NR,.FROM,PART,XREF,SCR,,RORESULT,"RORMSG")
  1. I $G(DIERR) K @RORESULT Q $$DBS^RORERR("RORMSG",-9,,,80.1)
  1. ;--- Add Operation/Procedure to RORESULT using API
  1. D GETOPPR(CODSYS)
  1. ;--- Success
  1. Q 0
  1. ;
  1. ;***** REFINES THE LIST OF DIAGNOSES
  1. REFINE(PART,FLAGS,DATE,CODSYS) ;
  1. N BUF,CNT,ICDINFO,MODE,RORDESC,SUBS,TMP
  1. S MODE=($TR(FLAGS,"DK")=FLAGS)
  1. S (CNT,SUBS)=0
  1. F S SUBS=$O(@RORESULT@(SUBS)) Q:SUBS'>0 D
  1. . S BUF=@RORESULT@(SUBS,0)
  1. . ;--- Remove duplicates created by the logic of the "BAA" xref
  1. . I MODE D I '(TMP?1.E1" ") K @RORESULT@(SUBS) Q
  1. . . S TMP=$P(BUF,U,4)
  1. . ;--- Load the additional data
  1. . S ICDINFO=$$ICDDATA^ICDXCODE(CODSYS,+$P(BUF,U),DATE,"I")
  1. . I ICDINFO<0 K @RORESULT@(SUBS) Q
  1. . ;--- Screen active/inactive records
  1. . S TMP=+$P(ICDINFO,U,10) ; Status
  1. . I $S(TMP:FLAGS["A",1:FLAGS["I") K @RORESULT@(SUBS) Q
  1. . S $P(BUF,U,4)=$P(ICDINFO,U,11) ; Birth Sex
  1. . S $P(BUF,U,5)=TMP
  1. . S $P(BUF,U,6)=$S(TMP:$P(ICDINFO,U,12),1:"") ; Inactivation Date
  1. . ;--- Versioned diagnosis
  1. . S TMP=$P(ICDINFO,U,4) S:TMP'="" $P(BUF,U,2)=TMP
  1. . ;--- Store the data
  1. . S CNT=CNT+1,@RORESULT@(SUBS,0)=BUF
  1. . ;--- Versioned description
  1. . S TMP=$$ICDDESC^ICDXCODE(CODSYS,$P(BUF,U,3),DATE,.RORDESC)
  1. . S @RORESULT@(SUBS,1)=$S($G(RORDESC(1))'="":RORDESC(1),1:$P(BUF,U,2))
  1. . K RORDESC
  1. ;---
  1. S $P(@RORESULT@(0),U)=CNT
  1. Q
  1. ;
  1. ;***** REFINES THE LIST OF OPERATION/PROCEDURES
  1. REFINE1(PART,FLAGS,DATE,CODSYS) ;
  1. N BUF,CNT,ICDINFO,MODE,RORDESC,SUBS,TMP
  1. S MODE=($TR(FLAGS,"DK")=FLAGS)
  1. S (CNT,SUBS)=0
  1. F S SUBS=$O(@RORESULT@(SUBS)) Q:SUBS'>0 D
  1. . S BUF=@RORESULT@(SUBS,0)
  1. . ;--- Remove duplicates created by the logic of the "BAA" xref
  1. . I MODE D I '(TMP?1.E1" ") K @RORESULT@(SUBS) Q
  1. . . S TMP=$P(BUF,U,4)
  1. . ;--- Load the additional data
  1. . S ICDINFO=$$ICDDATA^ICDXCODE(CODSYS,+$P(BUF,U),DATE,"I")
  1. . I ICDINFO<0 K @RORESULT@(SUBS) Q
  1. . ;--- Screen active/inactive records
  1. . S TMP=+$P(ICDINFO,U,10) ; Status
  1. . I $S(TMP:FLAGS["A",1:FLAGS["I") K @RORESULT@(SUBS) Q
  1. . S $P(BUF,U,4)=$P(ICDINFO,U,11) ; Birth Sex
  1. . S $P(BUF,U,5)=TMP
  1. . S $P(BUF,U,6)=$S(TMP:$P(ICDINFO,U,12),1:"") ; Inactivation Date
  1. . ;--- Versioned operation/procedure
  1. . S TMP=$P(ICDINFO,U,5) S:TMP'="" $P(BUF,U,2)=TMP
  1. . ;--- Store the data
  1. . S CNT=CNT+1,@RORESULT@(SUBS,0)=BUF
  1. . ;--- Versioned description
  1. . S TMP=$$ICDDESC^ICDXCODE(CODSYS,$P(BUF,U,3),DATE,.RORDESC)
  1. . S @RORESULT@(SUBS,1)=$S($G(RORDESC(1))'="":RORDESC(1),1:$P(BUF,U,2))
  1. . K RORDESC
  1. ;---
  1. S $P(@RORESULT@(0),U)=CNT
  1. Q
  1. ;
  1. ;***** Get Diagnosis code and add to the @RORESULT@("DILIST") array
  1. GETDIAG(CODSYS) ;
  1. N RORI,RORIEN,RORDIAG,ROR1,RORALL,RORNUM S RORI=0
  1. F S RORI=$O(@RORESULT@("DILIST",RORI)) Q:RORI="" D
  1. . S RORIEN=$P(@RORESULT@("DILIST",RORI,0),U,1)
  1. . S RORDIAG=$$VSTD^ICDEX(RORIEN)
  1. . ;get number of pieces in RORESULT
  1. . S RORNUM=$L(@RORESULT@("DILIST",RORI,0),U)
  1. . S ROR1=$P(@RORESULT@("DILIST",RORI,0),U,1) ;1st piece
  1. . S RORALL=$P(@RORESULT@("DILIST",RORI,0),U,2,RORNUM) ;all other pieces
  1. . S @RORESULT@("DILIST",RORI,0)=$G(ROR1)_U_$G(RORDIAG)_U_$G(RORALL)
  1. ;Update the 'map' in RORESULT to include field #3
  1. S RORNUM=$L(@RORESULT@("DILIST",0,"MAP"),U) ;number of pieces
  1. S ROR1=$P(@RORESULT@("DILIST",0,"MAP"),U,1) ;first piece
  1. S RORALL=$P(@RORESULT@("DILIST",0,"MAP"),U,2,RORNUM) ;all other pieces
  1. S @RORESULT@("DILIST",0,"MAP")=$G(ROR1)_U_"3"_U_$G(RORALL)
  1. Q
  1. ;***** Get Operation/Procedure and add to the RORESULT("DILIST") array
  1. GETOPPR(CODSYS) ;
  1. N RORI,RORIEN,ROROPPR,ROR1,RORALL,RORNUM S RORI=0
  1. F S RORI=$O(@RORESULT@("DILIST",RORI)) Q:RORI="" D
  1. . S RORIEN=$P(@RORESULT@("DILIST",RORI,0),U,1)
  1. . S ROROPPR=$$VSTP^ICDEX(RORIEN)
  1. . ;get number of pieces in RORESULT to reflect field #3
  1. . S RORNUM=$L(@RORESULT@("DILIST",RORI,0),U)
  1. . S ROR1=$P(@RORESULT@("DILIST",RORI,0),U,1) ;1st piece
  1. . S RORALL=$P(@RORESULT@("DILIST",RORI,0),U,2,RORNUM) ;all other pieces
  1. . S @RORESULT@("DILIST",RORI,0)=$G(ROR1)_U_$G(ROROPPR)_U_$G(RORALL)
  1. ;Update the 'map' in RORESULT to include field #4
  1. S RORNUM=$L(@RORESULT@("DILIST",0,"MAP"),U) ;number of pieces
  1. S ROR1=$P(@RORESULT@("DILIST",0,"MAP"),U,1) ;first piece
  1. S RORALL=$P(@RORESULT@("DILIST",0,"MAP"),U,2,RORNUM) ;all other pieces
  1. S @RORESULT@("DILIST",0,"MAP")=$G(ROR1)_U_"4"_U_$G(RORALL)
  1. Q