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

IBRFIHLU.m

Go to the documentation of this file.
  1. IBRFIHLU ;TDM/DAL - HL7 Utilities ;24-AUG-2015 ; 1/8/16 1:14pm
  1. ;;2.0;INTEGRATED BILLING;**547**;21-MAR-94;Build 119
  1. ;;Per VA Directive 6402, this routine should not be modified.
  1. ;
  1. HLP(PROTOCOL) ; Find the Protocol IEN
  1. Q +$O(^ORD(101,"B",PROTOCOL,0))
  1. ;
  1. NAME(NM) ; Convert a name that isn't in standard VISTA format -
  1. NEW LNM,FNM,MI
  1. ;
  1. I NM?." " Q NM
  1. ; LastName,FirstName MI
  1. I NM["," Q NM
  1. ;
  1. ; Remove double-spaces from name
  1. F Q:$L(NM," ")<2 S NM=$P(NM," ",1)_" "_$P(NM," ",2,9999)
  1. ;
  1. ; Trim leading/trailing spaces
  1. S NM=$$TRIM^XLFSTR(NM)
  1. ;
  1. ; Find number of spaces in name
  1. S II=$L(NM," ")
  1. ;
  1. I II>3 Q NM
  1. I II=3 S FNM=$P(NM," ",1),MI=" "_$P(NM," ",2),LNM=$P(NM," ",3)
  1. I II=2 S FNM=$P(NM," ",1),LNM=$P(NM," ",2),MI=""
  1. I II<2 Q NM
  1. Q LNM_","_FNM_MI
  1. ;
  1. SPAR ; Segment Parsing
  1. ;
  1. ; This tag will parse the current segment referenced by the HCT index
  1. ; and place the results in the IBSEG array.
  1. ;
  1. ; Input Variables
  1. ; HCT
  1. ;
  1. ; Output Variables
  1. ; IBSEG (ARRAY of fields in segment)
  1. ;
  1. N II,IJ,IK,IM,IS,ISBEG,ISCT,ISDATA,ISEND,ISPEC,LSDATA,NPC
  1. ;
  1. ;Reset IBSEG
  1. K IBSEG
  1. ;
  1. S ISCT="",II=0,IS=0
  1. F S ISCT=$O(^TMP($J,"IBRFIHLI",HCT,ISCT)) Q:ISCT="" D
  1. . S IS=IS+1
  1. . S ISDATA(IS)=$G(^TMP($J,"IBRFIHLI",HCT,ISCT))
  1. . I $E(ISDATA(IS),1)=$C(10) S ISDATA(IS)=$E(ISDATA(IS),2,($L(ISDATA(IS)))) ;Strip out Line Feed
  1. . I $O(^TMP($J,"IBRFIHLI",HCT,ISCT))="" S ISDATA(IS)=ISDATA(IS)_HLFS
  1. . S ISPEC(IS)=$L(ISDATA(IS),HLFS)
  1. ;
  1. S IM=0,LSDATA=""
  1. LP S IM=IM+1 Q:IM>IS
  1. S LSDATA=LSDATA_ISDATA(IM),NPC=ISPEC(IM)
  1. F IJ=1:1:NPC-1 D
  1. . S II=II+1,IBSEG(II)=$$CLNSTR($P(LSDATA,HLFS,IJ),$E(HL("ECH"),1,2)_$E(HL("ECH"),4),$E(HL("ECH")))
  1. S LSDATA=$P(LSDATA,HLFS,NPC)
  1. G LP
  1. CLNSTR(STRING,CHARS,SUBSEP) ; Remove extra trailing components and subcomponents in the HL7 seg
  1. ;
  1. N NUMPEC,PEC,RTSTRING
  1. ;
  1. S RTSTRING=$$RTRIMCH(STRING,CHARS)
  1. ; Now we have string w/o trailing chars, remove from subs
  1. S NUMPEC=$L(RTSTRING,SUBSEP)
  1. F PEC=1:1:NUMPEC S $P(RTSTRING,SUBSEP,PEC)=$$RTRIMCH($P(RTSTRING,SUBSEP,PEC),CHARS)
  1. Q RTSTRING
  1. ;
  1. RTRIMCH(STR,CHRS) ; Remove the trailing chars from string
  1. ;
  1. N R,L
  1. ;
  1. S L=1,CHRS=$G(CHRS," ")
  1. F R=$L(STR):-1:1 Q:CHRS'[$E(STR,R)
  1. I L=R,(CHRS[$E(STR)) S STR=""
  1. Q $E(STR,L,R)