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

MCARAM4.m

Go to the documentation of this file.
  1. MCARAM4 ;WASH ISC/JKL-MUSE TRANSFER LAB DATA TO LOCAL ;5/20/94 15:35
  1. ;;2.3;Medicine;;09/13/1996
  1. ;
  1. ;
  1. ;Checks format and/or reformats data
  1. AR(MCA,MCAA,MCD,MCFP,MCLP,MCCK) ;Sets l/t stripped data field into an array
  1. ; USAGE: S X=$$AR^MCARAM4(.A,B,C,D,E)
  1. ; WHERE: .A = array where data is placed
  1. ; B = array argument for data field
  1. ; C = data field value
  1. ; D = first position of data field
  1. ; E = last position of data field
  1. ; F = 1 to check numeric data field value for positive int value
  1. ; 2 to check "" for both positive and negative int value
  1. ; 3 to check "" for pos,neg,int, and decimal values
  1. N MCI,MCERR
  1. I '$D(MCCK) S MCCK=""
  1. S MCA(MCAA)=$E(MCD,MCFP,MCLP),MCI=MCA(MCAA),MCERR=$$SLTS^MCARAM4(.MCI),MCA(MCAA)=MCI I +MCERR>0 Q MCERR
  1. I MCCK=1 S MCERR=$$DFCK^MCARAM4(MCA(MCAA),MCCK) I +MCERR>0 Q MCERR
  1. I MCCK=2 S MCERR=$$DFCK^MCARAM4(MCA(MCAA),MCCK) I +MCERR>0 Q MCERR
  1. I MCCK=3 S MCERR=$$DFCK^MCARAM4(MCA(MCAA),MCCK) I +MCERR>0 Q MCERR
  1. Q 0
  1. ;
  1. DFCK(MCV,MCCK) ; Checks numeric,negative,positive,integer,decimal value
  1. ; USAGE: S X=$$DFCK^MCARAM4(A,B)
  1. ; WHERE: A=data field value
  1. ; B=1 for positive value numeric (integer) check
  1. ; B=2 for positive and negative value numeric (integer) check
  1. ; B=3 for positive, negative, decimal, or integer numeric check
  1. ; if successful, returns function value of 0
  1. ; if unsuccessful, returns error message for incorrect field format
  1. N MCERR
  1. I MCV="" S MCERR="2-Null data field" Q MCERR
  1. I MCV=0 Q 0
  1. I $G(MCCK)=1 I MCV?1N.N Q 0
  1. I $G(MCCK)=2 I MCV?."-"1N.N,$P(MCV,"-",2,99)'["-",-MCV+-MCV'=0 Q 0
  1. I $G(MCCK)=3 I MCV?."-"."."1N.N.".".N,$P(MCV,".",2,99)'[".",$P(MCV,"-",2,99)'["-",-MCV+-MCV'=0 Q 0
  1. S MCERR="1-Data field not numeric" Q MCERR
  1. ;
  1. SLTS(MCV) ; Strips leading and trailing spaces from data fields
  1. ; USAGE: S X=$$SLTS^MCARAM4(.A)
  1. ; WHERE: MCV=data field value
  1. ; .A = value where data is placed
  1. ; if successful, returns function value of 0 and data field value
  1. ; if unsuccessful, returns error message for incorrect field format
  1. N MCERR,MCI,MCJ
  1. I MCV="" S MCERR="2-Null data field" Q MCERR
  1. F MCI=1:1 I $E(MCV,MCI,MCI)'=" " Q
  1. F MCJ=$L(MCV):-1 I $E(MCV,MCJ,MCJ)'=" " Q
  1. S MCV=$E(MCV,MCI,MCJ) I MCV="" S MCERR="2-Null data field" Q MCERR
  1. Q 0
  1. ;
  1. DGCK(MCA) ;Removes null lines and resets numbering of diagnosis array
  1. ; USAGE: S X=$$DGCK^MCARAM4(.A)
  1. ; WHERE: MCA=diagnosis array
  1. ; .A=diagnosis array renumbered without null lines
  1. ; A("DX,0")=total number of non-null diagnosis lines
  1. ; if successful, returns function value of 0 and diagnosis array
  1. ; if unsuccessful, returns error message and A("DX,0")=0
  1. N MCI,MCJ,MCK,MCERR
  1. S MCI=0,MCJ="DX,0"
  1. F S MCJ=$O(MCA(MCJ)) Q:MCJ=""!($E(MCJ)'=$E("DX,0")) S:MCA(MCJ)'="" MCI=MCI+1 I MCA(MCJ)="" K MCA(MCJ) S MCK=MCJ F S MCK=$O(MCA(MCK)) Q:MCK=""!($E(MCK)'=$E("DX,0")) I MCA(MCK)'="" S MCA(MCJ)=MCA(MCK),MCI=MCI+1,MCA(MCK)="" Q
  1. S MCA("DX,0")=MCI I MCI>0 Q 0
  1. S MCERR="62-Diagnosis is a null data field" Q MCERR
  1. ;
  1. RXCK(MCA) ;Removes null lines and resets numbering of medication array
  1. ; USAGE: S X=$$RXCK^MCARAM4(.A)
  1. ; WHERE: MCA=medication array
  1. ; .A=medication array renumbered without null lines
  1. ; A("RX,0")=total number of non-null medication lines
  1. ; if successful, returns function value of 0 and medication array
  1. ; if unsuccessful, returns error message and A("RX,0")=0
  1. N MCI,MCJ,MCK,MCERR
  1. I MCA("RX,0")="" S MCA("RX,0")=0,MCERR="4-Medication is a null data field" Q MCERR
  1. F MCJ=1:1 S MCK="RX,"_MCJ,MCA(MCK)=$P(MCA("RX,0"),", ",MCJ) Q:MCA(MCK)="" S MCI=$P(MCA(MCK)," ") I MCI'="",$D(^PSDRUG("B",MCI)) S MCA(MCK)=$O(^(MCI,0))_U_$P(MCA(MCK)," ",2)_U_$P(MCA(MCK)," ",3)
  1. K MCA(MCK)
  1. S MCA("RX,0")=MCJ-1 I MCJ-1=0 S MCERR="4-Medication is a null data field" Q MCERR
  1. Q 0
  1. ;
  1. DGCT(MCA,MCD,MCL) ;Fill diagnosis array from continuation record
  1. ; USAGE: S X=$$DGCT^MCARAM4(.A,B,C)
  1. ; WHERE: MCA=diagnosis array
  1. ; .A=diagnosis array renumbered without null lines
  1. ; B=data field value, C=line number of data
  1. ; A("DX,0")=total number of non-null diagnosis lines
  1. ; "DX,L"=12th line of diagnosis, "DX,V"=22nd line
  1. ; if successful, returns function value of 0 and diagnosis array
  1. ; if unsuccessful, returns error message and A("DX,0")=0
  1. N MCI,MCERR
  1. S MCI="DX,"_MCA("CONT")
  1. I MCL=13!(MCL=25) S MCERR=$$AR^MCARAM4(.MCA,MCI,MCD,32,78) Q:+MCERR>0 MCERR Q 0
  1. S MCERR=$$AR^MCARAM4(.MCA,MCI,MCD,32,134) Q:+MCERR>0 MCERR
  1. Q 0
  1. ;
  1. ERR ;Error return
  1. Q MCERR