DGADDLST ;ALB/JAM - List Manager Screen for Address Validation ;Jun 12, 2020@12:34
;;5.3;Registration;**1014,1040**;AUG 13, 1993;Build 15
;
EN(DFN,DGFLDS,DGADDR,DGSELADD,DGTMOT) ;Main entry point to invoke the "DGEN ADDR VALID" list - called by DGADDVAL
; Input: DFN - Patient IEN
; DGFLDS - String of address field numbers
; DGADDR (Pass by reference) - Array containing the addresses to list
; Output: DGSELADD (Pass by reference) - Array containing selected address
; DGTMOT (Pass by reference) - DG*5.3*1040 - If "1", a timeout occurred
;
; DGFLDS - Field numbers are in the following format:
; "AddressLine1,AddressLine2,AddressLine3,City,State,County,Zip,Province,PostalCode^Country"
;
; DGADDR Format:
; DGADDR = Total number of records
; DGADDR(Counter,field#)=VALUE ForState: VALUE = "STATENAME^STATECODE"
; For Country: VALUE = "COUNTRY^COUNTRYCODE"
;
; DGSELADD Format:
; DGSELADD(field#)=VALUE ForState: VALUE = "STATENAME^STATECODE"
; For Country: VALUE = "COUNTRY^COUNTRYCODE"
;
D WAIT^DICD
D EN^VALM("DGEN ADDR VALID")
N VALMHDR,VALMBCK,VALMCNT,VALMSG,XQORM
Q
;
HDR ;Header code
N X,DGSSNSTR,DGPTYPE,DGSSN,DGDOB
S DGSSNSTR=$$SSNNM^DGRPU(DFN) ; add member id (edipi) and preferred name to banner
S DGSSN=$P($P(DGSSNSTR,";",2)," ",3)
S DGDOB=$$GET1^DIQ(2,DFN,.03,"I")
S DGDOB=$$UP^XLFSTR($$FMTE^XLFDT($E(DGDOB,1,12),1))
S DGPTYPE=$$GET1^DIQ(391,$$GET1^DIQ(2,DFN_",",391,"I")_",",.01)
S:DGPTYPE="" DGPTYPE="PATIENT TYPE UNKNOWN"
; If coming from screen 1.1, change the screen title to specify this as screen 1.2
; - DGPRS is a system-wide variable containing the screen number
; - VALM array is used by ListMan (do not NEW this variable)
; It contains data for the screen and is used to maintain the call stack when a Listman screen flows to another ListMan screen.
; Changes to VALM entries are unwound after exit - Listman restores the entries of the previous stack level.
I $G(DGRPS)=1.1 S VALM("TITLE")="Address Validation <1.2>"
S VALMHDR(1)=$P(DGSSNSTR,";",1)_$S($$GET1^DIQ(2,DFN,.2405)'="":" ("_$$GET1^DIQ(2,DFN,.2405)_")",1:"")_" "_DGDOB
S VALMHDR(2)=$S($P($P(DGSSNSTR,";",2)," ",2)'="":$E($P($P(DGSSNSTR,";",2)," ",2),1,40)_" ",1:"")_DGSSN_" "_DGPTYPE
S XQORM("B")="SEL"
Q
;
INIT ;Build address screen
D CLEAN^VALM10
K ^TMP("DGADDVAL",$J)
N DGGLBL,DGCNT,DGZ,DGCTRYCD,DGFORGN,DGZIP
S DGGLBL=$NA(^TMP("DGADDVAL",$J))
S VALMCNT=0,DGCNT=0
F S DGCNT=$O(DGADDR(DGCNT)) Q:'DGCNT D
. ; Get Country code and determine if this is domestic/foreign address
. S DGCTRYCD=$P(DGADDR(DGCNT,$P(DGFLDS,",",10)),"^",2)
. S DGFORGN=0
. S DGFORGN=$$FORIEN^DGADDUTL(DGCTRYCD)
. ; Save to List Manager array for display
. ; Address line 1
. S VALMCNT=VALMCNT+1
. S DGZ=DGADDR(DGCNT,$P(DGFLDS,",",1))
. S DGZ="["_DGCNT_"] "_DGZ
. S @DGGLBL@(VALMCNT,0)=DGZ
. ; Address line 2
. I $G(DGADDR(DGCNT,$P(DGFLDS,",",2)))'="" D
. . S VALMCNT=VALMCNT+1
. . S DGZ=DGADDR(DGCNT,$P(DGFLDS,",",2))
. . S @DGGLBL@(VALMCNT,0)=" "_DGZ
. ; Address line 3
. I $G(DGADDR(DGCNT,$P(DGFLDS,",",3)))'="" D
. . S VALMCNT=VALMCNT+1
. . S DGZ=DGADDR(DGCNT,$P(DGFLDS,",",3))
. . S @DGGLBL@(VALMCNT,0)=" "_DGZ
. ; Put together line for city, state zip or city Province Postal Code
. S DGZ=""
. ; City
. I $G(DGADDR(DGCNT,$P(DGFLDS,",",4)))'="" D
. . S DGZ=DGADDR(DGCNT,$P(DGFLDS,",",4))
. ; For domestic address, add State and Zip
. I 'DGFORGN D
. . I $G(DGADDR(DGCNT,$P(DGFLDS,",",5)))'="" D
. . . ; State
. . . S DGZ=DGZ_","_$P(DGADDR(DGCNT,$P(DGFLDS,",",5)),"^",1)
. . I $G(DGADDR(DGCNT,$P(DGFLDS,",",7)))'="" D
. . . ; Zip
. . . S DGZIP=DGADDR(DGCNT,$P(DGFLDS,",",7))
. . . S:$L(DGZIP)>5 DGZIP=$E(DGZIP,1,5)_"-"_$E(DGZIP,6,9)
. . . S DGZ=DGZ_" "_DGZIP
. ; For foreign address, add Province and Postal Code
. I DGFORGN D
. . I $G(DGADDR(DGCNT,$P(DGFLDS,",",8)))'="" D
. . . ; Province
. . . S DGZ=DGZ_" "_DGADDR(DGCNT,$P(DGFLDS,",",8))
. . I $G(DGADDR(DGCNT,$P(DGFLDS,",",9)))'="" D
. . . ; Postal Code
. . . S DGZ=DGZ_" "_DGADDR(DGCNT,$P(DGFLDS,",",9))
. ; Add the City string to list
. S VALMCNT=VALMCNT+1
. S @DGGLBL@(VALMCNT,0)=" "_DGZ
. ; Country
. S DGZ=$$CNTRYI^DGADDUTL(DGCTRYCD)
. S DGZ=$S(DGZ="":"UNSPECIFIED COUNTRY",DGZ=-1:"UNKNOWN COUNTRY",1:DGZ)
. S VALMCNT=VALMCNT+1
. S @DGGLBL@(VALMCNT,0)=" "_DGZ
. ;
. I DGCNT=1 S VALMCNT=VALMCNT+1,@DGGLBL@(VALMCNT,0)=" (User Entered Address)"
. I DGCNT>1 D
. . S DGZ=" "
. . S VALMCNT=VALMCNT+1
. . I $G(DGADDR(DGCNT,"deliveryPoint"))'="" S DGZ=DGZ_"Delivery Point: "_DGADDR(DGCNT,"deliveryPoint")_" "
. . S DGZ=DGZ_"Confidence Score: "_$G(DGADDR(DGCNT,"confidenceScore"))
. . S @DGGLBL@(VALMCNT,0)=DGZ
Q
;
HELP ;Help code
S X="?" D DISP^XQORM1 W !!
S VALMSG="+ Next Screen - Prev Screen ?? More Actions"
Q
;
EXIT ;Exit code
D CLEAN^VALM10
D CLEAR^VALM1
K ^TMP("DGADDVAL",$J)
Q
;
PEXIT ;DGEN ADD VALID 1.2 MENU protocol exit code
; DG*5.3*1040; If timeout on the menu, set flag and quit
I $D(DTOUT) S DGTMOT=1
S VALMSG="+ Next Screen - Prev Screen ?? More Actions"
S XQORM("B")="SEL"
Q
;
ACT(DGACT) ; Entry point for menu action selection
; = "SEL" - Select an Address -
;
N DGSEL
; SEL - user selects one address from the list - merge it into the return array
I DGACT="SEL" S DGSEL=$$SEL()
; DG*5.3*1040; If timeout, set flag and quit
I DGSEL=-1 S DGTMOT=1 Q
I DGSEL M DGSELADD=DGADDR(DGSEL) Q
;
S VALMBCK="R"
S XQORM("B")="SEL"
Q
;
SEL() ; function, prompt to select address
N DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
S DIR(0)="NA^1:"_DGADDR
S DIR("A",1)="",DIR("A")="Select Address (1-"_DGADDR_"): " D ^DIR K DIR
; DG*5.3*1040; return -1 on a timeout
I $D(DTOUT) Q -1
Q X
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HDGADDLST 5960 printed Nov 22, 2024@17:51:07 Page 2
DGADDLST ;ALB/JAM - List Manager Screen for Address Validation ;Jun 12, 2020@12:34
+1 ;;5.3;Registration;**1014,1040**;AUG 13, 1993;Build 15
+2 ;
EN(DFN,DGFLDS,DGADDR,DGSELADD,DGTMOT) ;Main entry point to invoke the "DGEN ADDR VALID" list - called by DGADDVAL
+1 ; Input: DFN - Patient IEN
+2 ; DGFLDS - String of address field numbers
+3 ; DGADDR (Pass by reference) - Array containing the addresses to list
+4 ; Output: DGSELADD (Pass by reference) - Array containing selected address
+5 ; DGTMOT (Pass by reference) - DG*5.3*1040 - If "1", a timeout occurred
+6 ;
+7 ; DGFLDS - Field numbers are in the following format:
+8 ; "AddressLine1,AddressLine2,AddressLine3,City,State,County,Zip,Province,PostalCode^Country"
+9 ;
+10 ; DGADDR Format:
+11 ; DGADDR = Total number of records
+12 ; DGADDR(Counter,field#)=VALUE ForState: VALUE = "STATENAME^STATECODE"
+13 ; For Country: VALUE = "COUNTRY^COUNTRYCODE"
+14 ;
+15 ; DGSELADD Format:
+16 ; DGSELADD(field#)=VALUE ForState: VALUE = "STATENAME^STATECODE"
+17 ; For Country: VALUE = "COUNTRY^COUNTRYCODE"
+18 ;
+19 DO WAIT^DICD
+20 DO EN^VALM("DGEN ADDR VALID")
+21 NEW VALMHDR,VALMBCK,VALMCNT,VALMSG,XQORM
+22 QUIT
+23 ;
HDR ;Header code
+1 NEW X,DGSSNSTR,DGPTYPE,DGSSN,DGDOB
+2 ; add member id (edipi) and preferred name to banner
SET DGSSNSTR=$$SSNNM^DGRPU(DFN)
+3 SET DGSSN=$PIECE($PIECE(DGSSNSTR,";",2)," ",3)
+4 SET DGDOB=$$GET1^DIQ(2,DFN,.03,"I")
+5 SET DGDOB=$$UP^XLFSTR($$FMTE^XLFDT($EXTRACT(DGDOB,1,12),1))
+6 SET DGPTYPE=$$GET1^DIQ(391,$$GET1^DIQ(2,DFN_",",391,"I")_",",.01)
+7 if DGPTYPE=""
SET DGPTYPE="PATIENT TYPE UNKNOWN"
+8 ; If coming from screen 1.1, change the screen title to specify this as screen 1.2
+9 ; - DGPRS is a system-wide variable containing the screen number
+10 ; - VALM array is used by ListMan (do not NEW this variable)
+11 ; It contains data for the screen and is used to maintain the call stack when a Listman screen flows to another ListMan screen.
+12 ; Changes to VALM entries are unwound after exit - Listman restores the entries of the previous stack level.
+13 IF $GET(DGRPS)=1.1
SET VALM("TITLE")="Address Validation <1.2>"
+14 SET VALMHDR(1)=$PIECE(DGSSNSTR,";",1)_$SELECT($$GET1^DIQ(2,DFN,.2405)'="":" ("_$$GET1^DIQ(2,DFN,.2405)_")",1:"")_" "_DGDOB
+15 SET VALMHDR(2)=$SELECT($PIECE($PIECE(DGSSNSTR,";",2)," ",2)'="":$EXTRACT($PIECE($PIECE(DGSSNSTR,";",2)," ",2),1,40)_" ",1:"")_DGSSN_" "_DGPTYPE
+16 SET XQORM("B")="SEL"
+17 QUIT
+18 ;
INIT ;Build address screen
+1 DO CLEAN^VALM10
+2 KILL ^TMP("DGADDVAL",$JOB)
+3 NEW DGGLBL,DGCNT,DGZ,DGCTRYCD,DGFORGN,DGZIP
+4 SET DGGLBL=$NAME(^TMP("DGADDVAL",$JOB))
+5 SET VALMCNT=0
SET DGCNT=0
+6 FOR
SET DGCNT=$ORDER(DGADDR(DGCNT))
if 'DGCNT
QUIT
Begin DoDot:1
+7 ; Get Country code and determine if this is domestic/foreign address
+8 SET DGCTRYCD=$PIECE(DGADDR(DGCNT,$PIECE(DGFLDS,",",10)),"^",2)
+9 SET DGFORGN=0
+10 SET DGFORGN=$$FORIEN^DGADDUTL(DGCTRYCD)
+11 ; Save to List Manager array for display
+12 ; Address line 1
+13 SET VALMCNT=VALMCNT+1
+14 SET DGZ=DGADDR(DGCNT,$PIECE(DGFLDS,",",1))
+15 SET DGZ="["_DGCNT_"] "_DGZ
+16 SET @DGGLBL@(VALMCNT,0)=DGZ
+17 ; Address line 2
+18 IF $GET(DGADDR(DGCNT,$PIECE(DGFLDS,",",2)))'=""
Begin DoDot:2
+19 SET VALMCNT=VALMCNT+1
+20 SET DGZ=DGADDR(DGCNT,$PIECE(DGFLDS,",",2))
+21 SET @DGGLBL@(VALMCNT,0)=" "_DGZ
End DoDot:2
+22 ; Address line 3
+23 IF $GET(DGADDR(DGCNT,$PIECE(DGFLDS,",",3)))'=""
Begin DoDot:2
+24 SET VALMCNT=VALMCNT+1
+25 SET DGZ=DGADDR(DGCNT,$PIECE(DGFLDS,",",3))
+26 SET @DGGLBL@(VALMCNT,0)=" "_DGZ
End DoDot:2
+27 ; Put together line for city, state zip or city Province Postal Code
+28 SET DGZ=""
+29 ; City
+30 IF $GET(DGADDR(DGCNT,$PIECE(DGFLDS,",",4)))'=""
Begin DoDot:2
+31 SET DGZ=DGADDR(DGCNT,$PIECE(DGFLDS,",",4))
End DoDot:2
+32 ; For domestic address, add State and Zip
+33 IF 'DGFORGN
Begin DoDot:2
+34 IF $GET(DGADDR(DGCNT,$PIECE(DGFLDS,",",5)))'=""
Begin DoDot:3
+35 ; State
+36 SET DGZ=DGZ_","_$PIECE(DGADDR(DGCNT,$PIECE(DGFLDS,",",5)),"^",1)
End DoDot:3
+37 IF $GET(DGADDR(DGCNT,$PIECE(DGFLDS,",",7)))'=""
Begin DoDot:3
+38 ; Zip
+39 SET DGZIP=DGADDR(DGCNT,$PIECE(DGFLDS,",",7))
+40 if $LENGTH(DGZIP)>5
SET DGZIP=$EXTRACT(DGZIP,1,5)_"-"_$EXTRACT(DGZIP,6,9)
+41 SET DGZ=DGZ_" "_DGZIP
End DoDot:3
End DoDot:2
+42 ; For foreign address, add Province and Postal Code
+43 IF DGFORGN
Begin DoDot:2
+44 IF $GET(DGADDR(DGCNT,$PIECE(DGFLDS,",",8)))'=""
Begin DoDot:3
+45 ; Province
+46 SET DGZ=DGZ_" "_DGADDR(DGCNT,$PIECE(DGFLDS,",",8))
End DoDot:3
+47 IF $GET(DGADDR(DGCNT,$PIECE(DGFLDS,",",9)))'=""
Begin DoDot:3
+48 ; Postal Code
+49 SET DGZ=DGZ_" "_DGADDR(DGCNT,$PIECE(DGFLDS,",",9))
End DoDot:3
End DoDot:2
+50 ; Add the City string to list
+51 SET VALMCNT=VALMCNT+1
+52 SET @DGGLBL@(VALMCNT,0)=" "_DGZ
+53 ; Country
+54 SET DGZ=$$CNTRYI^DGADDUTL(DGCTRYCD)
+55 SET DGZ=$SELECT(DGZ="":"UNSPECIFIED COUNTRY",DGZ=-1:"UNKNOWN COUNTRY",1:DGZ)
+56 SET VALMCNT=VALMCNT+1
+57 SET @DGGLBL@(VALMCNT,0)=" "_DGZ
+58 ;
+59 IF DGCNT=1
SET VALMCNT=VALMCNT+1
SET @DGGLBL@(VALMCNT,0)=" (User Entered Address)"
+60 IF DGCNT>1
Begin DoDot:2
+61 SET DGZ=" "
+62 SET VALMCNT=VALMCNT+1
+63 IF $GET(DGADDR(DGCNT,"deliveryPoint"))'=""
SET DGZ=DGZ_"Delivery Point: "_DGADDR(DGCNT,"deliveryPoint")_" "
+64 SET DGZ=DGZ_"Confidence Score: "_$GET(DGADDR(DGCNT,"confidenceScore"))
+65 SET @DGGLBL@(VALMCNT,0)=DGZ
End DoDot:2
End DoDot:1
+66 QUIT
+67 ;
HELP ;Help code
+1 SET X="?"
DO DISP^XQORM1
WRITE !!
+2 SET VALMSG="+ Next Screen - Prev Screen ?? More Actions"
+3 QUIT
+4 ;
EXIT ;Exit code
+1 DO CLEAN^VALM10
+2 DO CLEAR^VALM1
+3 KILL ^TMP("DGADDVAL",$JOB)
+4 QUIT
+5 ;
PEXIT ;DGEN ADD VALID 1.2 MENU protocol exit code
+1 ; DG*5.3*1040; If timeout on the menu, set flag and quit
+2 IF $DATA(DTOUT)
SET DGTMOT=1
+3 SET VALMSG="+ Next Screen - Prev Screen ?? More Actions"
+4 SET XQORM("B")="SEL"
+5 QUIT
+6 ;
ACT(DGACT) ; Entry point for menu action selection
+1 ; = "SEL" - Select an Address -
+2 ;
+3 NEW DGSEL
+4 ; SEL - user selects one address from the list - merge it into the return array
+5 IF DGACT="SEL"
SET DGSEL=$$SEL()
+6 ; DG*5.3*1040; If timeout, set flag and quit
+7 IF DGSEL=-1
SET DGTMOT=1
QUIT
+8 IF DGSEL
MERGE DGSELADD=DGADDR(DGSEL)
QUIT
+9 ;
+10 SET VALMBCK="R"
+11 SET XQORM("B")="SEL"
+12 QUIT
+13 ;
SEL() ; function, prompt to select address
+1 NEW DIR,DIROUT,DIRUT,DTOUT,DUOUT,X,Y
+2 SET DIR(0)="NA^1:"_DGADDR
+3 SET DIR("A",1)=""
SET DIR("A")="Select Address (1-"_DGADDR_"): "
DO ^DIR
KILL DIR
+4 ; DG*5.3*1040; return -1 on a timeout
+5 IF $DATA(DTOUT)
QUIT -1
+6 QUIT X