DGADDUTL ;ALB/PHH,EG,BAJ,ERC,CKN,TDM-PATIENT ADDRESS ; 4/2/09 2:29pm
;;5.3;PIMS;**1016**;JUN 30, 2012;Build 20
Q
ADDR ; validate/edit Patient address (entry for DG ADDRESS UPDATE option)
N %,QUIT,DIC,Y,DFN,USERSEL
ADDRLOOP ;
W !!
K DIC,Y,DFN,USERSEL
S DIC="^DPT(",DIC(0)="AEMZQ",DIC("A")="Veteran Name/SSN: " D ^DIC
I $D(DTOUT)!($D(DUOUT)) Q
Q:Y'>0
;
S DFN=+Y,QUIT=0
L +^DPT(DFN):3 E W !!,"Patient is being edited. Try again later." G ADDR
F D Q:QUIT
.W !!,"Do you want to update the (P)ermanent Address, (T)emporary Address, or (B)oth? "
.R USERSEL:300
.I '$T S USERSEL="^"
.I USERSEL["^"!(USERSEL="") S QUIT=1 Q
.S USERSEL=$TR(USERSEL,"ptb","PTB")
.I USERSEL'="P",USERSEL'="T",USERSEL'="B" D Q
..W !,"Invalid selection!"
.I USERSEL="P"!(USERSEL="B") W ! D UPDATE(DFN,"PERM")
.I USERSEL="T"!(USERSEL="B") D UPDATE(DFN,"TEMP")
.S QUIT=1
L -^DPT(DFN)
G ADDRLOOP
ADD(DFN) ; validate/edit Patient address (entry point for routine DGREG)
; Input -- DFN
;
N RETVAL,ADDYN
S (RETVAL,ADDYN)=0
F D Q:ADDYN
.S ADDYN=$$ADDYN("Do you want to validate/edit the Patient's Address")
.S RETVAL=ADDYN
.I ADDYN'=1,ADDYN'=2 S (ADDYN,RETVAL)=0
.I 'ADDYN W !?5,"Enter 'YES' to validate/edit Patient's Address or 'NO' to continue."
I ADDYN=1,$G(DFN)'="",$D(^DPT(DFN,0)) D
.D UPDATE(DFN,"PERM")
.S RETVAL=1
Q RETVAL
ADDYN(PROMPT) ; Yes/No Prompt to Edit/Validate Address
; Input -- None
; Output -- 1 = YES
; 2 = NO
; -1 = Aborted
;
N %
W !,PROMPT
D YN^DICN
Q %
UPDATE(DFN,TYPE) ; Update the Address
; Input -- TYPE = "PERM" for Permanent Address
; = "TEMP" for Temporary Address
; Output -- None
;
I TYPE'="PERM",TYPE'="TEMP" Q
I TYPE="PERM" D
.W !
.N FLG S (FLG(1),FLG(2))=1
.D ADDRED(DFN,.FLG)
;
I TYPE="TEMP" D
.D EDITTADR(DFN)
Q
UPDDTTM(DFN,TYPE) ; Update the PATIENT file #2 with the current date and time
;
D UPDDTTM^DGADDUT2(DFN,TYPE)
Q
ADDRED(DFN,FLG) ; Address Edit (Code copied from DGREGAED and modified)
;Input:
; DFN (required) - Internal Entry # of Patient File (#2)
; FLG (optional) - Flags of 1 or 0; if null, 0 is assumed. Details:
; FLG(1) - if 1, let user edit phone numbers (field #.131 and #.132)
; FLG(2) - if 1, display before & after address for user confirmation
N SRC,%,DGINPUT,I,X,Y
S SRC="ADDUTL"
D EN^DGREGAED(DFN,.FLG,SRC)
;
; Update the Date/Time Stamp
D UPDDTTM(DFN,TYPE)
Q
GETPRIOR(DFN,DGPRIOR) ; Get prior address fields.
N DGCURR,DGN,DGARRY,DGCIEN,DGST,DGCNTY
D GETS^DIQ(2,DFN_",",".111;.112;.113;.114;.115;.117;.1112;.131;.132;.121;.118;.119;.12;.122;.1171:.1173","I","DGCURR")
F DGN=.111,.112,.113,.114,.115,.117,.1112,.131,.132,.121,.118,.119,.12,.122,.1171,.1172,.1173 D
. S DGARRY("OLD",DGN)=$G(DGCURR(2,DFN_",",DGN,"I"))
M DGPRIOR=DGARRY("OLD")
Q
GETUPDTS(DFN,DGINPUT) ; Get current address fields.
N DGCURR,DGN,DGARRY
D GETS^DIQ(2,DFN_",",".118;.119;.12;.122","I","DGCURR")
F DGN=.118,.119,.12,.122 D
. S DGARRY("NEW",DGN)=$G(DGCURR(2,DFN_",",DGN,"I"))
M DGINPUT=DGARRY("NEW")
Q
FILEYN(DGOLD,DGNEW) ; Determine whether or not to file to #301.7
N RETVAL
S RETVAL=0
D
.I DGOLD(.111)'=$G(DGNEW(.111)) S RETVAL=1 Q
.I DGOLD(.112)'=$G(DGNEW(.112)) S RETVAL=1 Q
.I DGOLD(.113)'=$G(DGNEW(.113)) S RETVAL=1 Q
.I DGOLD(.114)'=$G(DGNEW(.114)) S RETVAL=1 Q
.I DGOLD(.115)'=$P($G(DGNEW(.115)),"^",2) S RETVAL=1 Q
.I DGOLD(.1112)'=$G(DGNEW(.1112)) S RETVAL=1 Q
.I DGOLD(.117)'=$P($G(DGNEW(.117)),"^",2) S RETVAL=1 Q
.I DGOLD(.131)'=$G(DGNEW(.131)) S RETVAL=1 Q
.I DGOLD(.1171)'=$G(DGNEW(.1171)) S RETVAL=1 Q
.I DGOLD(.1172)'=$G(DGNEW(.1172)) S RETVAL=1 Q
.I DGOLD(.1173)'=$P($G(DGNEW(.1173)),"^",2) S RETVAL=1 Q
.I DGOLD(.121)'=$G(DGNEW(.121)) S RETVAL=1 Q
Q RETVAL
FOREIGN(DFN,CIEN,FILE,FIELD,COUNTRY) ;
; ** NOTE we have to default the value for "US" into the prompt if it is blank
N FORGN,DA,DIR,DTOUT,DUOUT,DIROUT,DONE,INDX
S:'$G(FILE) FILE=2 I '$G(FIELD) S FIELD=.1173
S DIR(0)=FILE_","_FIELD,DA=DFN,DONE=0
S DIR("B")=$E($$CNTRYI^DGADDUTL(CIEN),1,19) I DIR("B")=-1 S DIR("B")="UNKNOWN COUNTRY"
F D Q:DONE
. D ^DIR
. I $D(DTOUT) S DONE=1,FORGN=-1 Q
. I $D(DUOUT)!$D(DIROUT) W !,"EXIT NOT ALLOWED" Q
. I $D(DIRUT) W !,"This is a required response." Q
. S COUNTRY=$P($G(Y),"^",2),FORGN=$$FORIEN($P($G(Y),"^")),DONE=1
Q FORGN
UPDADDLG(DFN,DGPRIOR,DGINPUT) ; Update the IVM ADDRESS CHANGE LOG file #301.7
;
D UPDADDLG^DGADDUT2(DFN,.DGPRIOR,.DGINPUT)
Q
EDITTADR(DFN) ; Edit Temporary Address
N DGPRIOR,DGCH,DGRPAN,DGDR,DGRPS
I $G(DFN)="" Q
;I ($G(DFN)'?.N) Q
;
; Get the current Temporary Address and display it
D GETTADR(DFN,.DGPRIOR)
D DISPTADR(DFN,.DGPRIOR)
W !!
;
S DGCH=5,DGRPAN="1,2,3,4,5,",DGDR="",DGRPS=1
D CHOICE^DGRPP
D ^DGRPE
; Update the Date/Time Stamp
D UPDDTTM(DFN,TYPE)
Q
GETTADR(DFN,DGPRIOR) ; Get prior temporary address fields.
N DGCURR,DGN,DGARRY,DGCIEN,DGST,DGCNTY
D GETS^DIQ(2,DFN_",",".1211;.1212;.1213;.1214;.1215;.1216;.1217;.1218;.12105;.1219;.12111;.12112;.12113;.12114;.1221:.1223","I","DGCURR")
F DGN=.1211,.1212,.1213,.1214,.1215,.1216,.1217,.1218,.12105,.1219,.12111,.12112,.12113,.12114,.1221,.1222,.1223 D
.S DGARRY("OLD",DGN)=$G(DGCURR(2,DFN_",",DGN,"I"))
M DGPRIOR=DGARRY("OLD")
Q
DISPTADR(DFN,DGARRY) ; Display Temporary Address
N DGADRACT,DGADR1,DGADR2,DGADR3,DGCITY,DGSTATE,DGZIP
N DGCOUNTY,DGPHONE,DGFROMDT,DGTODT,DGPROV,DGPCODE,DGCNTRY,DGFORN
;
S DGADRACT=$G(DGARRY(.12105))
S DGADR1=$G(DGARRY(.1211))
S DGADR2=$G(DGARRY(.1212))
S DGADR3=$G(DGARRY(.1213))
S DGCITY=$G(DGARRY(.1214))
S DGSTATE=$G(DGARRY(.1215))
S DGZIP=$G(DGARRY(.1216))
S DGCOUNTY=$G(DGARRY(.12111))
I DGCOUNTY'="",DGSTATE'="",$D(^DIC(5,DGSTATE,1,DGCOUNTY,0)) D
.S DGCOUNTY=$P(^DIC(5,DGSTATE,1,DGCOUNTY,0),"^")_" ("_$P(^DIC(5,DGSTATE,1,DGCOUNTY,0),"^",4)_")"
I DGADRACT'="Y" S DGCOUNTY="NOT APPLICABLE"
I DGSTATE'="",$D(^DIC(5,DGSTATE,0)) S DGSTATE=$P(^DIC(5,DGSTATE,0),"^",2)
S DGPROV=$G(DGARRY(.1221))
S DGPCODE=$G(DGARRY(.1222))
S DGCNTRY=$G(DGARRY(.1223))
S DGFORN=$$FORIEN(DGCNTRY)
I DGCNTRY]"" S DGCNTRY=$$CNTRYI(DGCNTRY)
S DGPHONE=$G(DGARRY(.1219))
S DGFROMDT=$$FMTE^XLFDT($G(DGARRY(.1217)))
S DGTODT=$$FMTE^XLFDT($G(DGARRY(.1218)))
;
W !!,"Temporary Address: "
I DGADRACT="Y" D
.W:DGADR1'="" !?9,DGADR1
.W:DGADR2'="" !?9,DGADR2
.W:DGADR3'="" !?9,DGADR3
.I DGFORN=0 D
..W !?9,$S(DGCITY'="":DGCITY,1:"")_$S(DGCITY'="":",",1:" ")_$S(DGSTATE'="":DGSTATE,1:"")_" "_$S(DGZIP'="":DGZIP,1:"")
.I DGFORN W !?9,$S(DGPCODE'="":DGPCODE,1:"")_" "_$S(DGCITY'="":DGCITY,1:"")_$S(DGCITY'="":",",1:" ")_$S(DGPROV'="":DGPROV,1:"")
.W !?9,$S(DGCITY'="":DGCITY,1:"")_","_$S(DGSTATE'="":DGSTATE,1:"")_" "_$S(DGZIP'="":DGZIP,1:"")
.W !," County: "_DGCOUNTY
.W !," Phone: "_DGPHONE
.W !,"From/To: "_$P(DGFROMDT,",")_","_$P(DGFROMDT,", ",2)_"-"_$P(DGTODT,",")_","_$P(DGTODT,", ",2)
;
I $G(DGARRY(.12105))="N" D
.W:$G(DGARRY(.1211))="" !?9,"NO TEMPORARY ADDRESS"
.W:$G(DGARRY(.1212))="" !?9,""
.W !," County: NOT APPLICABLE"
.W !," Phone: NOT APPLICABLE"
.W !,"From/To: NOT APPLICABLE"
Q
COUNTRY(DGC) ;
;where DGC is the external value of the country
;return value is in upper case display mode
;if DGC is invalid, return -1
N DGCC,DGIEN
; if input is NULL change to US
I $G(DGC)="" S DGC="USA"
; Get IEN from B index, error if not found
S DGIEN=$O(^HL(779.004,"B",DGC,"")) Q:DGIEN']"" -1
; xlate IEN to POSTAL NAME
S DGCC=$P(^HL(779.004,DGIEN,"SDS"),U,3)
; if POSTAL NAME = "<NULL>" return DESCRIPTION
I DGCC="<NULL>" D
. S DGCC=$$UPPER^DGUTL($P(^HL(779.004,DGIEN,0),U,2))
Q DGCC
FOR(DGC) ;returns a 1 if address is foreign, a 0 if domestic, -1 if DGC is not valid
; DGC is the external value of the country (.01 field of file 779.004)
N DGFOR
S DGFOR=0
I $G(DGC)="" Q DGFOR
I '$D(^HL(779.004,"B",DGC)) Q -1
I DGC'="USA" S DGFOR=1
Q DGFOR
CNTRYI(DGIEN) ;where DGC is the internal value of the country
;return DGC as the display value for the country
;if the input value is not a valid IEN, return -1
;if the input value is null, return null
N DGCC
I $G(DGIEN)="" Q ""
I '$D(^HL(779.004,DGIEN,0)) Q -1
; xlate IEN to POSTAL NAME
S DGCC=$P(^HL(779.004,DGIEN,"SDS"),U,3)
; if POSTAL NAME = "<NULL>" return DESCRIPTION
I DGCC="<NULL>" D
. S DGCC=$$UPPER^DGUTL($P(^HL(779.004,DGIEN,0),U,2))
Q DGCC
FORIEN(DGC) ;returns a 1 if address is foreign, a 0 if domestic, -1 if DGC is invalid
;DGC is the IEN of the country file (#779.004)
N DGFOR
S DGFOR=0
I $G(DGC)="" Q DGFOR
I DGC'?1.3N Q -1
I '$D(^HL(779.004,DGC,0)) Q -1
I DGC]"",(DGC'=$O(^HL(779.004,"B","USA",""))) S DGFOR=1
Q DGFOR
DGADDUTL ;ALB/PHH,EG,BAJ,ERC,CKN,TDM-PATIENT ADDRESS ; 4/2/09 2:29pm
+1 ;;5.3;PIMS;**1016**;JUN 30, 2012;Build 20
+2 QUIT
ADDR ; validate/edit Patient address (entry for DG ADDRESS UPDATE option)
+1 NEW %,QUIT,DIC,Y,DFN,USERSEL
ADDRLOOP ;
+1 WRITE !!
+2 KILL DIC,Y,DFN,USERSEL
+3 SET DIC="^DPT("
SET DIC(0)="AEMZQ"
SET DIC("A")="Veteran Name/SSN: "
DO ^DIC
+4 IF $DATA(DTOUT)!($DATA(DUOUT))
QUIT
+5 IF Y'>0
QUIT
+6 ;
+7 SET DFN=+Y
SET QUIT=0
+8 LOCK +^DPT(DFN):3
IF '$TEST
WRITE !!,"Patient is being edited. Try again later."
GOTO ADDR
+9 FOR
Begin DoDot:1
+10 WRITE !!,"Do you want to update the (P)ermanent Address, (T)emporary Address, or (B)oth? "
+11 READ USERSEL:300
+12 IF '$TEST
SET USERSEL="^"
+13 IF USERSEL["^"!(USERSEL="")
SET QUIT=1
QUIT
+14 SET USERSEL=$TRANSLATE(USERSEL,"ptb","PTB")
+15 IF USERSEL'="P"
IF USERSEL'="T"
IF USERSEL'="B"
Begin DoDot:2
+16 WRITE !,"Invalid selection!"
End DoDot:2
QUIT
+17 IF USERSEL="P"!(USERSEL="B")
WRITE !
DO UPDATE(DFN,"PERM")
+18 IF USERSEL="T"!(USERSEL="B")
DO UPDATE(DFN,"TEMP")
+19 SET QUIT=1
End DoDot:1
IF QUIT
QUIT
+20 LOCK -^DPT(DFN)
+21 GOTO ADDRLOOP
ADD(DFN) ; validate/edit Patient address (entry point for routine DGREG)
+1 ; Input -- DFN
+2 ;
+3 NEW RETVAL,ADDYN
+4 SET (RETVAL,ADDYN)=0
+5 FOR
Begin DoDot:1
+6 SET ADDYN=$$ADDYN("Do you want to validate/edit the Patient's Address")
+7 SET RETVAL=ADDYN
+8 IF ADDYN'=1
IF ADDYN'=2
SET (ADDYN,RETVAL)=0
+9 IF 'ADDYN
WRITE !?5,"Enter 'YES' to validate/edit Patient's Address or 'NO' to continue."
End DoDot:1
IF ADDYN
QUIT
+10 IF ADDYN=1
IF $GET(DFN)'=""
IF $DATA(^DPT(DFN,0))
Begin DoDot:1
+11 DO UPDATE(DFN,"PERM")
+12 SET RETVAL=1
End DoDot:1
+13 QUIT RETVAL
ADDYN(PROMPT) ; Yes/No Prompt to Edit/Validate Address
+1 ; Input -- None
+2 ; Output -- 1 = YES
+3 ; 2 = NO
+4 ; -1 = Aborted
+5 ;
+6 NEW %
+7 WRITE !,PROMPT
+8 DO YN^DICN
+9 QUIT %
UPDATE(DFN,TYPE) ; Update the Address
+1 ; Input -- TYPE = "PERM" for Permanent Address
+2 ; = "TEMP" for Temporary Address
+3 ; Output -- None
+4 ;
+5 IF TYPE'="PERM"
IF TYPE'="TEMP"
QUIT
+6 IF TYPE="PERM"
Begin DoDot:1
+7 WRITE !
+8 NEW FLG
SET (FLG(1),FLG(2))=1
+9 DO ADDRED(DFN,.FLG)
End DoDot:1
+10 ;
+11 IF TYPE="TEMP"
Begin DoDot:1
+12 DO EDITTADR(DFN)
End DoDot:1
+13 QUIT
UPDDTTM(DFN,TYPE) ; Update the PATIENT file #2 with the current date and time
+1 ;
+2 DO UPDDTTM^DGADDUT2(DFN,TYPE)
+3 QUIT
ADDRED(DFN,FLG) ; Address Edit (Code copied from DGREGAED and modified)
+1 ;Input:
+2 ; DFN (required) - Internal Entry # of Patient File (#2)
+3 ; FLG (optional) - Flags of 1 or 0; if null, 0 is assumed. Details:
+4 ; FLG(1) - if 1, let user edit phone numbers (field #.131 and #.132)
+5 ; FLG(2) - if 1, display before & after address for user confirmation
+6 NEW SRC,%,DGINPUT,I,X,Y
+7 SET SRC="ADDUTL"
+8 DO EN^DGREGAED(DFN,.FLG,SRC)
+9 ;
+10 ; Update the Date/Time Stamp
+11 DO UPDDTTM(DFN,TYPE)
+12 QUIT
GETPRIOR(DFN,DGPRIOR) ; Get prior address fields.
+1 NEW DGCURR,DGN,DGARRY,DGCIEN,DGST,DGCNTY
+2 DO GETS^DIQ(2,DFN_",",".111;.112;.113;.114;.115;.117;.1112;.131;.132;.121;.118;.119;.12;.122;.1171:.1173","I","DGCURR")
+3 FOR DGN=.111,.112,.113,.114,.115,.117,.1112,.131,.132,.121,.118,.119,.12,.122,.1171,.1172,.1173
Begin DoDot:1
+4 SET DGARRY("OLD",DGN)=$GET(DGCURR(2,DFN_",",DGN,"I"))
End DoDot:1
+5 MERGE DGPRIOR=DGARRY("OLD")
+6 QUIT
GETUPDTS(DFN,DGINPUT) ; Get current address fields.
+1 NEW DGCURR,DGN,DGARRY
+2 DO GETS^DIQ(2,DFN_",",".118;.119;.12;.122","I","DGCURR")
+3 FOR DGN=.118,.119,.12,.122
Begin DoDot:1
+4 SET DGARRY("NEW",DGN)=$GET(DGCURR(2,DFN_",",DGN,"I"))
End DoDot:1
+5 MERGE DGINPUT=DGARRY("NEW")
+6 QUIT
FILEYN(DGOLD,DGNEW) ; Determine whether or not to file to #301.7
+1 NEW RETVAL
+2 SET RETVAL=0
+3 Begin DoDot:1
+4 IF DGOLD(.111)'=$GET(DGNEW(.111))
SET RETVAL=1
QUIT
+5 IF DGOLD(.112)'=$GET(DGNEW(.112))
SET RETVAL=1
QUIT
+6 IF DGOLD(.113)'=$GET(DGNEW(.113))
SET RETVAL=1
QUIT
+7 IF DGOLD(.114)'=$GET(DGNEW(.114))
SET RETVAL=1
QUIT
+8 IF DGOLD(.115)'=$PIECE($GET(DGNEW(.115)),"^",2)
SET RETVAL=1
QUIT
+9 IF DGOLD(.1112)'=$GET(DGNEW(.1112))
SET RETVAL=1
QUIT
+10 IF DGOLD(.117)'=$PIECE($GET(DGNEW(.117)),"^",2)
SET RETVAL=1
QUIT
+11 IF DGOLD(.131)'=$GET(DGNEW(.131))
SET RETVAL=1
QUIT
+12 IF DGOLD(.1171)'=$GET(DGNEW(.1171))
SET RETVAL=1
QUIT
+13 IF DGOLD(.1172)'=$GET(DGNEW(.1172))
SET RETVAL=1
QUIT
+14 IF DGOLD(.1173)'=$PIECE($GET(DGNEW(.1173)),"^",2)
SET RETVAL=1
QUIT
+15 IF DGOLD(.121)'=$GET(DGNEW(.121))
SET RETVAL=1
QUIT
End DoDot:1
+16 QUIT RETVAL
FOREIGN(DFN,CIEN,FILE,FIELD,COUNTRY) ;
+1 ; ** NOTE we have to default the value for "US" into the prompt if it is blank
+2 NEW FORGN,DA,DIR,DTOUT,DUOUT,DIROUT,DONE,INDX
+3 IF '$GET(FILE)
SET FILE=2
IF '$GET(FIELD)
SET FIELD=.1173
+4 SET DIR(0)=FILE_","_FIELD
SET DA=DFN
SET DONE=0
+5 SET DIR("B")=$EXTRACT($$CNTRYI^DGADDUTL(CIEN),1,19)
IF DIR("B")=-1
SET DIR("B")="UNKNOWN COUNTRY"
+6 FOR
Begin DoDot:1
+7 DO ^DIR
+8 IF $DATA(DTOUT)
SET DONE=1
SET FORGN=-1
QUIT
+9 IF $DATA(DUOUT)!$DATA(DIROUT)
WRITE !,"EXIT NOT ALLOWED"
QUIT
+10 IF $DATA(DIRUT)
WRITE !,"This is a required response."
QUIT
+11 SET COUNTRY=$PIECE($GET(Y),"^",2)
SET FORGN=$$FORIEN($PIECE($GET(Y),"^"))
SET DONE=1
End DoDot:1
IF DONE
QUIT
+12 QUIT FORGN
UPDADDLG(DFN,DGPRIOR,DGINPUT) ; Update the IVM ADDRESS CHANGE LOG file #301.7
+1 ;
+2 DO UPDADDLG^DGADDUT2(DFN,.DGPRIOR,.DGINPUT)
+3 QUIT
EDITTADR(DFN) ; Edit Temporary Address
+1 NEW DGPRIOR,DGCH,DGRPAN,DGDR,DGRPS
+2 IF $GET(DFN)=""
QUIT
+3 ;I ($G(DFN)'?.N) Q
+4 ;
+5 ; Get the current Temporary Address and display it
+6 DO GETTADR(DFN,.DGPRIOR)
+7 DO DISPTADR(DFN,.DGPRIOR)
+8 WRITE !!
+9 ;
+10 SET DGCH=5
SET DGRPAN="1,2,3,4,5,"
SET DGDR=""
SET DGRPS=1
+11 DO CHOICE^DGRPP
+12 DO ^DGRPE
+13 ; Update the Date/Time Stamp
+14 DO UPDDTTM(DFN,TYPE)
+15 QUIT
GETTADR(DFN,DGPRIOR) ; Get prior temporary address fields.
+1 NEW DGCURR,DGN,DGARRY,DGCIEN,DGST,DGCNTY
+2 DO GETS^DIQ(2,DFN_",",".1211;.1212;.1213;.1214;.1215;.1216;.1217;.1218;.12105;.1219;.12111;.12112;.12113;.12114;.1221:.1223","I","DGCURR")
+3 FOR DGN=.1211,.1212,.1213,.1214,.1215,.1216,.1217,.1218,.12105,.1219,.12111,.12112,.12113,.12114,.1221,.1222,.1223
Begin DoDot:1
+4 SET DGARRY("OLD",DGN)=$GET(DGCURR(2,DFN_",",DGN,"I"))
End DoDot:1
+5 MERGE DGPRIOR=DGARRY("OLD")
+6 QUIT
DISPTADR(DFN,DGARRY) ; Display Temporary Address
+1 NEW DGADRACT,DGADR1,DGADR2,DGADR3,DGCITY,DGSTATE,DGZIP
+2 NEW DGCOUNTY,DGPHONE,DGFROMDT,DGTODT,DGPROV,DGPCODE,DGCNTRY,DGFORN
+3 ;
+4 SET DGADRACT=$GET(DGARRY(.12105))
+5 SET DGADR1=$GET(DGARRY(.1211))
+6 SET DGADR2=$GET(DGARRY(.1212))
+7 SET DGADR3=$GET(DGARRY(.1213))
+8 SET DGCITY=$GET(DGARRY(.1214))
+9 SET DGSTATE=$GET(DGARRY(.1215))
+10 SET DGZIP=$GET(DGARRY(.1216))
+11 SET DGCOUNTY=$GET(DGARRY(.12111))
+12 IF DGCOUNTY'=""
IF DGSTATE'=""
IF $DATA(^DIC(5,DGSTATE,1,DGCOUNTY,0))
Begin DoDot:1
+13 SET DGCOUNTY=$PIECE(^DIC(5,DGSTATE,1,DGCOUNTY,0),"^")_" ("_$PIECE(^DIC(5,DGSTATE,1,DGCOUNTY,0),"^",4)_")"
End DoDot:1
+14 IF DGADRACT'="Y"
SET DGCOUNTY="NOT APPLICABLE"
+15 IF DGSTATE'=""
IF $DATA(^DIC(5,DGSTATE,0))
SET DGSTATE=$PIECE(^DIC(5,DGSTATE,0),"^",2)
+16 SET DGPROV=$GET(DGARRY(.1221))
+17 SET DGPCODE=$GET(DGARRY(.1222))
+18 SET DGCNTRY=$GET(DGARRY(.1223))
+19 SET DGFORN=$$FORIEN(DGCNTRY)
+20 IF DGCNTRY]""
SET DGCNTRY=$$CNTRYI(DGCNTRY)
+21 SET DGPHONE=$GET(DGARRY(.1219))
+22 SET DGFROMDT=$$FMTE^XLFDT($GET(DGARRY(.1217)))
+23 SET DGTODT=$$FMTE^XLFDT($GET(DGARRY(.1218)))
+24 ;
+25 WRITE !!,"Temporary Address: "
+26 IF DGADRACT="Y"
Begin DoDot:1
+27 IF DGADR1'=""
WRITE !?9,DGADR1
+28 IF DGADR2'=""
WRITE !?9,DGADR2
+29 IF DGADR3'=""
WRITE !?9,DGADR3
+30 IF DGFORN=0
Begin DoDot:2
+31 WRITE !?9,$SELECT(DGCITY'="":DGCITY,1:"")_$SELECT(DGCITY'="":",",1:" ")_$SELECT(DGSTATE'="":DGSTATE,1:"")_" "_$SELECT(DGZIP'="":DGZIP,1:"")
End DoDot:2
+32 IF DGFORN
WRITE !?9,$SELECT(DGPCODE'="":DGPCODE,1:"")_" "_$SELECT(DGCITY'="":DGCITY,1:"")_$SELECT(DGCITY'="":",",1:" ")_$SELECT(DGPROV'="":DGPROV,1:"")
+33 WRITE !?9,$SELECT(DGCITY'="":DGCITY,1:"")_","_$SELECT(DGSTATE'="":DGSTATE,1:"")_" "_$SELECT(DGZIP'="":DGZIP,1:"")
+34 WRITE !," County: "_DGCOUNTY
+35 WRITE !," Phone: "_DGPHONE
+36 WRITE !,"From/To: "_$PIECE(DGFROMDT,",")_","_$PIECE(DGFROMDT,", ",2)_"-"_$PIECE(DGTODT,",")_","_$PIECE(DGTODT,", ",2)
End DoDot:1
+37 ;
+38 IF $GET(DGARRY(.12105))="N"
Begin DoDot:1
+39 IF $GET(DGARRY(.1211))=""
WRITE !?9,"NO TEMPORARY ADDRESS"
+40 IF $GET(DGARRY(.1212))=""
WRITE !?9,""
+41 WRITE !," County: NOT APPLICABLE"
+42 WRITE !," Phone: NOT APPLICABLE"
+43 WRITE !,"From/To: NOT APPLICABLE"
End DoDot:1
+44 QUIT
COUNTRY(DGC) ;
+1 ;where DGC is the external value of the country
+2 ;return value is in upper case display mode
+3 ;if DGC is invalid, return -1
+4 NEW DGCC,DGIEN
+5 ; if input is NULL change to US
+6 IF $GET(DGC)=""
SET DGC="USA"
+7 ; Get IEN from B index, error if not found
+8 SET DGIEN=$ORDER(^HL(779.004,"B",DGC,""))
IF DGIEN']""
QUIT -1
+9 ; xlate IEN to POSTAL NAME
+10 SET DGCC=$PIECE(^HL(779.004,DGIEN,"SDS"),U,3)
+11 ; if POSTAL NAME = "<NULL>" return DESCRIPTION
+12 IF DGCC="<NULL>"
Begin DoDot:1
+13 SET DGCC=$$UPPER^DGUTL($PIECE(^HL(779.004,DGIEN,0),U,2))
End DoDot:1
+14 QUIT DGCC
FOR(DGC) ;returns a 1 if address is foreign, a 0 if domestic, -1 if DGC is not valid
+1 ; DGC is the external value of the country (.01 field of file 779.004)
+2 NEW DGFOR
+3 SET DGFOR=0
+4 IF $GET(DGC)=""
QUIT DGFOR
+5 IF '$DATA(^HL(779.004,"B",DGC))
QUIT -1
+6 IF DGC'="USA"
SET DGFOR=1
+7 QUIT DGFOR
CNTRYI(DGIEN) ;where DGC is the internal value of the country
+1 ;return DGC as the display value for the country
+2 ;if the input value is not a valid IEN, return -1
+3 ;if the input value is null, return null
+4 NEW DGCC
+5 IF $GET(DGIEN)=""
QUIT ""
+6 IF '$DATA(^HL(779.004,DGIEN,0))
QUIT -1
+7 ; xlate IEN to POSTAL NAME
+8 SET DGCC=$PIECE(^HL(779.004,DGIEN,"SDS"),U,3)
+9 ; if POSTAL NAME = "<NULL>" return DESCRIPTION
+10 IF DGCC="<NULL>"
Begin DoDot:1
+11 SET DGCC=$$UPPER^DGUTL($PIECE(^HL(779.004,DGIEN,0),U,2))
End DoDot:1
+12 QUIT DGCC
FORIEN(DGC) ;returns a 1 if address is foreign, a 0 if domestic, -1 if DGC is invalid
+1 ;DGC is the IEN of the country file (#779.004)
+2 NEW DGFOR
+3 SET DGFOR=0
+4 IF $GET(DGC)=""
QUIT DGFOR
+5 IF DGC'?1.3N
QUIT -1
+6 IF '$DATA(^HL(779.004,DGC,0))
QUIT -1
+7 IF DGC]""
IF (DGC'=$ORDER(^HL(779.004,"B","USA","")))
SET DGFOR=1
+8 QUIT DGFOR