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

RORX015C.m

Go to the documentation of this file.
  1. RORX015C ;HCIOFO/SG - OUTPATIENT PROCEDURES (STORE) ;6/27/06 10:54am
  1. ;;1.5;CLINICAL CASE REGISTRIES;**1,19,21,31,34,39**;Feb 17, 2006;Build 4
  1. ;
  1. ; This routine uses the following IAs:
  1. ;
  1. ; #1995 $$CPT^ICPTCOD (supported)
  1. ; #5747 $$ICDOP^ICDEX, $$CSI^ICDEX (controlled)
  1. ;
  1. ;******************************************************************************
  1. ;******************************************************************************
  1. ; --- ROUTINE MODIFICATION LOG ---
  1. ;
  1. ;PKG/PATCH DATE DEVELOPER MODIFICATION
  1. ;----------- ---------- ----------- ----------------------------------------
  1. ;ROR*1.5*19 FEB 2012 J SCOTT Support for ICD-10 Coding System.
  1. ;ROR*1.5*21 SEP 2013 T KOPP Added ICN as last report column if
  1. ; additional identifier option selected
  1. ;ROR*1.5*31 MAY 2017 M FERRARESE Adding PACT, PCP, and AGE/DOB as additional
  1. ; identifiers.
  1. ;ROR*1.5*34 SEP 2018 F TRAXLER Adding FUT_APPT and FUT_CLIN
  1. ;ROR*1.5*39 JUL 2021 M FERRARESE Setting SSN and LAST4 to zeros
  1. ;******************************************************************************
  1. ;******************************************************************************
  1. Q
  1. ;
  1. ;***** STORES THE PROCEDURE CODE TABLE
  1. ;
  1. ; PTAG IEN of the parent element
  1. ;
  1. ; NODE Closed root of the node of the temporary global
  1. ;
  1. ; Return Values:
  1. ; <0 Error code
  1. ; 0 Ok
  1. ; >0 Number of non-fatal errors
  1. ;
  1. CODES(PTAG,NODE) ;
  1. N IEN,ITEM,NAME,SRC,TABLE,TMP,RORPROCSYS,RORPROCCODE
  1. S TABLE=$$ADDVAL^RORTSK11(RORTSK,"PROCLST",,PTAG)
  1. Q:TABLE<0 TABLE
  1. D ADDATTR^RORTSK11(RORTSK,TABLE,"TABLE","PROCLST")
  1. S NAME=""
  1. F S NAME=$O(@NODE@("PROC","B",NAME)) Q:NAME="" D
  1. . S SRC=""
  1. . F S SRC=$O(@NODE@("PROC","B",NAME,SRC)) Q:SRC="" D
  1. . . S IEN=0
  1. . . F S IEN=$O(@NODE@("PROC","B",NAME,SRC,IEN)) Q:IEN'>0 D
  1. . . . S ITEM=$$ADDVAL^RORTSK11(RORTSK,"PROCEDURE",,TABLE)
  1. . . . S TMP=@NODE@("PROC",SRC,IEN)
  1. . . . S RORPROCCODE=$P(TMP,U,1)
  1. . . . I SRC="I" D
  1. . . . . S RORPROCSYS=+$$CSI^ICDEX(80.1,IEN)
  1. . . . . S RORPROCCODE="("_$S(RORPROCSYS=2:"ICD-9",RORPROCSYS=31:"ICD-10",1:"UNKN")_") "_RORPROCCODE
  1. . . . D ADDVAL^RORTSK11(RORTSK,"PROCODE",RORPROCCODE,ITEM,2)
  1. . . . D ADDVAL^RORTSK11(RORTSK,"PROCNAME",$P(TMP,U,2),ITEM,2)
  1. . . . S TMP=$G(@NODE@("PROC",SRC,IEN,"P"))
  1. . . . D ADDVAL^RORTSK11(RORTSK,"NP",TMP,ITEM,3)
  1. . . . S TMP=$G(@NODE@("PROC",SRC,IEN,"C"))
  1. . . . D ADDVAL^RORTSK11(RORTSK,"NC",TMP,ITEM,3)
  1. . . . D ADDVAL^RORTSK11(RORTSK,"SOURCE",SRC,ITEM,1)
  1. Q 0
  1. ;
  1. ;***** STORES THE PATIENT TABLE
  1. ;
  1. ; PTAG IEN of the parent element
  1. ;
  1. ; NODE Closed root of the node of the temporary global
  1. ;
  1. ; Return Values:
  1. ; <0 Error code
  1. ; 0 Ok
  1. ; >0 Number of non-fatal errors
  1. ;
  1. PATIENTS(PTAG,NODE) ;
  1. N DATE,DOD,ICN,IEN,ITEM,LAST4,PACT,PCP,PTIEN,PROCLST,PTCPTL,PTLST,PTNAME,SRC,TMP,RORPROCSYS,RORPROCCODE,RORAPPT,RORAPPTINFO,RORCLIN
  1. N AGE,AGETYPE
  1. S (PROCLST,PTLST)=-1
  1. ;--- Table for patients with procedures
  1. I RORPROC>0 D Q:PROCLST<0 PROCLST
  1. . S PROCLST=$$ADDVAL^RORTSK11(RORTSK,"PROCEDURES",,PTAG)
  1. . D ADDATTR^RORTSK11(RORTSK,PROCLST,"TABLE","PROCEDURES")
  1. . ;--- Force the privacy note
  1. . D ADDVAL^RORTSK11(RORTSK,"PATIENT",,PTAG)
  1. ;--- Table for patients without procedures
  1. I RORPROC<0 D Q:PTLST<0 PTLST
  1. . S PTLST=$$ADDVAL^RORTSK11(RORTSK,"PATIENTS",,PTAG)
  1. . D ADDATTR^RORTSK11(RORTSK,PTLST,"TABLE","PATIENTS")
  1. ;---
  1. S PTIEN=0
  1. S AGETYPE=$$PARAM^RORTSK01("AGE_RANGE","TYPE")
  1. F S PTIEN=$O(@NODE@("PAT",PTIEN)) Q:PTIEN'>0 D
  1. . S TMP=@NODE@("PAT",PTIEN)
  1. . S LAST4="0000",PTNAME=$P(TMP,U,2),DOD=$P(TMP,U,3),ICN=$P(TMP,U,4),PACT=$P(TMP,U,5),PCP=$P(TMP,U,6),AGE=$P(TMP,U,7),RORAPPT=$P(TMP,U,8),RORCLIN=$P(TMP,U,9)
  1. . ;--- Patient list
  1. . I RORPROC<0 D Q
  1. . . S ITEM=$$ADDVAL^RORTSK11(RORTSK,"PATIENT",,PTLST,,PTIEN)
  1. . . D ADDVAL^RORTSK11(RORTSK,"NAME",PTNAME,ITEM,2)
  1. . . D ADDVAL^RORTSK11(RORTSK,"LAST4",LAST4,ITEM,2)
  1. . . I AGETYPE'="ALL" D ADDVAL^RORTSK11(RORTSK,AGETYPE,AGE,ITEM,1)
  1. . . D ADDVAL^RORTSK11(RORTSK,"DOD",DOD,ITEM,1)
  1. . . I $$PARAM^RORTSK01("PATIENTS","ICN") D ADDVAL^RORTSK11(RORTSK,"ICN",ICN,ITEM,1)
  1. . . I $$PARAM^RORTSK01("PATIENTS","PACT") D ADDVAL^RORTSK11(RORTSK,"PACT",PACT,ITEM,1)
  1. . . I $$PARAM^RORTSK01("PATIENTS","PCP") D ADDVAL^RORTSK11(RORTSK,"PCP",PCP,ITEM,1)
  1. . .I $$PARAM^RORTSK01("OPTIONS","FUT_APPT") D
  1. . . . D ADDVAL^RORTSK11(RORTSK,"FUT_APPT",RORAPPT,ITEM,1)
  1. . . . D ADDVAL^RORTSK11(RORTSK,"FUT_CLIN",RORCLIN,ITEM,1)
  1. . ;--- Patients and procedures
  1. . F SRC="I","O" D
  1. . . S IEN=0
  1. . . F S IEN=$O(@NODE@("PAT",PTIEN,SRC,IEN)) Q:IEN'>0 D
  1. . . . S ITEM=$$ADDVAL^RORTSK11(RORTSK,"PROCEDURE",,PROCLST,,PTIEN)
  1. . . . D ADDVAL^RORTSK11(RORTSK,"NAME",PTNAME,ITEM,2)
  1. . . . D ADDVAL^RORTSK11(RORTSK,"LAST4",LAST4,ITEM,2)
  1. . . . I AGETYPE'="ALL" D ADDVAL^RORTSK11(RORTSK,AGETYPE,AGE,ITEM,1)
  1. . . . D ADDVAL^RORTSK11(RORTSK,"DOD",DOD,ITEM,1)
  1. . . . I $$PARAM^RORTSK01("PATIENTS","ICN") D ADDVAL^RORTSK11(RORTSK,"ICN",ICN,ITEM,1)
  1. . . . I $$PARAM^RORTSK01("PATIENTS","PACT") S PACT="" S PACT=$$PACT^RORUTL02(PTIEN) D ADDVAL^RORTSK11(RORTSK,"PACT",PACT,ITEM,1)
  1. . . . I $$PARAM^RORTSK01("PATIENTS","PCP") S PCP="" S PCP=$$PCP^RORUTL02(PTIEN) D ADDVAL^RORTSK11(RORTSK,"PCP",PCP,ITEM,1)
  1. . . . I $$PARAM^RORTSK01("OPTIONS","FUT_APPT") D
  1. . . . . S RORAPPTINFO=$$FUTAPPT^RORUTL02(PTIEN,$$PARAM^RORTSK01("OPTIONS","FUT_APPT"))
  1. . . . . S RORAPPT=$P(RORAPPTINFO,U,1),RORCLIN=$P(RORAPPTINFO,U,2)
  1. . . . . D ADDVAL^RORTSK11(RORTSK,"FUT_APPT",RORAPPT,ITEM,1)
  1. . . . . D ADDVAL^RORTSK11(RORTSK,"FUT_CLIN",RORCLIN,ITEM,1)
  1. . . . S TMP=$G(@NODE@("PAT",PTIEN,SRC,IEN))
  1. . . . S DATE=$P(TMP,U)
  1. . . . I SRC="O" D
  1. . . . . S TMP=$$CPT^ICPTCOD(IEN,DATE) S:TMP<0 TMP=""
  1. . . . . D ADDVAL^RORTSK11(RORTSK,"PROCODE",$P(TMP,U,2),ITEM,2)
  1. . . . . D ADDVAL^RORTSK11(RORTSK,"PROCNAME",$P(TMP,U,3),ITEM,2)
  1. . . . E D
  1. . . . . S RORPROCSYS=+$$CSI^ICDEX(80.1,IEN)
  1. . . . . S TMP=$$ICDOP^ICDEX(IEN,DATE,,"I") S:TMP<0 TMP=""
  1. . . . . S RORPROCCODE="("_$S(RORPROCSYS=2:"ICD-9",RORPROCSYS=31:"ICD-10",1:"UNKN")_") "_$P(TMP,U,2)
  1. . . . . D ADDVAL^RORTSK11(RORTSK,"PROCODE",RORPROCCODE,ITEM,2)
  1. . . . . D ADDVAL^RORTSK11(RORTSK,"PROCNAME",$P(TMP,U,5),ITEM,2)
  1. . . . D ADDVAL^RORTSK11(RORTSK,"DATE",$$DATE^RORXU002(DATE\1),ITEM,1)
  1. . . . D ADDVAL^RORTSK11(RORTSK,"SOURCE",SRC,ITEM,1)
  1. Q 0
  1. ;
  1. ;***** STORES THE REPORT DATA
  1. ;
  1. ; REPORT IEN of the REPORT element
  1. ;
  1. ; Return Values:
  1. ; <0 Error code
  1. ; 0 Ok
  1. ; >0 Number of non-fatal errors
  1. ;
  1. STORE(REPORT) ;
  1. N ECNT,RC,SECTION,TMP
  1. S (ECNT,RC)=0
  1. ;--- Procedure codes
  1. I RORPROC>0 D Q:RC<0 RC
  1. . S RC=$$CODES(REPORT,RORTMP)
  1. . I RC Q:RC<0 S ECNT=ECNT+RC
  1. . S RC=$$LOOP^RORTSK01(.3)
  1. ;--- Patients
  1. S TMP=$$PARAM^RORTSK01("OPTIONS","COMPLETE")
  1. I TMP D I RC Q:RC<0 RC S ECNT=ECNT+RC
  1. . S RC=$$PATIENTS(REPORT,RORTMP)
  1. S RC=$$LOOP^RORTSK01(.99) Q:RC<0 RC
  1. ;--- Totals
  1. S SECTION=$$ADDVAL^RORTSK11(RORTSK,"SUMMARY",,REPORT)
  1. Q:SECTION<0 SECTION
  1. S TMP=$G(@RORTMP@("PROC"))
  1. D ADDVAL^RORTSK11(RORTSK,"NC",+$P(TMP,U,1),SECTION)
  1. D ADDVAL^RORTSK11(RORTSK,"NDC",+$P(TMP,U,2),SECTION)
  1. S TMP=$G(@RORTMP@("PAT"))
  1. D ADDVAL^RORTSK11(RORTSK,"NP",+TMP,SECTION)
  1. ;---
  1. Q ECNT