EDPMAIL ;SLC/KCM - Process incoming mail for posted events ; 10/19/21 9:50am
;;2.0;EMERGENCY DEPARTMENT;**16**;May 2, 2012;Build 6
;
MSG(MSG) ; parse message passed in from SEND^EDPFMON
N I,PARAM,LOG,ORIFN,EDPDBUG
S EDPDBUG=$$DEBUG^EDPCDBG("messages")
I EDPDBUG D PUTREQ^EDPCDBG(EDPDBUG,.MSG)
;
S I=0 F S I=$O(MSG(I)) Q:'I S PARAM($P(MSG(I),"="))=$P(MSG(I),"=",2,99)
S LOG=$$VAL("id"),ORIFN=$$VAL("orifn")
I $$VAL("command")="newOrder" D NEW
I $$VAL("command")="updateOrder" D UPD
I $$VAL("command")="deleteOrder" D DEL
I $$VAL("command")="verifyOrder" D VER
I $$VAL("command")="completeOrder" D COMP
I $$VAL("command")="patientCheckIn" D CHKIN
I $$VAL("command")="convertVisit" D VST^EDPCONV(.PARAM)
I $$VAL("command")="convertConfiguration" D CONFIG^EDPCONV1(.PARAM)
Q
;
NEW ; add new order
Q:'LOG Q:'ORIFN
N X,Y,DIC,DA
S DIC="^EDP(230,"_LOG_",8,",DIC(0)="LZ",DA(1)=LOG,X=+ORIFN
S DIC("DR")=".02///"_$$VAL("pkg")_";.03///"_$$VAL("sts")_";.05///"_$$VAL("release")
S:$$VAL("stat") DIC("DR")=DIC("DR")_";.04///1"
D FILE^DICN
Q
UPD ; update order
Q:'LOG Q:'ORIFN Q:'$L($$VAL("sts"))
N IEN S IEN=$$FIND Q:IEN<1
I $D(^EDP(230,LOG,8,+IEN,0)) S $P(^(0),U,3)=$$VAL("sts")
Q
DEL ; delete order
Q:'LOG Q:'ORIFN
N DIK,DA
S DA=$$FIND Q:DA<1
S DIK="^EDP(230,"_LOG_",8,",DA(1)=LOG
D ^DIK
Q
VER ; verify order
Q:'LOG Q:'ORIFN
N IEN S IEN=$$FIND Q:IEN<1
I $P($G(^EDP(230,LOG,8,IEN,0)),U,3)'="C" S $P(^(0),U,3)="A"
Q
COMP ; complete order
Q:'LOG Q:'ORIFN
N IEN S IEN=$$FIND Q:IEN<1
S $P(^EDP(230,LOG,8,IEN,0),U,3)="C"
Q
;
FIND() ; -- return ien of ORIFN in multiple
N Y S Y=+$O(^EDP(230,LOG,8,"B",+ORIFN,0))
Q Y
;
VAL(X) ; -- return parameter value or null if undefined
Q $G(PARAM(X))
;
CHKIN ; check in a patient
Q:'$$VAL("dfn") Q:'$$VAL("ssn") Q:'$L($$VAL("ptNm")) Q:'$L($$VAL("site"))
N NEWPT,EDPFAIL
S NEWPT="dfn="_$$VAL("dfn")_$C(9)_"name="_$$VAL("ptNm")_$C(9)_"dob="_$$VAL("dob")_$C(9)_"ssn="_$$VAL("ssn")_$C(9)_"clinic="_$$VAL("hloc")
S NEWPT=NEWPT_$C(9)_"create=1" ; set Creation Source to Scheduling
N AREA
S AREA=$O(^EDPB(231.9,"C",$$VAL("site"),0)) Q:'AREA
N EDPXML,EDPSITE,EDPSTA
S EDPUSER=DUZ,EDPSITE=DUZ(2),EDPSTA=$$STA^XUAF4(DUZ(2))
S EDPFAIL=$$ADD^EDPLOGA(NEWPT,AREA,$$VAL("time"),0)
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HEDPMAIL 2326 printed Nov 22, 2024@17:02:13 Page 2
EDPMAIL ;SLC/KCM - Process incoming mail for posted events ; 10/19/21 9:50am
+1 ;;2.0;EMERGENCY DEPARTMENT;**16**;May 2, 2012;Build 6
+2 ;
MSG(MSG) ; parse message passed in from SEND^EDPFMON
+1 NEW I,PARAM,LOG,ORIFN,EDPDBUG
+2 SET EDPDBUG=$$DEBUG^EDPCDBG("messages")
+3 IF EDPDBUG
DO PUTREQ^EDPCDBG(EDPDBUG,.MSG)
+4 ;
+5 SET I=0
FOR
SET I=$ORDER(MSG(I))
if 'I
QUIT
SET PARAM($PIECE(MSG(I),"="))=$PIECE(MSG(I),"=",2,99)
+6 SET LOG=$$VAL("id")
SET ORIFN=$$VAL("orifn")
+7 IF $$VAL("command")="newOrder"
DO NEW
+8 IF $$VAL("command")="updateOrder"
DO UPD
+9 IF $$VAL("command")="deleteOrder"
DO DEL
+10 IF $$VAL("command")="verifyOrder"
DO VER
+11 IF $$VAL("command")="completeOrder"
DO COMP
+12 IF $$VAL("command")="patientCheckIn"
DO CHKIN
+13 IF $$VAL("command")="convertVisit"
DO VST^EDPCONV(.PARAM)
+14 IF $$VAL("command")="convertConfiguration"
DO CONFIG^EDPCONV1(.PARAM)
+15 QUIT
+16 ;
NEW ; add new order
+1 if 'LOG
QUIT
if 'ORIFN
QUIT
+2 NEW X,Y,DIC,DA
+3 SET DIC="^EDP(230,"_LOG_",8,"
SET DIC(0)="LZ"
SET DA(1)=LOG
SET X=+ORIFN
+4 SET DIC("DR")=".02///"_$$VAL("pkg")_";.03///"_$$VAL("sts")_";.05///"_$$VAL("release")
+5 if $$VAL("stat")
SET DIC("DR")=DIC("DR")_";.04///1"
+6 DO FILE^DICN
+7 QUIT
UPD ; update order
+1 if 'LOG
QUIT
if 'ORIFN
QUIT
if '$LENGTH($$VAL("sts"))
QUIT
+2 NEW IEN
SET IEN=$$FIND
if IEN<1
QUIT
+3 IF $DATA(^EDP(230,LOG,8,+IEN,0))
SET $PIECE(^(0),U,3)=$$VAL("sts")
+4 QUIT
DEL ; delete order
+1 if 'LOG
QUIT
if 'ORIFN
QUIT
+2 NEW DIK,DA
+3 SET DA=$$FIND
if DA<1
QUIT
+4 SET DIK="^EDP(230,"_LOG_",8,"
SET DA(1)=LOG
+5 DO ^DIK
+6 QUIT
VER ; verify order
+1 if 'LOG
QUIT
if 'ORIFN
QUIT
+2 NEW IEN
SET IEN=$$FIND
if IEN<1
QUIT
+3 IF $PIECE($GET(^EDP(230,LOG,8,IEN,0)),U,3)'="C"
SET $PIECE(^(0),U,3)="A"
+4 QUIT
COMP ; complete order
+1 if 'LOG
QUIT
if 'ORIFN
QUIT
+2 NEW IEN
SET IEN=$$FIND
if IEN<1
QUIT
+3 SET $PIECE(^EDP(230,LOG,8,IEN,0),U,3)="C"
+4 QUIT
+5 ;
FIND() ; -- return ien of ORIFN in multiple
+1 NEW Y
SET Y=+$ORDER(^EDP(230,LOG,8,"B",+ORIFN,0))
+2 QUIT Y
+3 ;
VAL(X) ; -- return parameter value or null if undefined
+1 QUIT $GET(PARAM(X))
+2 ;
CHKIN ; check in a patient
+1 if '$$VAL("dfn")
QUIT
if '$$VAL("ssn")
QUIT
if '$LENGTH($$VAL("ptNm"))
QUIT
if '$LENGTH($$VAL("site"))
QUIT
+2 NEW NEWPT,EDPFAIL
+3 SET NEWPT="dfn="_$$VAL("dfn")_$CHAR(9)_"name="_$$VAL("ptNm")_$CHAR(9)_"dob="_$$VAL("dob")_$CHAR(9)_"ssn="_$$VAL("ssn")_$CHAR(9)_"clinic="_$$VAL("hloc")
+4 ; set Creation Source to Scheduling
SET NEWPT=NEWPT_$CHAR(9)_"create=1"
+5 NEW AREA
+6 SET AREA=$ORDER(^EDPB(231.9,"C",$$VAL("site"),0))
if 'AREA
QUIT
+7 NEW EDPXML,EDPSITE,EDPSTA
+8 SET EDPUSER=DUZ
SET EDPSITE=DUZ(2)
SET EDPSTA=$$STA^XUAF4(DUZ(2))
+9 SET EDPFAIL=$$ADD^EDPLOGA(NEWPT,AREA,$$VAL("time"),0)
+10 QUIT