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

BEHOCIR1.m

Go to the documentation of this file.
BEHOCIR1 ;MSC/IND/MGH - CCD calls ;06-Nov-2014 16:53;PLS
 ;;1.1;BEH COMPONENTS;**066001,066002**;March 12, 2008;Build 2
 ;=================================================================
 ; RPC: BEHOCIR1 GETCCDS
 ; Call to return a list of CCDs for a patient.
 ; Input is the pt and the date range
GETCCDS(DATA,DFN,STRTDT,ENDDT) ;
 N FLGS,MISCPRMS,LIST,TXT,I
 S FLGS="CE",DATA=$$TMPGBL
 S MISCPRMS(1)="IDFN^^"_DFN
 S MISCPRMS(2)="IXCLASS^^CLIN"
 S MISCPRMS(3)="IXTYPE^^CCD-SUMMARY"
 D GETIMGS^MAGSIXG1(.LIST,FLGS,STRTDT,ENDDT,"",.MISCPRMS)
 S I="" F  S I=$O(LIST(I)) Q:I=""  D
 .I I=0!(I=1) D
 ..S @DATA@(I)=LIST(I)
 .E  D
 ..S TXT=$G(LIST(I))
 ..I $P(TXT,U,10)="CCD-SUMMARY" S @DATA@(I)=LIST(I)
 Q
 ;RPC Find Reconciliation entries for a patient
 ;Input=patient DFN
 ;      Start date
 ;      end date
 ;Return list of CCD entries
 ;IEN^PATIENT^DATE STORED^SOURCE^RECONCILED^IMAGE^OID^EXT
PTCCD(RET,DFN,STRTDT,ENDDT) ;list of entries
 N BEGDT,EDATE,FIRST,IEN,CNT,IDTE,SRC,RES,REC,IMAGE,OID,EXT,ADATE,PDATE,MDATE,NEW,STRING,IARRAY
 S RET=$$TMPGBL()
 S CNT=0,IARRAY=""
 I $G(STRTDT)="" S STRTDT=3000101
 I $G(ENDDT)="" S ENDDT=$$NOW^XLFDT
 S BEGDT=9999999-STRTDT,EDATE=9999999-ENDDT
 S BEGDT=BEGDT+1
 S FIRST=EDATE-0.1 F  S FIRST=$O(^BEHOCIR("AA",DFN,FIRST)) Q:FIRST=""!($P(FIRST,".",1)>BEGDT)  D
 .S IEN="" F  S IEN=$O(^BEHOCIR("AA",DFN,FIRST,IEN)) Q:IEN=""  D
 ..S IMAGE=$$GET1^DIQ(90461.63,IEN,1.1,"I")
 ..S SRC=$$GET1^DIQ(90461.63,IEN,.03)
 ..S IDTE=$$GET1^DIQ(90461.63,IEN,.01)
 ..S REC=$$GET1^DIQ(90461.63,IEN,.04)
 ..S RES=$$GET1^DIQ(90461.63,IEN,.05)
 ..D DTE
 S I="" F  S I=$O(IARRAY(I)) Q:I=""  D
 .S CNT=CNT+1
 .S @RET@(CNT)=$G(IARRAY(I))
 Q
DTE ;Check reconcillation dates
 S ADATE=$$GET1^DIQ(90461.63,IEN,.07)
 S PDATE=$$GET1^DIQ(90461.63,IEN,.08)
 S MDATE=$$GET1^DIQ(90461.63,IEN,.09)
 I '+IMAGE D  Q
 .S STRING=IEN_U_IDTE_U_SRC_U_REC_U_IMAGE_U_ADATE_U_PDATE_U_MDATE_U_RES
 .S CNT=CNT+1
 .S @RET@(CNT)=STRING
 I $D(IARRAY(IMAGE)) D
 .S DATA=$G(IARRAY(IMAGE))
 .I ADATE>$P(DATA,U,6) S $P(DATA,U,6)=ADATE
 .I PDATE>$P(DATA,U,7) S $P(DATA,U,7)=PDATE
 .I MDATE>$P(DATA,U,8) S $P(DATA,U,8)=MDATE
 E  D
 .S IARRAY(IMAGE)=IEN_U_IDTE_U_SRC_U_REC_U_IMAGE_U_ADATE_U_PDATE_U_MDATE_U_RES
 Q
CCDCHECK ;EP
 N ST,TMP,X,Y
 S ST=$$GET^XPAR("SYS","BEHOCIR IMAGE SEARCH DT",1,"I")
 D ADDTOLST(ST)
 Q
ADDTOLST(ST) ;EP
 ;Loop through Image file from last date stored and add any CCD type images to the BEH RECONCILIATION list
 N LSTDT,IEN,TYPE,DESC,PT,NOW,ERR,SAVE,MAGRY
 S NOW=$$NOW^XLFDT
 S LSTDT=ST F  S LSTDT=$O(^MAG(2005,"AD",LSTDT)) Q:LSTDT=""  D
 .S IEN="" F  S IEN=$O(^MAG(2005,"AD",LSTDT,IEN)) Q:IEN=""  D
 ..S TYPE=$$GET1^DIQ(2005,IEN,42)
 ..S DESC=$$GET1^DIQ(2005,IEN,100)
 ..I TYPE="CCD-SUMMARY" D
 ...Q:DESC="LOCAL SITE ENTRY"
 ...S PT=$$GET1^DIQ(2005,IEN,5)
 ...S SAVE=$$GET1^DIQ(2005,IEN,7)
 ...D LOAD(.MAGRY,IEN)
 D PUT^XPAR("SYS","BEHOCIR IMAGE SEARCH DT",1,NOW,.ERR)
 Q
LOAD(MAGRY,MAGIEN) ;Save the data
 N FDA,ERR,CHK,CAP,DFN,DATA
 S CAP=$$GET1^DIQ(2005,MAGIEN,8.1,"I")
 Q:CAP="I"
 S MAGRY(0)="1^Storage to reconciliation file"
 ;S MAGRY(1)=MAGIEN_" "_$$NOW^XLFDT
 ;Quit if this image is already saved
 S CHK="" S CHK=$O(^BEHOCIR("D",MAGIEN,CHK))
 Q:+CHK
 S FDA=$NA(FDA(90461.63,"+1,"))
 S @FDA@(.01)=$$NOW^XLFDT
 S DFN=$$GET1^DIQ(2005,MAGIEN,5,"I")
 S @FDA@(.02)="`"_DFN
 S @FDA@(1.1)="`"_MAGIEN
 D UPDATE^DIE("E","FDA",,"ERR")
 ; Fire update event
 D GETNUM^BEHOCIR(.DATA,DFN)
 D BRDCAST^CIANBEVT("CIR."_DFN,DATA)
 Q
TMPGBL() ;EP
 K ^TMP("BEHCIR",$J) Q $NA(^($J))
AUTO ;EP
 ;Trigger setting up this routine in the taskman scheduling file
 K %DT,DIC
 N START,X,Y,DIE
 S DIC(0)="XZM",(DIE,DIC)="^DIC(19.2,",X="BEHOCIR CCDADD"
 D ^DIC
 Q:+Y>0
 S START=$$FMADD^XLFDT($$NOW^XLFDT(),,,60)
 D RESCH^XUTMOPT("BEHOCIR",START,"","1H","L")
 Q