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

BQIUTIL.m

Go to the documentation of this file.
BQIUTIL ;VNGT/HS/ALA-Utility Program ; 10 Nov 2008  9:53 AM
 ;;2.6;ICARE MANAGEMENT SYSTEM;;Jul 07, 2017;Build 72
 ;
MREC(PTDFN,FREF,ITEM) ;EP 
 ; Find the most recent value for a specified item
 ; Input
 ;   PTDFN   - Patient IEN
 ;   FREF    - FileMan file number
 ;   ITEM    - Item (.01 external value)
 ;
 NEW RESULT,GREF,ENDT,IEN,TIEN,TEMP,QFL,XREF,IGREF,RITEM,BQPAR
 S RESULT=0
 ;
 S ITEM=$G(ITEM,"")
 I ITEM="" Q RESULT
 D FIELD^DID(FREF,.01,"","POINTER","BQPAR")
 S IGREF=$G(BQPAR("POINTER")),XREF="""B""" I IGREF="" Q RESULT
 S IGREF=U_IGREF_XREF_")"
 S RITEM=$O(@IGREF@(ITEM,"")) I RITEM="" Q RESULT
 ;
 S GREF=$$ROOT^DILFD(FREF,"",1)
 S TEMP=$NA(^TMP("BQITEMP",UID)) K @TEMP
 S IEN="",QFL=0
 F  S IEN=$O(@GREF@("AC",PTDFN,IEN),-1) Q:'IEN  D
 . S TIEN=$$GET1^DIQ(FREF,IEN,.01,"I") I TIEN="" Q
 . I TIEN'=RITEM Q
 . S VISIT=$$GET1^DIQ(FREF,IEN,.03,"I") I VISIT="" Q
 . I $$GET1^DIQ(9000010,VISIT,.11,"I")=1 Q
 . S VSDTM=$$GET1^DIQ(9000010,VISIT,.01,"I")\1 Q:VSDTM=0
 . ; Set temporary
 . S @TEMP@(VSDTM,VISIT,IEN)=$$GET1^DIQ(FREF,IEN,.04,"E")
 ;
 S VSDTM="",QFL=0
 F  S VSDTM=$O(@TEMP@(VSDTM),-1) Q:VSDTM=""!(QFL)  D
 . S VISIT=""
 . F  S VISIT=$O(@TEMP@(VSDTM,VISIT),-1) Q:VISIT=""  D  Q:QFL
 .. S IEN=""
 .. F  S IEN=$O(@TEMP@(VSDTM,VISIT,IEN),-1) Q:IEN=""  D  Q:QFL
 ... S $P(RESULT,U,2)=VSDTM,$P(RESULT,U,4)=VISIT_U_IEN
 ... S QFL=1,$P(RESULT,U,1)=1,$P(RESULT,U,3)=@TEMP@(VSDTM,VISIT,IEN)
 K @TEMP
 Q RESULT
 ;
OLOC() ;EP - Default Outside Location
 NEW LCN,ULOC,ULCN,OLOC
 S OLOC=""
 S LCN=$O(^XTV(8989.51,"B","BEHOENCX OTHER LOCATION","")) I LCN="" Q OLOC
 S ULOC=$G(DUZ(2)) I ULOC="" Q OLOC
 S ULCN=$O(^XTV(8989.5,"AC",LCN,ULOC_";DIC(4,",""))
 I ULCN'="" D
 . S OLOC=^XTV(8989.5,"AC",LCN,ULOC_";DIC(4,",ULCN)
 . S OLOC=OLOC_$C(29)_$P(^DIC(4,OLOC,0),"^",1)
 Q OLOC
 ;
CLOC() ; EP - Current Default Location
 NEW ULOC,LOC
 S LOC=""
 S ULOC=$G(DUZ(2)) I ULOC="" Q LOC
 S LOC=ULOC_$C(29)_$P(^DIC(4,ULOC,0),"^",1)
 Q LOC