HMPDJ04E ;SLC/MKB,ASMR/RRB - EDIS VISIT;6/25/12 16:11
;;2.0;ENTERPRISE HEALTH MANAGEMENT PLATFORM;**2**;Sep 01, 2011;Build 28
;Per VA Directive 6402, this routine should not be modified.
;
; All tags expect DFN, ID, [HMPSTART, HMPSTOP, HMPMAX, HMPTEXT]
;
; External References DBIA#
; ------------------- -----
; EDP(230 6275
;
; DE2818/RRB SQA findings changed top line from EDIS to EDIS VISITS
Q
;
EDP1(ID) ; -- ED visit
;DE2818 modified to use FM calls to pull data from the EDP files
N IENS,EDP,X0,FAC,VST,LOC,LOC0,X,I,ICD,FILE,FLDS,FLGS,ARR,ERR
S IENS=$$FIND1^DIC(230,"","Q",ID,"V","") Q:IENS<1
S IENS=IENS_",",FLGS="IE",ARR="EDP",ERR="EDPERR",FLDS=".01;3.5;3.6;3.7;3.8;3.3;.08;.09;1.1;.02;.14;3.2"
D GETS^DIQ(230,IENS,FLDS,FLGS,ARR,ERR)
S X0=$G(^AUPNVSIT(ID,0))
;.01 LOG ENTRY TIME
;.08 TIME IN
;.08 TIME OUT
;1.1 COMPLAINT
;.02 INSTITUTION
;.14 CLINIC
;#3.2) STATUS [2P:233.1]
;(#3.3) ACUITY [3P:233.1] ^
;(#3.4) LOC [4P:231.8]
;(#3.5) MD ASSIGNED [5P:200]
;(#3.6) NURSE ASSIGNED [6P:200]
;(#3.7) RESIDENT ASSIGNED [7P:200] ^
;#3.8) COMMENT [8F]
;(#3.9) HELD LOC [9P:231.8] ^
S VST("localId")=ID,VST("uid")=$$SETUID^HMPUTILS("visit",DFN,ID)
S VST("dateTime")=$$JSONDT^HMPUTILS(+X0)
S:$G(EDP(230,IENS,.08,"I"))'="" VST("stay","arrivalDateTime")=$$JSONDT^HMPUTILS($G(EDP(230,IENS,.08,"I")))
S:$G(EDP(230,IENS,.09,"I"))'="" VST("stay","dischargeDateTime")=$$JSONDT^HMPUTILS($G(EDP(230,IENS,.09,"I")))
S:$G(EDP(230,IENS,.02,"I"))'="" FAC=$G(EDP(230,IENS,.02,"I"))
S:$G(EDP(230,IENS,.14,"I"))'="" LOC=$G(EDP(230,IENS,.14,"I")),LOC0=$S(LOC:$G(^SC(LOC,0)),1:"")
S:FAC X=$$STA^XUAF4(FAC)_U_$P($$NS^XUAF4(FAC),U)
S:'FAC X=$$FAC^HMPD(LOC) D FACILITY^HMPUTILS(X,"VST")
S VST("categoryCode")="urn:va:encounter-category:OV"
S VST("categoryName")="Outpatient Visit"
S VST("patientClassCode")="urn:va:patient-class:EMER"
S VST("patientClassName")="Emergency"
;
S X=$$CPT^HMPDJ04(ID) S:$G(X)'="" VST("typeName")=$P($$CPT^ICPTCOD(X),U,3)
I 'X S VST("typeName")=$S(LOC:$P(LOC0,U)_" VISIT",1:"EMERGENCY")
S X=$P(X0,U,8) S:X AMIS=$$AMIS^HMPDVSIT(X) I LOC D
. I 'X S AMIS=$$AMIS^HMPDVSIT($P(LOC0,U,7))
. S VST("locationUid")=$$SETUID^HMPUTILS("location",,+LOC)
. S VST("locationName")=$P(LOC0,U)
. S X=$$SERV^HMPDVSIT($P(LOC0,U,20)) Q:X=""
. S:$L(X) VST("service")=X,VST("summary")="${"_VST("service")_"}:"_$P(LOC0,U)
S:$G(AMIS) VST("stopCodeUid")="urn:va:stop-code:"_$P(AMIS,U),VST("stopCodeName")=$P(AMIS,U,2)
;
S:$G(EDP(230,IENS,1.1,"E"))'="" VST("reasonName")=$G(EDP(230,IENS,1.1,"E"))
S I=0 F S I=$O(^EDP(230,+IENS,4,I)) Q:I<1 I $P($G(^(I,0)),U,3) D ;primary Dx
. S X=$G(^EDP(230,+IENS,4,I,0)),VST("reasonName")=$P(X,U) Q:'$P(X,U,2)
. S ICD=$$ICD^HMPDVSIT($P(X,U,2)) Q:$L(ICD)'>1
. S VST("reasonUid")=$$SETNCS^HMPUTILS("icd",$P(ICD,U)),VST("reasonName")=$P(ICD,U,2)
;
; provider(s)
S I=0
I $G(EDP(230,IENS,3.5,"I"))'="" S I=I+1 D PROV("VST",I,$G(EDP(230,IENS,3.5,"I")),"P",1) ;primary/MD
I $G(EDP(230,IENS,3.6,"I"))'="" S I=I+1 D PROV("VST",I,$G(EDP(230,IENS,3.6,"I")),"P",1) ;nurse
I $G(EDP(230,IENS,3.7,"I"))'="" S I=I+1 D PROV("VST",I,$G(EDP(230,IENS,3.7,"I")),"P",1) ;resident
S:$G(EDP(230,IENS,3.8,"I"))'="" VST("comment")=$G(EDP(230,IENS,3.8,"I"))
S:$G(EDP(230,IENS,3.3,"E")) VST("appointmentStatus")=$G(EDP(230,IENS,3.3,"E"))
;
; note(s)
; TIU^HMPDJ04A(ID,.VST)
K ^TMP("PXKENC",$J,ID)
S VST("lastUpdateTime")=$$EN^HMPSTMP("visit") ;RHL 20150102
S VST("stampTime")=VST("lastUpdateTime") ; RHL 20150102
;US6734 - pre-compile metastamp
I $G(HMPMETA) D ADD^HMPMETA("visit",VST("uid"),VST("stampTime")) Q:HMPMETA=1 ;US6734,US11019
D ADD^HMPDJ("VST","visit")
Q
;
PROV(ARR,I,IEN,ROLE,PRIM) ; -- add providers
S @ARR@("providers",I,"providerUid")=$$SETUID^HMPUTILS("user",,+IEN)
S @ARR@("providers",I,"providerName")=$$GET1^DIQ(200,(+IEN)_",",.01) ;DE2818, ICR 10060
S @ARR@("providers",I,"role")=ROLE
S:$G(PRIM) @ARR@("providers",I,"primary")="true"
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HHMPDJ04E 4068 printed Oct 16, 2024@17:54:02 Page 2
HMPDJ04E ;SLC/MKB,ASMR/RRB - EDIS VISIT;6/25/12 16:11
+1 ;;2.0;ENTERPRISE HEALTH MANAGEMENT PLATFORM;**2**;Sep 01, 2011;Build 28
+2 ;Per VA Directive 6402, this routine should not be modified.
+3 ;
+4 ; All tags expect DFN, ID, [HMPSTART, HMPSTOP, HMPMAX, HMPTEXT]
+5 ;
+6 ; External References DBIA#
+7 ; ------------------- -----
+8 ; EDP(230 6275
+9 ;
+10 ; DE2818/RRB SQA findings changed top line from EDIS to EDIS VISITS
+11 QUIT
+12 ;
EDP1(ID) ; -- ED visit
+1 ;DE2818 modified to use FM calls to pull data from the EDP files
+2 NEW IENS,EDP,X0,FAC,VST,LOC,LOC0,X,I,ICD,FILE,FLDS,FLGS,ARR,ERR
+3 SET IENS=$$FIND1^DIC(230,"","Q",ID,"V","")
if IENS<1
QUIT
+4 SET IENS=IENS_","
SET FLGS="IE"
SET ARR="EDP"
SET ERR="EDPERR"
SET FLDS=".01;3.5;3.6;3.7;3.8;3.3;.08;.09;1.1;.02;.14;3.2"
+5 DO GETS^DIQ(230,IENS,FLDS,FLGS,ARR,ERR)
+6 SET X0=$GET(^AUPNVSIT(ID,0))
+7 ;.01 LOG ENTRY TIME
+8 ;.08 TIME IN
+9 ;.08 TIME OUT
+10 ;1.1 COMPLAINT
+11 ;.02 INSTITUTION
+12 ;.14 CLINIC
+13 ;#3.2) STATUS [2P:233.1]
+14 ;(#3.3) ACUITY [3P:233.1] ^
+15 ;(#3.4) LOC [4P:231.8]
+16 ;(#3.5) MD ASSIGNED [5P:200]
+17 ;(#3.6) NURSE ASSIGNED [6P:200]
+18 ;(#3.7) RESIDENT ASSIGNED [7P:200] ^
+19 ;#3.8) COMMENT [8F]
+20 ;(#3.9) HELD LOC [9P:231.8] ^
+21 SET VST("localId")=ID
SET VST("uid")=$$SETUID^HMPUTILS("visit",DFN,ID)
+22 SET VST("dateTime")=$$JSONDT^HMPUTILS(+X0)
+23 if $GET(EDP(230,IENS,.08,"I"))'=""
SET VST("stay","arrivalDateTime")=$$JSONDT^HMPUTILS($GET(EDP(230,IENS,.08,"I")))
+24 if $GET(EDP(230,IENS,.09,"I"))'=""
SET VST("stay","dischargeDateTime")=$$JSONDT^HMPUTILS($GET(EDP(230,IENS,.09,"I")))
+25 if $GET(EDP(230,IENS,.02,"I"))'=""
SET FAC=$GET(EDP(230,IENS,.02,"I"))
+26 if $GET(EDP(230,IENS,.14,"I"))'=""
SET LOC=$GET(EDP(230,IENS,.14,"I"))
SET LOC0=$SELECT(LOC:$GET(^SC(LOC,0)),1:"")
+27 if FAC
SET X=$$STA^XUAF4(FAC)_U_$PIECE($$NS^XUAF4(FAC),U)
+28 if 'FAC
SET X=$$FAC^HMPD(LOC)
DO FACILITY^HMPUTILS(X,"VST")
+29 SET VST("categoryCode")="urn:va:encounter-category:OV"
+30 SET VST("categoryName")="Outpatient Visit"
+31 SET VST("patientClassCode")="urn:va:patient-class:EMER"
+32 SET VST("patientClassName")="Emergency"
+33 ;
+34 SET X=$$CPT^HMPDJ04(ID)
if $GET(X)'=""
SET VST("typeName")=$PIECE($$CPT^ICPTCOD(X),U,3)
+35 IF 'X
SET VST("typeName")=$SELECT(LOC:$PIECE(LOC0,U)_" VISIT",1:"EMERGENCY")
+36 SET X=$PIECE(X0,U,8)
if X
SET AMIS=$$AMIS^HMPDVSIT(X)
IF LOC
Begin DoDot:1
+37 IF 'X
SET AMIS=$$AMIS^HMPDVSIT($PIECE(LOC0,U,7))
+38 SET VST("locationUid")=$$SETUID^HMPUTILS("location",,+LOC)
+39 SET VST("locationName")=$PIECE(LOC0,U)
+40 SET X=$$SERV^HMPDVSIT($PIECE(LOC0,U,20))
if X=""
QUIT
+41 if $LENGTH(X)
SET VST("service")=X
SET VST("summary")="${"_VST("service")_"}:"_$PIECE(LOC0,U)
End DoDot:1
+42 if $GET(AMIS)
SET VST("stopCodeUid")="urn:va:stop-code:"_$PIECE(AMIS,U)
SET VST("stopCodeName")=$PIECE(AMIS,U,2)
+43 ;
+44 if $GET(EDP(230,IENS,1.1,"E"))'=""
SET VST("reasonName")=$GET(EDP(230,IENS,1.1,"E"))
+45 ;primary Dx
SET I=0
FOR
SET I=$ORDER(^EDP(230,+IENS,4,I))
if I<1
QUIT
IF $PIECE($GET(^(I,0)),U,3)
Begin DoDot:1
+46 SET X=$GET(^EDP(230,+IENS,4,I,0))
SET VST("reasonName")=$PIECE(X,U)
if '$PIECE(X,U,2)
QUIT
+47 SET ICD=$$ICD^HMPDVSIT($PIECE(X,U,2))
if $LENGTH(ICD)'>1
QUIT
+48 SET VST("reasonUid")=$$SETNCS^HMPUTILS("icd",$PIECE(ICD,U))
SET VST("reasonName")=$PIECE(ICD,U,2)
End DoDot:1
+49 ;
+50 ; provider(s)
+51 SET I=0
+52 ;primary/MD
IF $GET(EDP(230,IENS,3.5,"I"))'=""
SET I=I+1
DO PROV("VST",I,$GET(EDP(230,IENS,3.5,"I")),"P",1)
+53 ;nurse
IF $GET(EDP(230,IENS,3.6,"I"))'=""
SET I=I+1
DO PROV("VST",I,$GET(EDP(230,IENS,3.6,"I")),"P",1)
+54 ;resident
IF $GET(EDP(230,IENS,3.7,"I"))'=""
SET I=I+1
DO PROV("VST",I,$GET(EDP(230,IENS,3.7,"I")),"P",1)
+55 if $GET(EDP(230,IENS,3.8,"I"))'=""
SET VST("comment")=$GET(EDP(230,IENS,3.8,"I"))
+56 if $GET(EDP(230,IENS,3.3,"E"))
SET VST("appointmentStatus")=$GET(EDP(230,IENS,3.3,"E"))
+57 ;
+58 ; note(s)
+59 ; TIU^HMPDJ04A(ID,.VST)
+60 KILL ^TMP("PXKENC",$JOB,ID)
+61 ;RHL 20150102
SET VST("lastUpdateTime")=$$EN^HMPSTMP("visit")
+62 ; RHL 20150102
SET VST("stampTime")=VST("lastUpdateTime")
+63 ;US6734 - pre-compile metastamp
+64 ;US6734,US11019
IF $GET(HMPMETA)
DO ADD^HMPMETA("visit",VST("uid"),VST("stampTime"))
if HMPMETA=1
QUIT
+65 DO ADD^HMPDJ("VST","visit")
+66 QUIT
+67 ;
PROV(ARR,I,IEN,ROLE,PRIM) ; -- add providers
+1 SET @ARR@("providers",I,"providerUid")=$$SETUID^HMPUTILS("user",,+IEN)
+2 ;DE2818, ICR 10060
SET @ARR@("providers",I,"providerName")=$$GET1^DIQ(200,(+IEN)_",",.01)
+3 SET @ARR@("providers",I,"role")=ROLE
+4 if $GET(PRIM)
SET @ARR@("providers",I,"primary")="true"
+5 QUIT
+6 ;