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

BGOREF.m

Go to the documentation of this file.
BGOREF ; IHS/BAO/TMD - Manage REFUSALS ;18-Apr-2014 12:29;DU
 ;;1.1;BGO COMPONENTS;**1,3,5,11,13**;Mar 20, 2007;Build 16
 ; Add/edit a refusal
 ;  INP = Refusal IEN [1] ^ Refusal Type [2] ^ Item IEN [3] ^ Patient IEN [4] ^
 ;        Refusal Date [5] ^ Comment [6] ^ Provider IEN [7] ^ Reason [8]
 ;Patch 5, changed mammogram code for bilateral mammogram
 ;Patch 13,changes for SNOMED
SET(RET,INP) ;EP
 N DFN,REFIEN,REFTYP,ITEMIEN,REFDATE,COMMENT,REASON,PRV,HST,HIS,CT
 S (CT,HIS)=""
 S DFN=$P(INP,U,4)
 I 'DFN S RET=$$ERR^BGOUTL(1050) Q
 I '$D(^AUPNPAT(DFN,0)) S RET=$$ERR^BGOUTL(1001) Q
 S REFIEN=+INP
 S REFTYP=$P(INP,U,2)
 S ITEMIEN=$P(INP,U,3)
 S REFDATE=$P(INP,U,5)
 S COMMENT=$P(INP,U,6)
 S PRV=$P(INP,U,7)
 S REASON=$P(INP,U,8)
 I $L(REASON)>0 D
 .;IHS/MSC/MGH Patch 11
 .;S REASON=$$UPPER^BGOVPED2(REASON)
 .;S REASON=$S(REASON="REFUSED SERVICE":"R",REASON="UNABLE TO SCREEN":"U",REASON="NOT MEDICALLY INDICATED":"N",REASON="NO RESPONSE TO FOLLOWUP":"F",REASON="PROVIDER DISCONTINUED":"P",1:"")
 .;Patch 13 cfhanged reason to SNOMED
 .S CT=$$GET1^DIQ(9999999.102,REASON,.01)
 .S HIS=$$GET1^DIQ(9999999.102,REASON,.04,"I")
 ;S:REASON="" REASON="R"
 S RET=$$REFSET2^BGOUTL2(DFN,REFDATE,ITEMIEN,REFTYP,HIS,COMMENT,PRV,REFIEN,CT)
 Q
 ; Get refusal data
 ;  INP = Patient IEN ^ Refusal IEN
 ;  List of records in the format:
 ;    R ^ Refusal IEN [2] ^ Type IEN [3] ^ Type Name [4] ^ Item IEN [5] ^ Item Name [6] ^ Provider IEN [7] ^
 ;    Provider Name [8] ^ Date [9] ^ Locked [10] ^ Reason [11] ^ Comment [12]
GET(RET,INP) ;EP
 N CNT,DFN,REFIEN
 S RET=$$TMPGBL^BGOUTL
 S DFN=+INP
 S REFIEN=$P(INP,U,2)
 I REFIEN S @RET@(1)=$$REFGET1^BGOUTL2(REFIEN)
 E  D
 .S REFIEN="",CNT=0
 .F  S REFIEN=$O(^AUPNPREF("AC",DFN,REFIEN),-1) Q:'REFIEN  D
 ..S CNT=CNT+1,@RET@(CNT)=$$REFGET1^BGOUTL2(REFIEN)
 Q
 ; Delete a refusal
DEL(RET,REFIEN) ;EP
 S RET=$$REFDEL^BGOUTL2(REFIEN)
 Q
 ; Return IEN for pap smear/mammogram/ekg
REFLIST(RET,INP) ;EP
 S INP=$$UP^XLFSTR(INP)
 I INP="PAP SMEAR" S RET=$O(^LAB(60,"B","PAP SMEAR",0))
 E  I INP="MAMMOGRAM" S RET=$O(^RAMIS(71,"D",76056,0))
 E  I INP="EKG" S RET=$O(^AUTTDXPR("B","ECG SUMMARY",0))
 E  S RET=$$ERR^BGOUTL(1051,INP)
 Q
 ;Return the list of SNOMED reasons for refusal
 ;Returns the list with the
 ;IEN [1] ^ TEXT [2]
GETREA(RET,TYPE) ;EP
 N IEN,SCREEN,CNT
 S RET=$$TMPGBL^BGOUTL
 S TYPE=$$UP^XLFSTR(TYPE)
 S CNT=0
 I $G(TYPE)="" S TYPE="IMMUNIZATION"
 S IEN=0 F  S IEN=$O(^AUTTREFR(IEN)) Q:'+IEN  D
 .S SCREEN=$$GET1^DIQ(9999999.102,IEN,.06,"I")
 .I TYPE="MEDICATION/DRUG"&(SCREEN=1!(SCREEN=3)) D ADD(IEN)
 .E  I SCREEN=2!(SCREEN=3) D ADD(IEN)
 Q
ADD(IEN) ;Add to array
 N IN,OUT,X,ARR,DESC,TXT
 S CT=$$GET1^DIQ(9999999.102,IEN,.01)
 S IN=CT_"^36^^1^"
 S OUT="ARR"
 S X=$$CNCLKP^BSTSAPI(.OUT,.IN)
 I X>0 D
 .S TXT=@OUT@(1,"PRE","TRM")
 .S CNT=CNT+1
 .S @RET@(CNT)=IEN_U_TXT
 Q