| 1 | SPNHL71 ;WDE/SAN-DIEGO;validate then build the segments | 
|---|
| 2 | ;;2.0;Spinal Cord Dysfunction;**10**;01/02/97 | 
|---|
| 3 | CHK(SPNFD0) ; | 
|---|
| 4 | ;      Called from the edit routine spnfedt0 | 
|---|
| 5 | ;      Check entry and create the hl7 message | 
|---|
| 6 | ;      that is associated with file 154.1 | 
|---|
| 7 | ; NOTE spnifn is the entry in 154.1 | 
|---|
| 8 | ;-------------------------------------------------------------------- | 
|---|
| 9 | ;check record type | 
|---|
| 10 | S SPNCHK=$$GET1^DIQ(154.1,SPNFD0_",",.02) | 
|---|
| 11 | I $G(SPNCHK)="" D ZAP Q | 
|---|
| 12 | ;check record date | 
|---|
| 13 | S SPNCHK=$$GET1^DIQ(154.1,SPNFD0_",",.04) | 
|---|
| 14 | I $G(SPNCHK)="" D ZAP Q | 
|---|
| 15 | ;the record passed the test and we want it | 
|---|
| 16 | CREATE ;this label is also called from the tag auto | 
|---|
| 17 | S SPNFDFN=$$GET1^DIQ(154.1,SPNFD0_",",.01,"I") | 
|---|
| 18 | D EN^SPNHPID(SPNFDFN) | 
|---|
| 19 | D EN^SPNHL2(SPNFD0)  ;build the message | 
|---|
| 20 | ;at this point we have the HL7 and want to send it | 
|---|
| 21 | D INIT^SPNHL7 | 
|---|
| 22 | I HLDAP="" D ZAP Q  ;init didn't find the HL7 interface | 
|---|
| 23 | I $P($G(^HL(771,HLDAP,0)),U,2)'="a" D ZAP Q  ;test for active/on | 
|---|
| 24 | D SEND^SPNHL7 | 
|---|
| 25 | ZAP ; | 
|---|
| 26 | K SPNFDFN,X,Y,HL,HLA,SPMSG,SPNTMP,HLA,HL,HLP,SPTMP,HLSAN,OBXCNT,OBRCNT,HLARYTYP,HLECH,HLFORMAT,HLFS,HLMTIEN,HLN,HLQ,HLRESLT | 
|---|
| 27 | Q | 
|---|
| 28 | AUTO ;  Note that spnifn should be the patients dfn | 
|---|
| 29 | ;--------------------------------------------------------------------- | 
|---|
| 30 | ;this tag is called from the SPNHL7 line auto and then some | 
|---|
| 31 | ;its function is to load all entrys for a particular patient | 
|---|
| 32 | ;You must know the dfn to entry here. | 
|---|
| 33 | S SPNFD0=0 F  S SPNFD0=$O(^SPNL(154.1,"B",SPNIFN,SPNFD0)) Q:(SPNFD0="")!('+SPNFD0)  D | 
|---|
| 34 | .D CHK(SPNFD0) | 
|---|
| 35 | .Q | 
|---|