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

INHMGD7.m

Go to the documentation of this file.
  1. INHMGD7 ;CAR; 7 May 97 11:43;HL7 MESSAGING - SEGMENT SUBROUTINE FOR SENSITIVITY ANALYSIS
  1. ;;3.01;BHL IHS Interfaces with GIS;;JUL 01, 2001
  1. ;COPYRIGHT 1991-2000 SAIC
  1. ;
  1. ; PURPOSE:
  1. ; Module SEG^INHMGD7 is used to navigate the segment list under
  1. ; each message in ^INTHL7M. It is called by INHMGD6 and it is called
  1. ; recursively to reach the children of parent segments, which are
  1. ; skipped by INHMGD6. And it is used to evaluate the address of each
  1. ; field in each segment.
  1. ;
  1. SEG(INSEG,INERN) ;process the segment
  1. ;get the segment description string and segment number from '7M.
  1. ; Inputs
  1. ; INSEG = Segment index
  1. ; INERN = Error counter.
  1. S INSEG(1)=^INTHL7M(INM,1,INSEG,0),INSEG(2)=INSEG,INSEG=+INSEG(1)
  1. Q:'$D(^INTHL7S(INSEG,0))
  1. ;
  1. N DIC,INWHILE,INCH,INUDI,INX,X
  1. S INSEG(0)=^INTHL7S(INSEG,0) Q:$P(INSEG(0),U,2)="MSH"
  1. S INWHILE=$P(INSEG(1),U,3)!$P(INSEG(1),U,4) ;REPEATS or OTHER
  1. S INUDI=$P(INSEG(1),U,12) ;user defined index
  1. I INWHILE,(INUDI="") D
  1. .I $P(INSEG(1),U,3),'$P(INSEG(1),U,4) D Q ;MULTIPLE
  1. ..;look up the multiple name to get the field#
  1. ..K DIC S (X,INX)=$P(INSEG(1),U,8),DIC="^DD("_+FILE(FLVL)_","
  1. ..S DIC(0)="FMZ",DIC("S")="I $P(^(0),U,2)" D ^DIC
  1. ..I Y<0 D Q
  1. ...S INWHILE=0 Q:INPARS&('INMODE) ;bogus seg. ok in input ParseOnly
  1. ...S INERN=INERN+.1
  1. ...S ^UTILITY("INHMGD",$J,"E",INM,INSEG,INERN)=+FILE(FLVL)_U_"Multiple "_INX_" does not exist"
  1. ..;multiple found, store file# in FILE(FLVL) and name in INWHILE(1)
  1. ..S FLVL=FLVL+1,FILE(FLVL)=+$P(Y(0),U,2),INWHILE(1)=$P(Y,U,2)
  1. .;must have been an OTHER
  1. .S FLVL=FLVL+1,FILE(FLVL)=+$P(INSEG(1),U,5)
  1. .I 'FILE(FLVL) D Q
  1. ..S INX="No OTHER file specified",INERN=INERN+.001
  1. ..S ^UTILITY("INHMGD",$J,"E",INM,INSEG,INERN)=FILE(FLVL)_U_INX
  1. .;store other file name
  1. .S INWHILE(1)=$P(^DIC(+FILE(FLVL),0),U)
  1. ;
  1. ;continue processing this segment.
  1. N INAS,INFC,INFIL,INFL,INFLD,INJ,INRS
  1. ;could have done this check earlier, but wanted to eval FILE(FLVL)
  1. I $D(^UTILITY("INHMGD",$J,"S",INSEG)) D
  1. .;now go through list of fields for this segment INAS="ien^ien^ien..."
  1. .S INAS=^UTILITY("INHMGD",$J,"S",INSEG)
  1. .F INJ=1:1:$L(INAS,U) K X D
  1. ..;separate out the field pointer, then get the contents INFC
  1. ..S INFL=$P(INAS,U,INJ) Q:'INFL
  1. ..S INFC=$G(^UTILITY("INHMGD",$J,"F",INFL)) Q:INFC=""
  1. ..;derive the address
  1. ..S INRS=$$RESOLVE^INHMGD3(FILE(FLVL),INFC)
  1. ..;If no results returned, mark as error and quit
  1. ..I '$L(INRS) D Q
  1. ...S ^UTILITY("INHMGD",$J,"E",INM,INSEG,INFL)=FILE(FLVL)_U_INFC_" Unable to resolve or missing from Data Dictionary."
  1. ..;mark progress?
  1. ..I INDOT S INDOT=INDOT+1 I INDOT>70 S INDOT=1 W "."
  1. ..;separate out root and field name
  1. ..S INFLD=+$P(INRS,":"),INFIL=+$P(INRS,":",2)
  1. ..I INFLD,INFIL S ^UTILITY("INHMGD",$J,"A",INFIL,INFLD,INFL,INSEG,INM)="" Q
  1. ..;trap for 'INFLD or 'INFIL
  1. ..S ^UTILITY("INHMGD",$J,"E",INM,INSEG,INFL)=FILE(FLVL)_U_"Missing "_INFLD_" or "_INFIL
  1. ;
  1. ;pick up child segments
  1. I $D(^INTHL7M(INM,1,"ASP",INSEG)) D
  1. .S INCH=0
  1. .F S INCH=$O(^INTHL7M(INM,1,"ASP",INSEG,INCH)) Q:'INCH D
  1. ..S INX=0 F S INX=$O(^INTHL7M(INM,1,"ASP",INSEG,INCH,INX)) Q:'INX D SEG(INX,.INERN)
  1. ;
  1. ;adjust file level
  1. I INWHILE S FLVL=FLVL-1
  1. I FLVL<0 D
  1. .S INERN=INERN+.001
  1. .S ^UTILITY("INHMGD",$J,"E",INM,INSEG,INERN)=FILE(0)_U_"FLVL at -1"
  1. .S FLVL=0
  1. Q
  1. ;