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

PXRMV1ID.m

Go to the documentation of this file.
  1. PXRMV1ID ; SLC/PJH - Build selectable code lists ;10/25/1999
  1. ;;1.5;CLINICAL REMINDERS;;Jun 19, 2000
  1. ;
  1. ;Implementation utility
  1. ;----------------------
  1. START ;Lock entire taxonomy file
  1. I $$LOCK D
  1. .D BMES^XPDUTL("Generating selectable codes from taxonomy file")
  1. .K ^TMP("PXRM",$J)
  1. .N TAXIND
  1. .S TAXIND=0
  1. .F S TAXIND=$O(^PXD(811.2,TAXIND)) Q:'TAXIND D
  1. ..;Remove any existing entries
  1. ..D DEL(TAXIND)
  1. ..;Build new list of selectable codes
  1. ..D BCL(TAXIND)
  1. .D BMES^XPDUTL("Generation completed")
  1. D UNLOCK
  1. Q
  1. ;
  1. ;Build the list of codes for one taxonomy
  1. ;----------------------------------------
  1. BCL(TAXIND) ;
  1. N CODELIST,IC,FINDING,FILE,HIGH,LOW,NCE,TEMP
  1. ;
  1. ;Setup file names for indirection, these will hold the taxonomy lists.
  1. N ICD9IEN,ICPTIEN
  1. S ICD9IEN="^TMP(""PXRM"",$J,""ICD9IEN"")"
  1. S ICPTIEN="^TMP(""PXRM"",$J,""ICPTIEN"")"
  1. ;
  1. S NCE=0
  1. F FILE=80,81 D
  1. .S IC=0
  1. .F S IC=$O(^PXD(811.2,TAXIND,FILE,IC)) Q:+IC=0 D
  1. ..S TEMP=$G(^PXD(811.2,TAXIND,FILE,IC,0))
  1. ..;Append the taxonomy and finding information to CODELIST.
  1. ..S NCE=NCE+1
  1. ..S CODELIST(NCE)=TEMP_U_FILE
  1. ;CODELIST is LOW_U_HIGH_U_FILE
  1. ;Go through the standard coded list and get the file IEN for each entry.
  1. F IC=1:1:NCE D
  1. .S LOW=$P(CODELIST(IC),U,1)
  1. .S HIGH=$P(CODELIST(IC),U,2)
  1. .S FILE=$P(CODELIST(IC),U,3)
  1. .I FILE=80 D ICD9(LOW,HIGH) Q
  1. .I FILE=81 D ICPT(LOW,HIGH) Q
  1. ;
  1. ;Store the results.
  1. D STORE(TAXIND)
  1. K ^TMP("PXRM",$J,"ICD9IEN")
  1. K ^TMP("PXRM",$J,"ICPTIEN")
  1. Q
  1. ;
  1. ;=======================================================================
  1. DEL(TAXIND) ;Delete existing entry
  1. K ^PXD(811.2,TAXIND,"SDX")
  1. K ^PXD(811.2,TAXIND,"SPR")
  1. Q
  1. ;
  1. ;Build the list of internal entries for ICD9 (File 80)
  1. ;-----------------------------------------------------
  1. ICD9(LOW,HIGH) ;
  1. N END,IEN,IND
  1. S IND=LOW_" "
  1. S END=HIGH_" "
  1. F Q:(IND]END)!(+IND>+END)!(IND="") D
  1. .S IEN=$O(^ICD9("BA",IND,""))
  1. .I (+IEN>0),$$CODE^PXRMVAL($TR(IND," "),80) D
  1. ..S ^TMP("PXRM",$J,"ICD9IEN",IND)=IEN
  1. .S IND=$O(^ICD9("BA",IND))
  1. Q
  1. ;
  1. ;Build the list of internal entries for ICPT (File 81)
  1. ;-----------------------------------------------------
  1. ICPT(LOW,HIGH) ;
  1. N IEN,IND
  1. S IND=LOW
  1. F Q:(IND]HIGH)!(+IND>+HIGH)!(IND="") D
  1. .S IEN=$O(^ICPT("B",IND,""))
  1. .I (+IEN>0),$$CODE^PXRMVAL($TR(IND," "),81) D
  1. ..S ^TMP("PXRM",$J,"ICPTIEN",IND)=IEN
  1. .S IND=$O(^ICPT("B",IND))
  1. Q
  1. ;
  1. ;Lock the taxonomy file
  1. LOCK() N IND,LOCK
  1. S LOCK=0
  1. F IND=1:1:30 Q:LOCK D
  1. .L +^PXD(811.2):1
  1. .S LOCK=$T
  1. ;If we can't get lock generate an error and quit.
  1. I 'LOCK D Q 0
  1. .D BMES^XPDUTL("Could not get lock for taxonomy file ")
  1. Q 1
  1. ;
  1. ;Store selectable codes in taxonomy
  1. ;----------------------------------
  1. STORE(TAXIND) ;
  1. K ^TMP("PXRMV1ID",$J)
  1. N FDA,FDAIEN,FITEM,I2N,IEN,IND,MSG,NAME,SEQ,SUB,TEMP
  1. ;
  1. S NAME=$P(^PXD(811.2,TAXIND,0),U)
  1. ;
  1. S FDAIEN(1)=TAXIND
  1. ;
  1. S SUB="",IND=1,SEQ=0
  1. F S SUB=$O(^TMP("PXRM",$J,"ICD9IEN",SUB)) Q:SUB="" D
  1. .S IEN=^TMP("PXRM",$J,"ICD9IEN",SUB)
  1. .S IND=IND+1,SEQ=SEQ+1
  1. .S I2N="+"_IND_","_FDAIEN(1)_","
  1. .S ^TMP("PXRMV1ID",$J,811.23102,I2N,.01)=IEN
  1. .;S ^TMP("PXRMV1ID",$J,811.23102,I2N,.01)=SEQ
  1. .;S ^TMP("PXRMV1ID",$J,811.23102,I2N,1)=IEN
  1. .;S ^TMP("PXRMV1ID",$J,811.23102,I2N,3)=1
  1. ;
  1. S SEQ=0
  1. F S SUB=$O(^TMP("PXRM",$J,"ICPTIEN",SUB)) Q:SUB="" D
  1. .S IEN=^TMP("PXRM",$J,"ICPTIEN",SUB)
  1. .S IND=IND+1,SEQ=SEQ+1
  1. .S I2N="+"_IND_","_FDAIEN(1)_","
  1. .S ^TMP("PXRMV1ID",$J,811.23104,I2N,.01)=IEN
  1. .;S ^TMP("PXRMV1ID",$J,811.23104,I2N,.01)=SEQ
  1. .;S ^TMP("PXRMV1ID",$J,811.23104,I2N,1)=IEN
  1. .;S ^TMP("PXRMV1ID",$J,811.23104,I2N,3)=1
  1. ;
  1. ;None found
  1. I IND=1 Q
  1. ;
  1. S TEMP="^TMP(""PXRMV1ID"","_$J_")"
  1. D UPDATE^DIE("",TEMP,"FDAIEN","MSG")
  1. I $D(MSG) D ERR
  1. K ^TMP("PXRMV1ID",$J)
  1. Q
  1. ;
  1. ;Unlock the taxonomy
  1. ;-------------------
  1. UNLOCK L -^PXD(811.2)
  1. Q
  1. ;
  1. ;Error Handler
  1. ;-------------
  1. ERR N ERROR,IC,REF
  1. S ERROR(1)="Unable to build selectable codes for taxonomy : "
  1. S ERROR(2)=NAME
  1. S ERROR(3)="Error in UPDATE^DIE, needs further investigation"
  1. ;Move MSG into ERROR
  1. S REF="MSG"
  1. F IC=4:1 S REF=$Q(@REF) Q:REF="" S ERROR(IC)=REF_"="_@REF
  1. ;Screen message
  1. D BMES^XPDUTL(.ERROR)
  1. ;Mail Message
  1. D ERR^PXRMV1IE(.ERROR)
  1. Q