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

BTIUPRVI.m

Go to the documentation of this file.
BTIUPRVI ; IHS/MSC/JS - Problem/Visit Objects ;24-Apr-2014 15:51;DU
 ;;1.0;TEXT INTEGRATION UTILITIES;**1012,1013**;MAR 20, 2013;Build 33
 ;Obects for visit-related problem entries from V Visit instructions
 ;V treatment/regimen and V referral files
 Q
 ;
VIDT(DFN,TARGET,NUM) ; Visit Instructions by date
 ;Get last (n) date entries for each date  of visit instructions
 ;Default is 99
 N ARRAY,PRIEN,INVDT,IEN,VCNT,CNT,EDATE,SIGN,STAT,NARR,SPRIEN,EIE
 K @TARGET
 S VCNT=0,CNT=0
 I $G(NUM)="" S NUM=99
 S PRIEN="" F  S PRIEN=$O(^AUPNVVI("AE",DFN,PRIEN)) Q:PRIEN=""  D
 .S INVDT="" F  S INVDT=$O(^AUPNVVI("AE",DFN,PRIEN,INVDT)) Q:INVDT=""  D
 ..S IEN="" F  S IEN=$O(^AUPNVVI("AE",DFN,PRIEN,INVDT,IEN)) Q:IEN=""  D
 ...S EIE=$$GET1^DIQ(9000010.58,IEN,.06,"I")
 ...Q:EIE=1
 ...S STAT=$P($G(^AUPNPROB(PRIEN,0)),U,12)
 ...Q:STAT="D"
 ...S ARRAY($P(INVDT,".",1),PRIEN,IEN)=""
 S INVDT="" F  S INVDT=$O(ARRAY(INVDT)) Q:INVDT=""!(CNT>NUM)  D
 .S CNT=CNT+1
 .Q:CNT>NUM
 .S EDATE=9999999-INVDT-1
 .S EDATE=$$FMTE^XLFDT(EDATE,5)
 .S VCNT=VCNT+1
 .S @TARGET@(VCNT,0)=EDATE
 .S SPRIEN=0
 .S PRIEN="" F  S PRIEN=$O(ARRAY(INVDT,PRIEN)) Q:PRIEN=""!(CNT>NUM)  D
 ..S IEN="" F  S IEN=$O(ARRAY(INVDT,PRIEN,IEN)) Q:IEN=""  D
 ...S SIGN=$$GET1^DIQ(9000010.58,IEN,.04,"E")
 ...S NARR=$$GET1^DIQ(9000011,PRIEN,.05)
 ...I SPRIEN'=PRIEN D
 ....S SPRIEN=PRIEN
 ....D PDATA(IEN)
 ...D TEXT
 I VCNT=0 S @TARGET@(1,0)="No visit instructions"
 Q "~@"_$NA(@TARGET)
PDATA(IEN) ;Get problem data
 S VCNT=VCNT+1
 S @TARGET@(VCNT,0)="Problem: "_NARR
 Q
 ;
TEXT ;do the text
 N TXTIEN
 S VCNT=VCNT+1
 S @TARGET@(VCNT,0)="  INSTRUCTIONS:"
 S TXTIEN=0 F  S TXTIEN=$O(^AUPNVVI(IEN,11,TXTIEN)) Q:'+TXTIEN  D
 .S VCNT=VCNT+1
 .S @TARGET@(VCNT,0)="   "_$G(^AUPNVVI(IEN,11,TXTIEN,0))
 S VCNT=VCNT+1
 S @TARGET@(VCNT,0)="  Signed by: "_SIGN
 S VCNT=VCNT+1
 S @TARGET@(VCNT,0)=""
 Q
VIPR(DFN,TARGET,NUM) ;Visit instructions by problem
 N ARRAY,PRIEN,INVDT,IEN,VCNT,EDATE,SIGN,STAT,SDATE,EIE,IENCNT
 K @TARGET
 S VCNT=0,CNT=0
 I $G(NUM)="" S NUM=99
 S PRIEN="" F  S PRIEN=$O(^AUPNVVI("AE",DFN,PRIEN)) Q:PRIEN=""  D
 .S STAT=$P($G(^AUPNPROB(PRIEN,0)),U,12)
 .S CNT=0
 .Q:STAT="D"
 .S NARR=$$GET1^DIQ(9000011,PRIEN,.05)
 .S VCNT=VCNT+1
 .S @TARGET@(VCNT,0)=NARR
 .S SDATE=0
 .S INVDT="" F  S INVDT=$O(^AUPNVVI("AE",DFN,PRIEN,INVDT)) Q:INVDT=""!(CNT>NUM)  D
 ..I SDATE'=$P(INVDT,".",1) S SDATE=$P(INVDT,".",1),CNT=CNT+1,IENCNT=0
 ..Q:CNT>NUM
 ..S IEN="" F  S IEN=$O(^AUPNVVI("AE",DFN,PRIEN,INVDT,IEN)) Q:IEN=""  D
 ...S EIE=$$GET1^DIQ(9000010.58,IEN,.06,"I")
 ...I EIE=1 Q
 ...S IENCNT=IENCNT+1
 ...S EDATE=$$GET1^DIQ(9000010.58,IEN,1201,"E")
 ...S SIGN=$$GET1^DIQ(9000010.58,IEN,.04,"E")
 ...S VCNT=VCNT+1
 ...S @TARGET@(VCNT,0)="  "_EDATE
 ...D TEXT
 ..I IENCNT=0 S CNT=CNT-1
 I VCNT=0 S @TARGET@(1,0)="No visit instructions"
 Q "~@"_$NA(@TARGET)
VTRDT(DFN,TARGET,NUM) ; Visit Treatment/Regimens  by date
 ;Get last (n) date entries for each problem  of treatments
 ;Default is 99
 N ARRAY,PRIEN,INVDT,IEN,VCNT,EDATE,SIGN,STAT,SNO,IN,OUT,ARR,X,TXT
 K @TARGET
 S VCNT=0,CNT=0
 I $G(NUM)="" S NUM=99
 E  S NUM=NUM-1
 S SNO="" F  S SNO=$O(^AUPNVTXR("AE",DFN,SNO)) Q:SNO=""  D
 .S INVDT="" F  S INVDT=$O(^AUPNVTXR("AE",DFN,SNO,INVDT)) Q:INVDT=""  D
 ..S IEN="" F  S IEN=$O(^AUPNVTXR("AE",DFN,SNO,INVDT,IEN)) Q:IEN=""  D
 ...S PRIEN=$P($G(^AUPNVTXR(IEN,0)),U,4)
 ...S STAT=$P($G(^AUPNPROB(PRIEN,0)),U,12)
 ...Q:STAT="D"
 ...S ARRAY(INVDT,PRIEN,IEN)=""
 S INVDT="" F  S INVDT=$O(ARRAY(INVDT)) Q:INVDT=""  D
 .S EDATE=9999999-INVDT
 .S EDATE=$$FMTE^XLFDT(EDATE,5)
 .S VCNT=VCNT+1
 .S @TARGET@(VCNT,0)=EDATE
 .S PRIEN="" F  S PRIEN=$O(ARRAY(INVDT,PRIEN)) Q:PRIEN=""  D
 ..S NARR=$$GET1^DIQ(9000011,PRIEN,.05)
 ..S VCNT=VCNT+1,CNT=CNT+1
 ..S @TARGET@(VCNT,0)="  "_NARR
 ..S IEN="" F  S IEN=$O(ARRAY(INVDT,PRIEN,IEN)) Q:IEN=""  D
 ...S SNO=$P($G(^AUPNVTXR(IEN,0)),U,1)
 ...S IN=SNO_"^^^1",OUT="ARR"
 ...S X=$$CNCLKP^BSTSAPI(.OUT,.IN)
 ...I X>0 D
 ....S TXT=ARR(1,"PRE","TRM")
 ....S VCNT=VCNT+1
 ....S @TARGET@(VCNT,0)="  "_TXT
 ..S VCNT=VCNT+1
 ..S @TARGET@(VCNT,0)=""
 I VCNT=0 S @TARGET@(1,0)="No visit treatments"
 Q "~@"_$NA(@TARGET)
VTRPR(DFN,TARGET,NUM) ; Visit Treatment/Regimens  by problem
 ;Default is 99
 N ARRAY,PRIEN,INVDT,IEN,VCNT,EDATE,SIGN,STAT,SNO,IN,OUT,ARR,X
 K @TARGET
 S VCNT=0,CNT=0
 I $G(NUM)="" S NUM=99
 E  S NUM=NUM-1
 S SNO="" F  S SNO=$O(^AUPNVTXR("AE",DFN,SNO)) Q:SNO=""  D
 .S INVDT="" F  S INVDT=$O(^AUPNVTXR("AE",DFN,SNO,INVDT)) Q:INVDT=""  D
 ..S IEN="" F  S IEN=$O(^AUPNVTXR("AE",DFN,SNO,INVDT,IEN)) Q:IEN=""  D
 ...S PRIEN=$P($G(^AUPNVTXR(IEN,0)),U,4)
 ...Q:PRIEN=""
 ...S STAT=$P($G(^AUPNPROB(PRIEN,0)),U,12)
 ...Q:STAT="D"
 ...S ARRAY(PRIEN,INVDT,IEN)=""
 S PRIEN="" F  S PRIEN=$O(ARRAY(PRIEN)) Q:PRIEN=""  D
 .S NARR=$$GET1^DIQ(9000011,PRIEN,.05)
 .S VCNT=VCNT+1
 .S @TARGET@(VCNT,0)=NARR
 .S INVDT="" F  S INVDT=$O(ARRAY(PRIEN,INVDT)) Q:INVDT=""  D
 ..S CNT=CNT+1
 ..S EDATE=9999999-INVDT
 ..S EDATE=$$FMTE^XLFDT(EDATE,5)
 ..S VCNT=VCNT+1
 ..S @TARGET@(VCNT,0)="  Date:"_EDATE
 ..S IEN="" F  S IEN=$O(ARRAY(PRIEN,INVDT,IEN)) Q:IEN=""  D
 ...S SNO=$P($G(^AUPNVTXR(IEN,0)),U,1)
 ...S IN=SNO_"^^^1",OUT="ARR"
 ...S X=$$CNCLKP^BSTSAPI(.OUT,.IN)
 ...I X>0 D
 ....S TXT=ARR(1,"PRE","TRM")
 ....S VCNT=VCNT+1
 ....S @TARGET@(VCNT,0)="  "_TXT
 ..S VCNT=VCNT+1
 ..S @TARGET@(VCNT,0)=""
 I VCNT=0 S @TARGET@(1,0)="No visit treatments"
 Q "~@"_$NA(@TARGET)
REFPR(DFN,TARGET,NUM) ; V referrals by problem
 ;Default is 99
 N ARRAY,PRIEN,INVDT,IEN,VCNT,EDATE,SIGN,STAT,SNO,IN,OUT,ARR,X,PRV
 K @TARGET
 S VCNT=0,CNT=0
 I $G(NUM)="" S NUM=99
 E  S NUM=NUM-1
 S SNO="" F  S SNO=$O(^AUPNVREF("AE",DFN,SNO)) Q:SNO=""  D
 .S INVDT="" F  S INVDT=$O(^AUPNVREF("AE",DFN,SNO,INVDT)) Q:INVDT=""  D
 ..S IEN="" F  S IEN=$O(^AUPNVREF("AE",DFN,SNO,INVDT,IEN)) Q:IEN=""  D
 ...S PRIEN=$P($G(^AUPNVREF(IEN,0)),U,4)
 ...Q:PRIEN=""
 ...S STAT=$P($G(^AUPNPROB(PRIEN,0)),U,12)
 ...Q:STAT="D"
 ...S ARRAY(PRIEN,INVDT,IEN)=""
 S PRIEN="" F  S PRIEN=$O(ARRAY(PRIEN)) Q:PRIEN=""  D
 .S NARR=$$GET1^DIQ(9000011,PRIEN,.05)
 .S VCNT=VCNT+1
 .S @TARGET@(VCNT,0)="Problem: "_NARR
 .S INVDT="" F  S INVDT=$O(ARRAY(PRIEN,INVDT)) Q:INVDT=""  D
 ..S CNT=CNT+1
 ..S EDATE=9999999-INVDT
 ..S EDATE=$P($$FMTE^XLFDT(EDATE,5),"@",1)
 ..S IEN="" F  S IEN=$O(ARRAY(PRIEN,INVDT,IEN)) Q:IEN=""  D
 ...S SNO=$P($G(^AUPNVREF(IEN,0)),U,1)
 ...S X=$$CONC^BSTSAPI(SNO_"^^^1")
 ...I +X D
 ....S TXT=$P(X,U,4)
 ....S VCNT=VCNT+1
 ....S @TARGET@(VCNT,0)=EDATE_" Referral: "_TXT_"("_SNO_")"
 ....S PRV=$$GET1^DIQ(9000010.59,IEN,1202)
 ....I PRV="" S PRV=$$GET1^DIQ(9000010.59,IEN,1204)
 ....S VCNT=VCNT+1
 ....S @TARGET@(VCNT,0)="Provider: "_PRV
 I VCNT=0 S @TARGET@(1,0)="No problem referrals"
 Q "~@"_$NA(@TARGET)
REFDT(DFN,TARGET,NUM) ; V referrals  by date
 ;Get last (n) date entries for each problem  of visit referrals
 ;Default is 99
 N ARRAY,PRIEN,INVDT,IEN,VCNT,EDATE,SIGN,STAT,SNO,IN,OUT,ARR,X,TXT
 K @TARGET
 S VCNT=0,CNT=0,STAT=""
 I $G(NUM)="" S NUM=99
 E  S NUM=NUM-1
 S SNO="" F  S SNO=$O(^AUPNVREF("AE",DFN,SNO)) Q:SNO=""  D
 .S INVDT="" F  S INVDT=$O(^AUPNVREF("AE",DFN,SNO,INVDT)) Q:INVDT=""  D
 ..S IEN="" F  S IEN=$O(^AUPNVREF("AE",DFN,SNO,INVDT,IEN)) Q:IEN=""  D
 ...S PRIEN=$P($G(^AUPNVREF(IEN,0)),U,4)
 ...;Q:PRIEN=""
 ...I PRIEN'="" S STAT=$P($G(^AUPNPROB(PRIEN,0)),U,12)
 ...Q:STAT="D"
 ...S ARRAY(INVDT,IEN)=""
 S INVDT="" F  S INVDT=$O(ARRAY(INVDT)) Q:INVDT=""  D
 .S EDATE=9999999-INVDT
 .S EDATE=$P($$FMTE^XLFDT(EDATE,5),".")
 .S VCNT=VCNT+1,CNT=CNT+1
 .S @TARGET@(VCNT,0)=EDATE
 .S IEN="" F  S IEN=$O(ARRAY(INVDT,IEN)) Q:IEN=""  D
 ..S PRIEN=$P($G(^AUPNVREF(IEN,0)),U,4)
 ..I +PRIEN D
 ...S NARR=$$GET1^DIQ(9000011,PRIEN,.05)
 ...S VCNT=VCNT+1
 ...S @TARGET@(VCNT,0)="Problem: "_NARR
 ..S SNO=$P($G(^AUPNVREF(IEN,0)),U,1)
 ..S X=$$CONC^BSTSAPI(SNO_"^^^1")
 ..I +X D
 ...S TXT=$P(X,U,4)
 ...S VCNT=VCNT+1
 ...S @TARGET@(VCNT,0)="Referral: "_TXT_"("_SNO_")"
 ..S PRV=$$GET1^DIQ(9000010.59,IEN,1202)
 ..I PRV="" S PRV=$$GET1^DIQ(9000010.59,IEN,1204)
 ..S VCNT=VCNT+1
 ..S @TARGET@(VCNT,0)="Provider: "_PRV
 ..S VCNT=VCNT+1
 ..S @TARGET@(VCNT,0)=""
 I VCNT=0 S @TARGET@(1,0)="No visit referrals"
 Q "~@"_$NA(@TARGET)