APCLV ; IHS/CMI/LAB - visit data ;
;;2.0;IHS PCC SUITE;**10**;MAY 14, 2009;Build 88
;IHS/TUCSON/LAB - added G parameter to provider call
;
;
COMM(V,F) ;PEP ; given V as visit ien, COMMUNITY - STATE,COUNTY,COMMUNITY codes of patient
;F="E":name of community, F="I":internal ien of community, F="C":stctycomm code
G COMM^APCLV1
;
PCHART(P,L) ;PEP - returns chart at facility L
;FOR FORMAT SEE CHART
G PCHART^APCLV1
CHART(V) ;PEP - returns ASUFAC_HRN ( 12 digits, HRN is left zero filled)
;V = visit ien, returns asufac_hrn for this visit
;if chart exists at Loc. of encounter it is returned
;if not, then chart at DUZ(2) is returned
;if none, then null returned
G CHART^APCLV1
;
LOCENC(V,F) ;PEP - given visit ien V, return loc. of encounter in format F
;F="E":name of location , F="I":ien of location, F="C":asufac
G LOCENC^APCLV1
;
VD(V,F) ;PEP - given visit ien in V, return date of visit in internal or external format
;F="I":internal fileman format, F="S":external slash date, F="E":external full (JAN 01, 1995)
;
G VD^APCLV1
VDTM(V,F) ;PEP - given visit ien in V, return visit date and time in F format
;F="S":01/01/98 3:15pm, F="E":JAN 01, 1998 3:15PM, F="I":fileman internal format
G VDTM^APCLV1
;
DDTM(V,F) ;PEP - discharge date/time
;
G DDTM^APCLV1
TIME(V,F) ;PEP - given visit ien in V, returns visit time of day i n format F
;F="E": form is 11:15 F="I" form is 1115 (fileman format), F="P" form in am/pm 11:15am
G TIME^APCLV1
;
DOW(V,F) ;PEP - given V, visit ien and F, format returns DOW of visit
;in F="E":Monday, F="I":1
G DOW^APCLV1
;
TYPE(V,F) ;PEP - given V, visit ien and F, format, returns type of visit
;F="I":internal set, F="E":external set
G TYPE^APCLV1
;
SC(V,F) ;PEP - given V=visit ien and F=format, returns service category of visit
;F="I":internal set, F="E":external set
G SC^APCLV1
CLINIC(V,F) ;PEP - given V is visit ien, F is format, returns clinic on visit
;F="E":clinic name, F="C":clinic code, F="I":internal ien of clinic
G CLINIC^APCLV1
;
EM(V,F) ;PEP - given V, visit ien and F, format, returns eval&man code of visit
;F="I":internal ien of cpt code, F="E":des of cpt code, F="C":cpt code
G EM^APCLV1
;
LS(V,F) ;PEP - given V, visit ien and F, format, returns level of servie of visit
;F="I":internal set, F="E":external set
G LS^APCLV1
;
ADMSERV(V,F) ;PEP - return admitting service in Code, internal or external form
G ADMSERV^APCLV1
DSCHSERV(V,F) ;PEP - return discharge service in format F
G DSCHSERV^APCLV1
NLAB(V) ;PEP - returns # of labs on the visit V
G NLAB^APCLV1
ADMTYPE(V,F) ;PEP - return admission type i format F
;I = internal format
;E = long name of the type
;C = coded value
G ADMTYPE^APCLV1
LOSHRS(AD,DSD,PAT) ;PEP; returns length of stay in hours
Q $J($$FMDIFF^XLFDT(DSD,AD,2)/3600,0,0)
ADMUB(V,F) ;PEP - return admission type i format F
G ADMUB^APCLV1
ADMSOURC(V,F) ;PEP - return admission type i format F
G ADMSOURC^APCLV1
DSCHTYPE(V,F) ;PEP - return discharge type in format F
;I - internal format
;E - external name
;C - coded value
G DSCHTYPE^APCLV1
NRX(V) ;PEP - returns # of rxs on visit V
G NRX^APCLV1
;
PRIMPROV(V,F) ;PEP - returns primary provider on that visit in F format
;F is defined as:
;I - returns ien of provider in file 200 or 6
;T - returns provider' initials
;A - returns internal set of affiliation (e.g. 1)
;B - returns external of affiliation (e.g. IHS)
;C - returns provider's code
;D - returns provider's discipline code (E.G. 01)
;E - returns provider's discipline in external format (PHYSICIAN)
;F - returns ien of provider's discipline (22)
;N - returns provider's name
;O - returns provider's affl_disc (e.g. 101 for IHS nurse)
;P - returns provider's affl_disc_code (e.g. 101LAB for nurse Lori Ann Butcher
;G - returns the event date&time for this provider
G PRIMPROV^APCLV06
;
SECPROV(V,F,N) ;PEP - returns secondary provider N in format F
; see primPROV for format definitions, N is the 1-N secondary providers, if you want an array of all secondary providers use SECPROVS EP.
G SECPROV^APCLV06
;
PRIMPOV(V,F) ;PEP - returns primary pov on visit V in format F
;F is defined as
;I - ien of ICD9 code
;E - external of ICD9 (text)
;C - icd9 code
;A - APC recode
;D - cause of dx
;J - cause of injury
;P - place of injury
;N - provider narrative external text
G PRIMPOV^APCLV07
;
SECPOV(V,F,N) ;PEP - returns secondary pov N in format F for visit V
;see primpov for definitions of F
G SECPOV^APCLV07
;
PROC(V,F,N) ;PEP - returns procedure N in format F for visit V
;F is defined as
;I -ien of icd9 code (.01)
;E - external of icd code
;C- icd code
;P - CPT CODE
;T - CPT INTERNAL IEN
;D - date of proc/int fm format
;G - date of proc/ext format
;F - INFECTION Y/N
;R - PROV AFFL_DISC
;X - DX DONE FOR - N
;N - provider narrative
G PROC^APCLV08
IMM(V,F,N) ;PEP - returns immunization done on visit V in format F number N
;F is defined as
;I - ien of immunization entry
;C - immunization code
;E - immunization name
;S - series
G IMM^APCLV11
DENT(V,F,N) ;PEP - returns dental
;F is defined as
;I - ien of dental entry
;C - ada code
;E - ada name
;S - series
G DENT^APCLV05
DSCHDATE(V,F) ;PEP - return discharge date in F format
;F="I":internal fileman format, F="S":external slash date, F="E":external full (JAN 01, 1995)
;
G DSCHDATE^APCLV1
CONSULTS(V) ;PEP - return # of consults
G CONSULTS^APCLV1
ATTPHY(V,F) ;PEP - return attending physician
G ATTPHY^APCLV06
LOS(V) ;PEP - return length of stay
G LOS^APCLV1
FACTX(V,F) ;PEP - return facility transferred to
G FACTX^APCLV1
MIDWIFE(V) ;PEP - return midwifery code
G MIDWIFE^APCLV06
ACTTIME(V) ;PEP - return activity time
G ACTTIME^APCLV1
TRAVTIME(V) ;PEP - return travel time
G TRAVTIME^APCLV1
CHSCOST(V) ;PEP - return CHS total cost
G CHSCOST^APCLV1
PATIENT(V,F) ;PEP - return patient
G PATIENT^APCLV1
DLM(V,F) ;PEP - return date last modified
G DLM^APCLV1
DVEX(V,F) ;PEP - return date visit exported
G DVEX^APCLV1
DWEX(V,F) ;PEP - return date visit exported to NDW (national data warehouse)
G DWEX^APCLV1
CODT(V,F) ;PEP - return check out date&time
G CODT^APCLV1
APDT(V,F) ;PEP - return appt date&time from visit
G APDT^APCLV1
APWI(V,F) ;PEP - return walk-in/appt
G APWI^APCLV1
OUTSL(V) ;PEP - returns outside location
G OUTSL^APCLV1
;see programmer for a copy of documentation
ADMDX(V,F) ;PEP - return admitting dx
G ADMDX^APCLV07
PCCVF(V,T,F,A) ;PEP return v file information
I $G(T)="" Q 1 ;no type of data defined
I '$G(V) Q 3 ;no visit ien passed
I $G(F)="" Q 2 ;no format defined
I '$D(^AUPNVSIT(V)) Q 4
NEW APCLTYPE,X,APCLPROG
S APCLTYPE=""
F I=1:1 S X=$T(TVAL+I) Q:X=""!(APCLTYPE]"") I $P(X,";;",2)=T S APCLTYPE=$P(X,";;",2),APCLPROG=$P(X,";;",3)
I APCLTYPE="" Q 5 ;not valid type
K APCLV
D @APCLPROG
Q ""
BMI(H,W,D) ;PEP - return BMI if passed Ht and Wt
;H - ht in inches
;W - wt in inches
;D - number of decimal digits to return, if null pass full BMI value and all decimal digits
I $G(H)="" Q "" ;no ht
I $G(W)="" Q "" ;no wt
NEW %
S W=W*.45359,H=(H*.0254),H=(H*H),%=(W/H)
I $G(D) S %=$J(%,(D+3),D) ;full length equal 2N1"." with D decimals
Q %
PBMI(P,EDATE) ;PEP - return patient's most current BMI as of EDATE
;P - patient DFN
;EDATE - as of date in internal Fileman format if null DT is assumed
;return value: will be a "^" pieced string with the following pieces:
; 1 - BMI value (not rounded)
; 2 - HT value used (not rounded) - IF BMI IS STORED THIS WILL BE DATE OF LAST HT
; 3 - Date of HT value used in internal fileman format
; 4 - visit ien of visit on which HT found
; 5 - WT used (not rounded)
; 6 - date of weight used
; 7 - visit ien of visit on which weight found
; 8 - error/warning messages in "|" delimted format e.g. warning 1|warning 2
; warnings:
; PATIENT DFN INVALID - either P is null or P does not exist in AUPNPAT or DPT
; NO WEIGHT FOUND ON OR PRIOR TO (edate) - no weight on file for
; this patient on or prior to the value of EDATE
; NO HEIGHT FOUND ON OR PRIOR TO (edate) - no height on file for
; this patiet on or prior to the value of EDATE
; 9 - DATE IF STORED BMI
; 10 - IEN OF V MEASUREMENT OF STORED BMI
;
;
;NOTE: any weight taken on a prenatal visit is excluded and a prior weight is used
;NOTE: if you add warnings, please use the word WARNING (caps) in the error message
;NOTE: pts <18 must have ht/wt on same day and within past year
; pts >50 must have ht/wt within past 2 years
; pts 19-50 must have ht/wt within past5 years
;
G PBMI^APCLV2
APCWL(V) ;PEP - is this visit APC Workload Reportable
;note: LOCATION OF ENCOUNTER NOT FIGURED IN HERE.
G APCWL^APCLV1
TVAL ;
;;MEASUREMENT;;MEAS^APCLV01;;9000010.01
;;PROVIDER;;PROV^APCLV06;;9000010.06
;;POV;;POV^APCLV07;;9000010.07
APCLV ; IHS/CMI/LAB - visit data ;
+1 ;;2.0;IHS PCC SUITE;**10**;MAY 14, 2009;Build 88
+2 ;IHS/TUCSON/LAB - added G parameter to provider call
+3 ;
+4 ;
COMM(V,F) ;PEP ; given V as visit ien, COMMUNITY - STATE,COUNTY,COMMUNITY codes of patient
+1 ;F="E":name of community, F="I":internal ien of community, F="C":stctycomm code
+2 GOTO COMM^APCLV1
+3 ;
PCHART(P,L) ;PEP - returns chart at facility L
+1 ;FOR FORMAT SEE CHART
+2 GOTO PCHART^APCLV1
CHART(V) ;PEP - returns ASUFAC_HRN ( 12 digits, HRN is left zero filled)
+1 ;V = visit ien, returns asufac_hrn for this visit
+2 ;if chart exists at Loc. of encounter it is returned
+3 ;if not, then chart at DUZ(2) is returned
+4 ;if none, then null returned
+5 GOTO CHART^APCLV1
+6 ;
LOCENC(V,F) ;PEP - given visit ien V, return loc. of encounter in format F
+1 ;F="E":name of location , F="I":ien of location, F="C":asufac
+2 GOTO LOCENC^APCLV1
+3 ;
VD(V,F) ;PEP - given visit ien in V, return date of visit in internal or external format
+1 ;F="I":internal fileman format, F="S":external slash date, F="E":external full (JAN 01, 1995)
+2 ;
+3 GOTO VD^APCLV1
VDTM(V,F) ;PEP - given visit ien in V, return visit date and time in F format
+1 ;F="S":01/01/98 3:15pm, F="E":JAN 01, 1998 3:15PM, F="I":fileman internal format
+2 GOTO VDTM^APCLV1
+3 ;
DDTM(V,F) ;PEP - discharge date/time
+1 ;
+2 GOTO DDTM^APCLV1
TIME(V,F) ;PEP - given visit ien in V, returns visit time of day i n format F
+1 ;F="E": form is 11:15 F="I" form is 1115 (fileman format), F="P" form in am/pm 11:15am
+2 GOTO TIME^APCLV1
+3 ;
DOW(V,F) ;PEP - given V, visit ien and F, format returns DOW of visit
+1 ;in F="E":Monday, F="I":1
+2 GOTO DOW^APCLV1
+3 ;
TYPE(V,F) ;PEP - given V, visit ien and F, format, returns type of visit
+1 ;F="I":internal set, F="E":external set
+2 GOTO TYPE^APCLV1
+3 ;
SC(V,F) ;PEP - given V=visit ien and F=format, returns service category of visit
+1 ;F="I":internal set, F="E":external set
+2 GOTO SC^APCLV1
CLINIC(V,F) ;PEP - given V is visit ien, F is format, returns clinic on visit
+1 ;F="E":clinic name, F="C":clinic code, F="I":internal ien of clinic
+2 GOTO CLINIC^APCLV1
+3 ;
EM(V,F) ;PEP - given V, visit ien and F, format, returns eval&man code of visit
+1 ;F="I":internal ien of cpt code, F="E":des of cpt code, F="C":cpt code
+2 GOTO EM^APCLV1
+3 ;
LS(V,F) ;PEP - given V, visit ien and F, format, returns level of servie of visit
+1 ;F="I":internal set, F="E":external set
+2 GOTO LS^APCLV1
+3 ;
ADMSERV(V,F) ;PEP - return admitting service in Code, internal or external form
+1 GOTO ADMSERV^APCLV1
DSCHSERV(V,F) ;PEP - return discharge service in format F
+1 GOTO DSCHSERV^APCLV1
NLAB(V) ;PEP - returns # of labs on the visit V
+1 GOTO NLAB^APCLV1
ADMTYPE(V,F) ;PEP - return admission type i format F
+1 ;I = internal format
+2 ;E = long name of the type
+3 ;C = coded value
+4 GOTO ADMTYPE^APCLV1
LOSHRS(AD,DSD,PAT) ;PEP; returns length of stay in hours
+1 QUIT $JUSTIFY($$FMDIFF^XLFDT(DSD,AD,2)/3600,0,0)
ADMUB(V,F) ;PEP - return admission type i format F
+1 GOTO ADMUB^APCLV1
ADMSOURC(V,F) ;PEP - return admission type i format F
+1 GOTO ADMSOURC^APCLV1
DSCHTYPE(V,F) ;PEP - return discharge type in format F
+1 ;I - internal format
+2 ;E - external name
+3 ;C - coded value
+4 GOTO DSCHTYPE^APCLV1
NRX(V) ;PEP - returns # of rxs on visit V
+1 GOTO NRX^APCLV1
+2 ;
PRIMPROV(V,F) ;PEP - returns primary provider on that visit in F format
+1 ;F is defined as:
+2 ;I - returns ien of provider in file 200 or 6
+3 ;T - returns provider' initials
+4 ;A - returns internal set of affiliation (e.g. 1)
+5 ;B - returns external of affiliation (e.g. IHS)
+6 ;C - returns provider's code
+7 ;D - returns provider's discipline code (E.G. 01)
+8 ;E - returns provider's discipline in external format (PHYSICIAN)
+9 ;F - returns ien of provider's discipline (22)
+10 ;N - returns provider's name
+11 ;O - returns provider's affl_disc (e.g. 101 for IHS nurse)
+12 ;P - returns provider's affl_disc_code (e.g. 101LAB for nurse Lori Ann Butcher
+13 ;G - returns the event date&time for this provider
+14 GOTO PRIMPROV^APCLV06
+15 ;
SECPROV(V,F,N) ;PEP - returns secondary provider N in format F
+1 ; see primPROV for format definitions, N is the 1-N secondary providers, if you want an array of all secondary providers use SECPROVS EP.
+2 GOTO SECPROV^APCLV06
+3 ;
PRIMPOV(V,F) ;PEP - returns primary pov on visit V in format F
+1 ;F is defined as
+2 ;I - ien of ICD9 code
+3 ;E - external of ICD9 (text)
+4 ;C - icd9 code
+5 ;A - APC recode
+6 ;D - cause of dx
+7 ;J - cause of injury
+8 ;P - place of injury
+9 ;N - provider narrative external text
+10 GOTO PRIMPOV^APCLV07
+11 ;
SECPOV(V,F,N) ;PEP - returns secondary pov N in format F for visit V
+1 ;see primpov for definitions of F
+2 GOTO SECPOV^APCLV07
+3 ;
PROC(V,F,N) ;PEP - returns procedure N in format F for visit V
+1 ;F is defined as
+2 ;I -ien of icd9 code (.01)
+3 ;E - external of icd code
+4 ;C- icd code
+5 ;P - CPT CODE
+6 ;T - CPT INTERNAL IEN
+7 ;D - date of proc/int fm format
+8 ;G - date of proc/ext format
+9 ;F - INFECTION Y/N
+10 ;R - PROV AFFL_DISC
+11 ;X - DX DONE FOR - N
+12 ;N - provider narrative
+13 GOTO PROC^APCLV08
IMM(V,F,N) ;PEP - returns immunization done on visit V in format F number N
+1 ;F is defined as
+2 ;I - ien of immunization entry
+3 ;C - immunization code
+4 ;E - immunization name
+5 ;S - series
+6 GOTO IMM^APCLV11
DENT(V,F,N) ;PEP - returns dental
+1 ;F is defined as
+2 ;I - ien of dental entry
+3 ;C - ada code
+4 ;E - ada name
+5 ;S - series
+6 GOTO DENT^APCLV05
DSCHDATE(V,F) ;PEP - return discharge date in F format
+1 ;F="I":internal fileman format, F="S":external slash date, F="E":external full (JAN 01, 1995)
+2 ;
+3 GOTO DSCHDATE^APCLV1
CONSULTS(V) ;PEP - return # of consults
+1 GOTO CONSULTS^APCLV1
ATTPHY(V,F) ;PEP - return attending physician
+1 GOTO ATTPHY^APCLV06
LOS(V) ;PEP - return length of stay
+1 GOTO LOS^APCLV1
FACTX(V,F) ;PEP - return facility transferred to
+1 GOTO FACTX^APCLV1
MIDWIFE(V) ;PEP - return midwifery code
+1 GOTO MIDWIFE^APCLV06
ACTTIME(V) ;PEP - return activity time
+1 GOTO ACTTIME^APCLV1
TRAVTIME(V) ;PEP - return travel time
+1 GOTO TRAVTIME^APCLV1
CHSCOST(V) ;PEP - return CHS total cost
+1 GOTO CHSCOST^APCLV1
PATIENT(V,F) ;PEP - return patient
+1 GOTO PATIENT^APCLV1
DLM(V,F) ;PEP - return date last modified
+1 GOTO DLM^APCLV1
DVEX(V,F) ;PEP - return date visit exported
+1 GOTO DVEX^APCLV1
DWEX(V,F) ;PEP - return date visit exported to NDW (national data warehouse)
+1 GOTO DWEX^APCLV1
CODT(V,F) ;PEP - return check out date&time
+1 GOTO CODT^APCLV1
APDT(V,F) ;PEP - return appt date&time from visit
+1 GOTO APDT^APCLV1
APWI(V,F) ;PEP - return walk-in/appt
+1 GOTO APWI^APCLV1
OUTSL(V) ;PEP - returns outside location
+1 GOTO OUTSL^APCLV1
+2 ;see programmer for a copy of documentation
ADMDX(V,F) ;PEP - return admitting dx
+1 GOTO ADMDX^APCLV07
PCCVF(V,T,F,A) ;PEP return v file information
+1 ;no type of data defined
IF $GET(T)=""
QUIT 1
+2 ;no visit ien passed
IF '$GET(V)
QUIT 3
+3 ;no format defined
IF $GET(F)=""
QUIT 2
+4 IF '$DATA(^AUPNVSIT(V))
QUIT 4
+5 NEW APCLTYPE,X,APCLPROG
+6 SET APCLTYPE=""
+7 FOR I=1:1
SET X=$TEXT(TVAL+I)
IF X=""!(APCLTYPE]"")
QUIT
IF $PIECE(X,";;",2)=T
SET APCLTYPE=$PIECE(X,";;",2)
SET APCLPROG=$PIECE(X,";;",3)
+8 ;not valid type
IF APCLTYPE=""
QUIT 5
+9 KILL APCLV
+10 DO @APCLPROG
+11 QUIT ""
BMI(H,W,D) ;PEP - return BMI if passed Ht and Wt
+1 ;H - ht in inches
+2 ;W - wt in inches
+3 ;D - number of decimal digits to return, if null pass full BMI value and all decimal digits
+4 ;no ht
IF $GET(H)=""
QUIT ""
+5 ;no wt
IF $GET(W)=""
QUIT ""
+6 NEW %
+7 SET W=W*.45359
SET H=(H*.0254)
SET H=(H*H)
SET %=(W/H)
+8 ;full length equal 2N1"." with D decimals
IF $GET(D)
SET %=$JUSTIFY(%,(D+3),D)
+9 QUIT %
PBMI(P,EDATE) ;PEP - return patient's most current BMI as of EDATE
+1 ;P - patient DFN
+2 ;EDATE - as of date in internal Fileman format if null DT is assumed
+3 ;return value: will be a "^" pieced string with the following pieces:
+4 ; 1 - BMI value (not rounded)
+5 ; 2 - HT value used (not rounded) - IF BMI IS STORED THIS WILL BE DATE OF LAST HT
+6 ; 3 - Date of HT value used in internal fileman format
+7 ; 4 - visit ien of visit on which HT found
+8 ; 5 - WT used (not rounded)
+9 ; 6 - date of weight used
+10 ; 7 - visit ien of visit on which weight found
+11 ; 8 - error/warning messages in "|" delimted format e.g. warning 1|warning 2
+12 ; warnings:
+13 ; PATIENT DFN INVALID - either P is null or P does not exist in AUPNPAT or DPT
+14 ; NO WEIGHT FOUND ON OR PRIOR TO (edate) - no weight on file for
+15 ; this patient on or prior to the value of EDATE
+16 ; NO HEIGHT FOUND ON OR PRIOR TO (edate) - no height on file for
+17 ; this patiet on or prior to the value of EDATE
+18 ; 9 - DATE IF STORED BMI
+19 ; 10 - IEN OF V MEASUREMENT OF STORED BMI
+20 ;
+21 ;
+22 ;NOTE: any weight taken on a prenatal visit is excluded and a prior weight is used
+23 ;NOTE: if you add warnings, please use the word WARNING (caps) in the error message
+24 ;NOTE: pts <18 must have ht/wt on same day and within past year
+25 ; pts >50 must have ht/wt within past 2 years
+26 ; pts 19-50 must have ht/wt within past5 years
+27 ;
+28 GOTO PBMI^APCLV2
APCWL(V) ;PEP - is this visit APC Workload Reportable
+1 ;note: LOCATION OF ENCOUNTER NOT FIGURED IN HERE.
+2 GOTO APCWL^APCLV1
TVAL ;
+1 ;;MEASUREMENT;;MEAS^APCLV01;;9000010.01
+2 ;;PROVIDER;;PROV^APCLV06;;9000010.06
+3 ;;POV;;POV^APCLV07;;9000010.07