PRCVIBH ;WOIFO/DST - Issue Book Processing, from DynaMed to IFCAP ;7/26/05 17:10 ;;5.1;IFCAP;**81,86**;Oct 20, 2000 ;Per VHA Directive 10-93-142, this routine should not be modified. ; ; IV - Internal Voucher, SV - Standard Voucher Q CRT ; Process Issue Book transactions sent from DynaMed to IFCAP K HLERR N %,PRCVDT,PRCVI,PRCVJ,PRCVK,PRCVIBF,PRCVSUB,PRCVSITE D:'$D(U) DT^DICRW D NOW^%DTC S PRCVDT=% S PRCVSUB="PRCVFMS2;"_HL("MID") K ^TMP(PRCVSUB),^TMP($J,"PRCVIB") F PRCVI=1:1 X HLNEXT Q:HLQUIT'>0 D . S ^TMP($J,"PRCVIB",PRCVI)=HLNODE,PRCVJ=0 . F S PRCVJ=$O(HLNODE(PRCVJ)) Q:'PRCVJ S ^TMP($J,"PRCVIB",PRCVI,PRCVJ)=HLNODE(PRCVJ) . Q ; MAIN ; Main routine ; Check HL7 message type and message event ; PRCVEA - Error message array ; PRCVTDT - Transaction Date ; PRCVDAC - Document Action N PRCVFS,PRCVRS,PRCVCS,PRCVES,PRCVSS,PRCVCC,PRCVSCC N PRCVEA,PRCVTDT,PRCVBID,PRCVLID,PRCVND,PRCVSEG,PRCVY,X,X1,X2 ; S PRCVK=0 S PRCVFS=$G(HL("FS")),PRCVCS=$E($G(HL("ECH"))),PRCVRS=$E($G(HL("ECH")),2),PRCVES=$E($G(HL("ECH")),U,3),PRCVSS=$E($G(HL("ECH")),U,4) ; HEADER I HL("MTN")'="DFT"!(HL("ETN")'="P03") D Q . D ADDERR("PRCV1"_U_"Wrong Message or Event Type: "_HL("MTN")_U_HL("ETN")) . D GENACK("AR",HL("MID"),PRCVDT,.PRCVEA) . Q ; S X1=$P(PRCVDT,"."),X2=14 D C^%DTC S ^TMP(PRCVSUB,$J,0)=X_U_$P(PRCVDT,".")_"^IB Sent from DynaMed to IFCAP" ; ; Check each segments - EVN,PID,FT1 ; PRCVTCD - Transaction Code - "IV" or "SV" ; PRCVSTN - Station Number ; START N PREVSEG,PRCVSTN,PRCVDAC,PRCVTDT,PRCVTCD S PRCVSITE=$$GET1^DIQ(4,$$KSP^XUPARAM("INST")_",",99) S PREVSEG="" S PRCVI=0 D NOW^%DTC S PRCVDT=% F S PRCVI=$O(^TMP($J,"PRCVIB",PRCVI)) Q:'PRCVI D . S PRCVND=$G(^TMP($J,"PRCVIB",PRCVI)) . S PRCVSEG=$P(PRCVND,PRCVFS) . Q:PRCVSEG="MSH"!(PRCVSEG="") . I $$CHKSEQ(PRCVSEG) K ^TMP($J,"PRCVIB") S PRCVI="" Q . S PREVSEG=PRCVSEG . D @PRCVSEG . Q I PRCVSEG'="FT1" D ADDERR("PRCV1"_U_"No Item line for this transaction.") ; ; If errored, send AE ACK, clean up and QUIT ERR I $D(PRCVEA)!(PRCVTCD']"") D XTMP("AE"),FIN Q OK ; Calling IFCAP and FMS routines for Issue Book and FMS update ; I PRCVTCD="SV" D . I '$$ENT^PRCVFMS2(PRCVSUB) D .. D ADDERR("PRCV3"_U_"Error in generating FMS Code Sheet.") .. D XTMP("AE") .. Q . Q I PRCVTCD="IV" D . S PRCVIBF=$$INIT^PRCVIBF(PRCVSUB) . ; PRCVIBF - return "IEN of 410^Error Code^Error Description" . ; If errored, move ^TMP to ^XTMP and quit . I '+PRCVIBF D Q .. D ADDERR("PRCV3"_U_$P(PRCVIBF,U,2)_"-"_$P(PRCVIBF,U,3)) .. D XTMP("AE") .. Q . I '$$ENT^PRCVFMS1(PRCVSUB,+PRCVIBF) D .. D ADDERR("PRCV3"_U_"Error in generating FMS Code Sheet.") .. D XTMP("AE") .. Q . Q ; I '$D(PRCVEA) D GENACK("AA",HL("MID"),PRCVDT) D FIN Q ; CHKSEQ(SEG) ; SEG - Segment name N SEGERR,PREV1,PREV2,PRCVER1 S SEGERR=0 S PREV1=$P($P($T(@(SEG_1)),";;",2),U) S PREV2=$P($P($T(@(SEG_1)),";;",2),U,2) I PREVSEG=PREV1!(PREVSEG=PREV2) Q SEGERR S SEGERR=1 S PRCVER1=$P($P($T(@(SEG_1)),";;",2),U,4)_SEG D ADDERR("PRCV1"_U_PRCVER1) Q SEGERR ; EVN ; Process EVN segment ; S PRCVSTN=$P(PRCVND,PRCVFS,8) I PRCVSTN']"" D ADDERR("PRCV2"_U_"Station Number is missing.",8) I PRCVSTN'=PRCVSITE D ADDERR("PRCV2"_U_"Invalid Station Number: "_PRCVSTN,8) S PRCVDAC=$P(PRCVND,PRCVFS,5) I "EMX"'[PRCVDAC!(PRCVDAC']"") D ADDERR("PRCV2"_U_"Invalid Document Action: "_PRCVDAC,5) S PRCVTDT=$P(PRCVND,PRCVFS,3) I PRCVTDT']"" D ADDERR("PRCV2"_U_"Transaction Date is missing.",3) Q S PRCVTDT=$$HL7TFM^XLFDT(PRCVTDT,"L",0) I $P(PRCVTDT,".")>PRCVDT D ADDERR("PRCV2"_U_"Invalid Transaction Date: "_PRCVTDT,3) Q ; PID ; Process PID segment ; N PRCVDUZ,PRCVFCP1,PRCVFCP2,PRCVBOC,PRCVTERM ; S PRCVBID=$P(PRCVND,PRCVFS,4) I PRCVBID']"" D ADDERR("PRCV2"_U_"Batch ID is missing.",4) S PRCVTCD=$P(PRCVND,PRCVFS,5) I PRCVTCD']"" D ADDERR("PRCV2"_U_"Transaction Code is missing.",5) I PRCVTCD'="IV",(PRCVTCD'="SV") D ADDERR("PRCV2"_U_"Invalid Transaction Code: "_PRCVTCD,5) ; Check User ID, Termination Date and is authorized FCP user S PRCVDUZ=$P(PRCVND,PRCVFS,3) I PRCVDUZ']"" D ADDERR("PRCV2"_U_"User ID is missing.",3) I PRCVDUZ]"" D . I '$$FIND1^DIC(200,"","","`"_PRCVDUZ,"","","PRCVERR") D ADDERR("PRCV2"_U_"Invalid User ID: "_PRCVDUZ,3) . E D .. S PRCVTERM=$$GET1^DIQ(200,PRCVDUZ_",",9.2,"I") .. I +PRCVTERM>0,(PRCVTERM