Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: DGRRPSGT

DGRRPSGT.m

Go to the documentation of this file.
DGRRPSGT ; ALB/SGG - DG R&R PatientServices GET data - return XML ; 09/30/03
 ;;5.3;Registration;**557**;Aug 13, 1993
 ;
DOC ;
 ; ==================================================================
 ;      Documentation for the DGRRPS* routines is in DGRRPSAA.
 ; ==================================================================
 ; This routine is called from the RPC DGRR GET PATIENT SERVICES DATA
 ; ==================================================================
 ;
 ;
PATIENT(RESULT,PARAMS) ;
 ;
 NEW CURLINE,ICN,PTID,ERRMESS,PSARRAY,PSGLBCNT,DGRRPS,GLOB,TRACECNT,TRACENO,REQDT
 ;
 DO INITIZE
 ;Call to INTRACE commented out to prevent to building of the XTMP global.
 ;DO INTRACE
 DO GETPATID(.ICN,.PTID,.ERRMESS) IF $G(ERRMESS)'="" GOTO ERROR
 S REQDT=$G(PARAMS("REQUESTED_DATE"))
 DO GETGLOBS
 ;
BUILD ; BUILD THE PATIENT XML
 SET PSARRAY(1)=$$XMLHDR^DGRR557U_"^^^1" DO APPEND(.PSARRAY)
 SET PSARRAY(1)="<Patient>" DO APPEND(.PSARRAY)
 DO GETPSARY^DGRRPSID(.PSARRAY) DO APPEND(.PSARRAY)
 IF +$G(PARAMS("PrimaryDemo")) DO GETPSARY^DGRRPSD1(.PSARRAY) DO APPEND(.PSARRAY)
 IF +$G(PARAMS("SecondaryDemo")) DO GETPSARY^DGRRPSD2(.PSARRAY) DO APPEND(.PSARRAY)
 IF +$G(PARAMS("TertiaryDemo")) DO GETPSARY^DGRRPSD3(.PSARRAY) DO APPEND(.PSARRAY)
 IF +$G(PARAMS("MainAddress")) DO GETPSARY^DGRRPSAM(.PSARRAY) DO APPEND(.PSARRAY)
 IF +$G(PARAMS("TemporaryAddress")) DO GETPSARY^DGRRPSAT(.PSARRAY) DO APPEND(.PSARRAY)
 IF +$G(PARAMS("ConfidentialAddress")) DO GETPSARY^DGRRPSAC(.PSARRAY) DO APPEND(.PSARRAY)
 IF +$G(PARAMS("ContactInfo")) DO GETPSARY^DGRRPSKN(.PSARRAY) DO APPEND(.PSARRAY)
 IF +$G(PARAMS("ADTInfo")) DO GETPSARY^DGRRPSAD(.PSARRAY,REQDT) DO APPEND(.PSARRAY)
 IF +$G(PARAMS("EnrollEligibility")) DO GETPSARY^DGRRPSEE(.PSARRAY) DO APPEND(.PSARRAY)
 IF +$G(PARAMS("Incompetent")) DO GETPSARY^DGRRPSIC(.PSARRAY) DO APPEND(.PSARRAY)
 DO GETPSARY^DGRRPSIN(.PSARRAY) DO APPEND(.PSARRAY)
 SET PSARRAY(1)="<Error Message=''></Error>" DO APPEND(.PSARRAY)
 SET PSARRAY(1)="</Patient>"_"^^^1" DO APPEND(.PSARRAY)
 ;Call to OUTTRACE commented out preventing the building/purging of the
 ;XTMP global.
 ;DO OUTTRACE
EXIT QUIT
 ;
APPEND(PSARRAY) ; 
 ; Append PSARRAY(1...n)= TextOnly ^ XML_attribute ^ ValueOfAttribute ^ FileNowFlag
 ; In some code there are 5th and 6th pieces to this,,  they are not used,, it was the start of a receiver/parser that was never needed
 NEW MAXGL,TEXT,ATTRIB,VALUE,CLOSEOUT,NEWLINE
 SET MAXGL=240 ; maximum global length
 SET PSARRAY="" FOR  SET PSARRAY=$O(PSARRAY(PSARRAY)) QUIT:PSARRAY=""  DO
 .SET TEXT=$P(PSARRAY(PSARRAY),"^",1)
 .SET ATTRIB=$P(PSARRAY(PSARRAY),"^",2)
 .SET VALUE=$P(PSARRAY(PSARRAY),"^",3)
 .SET CLOSEOUT=$P(PSARRAY(PSARRAY),"^",4)
 .SET CURLINE=$G(CURLINE)
 .SET NEWLINE=TEXT
 .IF ATTRIB'="" SET NEWLINE=NEWLINE_" "_ATTRIB_"='"_$S(VALUE'="":$$CHARCHK^DGRR557U(VALUE),1:"")_"'"
 .IF ($L(CURLINE)+$L(NEWLINE))>MAXGL DO
 ..SET ^TMP($J,"PS-DATA",PSGLBCNT)=$E(CURLINE_NEWLINE,1,MAXGL)
 ..SET PSGLBCNT=PSGLBCNT+1
 ..SET CURLINE=$E(CURLINE_NEWLINE,MAXGL+1,999),NEWLINE=""
 .SET CURLINE=CURLINE_NEWLINE
 .IF +$G(CLOSEOUT),+$L(CURLINE) DO
 ..SET ^TMP($J,"PS-DATA",PSGLBCNT)=CURLINE
 ..SET PSGLBCNT=PSGLBCNT+1
 ..SET CURLINE=""
 .QUIT
 KILL PSARRAY
 QUIT
 ;
INITIZE ; Initialize variables
 KILL RESULT
 KILL ^TMP($J,"PS-DATA")
 SET PSGLBCNT=1
 SET DGRRPS="^TMP($J,""PS-DATA"")"
 SET RESULT=$NA(@DGRRPS)
 IF '$D(DT) D DTNOLF^DICRW
 KILL PSARRAY
 QUIT
 ;
INTRACE ; Keep a record of what has been requested
 N PURGDT
 S PURGDT=$$FMADD^XLFDT(DT,31)
 IF '$D(^XTMP("DGRRPS",0)) SET ^XTMP("DGRRPS",0)=PURGDT_"^"_DT_"^"_"LAST 30 DAYS OF PATIENT SERVICES ACTIVITY - CREATED IN RTN DGRRPSGT - THIS GLOBAL IS SELF PURGING ON >10,000 RECORDS OR >31 DAYS - email:VHA OI SDD CS Person Demographic"
 SET $P(^XTMP("DGRRPS",0),"^",1)=PURGDT
 SET TRACECNT=$G(^XTMP("DGRRPS","COUNT"))+1,^XTMP("DGRRPS","COUNT")=TRACECNT
 SET ^XTMP("DGRRPS","TRACE",TRACECNT,"DATE",DT)=$$NOW^XLFDT
 MERGE ^XTMP("DGRRPS","TRACE",TRACECNT,"PARAMS")=PARAMS
 QUIT
 ;
GETPATID(ICN,PTID,ERRMESS) ; Get patient PTID and ICN
 IF $G(PARAMS("PatientId_Type"))="ICN" DO
 .SET ICN=$G(PARAMS("PatientId"))
 .IF $E(ICN,1,6)=" ICN: " SET ICN=$E(ICN,7,99)
 .SET ICN=$P(ICN,"^",1)
 .SET PTID=$$GETDFN^MPIF001(ICN)
 .; Call MPI API to be sure ICN is returned in ICN_V_checksum format
 .SET ICN=$$GETICN^MPIF001(PTID)
 .IF $G(PTID)<1 SET ERRMESS=$P(PTID,"^",2)
 IF $G(PARAMS("PatientId_Type"))="DFN" DO
 .SET PTID=+$G(PARAMS("PatientId"))
 .SET ICN=$$GETICN^MPIF001(PTID)
 .;IF +ICN<1 SET ERRMESS=$P(ICN,"^",2)
 .IF ICN<1 SET ICN=""
 IF ($G(PARAMS("PatientId_Type"))'="DFN"),($G(PARAMS("PatientId_Type"))'="ICN") SET ERRMESS="Unknown PatientId_Type"
 QUIT
 ;
GETGLOBS ; Get required DPT globals
 SET GLOB(0)=$G(^DPT(PTID,0))
 SET GLOB(.11)=$G(^DPT(PTID,.11))
 SET GLOB(.121)=$G(^DPT(PTID,.121))
 SET GLOB(.13)=$G(^DPT(PTID,.13))
 KILL GLOB(.14) MERGE GLOB(.14)=^DPT(PTID,.14)
 SET GLOB(.141)=$G(^DPT(PTID,.141))
 SET GLOB(.15)=$G(^DPT(PTID,.15))
 SET GLOB(.22)=$G(^DPT(PTID,.22))
 SET GLOB(.24)=$G(^DPT(PTID,.24))
 SET GLOB(.29)=$G(^DPT(PTID,.29))
 SET GLOB(.291)=$G(^DPT(PTID,.291))
 SET GLOB(.3)=$G(^DPT(PTID,.3))
 SET GLOB(.31)=$G(^DPT(PTID,.31))
 SET GLOB(.32)=$G(^DPT(PTID,.32))
 SET GLOB(.35)=$G(^DPT(PTID,.35))
 SET GLOB(.36)=$G(^DPT(PTID,.36))
 SET GLOB(.361)=$G(^DPT(PTID,.361))
 SET GLOB(38.1)=$G(^DGSL(38.1,PTID,0))
 SET GLOB(57)=$G(^DPT(PTID,57))
 SET GLOB("NAME")=$$GETNME(PTID)
 QUIT
 ;
GETNME(PTID) ; return patient name components
 NEW RE,DGRRN
 S DGRRN("FILE")=2
 S DGRRN("FIELD")=.01
 S DGRRN("IENS")=$$IENS^DILF(+PTID)
 S RE=$$HLNAME^XLFNAME(.DGRRN)
 Q RE
 ;
OUTTRACE ; Keep a record of what has been put out
 MERGE ^XTMP("DGRRPS","TRACE",+$G(TRACECNT),"DATA")=^TMP($J,"PS-DATA")
PURGE ; Purge trace > 31 days and >10,000 records
 SET TRACENO="" FOR  SET TRACENO=$O(^XTMP("DGRRPS","TRACE",TRACENO)) QUIT:TRACENO=""  QUIT:($O(^XTMP("DGRRPS","TRACE",TRACENO,"DATE",""))>($$FMADD^XLFDT(DT,-31)))  KILL ^XTMP("DGRRPS","TRACE",TRACENO)
 SET TRACENO="" FOR  SET TRACENO=$O(^XTMP("DGRRPS","TRACE",TRACENO)) QUIT:TRACENO=""  QUIT:(TRACENO>($O(^XTMP("DGRRPS","TRACE",""),-1)-10000))  KILL ^XTMP("DGRRPS","TRACE",TRACENO)
 QUIT
 ;
ERROR ; Build an Error XML and quit
 DO INITIZE
 SET PSARRAY(1)=$$XMLHDR^DGRR557U_"^^^1"
 SET PSARRAY(2)="<Patient>"_"^^^1"
 SET PSARRAY(3)="<Error"
 SET PSARRAY(4)="^Message^"_ERRMESS
 SET PSARRAY(5)="^PatientId^"_$G(PARAMS("PatientId"))
 SET PSARRAY(6)="></Error>"_"^^^1"
 SET PSARRAY(7)="</Patient>"_"^^^1" DO APPEND(.PSARRAY)
 ;DO OUTTRACE
 QUIT