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

ACPT28PD.m

Go to the documentation of this file.
  1. ACPT28PD ;IHS/VEN/TOAD - ACPT*2.08*1 postinit step 4.2 ; 04/21/2008 11:24
  1. ;;2.08;CPT FILES;**1**;DEC 17, 2007
  1. ;
  1. ; This subroutine of the post-init for ACPT*2.08*1 loads the HCPCS 2008
  1. ; modifiers from the American Medical Association's text file
  1. ; acpt2008.01c and installs them in the RPMS CPT Modifier file
  1. ; (9999999.88). It does not do all of the actions needed to install
  1. ; those modifiers, only the raw loading. See routine ACPT28PA for the
  1. ; complete algorithm and overview.
  1. ;
  1. QUIT ; This routine should not be called at the top or anywhere
  1. ; else. It is only to be called at LOADMOD by ACPT28PA as part of the
  1. ; post-init for ACPT*2.08*1.
  1. ;
  1. ; 2008 04 16-20 Rick Marshall refactored this routine for
  1. ; maintainability. All commented-out code was removed so this version of
  1. ; the routine handles only HCPCS codes. Fixed bug in unportable handling
  1. ; of Description & Long Description fields. Renamed routine from
  1. ; ACPTPST2 to ACPT28PD.
  1. ;
  1. ; The original code was written by IHS/ASDST/DMJ and Shonda Render
  1. ; (SDR).
  1. ;
  1. ;
  1. LOADMOD ;load HCPCS modifiers from AMA HCPCS Modifiers file
  1. ;
  1. ; private: called only by step 4 of routine ACPT28PA
  1. ;
  1. ; input: ACPTPTH = path to directory where file is stored
  1. ; ACPTYR = flag to identify newly added entries (3080000)
  1. ;
  1. N POP D Q:POP
  1. . D OPEN^%ZISH("CPTHFILE",ACPTPTH,"acpt2008.01c","R") ; open read-only
  1. . U IO(0) ; use terminal
  1. . I POP D MES^XPDUTL($$T("MSG+1")) ; Could not open HCPCS Modifiers f...
  1. . E D MES^XPDUTL($$T("MSG+2")) ; Reading HCPCS Modifiers file.
  1. ;
  1. N ACPTCNT ; count entries to print a dot for every 100
  1. F ACPTCNT=1:1 D Q:$$STATUS^%ZISH ; loop until end of file
  1. . ;
  1. . N ACPTLINE ; each line extracted from the file
  1. . U IO R ACPTLINE Q:$$STATUS^%ZISH
  1. . ;
  1. . N ACPTCODE ; HCPCS modifier, aka Code (.01)
  1. . S ACPTCODE=$E(ACPTLINE,1,2) ; 1st 2 chars contain the HCPCS modifier
  1. . ;
  1. . N ACPTIEN ; IEN of entry in CPT Modifier file
  1. . S ACPTIEN=$O(^AUTTCMOD("B",ACPTCODE,0)) ; find code's record number
  1. . I 'ACPTIEN D ; if there isn't one yet, create it
  1. . . S ACPTIEN=$A(ACPTCODE)_$A(ACPTCODE,2) ; DINUM based on ASCII of code
  1. . . S ^AUTTCMOD(ACPTIEN,0)=ACPTCODE_U_U_ACPTYR ; set Code & Date Added
  1. . . S ^AUTTCMOD("B",ACPTCODE,ACPTIEN)="" ; and cross-reference it
  1. . ;
  1. . N ACPTDESC ; Description (.02)
  1. . S ACPTDESC=$$CLEAN($E(ACPTLINE,3,153),1) ; Description up to 150 chars
  1. . I ACPTDESC'="" D ; if a description is present in the AMA file
  1. . . S $P(^AUTTCMOD(ACPTIEN,0),U,2)=ACPTDESC ; set the field
  1. . I "^AE^AF^AG^AK^CB^FP^QA^"[(U_ACPTCODE_U) D ; if one of these codes
  1. . . S $P(^AUTTCMOD(ACPTIEN,0),U,2)="" ; description is wrong, so delete
  1. . ;
  1. . S $P(^AUTTCMOD(ACPTIEN,0),U,4)="" ; clear Date Deleted (.04)
  1. . ;
  1. . N ACPTLONG ; Long Description (1)
  1. . S ACPTLONG=$$CLEAN($E(ACPTLINE,3,536)) ; rest of up to 536 = Long Desc
  1. . D TEXT(.ACPTLONG) ; convert string to WP array
  1. . K ^AUTTCMOD(ACPTIEN,1) ; delete its subtree
  1. . M ^AUTTCMOD(ACPTIEN,1)=ACPTLONG ; copy array to field, incl. header
  1. . ;
  1. . U IO(0) W:'(ACPTCNT#100) "."
  1. ;
  1. D ^%ZISC ; close the file
  1. ;
  1. QUIT ; end of LOADMOD
  1. ;
  1. ;
  1. T(TAG) QUIT $P($T(@TAG),";;",2)
  1. ;
  1. ;
  1. MSG ; messages to display
  1. ;;Could not open HCPCS Modifiers file.
  1. ;;Reading HCPCS Modifiers file.
  1. ;
  1. ;
  1. CLEAN(ACPTDESC,ACPTUP) ; clean up description field
  1. ;
  1. ; private, called only by LOADCODE above
  1. ;
  1. ; 1) strip out control characters
  1. I ACPTDESC?.E1C.E D CLEAN^ACPT28P1(.ACPTDESC)
  1. ;
  1. ; 2) trim extra spaces
  1. N ACPTCLN S ACPTCLN=""
  1. N ACPTPIEC F ACPTPIEC=1:1:$L(ACPTDESC," ") D ; traverse words
  1. . N ACPTWORD S ACPTWORD=$P(ACPTDESC," ",ACPTPIEC) ; grab each word
  1. . Q:ACPTWORD="" ; skip empty words (multiple spaces together)
  1. . S ACPTCLN=ACPTCLN_" "_ACPTWORD ; reassemble words with 1 space between
  1. S $E(ACPTCLN)="" ; remove extraneous leading space
  1. ;
  1. ; 3) optionally, convert to upper case
  1. I $G(ACPTUP) S ACPTDESC=$$UP^XLFSTR(ACPTCLN)
  1. ;
  1. QUIT ACPTCLN ; end of CLEAN
  1. ;
  1. ;
  1. TEXT(ACPTLONG) ; convert Long Description text to Word-Processing data type
  1. ;
  1. ; private, called only by LOADCODE above
  1. ;
  1. ; input: .ACPTLONG = passed by reference, starts out as long string,
  1. ; ends as Fileman WP-format array complete with header
  1. ;
  1. N ACPTSTRN S ACPTSTRN=ACPTLONG ; copy string out
  1. K ACPTLONG ; clear what will now become a WP array
  1. N ACPTCNT S ACPTCNT=0 ; count WP lines for header
  1. ;
  1. F Q:ACPTSTRN="" D ; loop until ACPTSTRN is fully transformed
  1. . ;
  1. . N ACPTBRK S ACPTBRK=0 ; character position to break at
  1. . ;
  1. . D ; find the character position to break at
  1. . . N ACPTRY ; break position to try
  1. . . S ACPTRY=$L(ACPTSTRN) ; how long is the string?
  1. . . I ACPTRY<81 S ACPTBRK=ACPTRY Q ; if 1 full line or less, we're done
  1. . . ;
  1. . . F ACPTRY=80:-1:2 D Q:ACPTBRK
  1. . . . I $E(ACPTSTRN,ACPTRY+1)=" " D Q ; can break on a space
  1. . . . . S $E(ACPTSTRN,ACPTRY+1)="" ; remove the space
  1. . . . . S ACPTBRK=ACPTRY ; and let's break here
  1. . . . ;
  1. . . . I "&_+-*/<=>}])|:;,.?!"[$E(ACPTSTRN,ACPTRY) D Q ; on delimiter?
  1. . . . . S ACPTBRK=ACPTRY ; so let's break here
  1. . . ;
  1. . . Q:ACPTBRK ; if we found a good spot to break, we're done
  1. . . ;
  1. . . S ACPTBRK=80 ; otherwise, hard-break on 80 (weird content)
  1. . ;
  1. . S ACPTCNT=ACPTCNT+1 ; one more line
  1. . S ACPTLONG(ACPTCNT,0)=$E(ACPTSTRN,1,ACPTBRK) ; copy line into array
  1. . S $E(ACPTSTRN,1,ACPTBRK)="" ; & remove it from the string
  1. ;
  1. S ACPTLONG(0)="^9999999.881^"_ACPTCNT_U_ACPTCNT_U_DT ; set WP header
  1. ;
  1. QUIT ; end of TEXT
  1. ;
  1. ;
  1. ; end of routine ACPT28PD