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

BADECTRL.m

Go to the documentation of this file.
BADECTRL ; IHS/OIT/FJE/VAC - Dentrix HL7 PROCESS INCOMING EIE MESSAGES ;14-Sep-2010 13:27;EDR
 ;;1.0;DENTAL/EDR INTERFACE;**1**;AUG 22, 2011
 ;; Modified - IHS/MSC/PLS,AMF - 1/12/2011 - receive inbound messages from multiple Dentrix messages
 ;;
 Q
 ;IHS/MSC/AMF 1/12/2011 Modification to support multiple Dentrix messages 
TSK ;EP 
 N MSGDT,MSGTYP,MSGEVT,MSGIEN,QNM,QIEN,PDAYS
 S QNM="RPMS-DEN"
 Q:'$$GETIEN^HLOAPP(QNM)  ;The RPMS-DEN entry in HLO APPLICATION REGISTRY is missing.
 S MSGDT=""
 F  S MSGDT=$O(^HLB("QUEUE","IN",MSGDT)) Q:MSGDT=""  D
 .S MSGTYP=""
 .F  S MSGTYP=$O(^HLB("QUEUE","IN",MSGDT,QNM,MSGTYP)) Q:MSGTYP=""  D
 ..S MSGEVT=""
 ..F  S MSGEVT=$O(^HLB("QUEUE","IN",MSGDT,QNM,MSGTYP,MSGEVT)) Q:MSGEVT=""  D
 ...S MSGIEN=""
 ...F  S MSGIEN=$O(^HLB("QUEUE","IN",MSGDT,QNM,MSGTYP,MSGEVT,MSGIEN)) Q:MSGIEN=""  D
 ....D PROC(MSGIEN)
 Q
 ; Process a single message
PROC(MSGIEN) ;EP
 N PDAYS
 S PDAYS=+$$GET^XPAR("ALL","BADE EDR DEFAULT PURGE DAYS")
 W !,"PDAYS=",PDAYS
 S:'PDAYS PDAYS=7  ;Set default of 7 days
 S ER=""
 D PROCNOW^HLOAPI3(MSGIEN,$$FMADD^XLFDT($$NOW^XLFDT,PDAYS),ER)
 W !,"ERROR=",ER
 K ^HLB("QUEUE","IN",MSGDT,QNM,MSGTYP,MSGEVT,MSGIEN)  ;Remove from "IN" queue
 Q
 ; ----- end IHS/MSC/AMF 1/12/2011 
TSK1 ;This is the code to process DFT/P03 message
 ;This code used to be dot code from previous call
 S:$P(^HLB(BADEIEN,0),U,5)="" $P(^HLB(BADEIEN,0),U,5)="HLO RPMS"
 S:$P(^HLB(BADEIEN,0),U,6)="" $P(^HLB(BADEIEN,0),U,6)="CHARGE RPMS"
 S HLMSGIEN=BADEIEN
 D PROC^BADEHL3
 S X="T+7" D ^%DT
 S $P(^HLB(BADEIEN,0),U,9)=+Y_".1201"
 S $P(^HLB(BADEIEN,0),U,20)="SU"
 S BADETDT=$P(^HLB(BADEIEN,0),U,16)
 I $L(BADETDT) K ^HLB("QUEUE",BADETDT,"RPMS-DEN",BADETYP,BADETRG,BADEIEN)
 Q
 ;
SINGLE ;
 S DIR(0)="N",DIR("A")="Enter HLB IEN to test" D ^DIR K DIR
 Q:Y="^"  S BADEIEN=Y
 Q:'$D(^HLB(BADEIEN,0))
 Q:'$D(^HLB(BADEIEN,1))
 Q:'$D(^HLB(BADEIEN,2))
 D INIT
 S U="^"
 D
 .S BADEX=$G(^HLB(BADEIEN,0))
 .Q:$P(BADEX,U,4)'="I"  ;If message is other than inbound
 .Q:$L($P(BADEX,U,20))  ;If present then message previously processed
 .S BADEMSH=$G(^HLB(BADEIEN,1))_$G(^HLB(BADEIEN,2))
 .S U1=$E(BADEMSH,4,4)
 .S BADESF=$P(BADEMSH,U1,4) Q:'$L(BADESF)
 .S BADESA=$P(BADEMSH,U1,3) Q:'$L(BADESA)
 .Q:BADESF'="Dental"
 .Q:BADESA'="DENTRIX"
 .S BADETYP=$P(BADEMSH,U1,9)
 .S BADETRG=$P(BADETYP,U,2),BADETYP=$P(BADETYP,U,1)
 .Q:'$L(BADETYP)
 .Q:'$L(BADETRG)
 .Q:BADETYP'="DFT"
 .Q:BADETRG'="P03"
 .S:$P(^HLB(BADEIEN,0),U,5)="" $P(^HLB(BADEIEN,0),U,5)="HLO RPMS"
 .S:$P(^HLB(BADEIEN,0),U,6)="" $P(^HLB(BADEIEN,0),U,6)="CHARGE RPMS"
 .;D @BADERUN
 .S HLMSGIEN=BADEIEN
 .D PROC^BADEHL3
 .S X="T+7" D ^%DT
 .S $P(^HLB(BADEIEN,0),U,9)=+Y_".1201"
 .S $P(^HLB(BADEIEN,0),U,20)="SU"
 .S BADETDT=$P(^HLB(BADEIEN,0),U,16)
 .I $L(BADETDT) K ^HLB("QUEUE",BADETDT,"RPMS-DEN",BADETYP,BADETRG,BADEIEN)
 D EXIT
 Q
 ;
INIT ;EP initialize variables
 D ^XBKVAR
 Q
 ;
CTRL ;EP create control array
 S X=0 F  S X=$O(^BADECTRL(X)) Q:+X=0  D
 .S BADECACT=$P($G(^BADECTRL(X,0)),U,2)
 .S BADECRF=$P($G(^BADECTRL(X,0)),U,9)
 .S BADECSA=$P($G(^BADECTRL(X,0)),U,4)
 .S BADECSF=$P($G(^BADECTRL(X,0)),U,3)
 .S BADECTYP=$P($G(^BADECTRL(X,0)),U,5)
 .S BADECTRG=$P($G(^BADECTRL(X,0)),U,6)
 .S BADECTAG=$P($G(^BADECTRL(X,0)),U,7)
 .S BADECRTN=$P($G(^BADECTRL(X,0)),U,8)
 .S BADECLNK=$P($G(^BADECTRL(X,0)),U,10)
 .S BADECQUE=$P($G(^BADECTRL(X,2)),U,1)
 .Q:BADECACT'=1
 .I (BADECRF="")!(BADECSA="")!(BADECSF="")!(BADECTYP="")!(BADECTRG="") Q
 .I (BADECTAG="")!(BADECRTN="")!(BADECLNK="")!(BADECQUE="") Q
 .I '$D(BADETMP(BADECRF,BADECSF,BADECSA,BADECTYP,BADECTRG,X)) D
 ..S BADETMP(BADECRF,BADECSF,BADECSA,BADECTYP,BADECTRG,X)=BADECTAG_"^"_BADECRTN
 ..I $G(BADEQUET)'=1 W !,BADETMP(BADECRF,BADECSF,BADECSA,BADECTYP,BADECTRG,X)
 Q
 ;
SCAN ;EP scan HLB global for new incoming messages
 S U="^"
 ;change to queue node
 S BADEIEN=0 F  S BADEIEN=$O(^HLB(BADEIEN)) Q:+BADEIEN=0  D
 .S BADEX=$G(^HLB(BADEIEN,0))
 .Q:$P(BADEX,U,4)'="I"  ;If message is other than inbound
 .Q:+$P(BADEX,U,20)  ;If DATETIME present then message previously processed
 .I $G(BADEQUET)'=1 W !,"Inbound Message:  ",BADEIEN
 .S BADEMSH=$G(^HLB(BADEIEN,1))_$G(^HLB(BADEIEN,2))
 .S U1=$E(BADEMSH,4,4)
 .S BADERF=$P(BADEMSH,U1,5) Q:'$L(BADERF)  Q:'$D(BADETMP(BADERF))
 .S BADESF=$P(BADEMSH,U1,4) Q:'$L(BADESF)  Q:'$D(BADETMP(BADERF,BADESF))
 .S BADESA=$P(BADEMSH,U1,3) Q:'$L(BADESA)  Q:'$D(BADETMP(BADERF,BADESF,BADESA))
 .S BADETYP=$P(BADEMSH,U1,9)
 .S BADETRG=$P(BADETYP,U,2),BADETYP=$P(BADETYP,U,1)
 .Q:'$L(BADETYP)  Q:'$D(BADETMP(BADERF,BADESF,BADESA,BADETYP))
 .Q:'$L(BADETRG)  Q:'$D(BADETMP(BADERF,BADESF,BADESA,BADETYP,BADETRG))
 .S BADEY=0,BADEY=$O(BADETMP(BADERF,BADESF,BADESA,BADETYP,BADETRG,BADEY)) Q:+BADEY=0  D
 ..S BADERUN=BADETMP(BADERF,BADESF,BADESA,BADETYP,BADETRG,BADEY)
 ..Q:$P(BADERUN,U,1)=""
 ..Q:$P(BADERUN,U,2)=""
 ..I $G(BADEQUET)'=1 W !,BADERF_U1_BADESF_U1_BADESA_U1_BADETYP_U1_BADETRG_U1_BADEY_U1_BADERUN
 ..S:$P(^HLB(BADEIEN,0),U,5)="" $P(^HLB(BADEIEN,0),U,5)=BADECLNK
 ..S:$P(^HLB(BADEIEN,0),U,6)="" $P(^HLB(BADEIEN,0),U,6)=BADECQUE
 ..;S:$P(^HLB(BADEIEN,0),U,7)="" $P(^HLB(BADEIEN,0),U,7)=$P(BADERUN,U,1)
 ..;S:$P(^HLB(BADEIEN,0),U,8)="" $P(^HLB(BADEIEN,0),U,8)=$P(BADERUN,U,2)
 ...D @BADERUN
 ..;I $G(BADEQUET)'=1 W:Y=1 !,"Message processed successfully" H 2
 ..;I $G(BADEQUET)'=1 W:Y=0 !,ERROR H 2
 Q
 ;
EXIT ;EP clean up
 D ^XBKVAR
 K BADETMP,BADEX,BADEY,BADERUN,BADERF,BADESF,BADESA,BADETYP,BADETRG
 K BADECRF,BADECSF,BADECSA,BADECTYP,BADECTRG
 K ^BADECTRL("TASK RUNNING")
 Q
 ;