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

HLCIRN.m

Go to the documentation of this file.
  1. HLCIRN ;SFISC/RJH-Don't Purge and Reprocessing message ;07/28/97 10:14
  1. ;;1.6;HEALTH LEVEL SEVEN;**33**;Oct 13, 1995
  1. Q
  1. ;
  1. DONTPURG() ; set the DONT PURGE field to 1 in order to prevent the message
  1. ; from purging.
  1. ; return value : 1 for successfully set the field
  1. ; -1 for failure
  1. ;
  1. N FLAG
  1. S FLAG=$$SETPURG(1)
  1. Q FLAG
  1. ;
  1. TOPURG() ; clear the DONT PURGE field to allow the message to be purged.
  1. ; return value : 0 for successfully clear the field
  1. ; -1 for failure
  1. ;
  1. N FLAG
  1. S FLAG=$$SETPURG(0)
  1. Q FLAG
  1. ;
  1. SETPURG(STATUS) ; to set or to clear the DONT PURGE field
  1. ; at least one of the variables, HLMTIEN and HLMTIENS, must be defined
  1. ; HLMTIEN- parent message IEN
  1. ; HLMTIENS- child message IEN
  1. ; input: 1 to set the DONT PURGE field
  1. ; 0 to clear the DONT PURGE field.
  1. ; return value: 1 means successfully set the DONT PURGE field
  1. ; 0 means successfully clear the DONT PURGE field
  1. ; -1 means fail to set or to clear the field
  1. ;
  1. N FLAG
  1. S FLAG=""
  1. I (STATUS'=1)&(STATUS'=0) Q -1
  1. I '$G(HLMTIEN),'$G(HLMTIENS) Q -1
  1. ;
  1. ; both HLMTIEN and HLMTIENS are defined
  1. I $G(HLMTIEN),$G(HLMTIENS) D
  1. . I '$D(^HL(772,HLMTIEN)) S FLAG=-1 Q
  1. . I '$D(^HL(772,HLMTIENS)) S FLAG=-1 Q
  1. . I (HLMTIEN'=$P(^HL(772,HLMTIENS,0),"^",8)) S FLAG=-1 Q
  1. . D SETVALUE
  1. . S FLAG=STATUS
  1. I (FLAG=-1)!(FLAG=STATUS) Q FLAG
  1. ;
  1. ; only HLMTIEN(parent message IEN) is defined
  1. I $G(HLMTIEN) D
  1. . I '$D(^HL(772,HLMTIEN)) S FLAG=-1 Q
  1. . I (HLMTIEN'=$P(^HL(772,HLMTIEN,0),"^",8)) S FLAG=-1 Q
  1. . D SETVALUE
  1. . S FLAG=STATUS
  1. I (FLAG=-1)!(FLAG=STATUS) Q FLAG
  1. ;
  1. ; only HLMTIENS(child message IEN) is defined
  1. I $G(HLMTIENS) D
  1. . I '$D(^HL(772,HLMTIENS)) S FLAG=-1 Q
  1. . S HLMTIEN=$P(^HL(772,HLMTIENS,0),"^",8)
  1. . I 'HLMTIEN S FLAG=-1 Q
  1. . I '$D(^HL(772,HLMTIEN)) S FLAG=-1 Q
  1. . I (HLMTIEN'=$P(^HL(772,HLMTIEN,0),"^",8)) S FLAG=-1 Q
  1. . D SETVALUE
  1. . S FLAG=STATUS
  1. Q FLAG
  1. ;
  1. SETVALUE ; set or clear the DONT PURGE field
  1. L +^HL(772,HLMTIEN)
  1. S ^HL(772,HLMTIEN,2)=STATUS
  1. I $G(HLMTIENS) S ^HL(772,HLMTIENS,2)=STATUS
  1. L -^HL(772,HLMTIEN)
  1. Q
  1. ;
  1. REPROC(IEN,RTN) ; reprocessing message
  1. ; IEN- either the parent message IEN or the child message IEN
  1. ; RTN- the routine, to be Xecuted for processing the message
  1. ; return value: 0 for success, -1 for failure
  1. ;
  1. N HLMTIEN,HLMTIENS,HLNEXT,HLNODE,HLQUIT,HLERR,HLRESLT
  1. N HL,HDR,FS,ECH,HLMSA,X,X1,X2
  1. S HLQUIT=0,HLNODE="",HLNEXT="D HLNEXT^HLCSUTL"
  1. S HLMSA=""
  1. I '$G(IEN) Q -1
  1. I '$D(^HL(772,IEN)) Q -1
  1. I $G(RTN)'["" Q -1
  1. S HLMTIEN=$P(^HL(772,IEN,0),"^",8)
  1. Q:'HLMTIEN -1
  1. I HLMTIEN'=IEN S HLMTIENS=IEN
  1. ;
  1. S X=0
  1. F S X=$O(^HL(772,HLMTIEN,"IN",X)) Q:X'>0 D
  1. . S X1=$G(^HL(772,HLMTIEN,"IN",X,0))
  1. . Q:"FHS,BHS,MSH,MSA"'[$E(X1,1,3)
  1. . ; If header segment, process it and set HDR equal to it
  1. . I '$D(HDR),"FHS,BHS,MSH"[$E(X1,1,3) D
  1. .. S HDR=X1
  1. .. S (HL("FS"),FS)=$E(HDR,4)
  1. .. S (HL("ECH"),ECH)=$P(HDR,FS,2)
  1. .. S $P(HDR,FS,8)=""
  1. .. I "FHS,BHS"[$E(HDR,1,3) D
  1. ... S HL("DTM")=$P(HDR,FS,7)
  1. ... S HL("MID")=$P(HDR,FS,11)
  1. ... S X2=$P(HDR,FS,9)
  1. ... S HL("PID")=$P(X2,$E(ECH),2)
  1. ... S HL("MTN")=$P($P(X2,$E(ECH),3),$E(ECH,4))
  1. ... S HL("ETN")=$P($P(X2,$E(ECH),3),$E(ECH,4),2)
  1. ... S HL("VER")=$P(X2,$E(ECH),4)
  1. ... I $P(HDR,FS,10)]"" S HLMSA="MSA"_FS_$P($P(HDR,FS,10),$E(HDR,5),1)_FS_$P(HDR,FS,12)_FS_$P($P(HDR,FS,10),$E(HDR,5),2)
  1. .. I $E(HDR,1,3)="MSH" D
  1. ... S HL("DTM")=$P(HDR,FS,7)
  1. ... S HL("MID")=$P(HDR,FS,10)
  1. ... S HL("PID")=$P(HDR,FS,11)
  1. ... S HL("MTN")=$P($P(HDR,FS,9),$E(ECH))
  1. ... S HL("ETN")=$P($P(HDR,FS,9),$E(ECH),2)
  1. ... S HL("VER")=$P(HDR,FS,12)
  1. ... S:$P(HDR,FS,15)]"" HL("ACAT")=$P(HDR,FS,15)
  1. ... S:$P(HDR,FS,16)]"" HL("APAT")=$P(HDR,FS,16)
  1. ... S:$P(HDR,FS,17)]"" HL("CC")=$P(HDR,FS,17)
  1. . ; If acknowledgement segment, set MSA equal to it
  1. . I $E(X1,1,3)="MSA",$G(HLMSA)="",$E($G(HDR),1,3)="MSH" S HLMSA=X1
  1. Q:'$D(HDR) -1
  1. ;
  1. I RTN["D " X RTN
  1. I RTN'["D " D
  1. . I RTN["^" X "D "_RTN
  1. . I RTN'["^" X "D ^"_RTN
  1. S HLRESLT=0 S:($D(HLERR)) HLRESLT="9^"_$G(^HL(771.7,9,0))
  1. ; update the status of child message
  1. I $G(HLMTIENS) D STATUS^HLTF0(HLMTIENS,$S(HLRESLT:4,1:3),$S(HLRESLT:+HLRESLT,1:""),$S($D(HLERR):HLERR,HLRESLT:$P(HLRESLT,"^",2),1:""))
  1. ; update the status of parent message
  1. D STATUS^HLTF0(HLMTIEN,$S(HLRESLT:4,1:3),$S(HLRESLT:+HLRESLT,1:""),$S(HLRESLT:$P(HLRESLT,"^",2),1:""))
  1. Q 0