source: FOIAVistA/trunk/r/OUTPATIENT_PHARMACY-PSO-APSP-HUIP/PSOHLEXC.m@ 1635

Last change on this file since 1635 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 3.3 KB
Line 
1PSOHLEXC ;BIR/RTR-Process exceptions in HL7 message ;07/01/02
2 ;;7.0;OUTPATIENT PHARMACY;**111**;DEC 1997
3 ;External reference to ^PSDRUG supported by DBIA 221
4 ;External reference to ^VA(200 supported by DBIA 224
5 ;
6 ;Don't worry about ICN, just get it when you build message
7CHECK ;Check for application acknowledgement exceptions
8 I $G(HL("SAN"))="" S PSOEXMS="Missing sending application name." D NAK Q
9 S PSOHY("EXAPP")=HL("SAN")
10 I '$G(PSOHY("PAT"))!('$D(^DPT(+$G(PSOHY("PAT")),0))) S PSOEXMS="Invalid patient entry." D NAK Q
11 I +$P($G(^DPT(PSOHY("PAT"),.35)),"^") S PSOEXMS="Patient is deceased." D NAK Q
12 I $G(PSOHY("OCC"))'="NW" S PSOEXMS="Invalid Order Control Code." D NAK Q
13 I '$G(PSOHY("LOC")) S PSOEXMS="No Patient Location." D NAK Q
14 I $G(PSOHY("CHNUM"))="" S PSOEXMS="Missing CHCS Placer Order Number." D NAK Q
15 I $D(^PS(52.41,"C",PSOHY("CHNUM"),PSOHY("EXAPP"))) S PSOEXMS="Duplicate order number in Outpatient Pending file." D NAK Q
16 I $D(^PSRX("D",PSOHY("CHNUM"),PSOHY("EXAPP"))) S PSOEXMS="Duplicate order number in Outpatient Prescription file." D NAK Q
17 I $G(PSOHY("REF"))="" S PSOEXMS="Missing number of refills." D NAK Q
18 I $G(PSOHY("SDT"))="" S PSOEXMS="Missing effective date." D NAK Q
19 I '$G(PSOHY("ENTER")) S PSOEXMS="Missing Entered by data." D NAK Q
20 ;Drug exceptions
21 I '$G(PSOHY("DRUG"))!('$D(^PSDRUG(+$G(PSOHY("DRUG")),0))) S PSOEXMS="Invalid drug entry." D NAK Q
22 I $P($G(^PSDRUG(PSOHY("DRUG"),2)),"^",3)'["O" S PSOEXMS="Drug not marked for outpatient use." D NAK Q
23 I $P($G(^PSDRUG(PSOHY("DRUG"),"I")),"^"),$P($G(^("I")),"^")<DT S PSOEXMS="Drug is inactive." D NAK Q
24 I '$P($G(^PSDRUG(PSOHY("DRUG"),2)),"^") S PSOEXMS="Drug not associated with a Pharmacy Orderable Item." D NAK Q
25 S PSOHY("ITEM")=$P($G(^PSDRUG(PSOHY("DRUG"),2)),"^")
26 ;Provider exceptions
27CAN ;Also doing provider exceptions on the cancel message
28 I '$G(PSOHY("PROV")) S PSOEXMS="Invalid provider entry." D NAK Q
29 I '$P($G(^VA(200,PSOHY("PROV"),"PS")),"^") S PSOEXMS="Provider is not authorized to write med orders." D NAK Q
30 I '$D(^XUSEC("PROVIDER",PSOHY("PROV"))) S PSOEXMS="Provider does not hold the PROVIDER key." D NAK Q
31 N DA,DIC,DIQ,DR,X,Y
32 K ^UTILITY("DIQ1",$J) S DIC=200,DR="9.2;53.4",DA=PSOHY("PROV"),DIQ(0)="I" D EN^DIQ1
33 I $G(^UTILITY("DIQ1",$J,200,PSOHY("PROV"),9.2,"I")),$P($G(^("I")),"^")'>DT S PSOEXMS="Provider has a termination date." D NAK G END
34 I $G(^UTILITY("DIQ1",$J,200,PSOHY("PROV"),53.4,"I")),$P($G(^("I")),"^")'>DT S PSOEXMS="Provider has an inactive date." D NAK
35END K ^UTILITY("DIQ1",$J)
36 Q
37 Q
38ACK ;Send a positive acknowledgement of the order
39 I $G(HL("APAT"))'="AL" Q
40 K PSOEXMS
41 D MSH
42 S ^TMP("HLA",$J,1)="MSA"_HL("FS")_"AA"_HL("FS")_$G(HL("MID"))_HL("FS")_$G(PSOEXMS)
43 D SEND
44 Q
45NAK ;Send a negative acknowledgement of the order
46 S PSOEXXQ=1
47 I $G(HL("APAT"))'="AL" Q
48 D MSH
49 ;S ^TMP("HLA",$J,1)="MSA"_HL("FS")_$S($G(PSOHBDS):"AR",1:"AE")_HL("FS")_$G(HL("MID"))_HL("FS")_$G(PSOEXMS)
50 ;For now, always sending back the AA, not the AR or AE
51 S ^TMP("HLA",$J,1)="MSA"_HL("FS")_"AA"_HL("FS")_$G(HL("MID"))_HL("FS")_$G(PSOEXMS)
52 ;Sending AR back for missing segments, AE for other data validations
53 D SEND
54 Q
55MSH ;
56 K ^TMP("HLA",$J)
57 S PSOHEID=$G(HL("EID")),PSOHEIDS=$G(HL("EIDS"))
58 S PSOHLRS=""
59 ;Vista HL7 will build the MSH
60 Q
61SEND ;
62 D GENACK^HLMA1(PSOHEID,HLMTIENS,PSOHEIDS,"GM",1,.PSOHLRS)
63 K ^TMP("HLA",$J)
64 Q
Note: See TracBrowser for help on using the repository browser.