APCD3MG ; IHS/CMI/LAB - install and generate HL7 messages to 3M ;
;;2.0;IHS PCC SUITE;;MAY 14, 2009
;
;
OK3M(V) ;EP - check visit for 3M
I '$G(V) Q "1^No visit ien passed"
I '$D(^AUPNVSIT(V,0)) Q "2^Invalid Visit passed"
I $P(^AUPNVSIT(V,0),"^",11) Q "3^Deleted visit passed"
I '$P(^AUPNVSIT(V,0),"^",9) Q "4^Visit has no dependent entries"
;I '$D(^AUPNVPOV("AD",V)) Q "5^No POV for this visit"
;check all POVs for provider narrative
;NEW X,% S (X,%)=0 F S X=$O(^AUPNVPOV("AD",V,X)) Q:X'=+X I $P(^AUPNVPOV(X,0),"^",4)="" S %="6^No Provider Narrative on POV "_X
S U="^"
;I % Q %
;NEW F S (F,X,%)=0 F S X=$O(^AUPNVPOV("AD",V,X)) Q:X'=+X!(F) I $$VAL^XBDIQ1(9000010.07,X,.01)=".9999",$P(^AUPNVPOV(X,0),"^",18)="" S F=1
;I 'F Q "13^No VPOV's with a .9999 diagnosis."
NEW P S P=$P(^AUPNVSIT(V,0),"^",5)
I 'P Q "7^No patient entered"
I '$D(^DPT(P)) Q "8^Invalid DPT entry"
I $P(^DPT(P,0),"^",2)="" Q "9^Sex of patient missing"
I $P(^DPT(P,0),"^",3)="" Q "10^DOB of patient missing"
NEW % S %="" D HOSPCHK I % Q %
Q 0
HOSPCHK ;
Q:$P(^AUPNVSIT(V,0),"^",7)'="H"
I '$D(^AUPNVINP("AD",V)) S %="11^No V HOSPITALIZATION Entry" Q
NEW H S H=$O(^AUPNVINP("AD",V,""))
I $P(^AUPNVINP(H,0),"^",6)="" S %="12^No discharge type entered on Hospitalization" Q
Q
;
GEN(APCDV) ;EP - generate HL7 message outbound to 3M
K APCDHL7M
S %=$$OK3M(APCDV) I $P(%,"^") S APCD3MER=% Q
NEW % S %=$$OK3M(APCDV) I $P(%,"^") S APCD3MER=% Q
Q
;
APCD3MG ; IHS/CMI/LAB - install and generate HL7 messages to 3M ;
+1 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
+2 ;
+3 ;
OK3M(V) ;EP - check visit for 3M
+1 IF '$GET(V)
QUIT "1^No visit ien passed"
+2 IF '$DATA(^AUPNVSIT(V,0))
QUIT "2^Invalid Visit passed"
+3 IF $PIECE(^AUPNVSIT(V,0),"^",11)
QUIT "3^Deleted visit passed"
+4 IF '$PIECE(^AUPNVSIT(V,0),"^",9)
QUIT "4^Visit has no dependent entries"
+5 ;I '$D(^AUPNVPOV("AD",V)) Q "5^No POV for this visit"
+6 ;check all POVs for provider narrative
+7 ;NEW X,% S (X,%)=0 F S X=$O(^AUPNVPOV("AD",V,X)) Q:X'=+X I $P(^AUPNVPOV(X,0),"^",4)="" S %="6^No Provider Narrative on POV "_X
+8 SET U="^"
+9 ;I % Q %
+10 ;NEW F S (F,X,%)=0 F S X=$O(^AUPNVPOV("AD",V,X)) Q:X'=+X!(F) I $$VAL^XBDIQ1(9000010.07,X,.01)=".9999",$P(^AUPNVPOV(X,0),"^",18)="" S F=1
+11 ;I 'F Q "13^No VPOV's with a .9999 diagnosis."
+12 NEW P
SET P=$PIECE(^AUPNVSIT(V,0),"^",5)
+13 IF 'P
QUIT "7^No patient entered"
+14 IF '$DATA(^DPT(P))
QUIT "8^Invalid DPT entry"
+15 IF $PIECE(^DPT(P,0),"^",2)=""
QUIT "9^Sex of patient missing"
+16 IF $PIECE(^DPT(P,0),"^",3)=""
QUIT "10^DOB of patient missing"
+17 NEW %
SET %=""
DO HOSPCHK
IF %
QUIT %
+18 QUIT 0
HOSPCHK ;
+1 IF $PIECE(^AUPNVSIT(V,0),"^",7)'="H"
QUIT
+2 IF '$DATA(^AUPNVINP("AD",V))
SET %="11^No V HOSPITALIZATION Entry"
QUIT
+3 NEW H
SET H=$ORDER(^AUPNVINP("AD",V,""))
+4 IF $PIECE(^AUPNVINP(H,0),"^",6)=""
SET %="12^No discharge type entered on Hospitalization"
QUIT
+5 QUIT
+6 ;
GEN(APCDV) ;EP - generate HL7 message outbound to 3M
+1 KILL APCDHL7M
+2 SET %=$$OK3M(APCDV)
IF $PIECE(%,"^")
SET APCD3MER=%
QUIT
+3 NEW %
SET %=$$OK3M(APCDV)
IF $PIECE(%,"^")
SET APCD3MER=%
QUIT
+4 QUIT
+5 ;