DGCLAPI1 ;ALB/TMK - Utilities for OEF/OIF/UNKNOWN OEF/OIF conflict loc; 10/20/05
;;5.3;Registration;**673,1015**;Aug 13, 1993;Build 21
Q
;
OEIFUPD(DGDFN,DGOEIF) ;
;Entry point for OEF, OIF, UNKNOWN OEF/OIF conflict data
; updates via the ZMH HL7 message upload.
;
; Input:
; DGDFN - PATIENT file (#2) IEN
; DGOEIF - update values array passed by reference
; DGOEIF("COUNT") - count of the # of entries
; DGOEIF("LOC") - Conflict Location Indicator
; DGOEIF("FR") - OEF/OIF/UNKNOWN OEF/OIF Date From
; DGOEIF("TO") - OEF/OIF/UNKNOWN OEF/OIF Date To
; DGOEIF("SITE") - Source of data (ptr to file 4 or null for CEV)
;
; Output:
; Function result 1-success, 0-failure
;
N DA,DIC,DIK,DGRSLT,DGX,DGX1,DGARY,DGCHG,X,Y,DO,DD
;
S DGCHG=0,DGRSLT=1,DGDFN=+$G(DGDFN)
I DGDFN>0,$D(^DPT(DGDFN)),$$CHANGE(DGDFN,.DGOEIF) S DGCHG=1
; If changes found, delete the existing data, add new records
I DGCHG D
. S DGRSLT=0
. S DA=0 F S DA=$O(^DPT(DGDFN,.3215,DA)) Q:'DA S DA(1)=DGDFN,DIK="^DPT("_DA(1)_",.3215," D ^DIK
. F DGX="LOC","FR","TO","LOCK","SITE" S DGX1=0 F S DGX1=$O(DGOEIF(DGX,DGX1)) Q:'DGX1 S DGARY(DGX1,DGX)=DGOEIF(DGX,DGX1)
. S DGX=0 F S DGX=$O(DGARY(DGX)) Q:'DGX D Q:'DGRSLT
.. ; Add a new entry
.. S DIC(0)="L",DIC("DR")=".02////"_$G(DGARY(DGX,"FR"))_";.03////"_$G(DGARY(DGX,"TO"))_";.04////1"_$S($G(DGARY(DGX,"SITE"))'="":";.06////"_DGARY(DGX,"SITE"),1:"")
.. S DA(1)=DGDFN,DIC="^DPT("_DA(1)_",.3215,"
.. S X=$G(DGARY(DGX,"LOC")),X=$S(X="OIF":1,X="OEF":2,X="UNK":3,1:"") I X D FILE^DICN K DIC S DGRSLT=(Y>0)
Q DGRSLT
;
CHANGE(DGDFN,DGOEIF) ;Did the data change?
; Input
; DGDFN - Patients DFN
; DGOEIF("COUNT") - the count of the # of entries in the multiple
; DGOEIF("LOC",n)=Conflict Location Indicator
; DGOEIF("FR",n)=OEF/OIF/UNKNOWN OEF/OIF Date From
; DGOEIF("TO",n)=OEF/OIF/UNKNOWN OEF/OIF Date To
; DGOEIF("LOCK")=Lock flag for HEC data
; DGOEIF("site",n)=Source of data if a site or null if CEV
;
; Output
; Returns 0 if no status change
; 1 if status changed
;
N DGCHG,DGOEIFO,DGX,DGX1,Z
;
I +$G(DGDFN)'>0 Q 0
S DGOEIF("COUNT")=$G(DGOEIF("COUNT"))
S DGCHG=0
I 'DGOEIF("COUNT"),'$O(^DPT(DGDFN,.3215,0)) S DGCHG=0 G CHNGQ
S Z=+$$GET^DGENOEIF(DGDFN,.DGOEIFO,0)
I DGOEIF("COUNT")'=Z S DGCHG=1 G CHNGQ
S Z=0 F S Z=$O(DGOEIFO("LOC",Z)) Q:'Z S DGOEIFO("LOC",Z)=$E($$EXTERNAL^DILFD(2.3215,.01,,+DGOEIFO("LOC",Z)),1,3)
S DGX="" F S DGX=$O(DGOEIF(DGX)) Q:DGX=""!DGCHG D Q:DGCHG
. S DGX1=0 F S DGX1=$O(DGOEIF(DGX,DGX1)) Q:'DGX1 D Q:DGCHG
.. I DGX="SITE",$S($G(DGOEIF("SITE",DGX1))="":$G(DGOEIFO("SITE",DGX1))="CEV",1:0) Q
.. I DGX="LOCK",$G(DGOEIFO("LOCK",DGX1))=1 Q
.. I $G(DGOEIFO(DGX,DGX1))'=$G(DGOEIF(DGX,DGX1)) S DGCHG=1 Q
CHNGQ Q DGCHG
;
DGCLAPI1 ;ALB/TMK - Utilities for OEF/OIF/UNKNOWN OEF/OIF conflict loc; 10/20/05
+1 ;;5.3;Registration;**673,1015**;Aug 13, 1993;Build 21
+2 QUIT
+3 ;
OEIFUPD(DGDFN,DGOEIF) ;
+1 ;Entry point for OEF, OIF, UNKNOWN OEF/OIF conflict data
+2 ; updates via the ZMH HL7 message upload.
+3 ;
+4 ; Input:
+5 ; DGDFN - PATIENT file (#2) IEN
+6 ; DGOEIF - update values array passed by reference
+7 ; DGOEIF("COUNT") - count of the # of entries
+8 ; DGOEIF("LOC") - Conflict Location Indicator
+9 ; DGOEIF("FR") - OEF/OIF/UNKNOWN OEF/OIF Date From
+10 ; DGOEIF("TO") - OEF/OIF/UNKNOWN OEF/OIF Date To
+11 ; DGOEIF("SITE") - Source of data (ptr to file 4 or null for CEV)
+12 ;
+13 ; Output:
+14 ; Function result 1-success, 0-failure
+15 ;
+16 NEW DA,DIC,DIK,DGRSLT,DGX,DGX1,DGARY,DGCHG,X,Y,DO,DD
+17 ;
+18 SET DGCHG=0
SET DGRSLT=1
SET DGDFN=+$GET(DGDFN)
+19 IF DGDFN>0
IF $DATA(^DPT(DGDFN))
IF $$CHANGE(DGDFN,.DGOEIF)
SET DGCHG=1
+20 ; If changes found, delete the existing data, add new records
+21 IF DGCHG
Begin DoDot:1
+22 SET DGRSLT=0
+23 SET DA=0
FOR
SET DA=$ORDER(^DPT(DGDFN,.3215,DA))
IF 'DA
QUIT
SET DA(1)=DGDFN
SET DIK="^DPT("_DA(1)_",.3215,"
DO ^DIK
+24 FOR DGX="LOC","FR","TO","LOCK","SITE"
SET DGX1=0
FOR
SET DGX1=$ORDER(DGOEIF(DGX,DGX1))
IF 'DGX1
QUIT
SET DGARY(DGX1,DGX)=DGOEIF(DGX,DGX1)
+25 SET DGX=0
FOR
SET DGX=$ORDER(DGARY(DGX))
IF 'DGX
QUIT
Begin DoDot:2
+26 ; Add a new entry
+27 SET DIC(0)="L"
SET DIC("DR")=".02////"_$GET(DGARY(DGX,"FR"))_";.03////"_$GET(DGARY(DGX,"TO"))_";.04////1"_$SELECT($GET(DGARY(DGX,"SITE"))'="":";.06////"_DGARY(DGX,"SITE"),1:"")
+28 SET DA(1)=DGDFN
SET DIC="^DPT("_DA(1)_",.3215,"
+29 SET X=$GET(DGARY(DGX,"LOC"))
SET X=$SELECT(X="OIF":1,X="OEF":2,X="UNK":3,1:"")
IF X
DO FILE^DICN
KILL DIC
SET DGRSLT=(Y>0)
End DoDot:2
IF 'DGRSLT
QUIT
End DoDot:1
+30 QUIT DGRSLT
+31 ;
CHANGE(DGDFN,DGOEIF) ;Did the data change?
+1 ; Input
+2 ; DGDFN - Patients DFN
+3 ; DGOEIF("COUNT") - the count of the # of entries in the multiple
+4 ; DGOEIF("LOC",n)=Conflict Location Indicator
+5 ; DGOEIF("FR",n)=OEF/OIF/UNKNOWN OEF/OIF Date From
+6 ; DGOEIF("TO",n)=OEF/OIF/UNKNOWN OEF/OIF Date To
+7 ; DGOEIF("LOCK")=Lock flag for HEC data
+8 ; DGOEIF("site",n)=Source of data if a site or null if CEV
+9 ;
+10 ; Output
+11 ; Returns 0 if no status change
+12 ; 1 if status changed
+13 ;
+14 NEW DGCHG,DGOEIFO,DGX,DGX1,Z
+15 ;
+16 IF +$GET(DGDFN)'>0
QUIT 0
+17 SET DGOEIF("COUNT")=$GET(DGOEIF("COUNT"))
+18 SET DGCHG=0
+19 IF 'DGOEIF("COUNT")
IF '$ORDER(^DPT(DGDFN,.3215,0))
SET DGCHG=0
GOTO CHNGQ
+20 SET Z=+$$GET^DGENOEIF(DGDFN,.DGOEIFO,0)
+21 IF DGOEIF("COUNT")'=Z
SET DGCHG=1
GOTO CHNGQ
+22 SET Z=0
FOR
SET Z=$ORDER(DGOEIFO("LOC",Z))
IF 'Z
QUIT
SET DGOEIFO("LOC",Z)=$EXTRACT($$EXTERNAL^DILFD(2.3215,.01,,+DGOEIFO("LOC",Z)),1,3)
+23 SET DGX=""
FOR
SET DGX=$ORDER(DGOEIF(DGX))
IF DGX=""!DGCHG
QUIT
Begin DoDot:1
+24 SET DGX1=0
FOR
SET DGX1=$ORDER(DGOEIF(DGX,DGX1))
IF 'DGX1
QUIT
Begin DoDot:2
+25 IF DGX="SITE"
IF $SELECT($GET(DGOEIF("SITE",DGX1))="":$GET(DGOEIFO("SITE",DGX1))="CEV",1:0)
QUIT
+26 IF DGX="LOCK"
IF $GET(DGOEIFO("LOCK",DGX1))=1
QUIT
+27 IF $GET(DGOEIFO(DGX,DGX1))'=$GET(DGOEIF(DGX,DGX1))
SET DGCHG=1
QUIT
End DoDot:2
IF DGCHG
QUIT
End DoDot:1
IF DGCHG
QUIT
CHNGQ QUIT DGCHG
+1 ;