HMPPTDEM  ;ASMR/EJK,JD - File Patient Demographic Information passed via RPC ; 09/16/2014
 ;;2.0;ENTERPRISE HEALTH MANAGEMENT PLATFORM;**;Oct 10, 2014;Build 63
 ;Per VA Directive 6402, this routine should not be modified.
 ;
 ; RPC = HMP WRITEBACK PT DEM
 ;
 ; *** NOTES ***
 ; Return variable must be an ARRAY
 ; A success MUST be sent as a 1
 ; A failure may take any form
 ; *************
 ;
 
Q  ;Must come in at a tag.
 ;
FILE(RSP,HMPDEM) ;File Patient Demographic information.
 ;Inbound data layout:
 ; "^" delimited
 ; Piece 1: DFN
 ; Piece 2: Home Phone Number - ^DD(2,.131 - ^DPT(DFN,.13) piece 1
 ; Piece 3: Cell Phone Number - ^DD(2,.134 - ^DPT(DFN,.13) piece 4
 ; Piece 4: Work Phone Number - ^DD(2,.132 - ^DPT(DFN,.13) piece 2
 ; Piece 5: Emergency Phone Number - ^DD(2,.339 - ^DPT(DFN,.33) piece 9
 ; Piece 6: NOK Phone Number - ^DD(2,.219 - ^DPT(DFN,.21) piece 9
 ;
 ; If a piece contains -1, it means DELETE it
 ; If a piece is null, it means LEAVE it ALONE
 ; If a piece is not -1 and not null, it means UPDATE it
 ; 
 ;D BEFORE  ; testing ONLY
 
PROC
 
;D AFTER  ; testing ONLY
 
Q
 
;
PROC ;
 
HMPDFN,HMPHPN,HMPCPN,HMPWPN,HMPEPN,HMPNPN,RSPCNT
 
HMPER,HMPX
 
HMPX
 
RSPCNT=0,HMPER=""
 
HMPDFN=$P(HMPDEM,"^",1)
 
HMPHPN=$P(HMPDEM,"^",2)
 
HMPCPN=$P(HMPDEM,"^",3)
 
HMPWPN=$P(HMPDEM,"^",4)
 
HMPEPN=$P(HMPDEM,"^",5)
 
HMPNPN=$P(HMPDEM,"^",6)
 
DA=HMPDFN
 
RSP
 
RSP(0)=1 ;"Writeback was successful"  ; default to good news!
 
HMPDFN']"" RSP(0)="No DFN" Q
 I 
'$D(^DPT(HMPDFN)) RSP(0)="Patient does not exist.  DFN: "_HMPDFN Q  ;ICR 10035 DE2818 ASF 11/12/15
 
I $$GET1^DIQ(2,HMPDFN_",",.331)']"",HMPEPN]"" RSP(0)="Setting EM CO PH w/o EM CO Name" Q
 I $$
GET1^DIQ(2,HMPDFN_",",.211)']"",HMPNPN]"" RSP(0)="Setting NOK PH w/o NOK Name" Q
 S 
HMPX(2,DA_",",.131)=$S(HMPHPN=-1:"",HMPHPN="":$$GET1^DIQ(2,HMPDFN_",",.131),1:HMPHPN)
 
HMPX(2,DA_",",.132)=$S(HMPWPN=-1:"",HMPWPN="":$$GET1^DIQ(2,HMPDFN_",",.132),1:HMPWPN)
 
HMPX(2,DA_",",.134)=$S(HMPCPN=-1:"",HMPCPN="":$$GET1^DIQ(2,HMPDFN_",",.134),1:HMPCPN)
 
HMPX(2,DA_",",.219)=$S(HMPNPN=-1:"",HMPNPN="":$$GET1^DIQ(2,HMPDFN_",",.219),1:HMPNPN)
 
HMPX(2,DA_",",.339)=$S(HMPEPN=-1:"",HMPEPN="":$$GET1^DIQ(2,HMPDFN_",",.339),1:HMPEPN)
 
UPDATE^DIE(,"HMPX",,"HMPER")
 
HMPER]"" RSP(0)=HMPER
 
Q
BEFORE ;
 
DFN=$P(HMPDEM,"^",1)
 
HPN,CPN,WPN,EPN,NPN,PTNAME
 
(HPN,CPN,WPN,EPN,NPN)=""
 
PTNAME=$$GET1^DIQ(2,DFN_",",.01,"E")
 
HPN=$$GET1^DIQ(2,DFN_",",.131,"E")
 
CPN=$$GET1^DIQ(2,DFN_",",.134,"E")
 
WPN=$$GET1^DIQ(2,DFN_",",.132,"E")
 
EPN=$$GET1^DIQ(2,DFN_",",.339,"E")
 
NPN=$$GET1^DIQ(2,DFN_",",.219,"E")
 
"Patient: "_PTNAME,!
 
"Before executing input string:",!
 
?5,"Home Phone: "_HPN,!
 
?5,"Cell Phone: "_CPN,!
 
?5,"Work Phone: "_WPN,!
 
?5,"Emergency Phone: "_EPN,!
 
?5,"NOK Phone: "_NPN,!!
 
Q
AFTER ;
 
(HPN,CPN,WPN,EPN,NPN)=""
 
PTNAME=$$GET1^DIQ(2,DFN_",",.01,"E")
 
HPN=$$GET1^DIQ(2,DFN_",",.131,"E")
 
CPN=$$GET1^DIQ(2,DFN_",",.134,"E")
 
WPN=$$GET1^DIQ(2,DFN_",",.132,"E")
 
EPN=$$GET1^DIQ(2,DFN_",",.339,"E")
 
NPN=$$GET1^DIQ(2,DFN_",",.219,"E")
 
"After executing input string:",!
 
"Patient: "_PTNAME,!
 
?5,"Home Phone: "_HPN,!
 
?5,"Cell Phone: "_CPN,!
 
?5,"Work Phone: "_WPN,!
 
?5,"Emergency Phone: "_EPN,!
 
?5,"NOK Phone: "_NPN
 
Q