5255 lines
153 KiB
Genshi
5255 lines
153 KiB
Genshi
Released NHIN*1*1 SEQ #1
|
|
Extracted from mail message
|
|
**KIDS**:NHIN*1.0*1^
|
|
|
|
**INSTALL NAME**
|
|
NHIN*1.0*1
|
|
"BLD",7816,0)
|
|
NHIN*1.0*1^NATIONAL HEALTH INFO NETWORK^0^3110215^y
|
|
"BLD",7816,4,0)
|
|
^9.64PA^^
|
|
"BLD",7816,6.3)
|
|
11
|
|
"BLD",7816,"ABPKG")
|
|
n
|
|
"BLD",7816,"KRN",0)
|
|
^9.67PA^8989.52^19
|
|
"BLD",7816,"KRN",.4,0)
|
|
.4
|
|
"BLD",7816,"KRN",.401,0)
|
|
.401
|
|
"BLD",7816,"KRN",.402,0)
|
|
.402
|
|
"BLD",7816,"KRN",.403,0)
|
|
.403
|
|
"BLD",7816,"KRN",.5,0)
|
|
.5
|
|
"BLD",7816,"KRN",.84,0)
|
|
.84
|
|
"BLD",7816,"KRN",3.6,0)
|
|
3.6
|
|
"BLD",7816,"KRN",3.8,0)
|
|
3.8
|
|
"BLD",7816,"KRN",9.2,0)
|
|
9.2
|
|
"BLD",7816,"KRN",9.8,0)
|
|
9.8
|
|
"BLD",7816,"KRN",9.8,"NM",0)
|
|
^9.68A^28^18
|
|
"BLD",7816,"KRN",9.8,"NM",1,0)
|
|
NHINV^^0^B15789004
|
|
"BLD",7816,"KRN",9.8,"NM",2,0)
|
|
NHINVART^^0^B30332823
|
|
"BLD",7816,"KRN",9.8,"NM",4,0)
|
|
NHINVIT^^0^B33591565
|
|
"BLD",7816,"KRN",9.8,"NM",5,0)
|
|
NHINVLR^^0^B25540846
|
|
"BLD",7816,"KRN",9.8,"NM",11,0)
|
|
NHINVRA^^0^B18363736
|
|
"BLD",7816,"KRN",9.8,"NM",12,0)
|
|
NHINVSR^^0^B25931760
|
|
"BLD",7816,"KRN",9.8,"NM",13,0)
|
|
NHINVTIU^^0^B18326219
|
|
"BLD",7816,"KRN",9.8,"NM",14,0)
|
|
NHINVIMM^^0^B9313203
|
|
"BLD",7816,"KRN",9.8,"NM",15,0)
|
|
NHINVSIT^^0^B60599762
|
|
"BLD",7816,"KRN",9.8,"NM",16,0)
|
|
NHINVPRC^^0^B6896734
|
|
"BLD",7816,"KRN",9.8,"NM",17,0)
|
|
NHINVAPT^^0^B9234836
|
|
"BLD",7816,"KRN",9.8,"NM",21,0)
|
|
NHINVLRA^^0^B45252098
|
|
"BLD",7816,"KRN",9.8,"NM",22,0)
|
|
NHINVLRO^^0^B32647424
|
|
"BLD",7816,"KRN",9.8,"NM",24,0)
|
|
NHINVPSI^^0^B41411886
|
|
"BLD",7816,"KRN",9.8,"NM",25,0)
|
|
NHINVPT^^0^B59592091
|
|
"BLD",7816,"KRN",9.8,"NM",26,0)
|
|
NHINVPL^^0^B19846807
|
|
"BLD",7816,"KRN",9.8,"NM",27,0)
|
|
NHINVPS^^0^B14129801
|
|
"BLD",7816,"KRN",9.8,"NM",28,0)
|
|
NHINVPSO^^0^B65991145
|
|
"BLD",7816,"KRN",9.8,"NM","B","NHINV",1)
|
|
|
|
"BLD",7816,"KRN",9.8,"NM","B","NHINVAPT",17)
|
|
|
|
"BLD",7816,"KRN",9.8,"NM","B","NHINVART",2)
|
|
|
|
"BLD",7816,"KRN",9.8,"NM","B","NHINVIMM",14)
|
|
|
|
"BLD",7816,"KRN",9.8,"NM","B","NHINVIT",4)
|
|
|
|
"BLD",7816,"KRN",9.8,"NM","B","NHINVLR",5)
|
|
|
|
"BLD",7816,"KRN",9.8,"NM","B","NHINVLRA",21)
|
|
|
|
"BLD",7816,"KRN",9.8,"NM","B","NHINVLRO",22)
|
|
|
|
"BLD",7816,"KRN",9.8,"NM","B","NHINVPL",26)
|
|
|
|
"BLD",7816,"KRN",9.8,"NM","B","NHINVPRC",16)
|
|
|
|
"BLD",7816,"KRN",9.8,"NM","B","NHINVPS",27)
|
|
|
|
"BLD",7816,"KRN",9.8,"NM","B","NHINVPSI",24)
|
|
|
|
"BLD",7816,"KRN",9.8,"NM","B","NHINVPSO",28)
|
|
|
|
"BLD",7816,"KRN",9.8,"NM","B","NHINVPT",25)
|
|
|
|
"BLD",7816,"KRN",9.8,"NM","B","NHINVRA",11)
|
|
|
|
"BLD",7816,"KRN",9.8,"NM","B","NHINVSIT",15)
|
|
|
|
"BLD",7816,"KRN",9.8,"NM","B","NHINVSR",12)
|
|
|
|
"BLD",7816,"KRN",9.8,"NM","B","NHINVTIU",13)
|
|
|
|
"BLD",7816,"KRN",19,0)
|
|
19
|
|
"BLD",7816,"KRN",19.1,0)
|
|
19.1
|
|
"BLD",7816,"KRN",101,0)
|
|
101
|
|
"BLD",7816,"KRN",409.61,0)
|
|
409.61
|
|
"BLD",7816,"KRN",771,0)
|
|
771
|
|
"BLD",7816,"KRN",870,0)
|
|
870
|
|
"BLD",7816,"KRN",8989.51,0)
|
|
8989.51
|
|
"BLD",7816,"KRN",8989.52,0)
|
|
8989.52
|
|
"BLD",7816,"KRN",8994,0)
|
|
8994
|
|
"BLD",7816,"KRN",8994,"NM",0)
|
|
^9.68A^^0
|
|
"BLD",7816,"KRN","B",.4,.4)
|
|
|
|
"BLD",7816,"KRN","B",.401,.401)
|
|
|
|
"BLD",7816,"KRN","B",.402,.402)
|
|
|
|
"BLD",7816,"KRN","B",.403,.403)
|
|
|
|
"BLD",7816,"KRN","B",.5,.5)
|
|
|
|
"BLD",7816,"KRN","B",.84,.84)
|
|
|
|
"BLD",7816,"KRN","B",3.6,3.6)
|
|
|
|
"BLD",7816,"KRN","B",3.8,3.8)
|
|
|
|
"BLD",7816,"KRN","B",9.2,9.2)
|
|
|
|
"BLD",7816,"KRN","B",9.8,9.8)
|
|
|
|
"BLD",7816,"KRN","B",19,19)
|
|
|
|
"BLD",7816,"KRN","B",19.1,19.1)
|
|
|
|
"BLD",7816,"KRN","B",101,101)
|
|
|
|
"BLD",7816,"KRN","B",409.61,409.61)
|
|
|
|
"BLD",7816,"KRN","B",771,771)
|
|
|
|
"BLD",7816,"KRN","B",870,870)
|
|
|
|
"BLD",7816,"KRN","B",8989.51,8989.51)
|
|
|
|
"BLD",7816,"KRN","B",8989.52,8989.52)
|
|
|
|
"BLD",7816,"KRN","B",8994,8994)
|
|
|
|
"BLD",7816,"QUES",0)
|
|
^9.62^^
|
|
"BLD",7816,"REQB",0)
|
|
^9.611^1^1
|
|
"BLD",7816,"REQB",1,0)
|
|
NHIN 1.0^2
|
|
"BLD",7816,"REQB","B","NHIN 1.0",1)
|
|
|
|
"MBREQ")
|
|
0
|
|
"PKG",568,-1)
|
|
1^1
|
|
"PKG",568,0)
|
|
NATIONAL HEALTH INFO NETWORK^NHIN^NATIONAL HEALTH INFORMATION NETWORK ADAPTER
|
|
"PKG",568,20,0)
|
|
^9.402P^^
|
|
"PKG",568,22,0)
|
|
^9.49I^1^1
|
|
"PKG",568,22,1,0)
|
|
1.0^3100914^3101007^10000000219
|
|
"PKG",568,22,1,"PAH",1,0)
|
|
1^3110215^10000000219
|
|
"QUES","XPF1",0)
|
|
Y
|
|
"QUES","XPF1","??")
|
|
^D REP^XPDH
|
|
"QUES","XPF1","A")
|
|
Shall I write over your |FLAG| File
|
|
"QUES","XPF1","B")
|
|
YES
|
|
"QUES","XPF1","M")
|
|
D XPF1^XPDIQ
|
|
"QUES","XPF2",0)
|
|
Y
|
|
"QUES","XPF2","??")
|
|
^D DTA^XPDH
|
|
"QUES","XPF2","A")
|
|
Want my data |FLAG| yours
|
|
"QUES","XPF2","B")
|
|
YES
|
|
"QUES","XPF2","M")
|
|
D XPF2^XPDIQ
|
|
"QUES","XPI1",0)
|
|
YO
|
|
"QUES","XPI1","??")
|
|
^D INHIBIT^XPDH
|
|
"QUES","XPI1","A")
|
|
Want KIDS to INHIBIT LOGONs during the install
|
|
"QUES","XPI1","B")
|
|
NO
|
|
"QUES","XPI1","M")
|
|
D XPI1^XPDIQ
|
|
"QUES","XPM1",0)
|
|
PO^VA(200,:EM
|
|
"QUES","XPM1","??")
|
|
^D MG^XPDH
|
|
"QUES","XPM1","A")
|
|
Enter the Coordinator for Mail Group '|FLAG|'
|
|
"QUES","XPM1","B")
|
|
|
|
"QUES","XPM1","M")
|
|
D XPM1^XPDIQ
|
|
"QUES","XPO1",0)
|
|
Y
|
|
"QUES","XPO1","??")
|
|
^D MENU^XPDH
|
|
"QUES","XPO1","A")
|
|
Want KIDS to Rebuild Menu Trees Upon Completion of Install
|
|
"QUES","XPO1","B")
|
|
NO
|
|
"QUES","XPO1","M")
|
|
D XPO1^XPDIQ
|
|
"QUES","XPZ1",0)
|
|
Y
|
|
"QUES","XPZ1","??")
|
|
^D OPT^XPDH
|
|
"QUES","XPZ1","A")
|
|
Want to DISABLE Scheduled Options, Menu Options, and Protocols
|
|
"QUES","XPZ1","B")
|
|
NO
|
|
"QUES","XPZ1","M")
|
|
D XPZ1^XPDIQ
|
|
"QUES","XPZ2",0)
|
|
Y
|
|
"QUES","XPZ2","??")
|
|
^D RTN^XPDH
|
|
"QUES","XPZ2","A")
|
|
Want to MOVE routines to other CPUs
|
|
"QUES","XPZ2","B")
|
|
NO
|
|
"QUES","XPZ2","M")
|
|
D XPZ2^XPDIQ
|
|
"RTN")
|
|
18
|
|
"RTN","NHINV")
|
|
0^1^B15789004^n/a
|
|
"RTN","NHINV",1,0)
|
|
NHINV ;SLC/MKB - Serve VistA data as XML via RPC
|
|
"RTN","NHINV",2,0)
|
|
;;1.0;NHIN;**1**;Oct 25, 2010;Build 11
|
|
"RTN","NHINV",3,0)
|
|
;
|
|
"RTN","NHINV",4,0)
|
|
; External References DBIA#
|
|
"RTN","NHINV",5,0)
|
|
; ------------------- -----
|
|
"RTN","NHINV",6,0)
|
|
; ^DPT 10035
|
|
"RTN","NHINV",7,0)
|
|
; ^SC 10040
|
|
"RTN","NHINV",8,0)
|
|
; DIQ 2056
|
|
"RTN","NHINV",9,0)
|
|
; MPIF001 2701
|
|
"RTN","NHINV",10,0)
|
|
; VASITE 10112
|
|
"RTN","NHINV",11,0)
|
|
; XLFDT 10103
|
|
"RTN","NHINV",12,0)
|
|
; XLFSTR 10104
|
|
"RTN","NHINV",13,0)
|
|
; XUAF4 2171
|
|
"RTN","NHINV",14,0)
|
|
;
|
|
"RTN","NHINV",15,0)
|
|
GET(NHIN,DFN,TYPE,START,STOP,MAX,ID) ; -- Return search results as XML in @NHIN@(n)
|
|
"RTN","NHINV",16,0)
|
|
; RPC = NHIN GET VISTA DATA
|
|
"RTN","NHINV",17,0)
|
|
N ICN,NHINI,NHINTOTL
|
|
"RTN","NHINV",18,0)
|
|
S NHIN=$NA(^TMP("NHINV",$J)) K @NHIN
|
|
"RTN","NHINV",19,0)
|
|
;
|
|
"RTN","NHINV",20,0)
|
|
; parse & validate input parameters
|
|
"RTN","NHINV",21,0)
|
|
S ICN=+$P(DFN,";",2),DFN=+$G(DFN)
|
|
"RTN","NHINV",22,0)
|
|
I 'DFN S DFN=+$$GETDFN^MPIF001(ICN)
|
|
"RTN","NHINV",23,0)
|
|
I DFN<1!'$D(^DPT(DFN)) D ERR(1,DFN) G GTQ
|
|
"RTN","NHINV",24,0)
|
|
S TYPE=$G(TYPE) I TYPE="" S TYPE=$$ALL
|
|
"RTN","NHINV",25,0)
|
|
S:'$G(START) START=1410101 S:'$G(STOP) STOP=9999998 S:'$G(MAX) MAX=9999
|
|
"RTN","NHINV",26,0)
|
|
I START,STOP,STOP<START N X S X=START,START=STOP,STOP=X ;switch
|
|
"RTN","NHINV",27,0)
|
|
I STOP,$L(STOP,".")<2 S STOP=STOP_".24"
|
|
"RTN","NHINV",28,0)
|
|
S ID=$G(ID)
|
|
"RTN","NHINV",29,0)
|
|
;
|
|
"RTN","NHINV",30,0)
|
|
; extract data
|
|
"RTN","NHINV",31,0)
|
|
N NHINTYPE,NHINP,RTN
|
|
"RTN","NHINV",32,0)
|
|
S NHINTYPE=TYPE D ADD("<results>")
|
|
"RTN","NHINV",33,0)
|
|
F NHINP=1:1:$L(NHINTYPE,";") S TYPE=$P(NHINTYPE,";",NHINP) I $L(TYPE) D
|
|
"RTN","NHINV",34,0)
|
|
. S RTN="EN^"_$$RTN(TYPE) Q:'$L($T(@RTN)) ;D ERR(2) Q
|
|
"RTN","NHINV",35,0)
|
|
. D @(RTN_"(DFN,START,STOP,MAX,ID)")
|
|
"RTN","NHINV",36,0)
|
|
D ADD("</results>")
|
|
"RTN","NHINV",37,0)
|
|
;
|
|
"RTN","NHINV",38,0)
|
|
I $G(NHINTOTL),$G(@NHIN@(1))="<results>" S @NHIN@(1)="<results total='"_NHINTOTL_"' >"
|
|
"RTN","NHINV",39,0)
|
|
;
|
|
"RTN","NHINV",40,0)
|
|
GTQ ; end
|
|
"RTN","NHINV",41,0)
|
|
Q
|
|
"RTN","NHINV",42,0)
|
|
;
|
|
"RTN","NHINV",43,0)
|
|
RTN(X) ; -- Return name of NHINVxxx routine for clinical domain X
|
|
"RTN","NHINV",44,0)
|
|
S X=$$UP^XLFSTR(X),Y="NHINV"
|
|
"RTN","NHINV",45,0)
|
|
I X="ACCESSION" S Y="NHINVLRA"
|
|
"RTN","NHINV",46,0)
|
|
I X="ALLERGY" S Y="NHINVART"
|
|
"RTN","NHINV",47,0)
|
|
I X="APPOINTMENT" S Y="NHINVAPT"
|
|
"RTN","NHINV",48,0)
|
|
; X="CONSULT" S Y="NHINVCON"
|
|
"RTN","NHINV",49,0)
|
|
I X="DOCUMENT" S Y="NHINVTIU"
|
|
"RTN","NHINV",50,0)
|
|
I X="IMMUNIZATION" S Y="NHINVIMM"
|
|
"RTN","NHINV",51,0)
|
|
I X="LAB" S Y="NHINVLR"
|
|
"RTN","NHINV",52,0)
|
|
I X="PANEL" S Y="NHINVLRO"
|
|
"RTN","NHINV",53,0)
|
|
I X="MED" S Y="NHINVPS"
|
|
"RTN","NHINV",54,0)
|
|
I X="RX" S Y="NHINVPSO"
|
|
"RTN","NHINV",55,0)
|
|
; X="ORDER" S Y="NHINVOR"
|
|
"RTN","NHINV",56,0)
|
|
I X="PATIENT" S Y="NHINVPT"
|
|
"RTN","NHINV",57,0)
|
|
I X="PROBLEM" S Y="NHINVPL"
|
|
"RTN","NHINV",58,0)
|
|
I X="PROCEDURE" S Y="NHINVPRC"
|
|
"RTN","NHINV",59,0)
|
|
I X="SURGERY" S Y="NHINVSR"
|
|
"RTN","NHINV",60,0)
|
|
I X="VISIT" S Y="NHINVSIT"
|
|
"RTN","NHINV",61,0)
|
|
I X="VITAL" S Y="NHINVIT"
|
|
"RTN","NHINV",62,0)
|
|
I X="RADIOLOGY" S Y="NHINVRA"
|
|
"RTN","NHINV",63,0)
|
|
I X="NEW" S Y="NHINVPR"
|
|
"RTN","NHINV",64,0)
|
|
Q Y
|
|
"RTN","NHINV",65,0)
|
|
;
|
|
"RTN","NHINV",66,0)
|
|
ALL() ; -- return string for all types of data
|
|
"RTN","NHINV",67,0)
|
|
Q "patient;allergy;problem;vital;lab;med;immunization;visit;appointment;document;procedure"
|
|
"RTN","NHINV",68,0)
|
|
;
|
|
"RTN","NHINV",69,0)
|
|
ERR(X,VAL) ; -- return error message
|
|
"RTN","NHINV",70,0)
|
|
N MSG S MSG="Error"
|
|
"RTN","NHINV",71,0)
|
|
I X=1 S MSG="Patient with dfn '"_$G(VAL)_"' not found"
|
|
"RTN","NHINV",72,0)
|
|
I X=2 S MSG="Requested domain type '"_$G(VAL)_"' not recognized"
|
|
"RTN","NHINV",73,0)
|
|
I X=99 S MSG="Unknown request"
|
|
"RTN","NHINV",74,0)
|
|
;
|
|
"RTN","NHINV",75,0)
|
|
D ADD("<error>")
|
|
"RTN","NHINV",76,0)
|
|
D ADD("<message>"_MSG_"</message>")
|
|
"RTN","NHINV",77,0)
|
|
D ADD("</error>")
|
|
"RTN","NHINV",78,0)
|
|
Q
|
|
"RTN","NHINV",79,0)
|
|
;
|
|
"RTN","NHINV",80,0)
|
|
ESC(X) ; -- escape outgoing XML
|
|
"RTN","NHINV",81,0)
|
|
; Q $ZCONVERT(X,"O","HTML") ; uncomment for fastest performance on Cache
|
|
"RTN","NHINV",82,0)
|
|
;
|
|
"RTN","NHINV",83,0)
|
|
N I,Y,QOT S QOT=""""
|
|
"RTN","NHINV",84,0)
|
|
S Y=$P(X,"&") F I=2:1:$L(X,"&") S Y=Y_"&"_$P(X,"&",I)
|
|
"RTN","NHINV",85,0)
|
|
S X=Y,Y=$P(X,"<") F I=2:1:$L(X,"<") S Y=Y_"<"_$P(X,"<",I)
|
|
"RTN","NHINV",86,0)
|
|
S X=Y,Y=$P(X,">") F I=2:1:$L(X,">") S Y=Y_">"_$P(X,">",I)
|
|
"RTN","NHINV",87,0)
|
|
S X=Y,Y=$P(X,"'") F I=2:1:$L(X,"'") S Y=Y_"'"_$P(X,"'",I)
|
|
"RTN","NHINV",88,0)
|
|
S X=Y,Y=$P(X,QOT) F I=2:1:$L(X,QOT) S Y=Y_"""_$P(X,QOT,I)
|
|
"RTN","NHINV",89,0)
|
|
Q Y
|
|
"RTN","NHINV",90,0)
|
|
;
|
|
"RTN","NHINV",91,0)
|
|
ADD(X) ; Add a line @NHIN@(n)=X
|
|
"RTN","NHINV",92,0)
|
|
S NHINI=$G(NHINI)+1
|
|
"RTN","NHINV",93,0)
|
|
S @NHIN@(NHINI)=X
|
|
"RTN","NHINV",94,0)
|
|
Q
|
|
"RTN","NHINV",95,0)
|
|
;
|
|
"RTN","NHINV",96,0)
|
|
STRING(ARRAY) ; -- Return text in ARRAY(n) or ARRAY(n,0) as a string
|
|
"RTN","NHINV",97,0)
|
|
N I,X,Y S Y=""
|
|
"RTN","NHINV",98,0)
|
|
S I=+$O(ARRAY("")) I I=0 S I=+$O(ARRAY(0))
|
|
"RTN","NHINV",99,0)
|
|
S Y=$S($D(ARRAY(I,0)):ARRAY(I,0),1:$G(ARRAY(I)))
|
|
"RTN","NHINV",100,0)
|
|
F S I=$O(ARRAY(I)) Q:I<1 D
|
|
"RTN","NHINV",101,0)
|
|
. S X=$S($D(ARRAY(I,0)):ARRAY(I,0),1:ARRAY(I))
|
|
"RTN","NHINV",102,0)
|
|
. I $E(X)=" " S Y=Y_$C(13,10)_X Q
|
|
"RTN","NHINV",103,0)
|
|
. S Y=Y_$S($E(Y,$L(Y))=" ":"",1:" ")_X
|
|
"RTN","NHINV",104,0)
|
|
Q Y
|
|
"RTN","NHINV",105,0)
|
|
;
|
|
"RTN","NHINV",106,0)
|
|
FAC(X) ; -- return Institution file station# for location X
|
|
"RTN","NHINV",107,0)
|
|
N HLOC,FAC,Y0,Y S Y=""
|
|
"RTN","NHINV",108,0)
|
|
S HLOC=$G(^SC(+$G(X),0)),FAC=$P(HLOC,U,4) ;Institution ien
|
|
"RTN","NHINV",109,0)
|
|
; Get P:4 via Med Ctr Div, if not directly linked
|
|
"RTN","NHINV",110,0)
|
|
I 'FAC,$P(HLOC,U,15) S FAC=$$GET1^DIQ(40.8,+$P(HLOC,U,15)_",",.07,"I")
|
|
"RTN","NHINV",111,0)
|
|
S Y0=$S(FAC:$$NS^XUAF4(FAC),1:$P($$SITE^VASITE,U,2,3)) ;name^stn#
|
|
"RTN","NHINV",112,0)
|
|
S:$L(Y0) Y=$P(Y0,U,2)_U_$P(Y0,U) ;switch to stn#^name
|
|
"RTN","NHINV",113,0)
|
|
I $L(Y),'Y S $P(Y,U)=FAC
|
|
"RTN","NHINV",114,0)
|
|
Q Y
|
|
"RTN","NHINV",115,0)
|
|
;
|
|
"RTN","NHINV",116,0)
|
|
VUID(IEN,FILE) ; -- Return VUID for item
|
|
"RTN","NHINV",117,0)
|
|
Q $$GET1^DIQ(FILE,IEN_",",99.99)
|
|
"RTN","NHINVAPT")
|
|
0^17^B9234836^n/a
|
|
"RTN","NHINVAPT",1,0)
|
|
NHINVAPT ;SLC/MKB -- Appointment extract
|
|
"RTN","NHINVAPT",2,0)
|
|
;;1.0;NHIN;**1**;Oct 25, 2010;Build 11
|
|
"RTN","NHINVAPT",3,0)
|
|
;
|
|
"RTN","NHINVAPT",4,0)
|
|
; External References DBIA#
|
|
"RTN","NHINVAPT",5,0)
|
|
; ------------------- -----
|
|
"RTN","NHINVAPT",6,0)
|
|
; DIQ 2056
|
|
"RTN","NHINVAPT",7,0)
|
|
; SDAMA201 3859
|
|
"RTN","NHINVAPT",8,0)
|
|
; VADPT 10061
|
|
"RTN","NHINVAPT",9,0)
|
|
;
|
|
"RTN","NHINVAPT",10,0)
|
|
; ------------ Get appointment(s) from VistA ------------
|
|
"RTN","NHINVAPT",11,0)
|
|
;
|
|
"RTN","NHINVAPT",12,0)
|
|
EN(DFN,BEG,END,MAX,ID) ; -- find patient's appointments
|
|
"RTN","NHINVAPT",13,0)
|
|
N NHICNT,NHITOT,NHI,X1,X2,X3,X12,NHITM
|
|
"RTN","NHINVAPT",14,0)
|
|
S DFN=+$G(DFN) Q:DFN<1
|
|
"RTN","NHINVAPT",15,0)
|
|
S BEG=$G(BEG,DT),END=$G(END,9999998),MAX=$G(MAX,999999)
|
|
"RTN","NHINVAPT",16,0)
|
|
;
|
|
"RTN","NHINVAPT",17,0)
|
|
; get one appt
|
|
"RTN","NHINVAPT",18,0)
|
|
I $L($G(ID)) D Q
|
|
"RTN","NHINVAPT",19,0)
|
|
. S (BEG,END)=$P(ID,";",2)
|
|
"RTN","NHINVAPT",20,0)
|
|
. D GETAPPT^SDAMA201(DFN,"1;2;3;12","",BEG,END,.NHITOT)
|
|
"RTN","NHINVAPT",21,0)
|
|
. I NHITOT>0 F NHI=1:1:NHITOT D
|
|
"RTN","NHINVAPT",22,0)
|
|
.. S X1=+$G(^TMP($J,"SDAMA201","GETAPPT",NHI,1)),X2=$G(^(2)),X3=$G(^(3)),X12=$G(^(12))
|
|
"RTN","NHINVAPT",23,0)
|
|
.. Q:+X2'=$P(ID,";",3) ;not same location
|
|
"RTN","NHINVAPT",24,0)
|
|
.. D EN1(X1,X2,X3,X12,.NHITM),XML(.NHITM)
|
|
"RTN","NHINVAPT",25,0)
|
|
. K ^TMP($J,"SDAMA201","GETAPPT")
|
|
"RTN","NHINVAPT",26,0)
|
|
;
|
|
"RTN","NHINVAPT",27,0)
|
|
; get all [future] appointments
|
|
"RTN","NHINVAPT",28,0)
|
|
D GETAPPT^SDAMA201(DFN,"1;2;3;12","",BEG,END,.NHITOT)
|
|
"RTN","NHINVAPT",29,0)
|
|
I NHITOT>0 S NHICNT=0 F NHI=1:1:NHITOT D Q:NHICNT'<MAX
|
|
"RTN","NHINVAPT",30,0)
|
|
. S X1=+$G(^TMP($J,"SDAMA201","GETAPPT",NHI,1)),X2=+$G(^(2)),X3=$G(^(3))
|
|
"RTN","NHINVAPT",31,0)
|
|
. ;no cancelled, or prior kept appointments [ORWCV]
|
|
"RTN","NHINVAPT",32,0)
|
|
. Q:X3="C" I X1<DT,(X3="R"!(X3="NT")) Q
|
|
"RTN","NHINVAPT",33,0)
|
|
. K NHITM D EN1(X1,X2,X3,X12,.NHITM) Q:'$D(NHITM)
|
|
"RTN","NHINVAPT",34,0)
|
|
. D XML(.NHITM) S NHICNT=NHICNT+1
|
|
"RTN","NHINVAPT",35,0)
|
|
K ^TMP($J,"SDAMA201","GETAPPT")
|
|
"RTN","NHINVAPT",36,0)
|
|
Q
|
|
"RTN","NHINVAPT",37,0)
|
|
;
|
|
"RTN","NHINVAPT",38,0)
|
|
EN1(DATE,HLOC,STS,CLS,APPT) ; -- return an appointment in APPT("attribute")=value
|
|
"RTN","NHINVAPT",39,0)
|
|
N X,VIEN K APPT
|
|
"RTN","NHINVAPT",40,0)
|
|
S DATE=+$G(DATE),HLOC=$G(HLOC),STS=$G(STS),CLS=$G(CLS)
|
|
"RTN","NHINVAPT",41,0)
|
|
S APPT("id")="A;"_DATE_";"_+HLOC,APPT("dateTime")=DATE I HLOC D
|
|
"RTN","NHINVAPT",42,0)
|
|
. S APPT("location")=$P(HLOC,U,2)
|
|
"RTN","NHINVAPT",43,0)
|
|
. S APPT("type")=U_$P(HLOC,U,2)_" APPOINTMENT"
|
|
"RTN","NHINVAPT",44,0)
|
|
. S X=$$GET1^DIQ(44,+HLOC_",",9.5,"I")
|
|
"RTN","NHINVAPT",45,0)
|
|
. I X S APPT("service")=$$SERV(X)
|
|
"RTN","NHINVAPT",46,0)
|
|
S APPT("facility")=$$FAC^NHINV(+HLOC)
|
|
"RTN","NHINVAPT",47,0)
|
|
S APPT("patientClass")=$S(CLS="I":"IMP",1:"AMB")
|
|
"RTN","NHINVAPT",48,0)
|
|
S APPT("serviceCategory")=$S(CLS="I":"I^INPATIENT VISIT",1:"A^AMBULATORY")
|
|
"RTN","NHINVAPT",49,0)
|
|
S X=$S(STS="N":"NO-SHOW",STS="C":"CANCELLED",STS="R":"SCHEDULED/KEPT",STS="NT":"NO ACTION TAKEN",1:"")
|
|
"RTN","NHINVAPT",50,0)
|
|
S:$L(X) APPT("apptStatus")=X
|
|
"RTN","NHINVAPT",51,0)
|
|
S APPT("visitString")=+HLOC_";"_DATE_";A"
|
|
"RTN","NHINVAPT",52,0)
|
|
Q
|
|
"RTN","NHINVAPT",53,0)
|
|
;
|
|
"RTN","NHINVAPT",54,0)
|
|
SERV(FTS) ; -- Return #42.4 Service for a Facility Treating Specialty
|
|
"RTN","NHINVAPT",55,0)
|
|
N Y S Y="",FTS=+$G(FTS)
|
|
"RTN","NHINVAPT",56,0)
|
|
S Y=$$GET1^DIQ(45.7,FTS_",","1:3","E")
|
|
"RTN","NHINVAPT",57,0)
|
|
Q Y
|
|
"RTN","NHINVAPT",58,0)
|
|
;
|
|
"RTN","NHINVAPT",59,0)
|
|
; ------------ Return data to middle tier ------------
|
|
"RTN","NHINVAPT",60,0)
|
|
;
|
|
"RTN","NHINVAPT",61,0)
|
|
XML(APPT) ; -- Return appointment as XML
|
|
"RTN","NHINVAPT",62,0)
|
|
N ATT,X,Y,NAMES
|
|
"RTN","NHINVAPT",63,0)
|
|
D ADD("<appointment>") S NHINTOTL=$G(NHINTOTL)+1
|
|
"RTN","NHINVAPT",64,0)
|
|
S ATT="" F S ATT=$O(APPT(ATT)) Q:ATT="" D
|
|
"RTN","NHINVAPT",65,0)
|
|
. S X=$G(APPT(ATT)),Y="" Q:'$L(X)
|
|
"RTN","NHINVAPT",66,0)
|
|
. I X'["^" S Y="<"_ATT_" value='"_$$ESC^NHINV(X)_"' />"
|
|
"RTN","NHINVAPT",67,0)
|
|
. I $L(X)>1 S NAMES="code^name^Z",Y="<"_ATT_" "_$$LOOP_"/>"
|
|
"RTN","NHINVAPT",68,0)
|
|
. D:$L(Y) ADD(Y)
|
|
"RTN","NHINVAPT",69,0)
|
|
D ADD("</appointment>")
|
|
"RTN","NHINVAPT",70,0)
|
|
Q
|
|
"RTN","NHINVAPT",71,0)
|
|
;
|
|
"RTN","NHINVAPT",72,0)
|
|
LOOP() ; -- build sub-items string from NAMES and X
|
|
"RTN","NHINVAPT",73,0)
|
|
N STR,P,TAG S STR=""
|
|
"RTN","NHINVAPT",74,0)
|
|
F P=1:1 S TAG=$P(NAMES,U,P) Q:TAG="Z" I $L($P(X,U,P)) S STR=STR_TAG_"='"_$$ESC^NHINV($P(X,U,P))_"' "
|
|
"RTN","NHINVAPT",75,0)
|
|
Q STR
|
|
"RTN","NHINVAPT",76,0)
|
|
;
|
|
"RTN","NHINVAPT",77,0)
|
|
ADD(X) ; -- Add a line @NHIN@(n)=X
|
|
"RTN","NHINVAPT",78,0)
|
|
S NHINI=$G(NHINI)+1
|
|
"RTN","NHINVAPT",79,0)
|
|
S @NHIN@(NHINI)=X
|
|
"RTN","NHINVAPT",80,0)
|
|
Q
|
|
"RTN","NHINVART")
|
|
0^2^B30332823^n/a
|
|
"RTN","NHINVART",1,0)
|
|
NHINVART ;SLC/MKB -- Allergy/Reaction extract
|
|
"RTN","NHINVART",2,0)
|
|
;;1.0;NHIN;**1**;Oct 25, 2010;Build 11
|
|
"RTN","NHINVART",3,0)
|
|
;
|
|
"RTN","NHINVART",4,0)
|
|
; External References DBIA#
|
|
"RTN","NHINVART",5,0)
|
|
; ------------------- -----
|
|
"RTN","NHINVART",6,0)
|
|
; %DT 10003
|
|
"RTN","NHINVART",7,0)
|
|
; GMRADPT 10099
|
|
"RTN","NHINVART",8,0)
|
|
; EN1^GMRAOR2 2422
|
|
"RTN","NHINVART",9,0)
|
|
; PSN50P41 4531
|
|
"RTN","NHINVART",10,0)
|
|
; PSN50P65 4543
|
|
"RTN","NHINVART",11,0)
|
|
;
|
|
"RTN","NHINVART",12,0)
|
|
; ------------ Get reactions from VistA ------------
|
|
"RTN","NHINVART",13,0)
|
|
;
|
|
"RTN","NHINVART",14,0)
|
|
EN(DFN,BEG,END,MAX,IFN) ; -- find patient's allergies/reactions
|
|
"RTN","NHINVART",15,0)
|
|
N GMRA,GMRAL,NHI,NHITM,NHICNT
|
|
"RTN","NHINVART",16,0)
|
|
S DFN=+$G(DFN) Q:DFN<1
|
|
"RTN","NHINVART",17,0)
|
|
S BEG=$G(BEG,1410101),END=$G(END,9999998),MAX=$G(MAX,999999),NHICNT=0
|
|
"RTN","NHINVART",18,0)
|
|
D EN1^GMRADPT
|
|
"RTN","NHINVART",19,0)
|
|
;
|
|
"RTN","NHINVART",20,0)
|
|
; get one reaction
|
|
"RTN","NHINVART",21,0)
|
|
I $G(IFN) D EN1(IFN,.NHITM),XML(.NHITM) Q
|
|
"RTN","NHINVART",22,0)
|
|
;
|
|
"RTN","NHINVART",23,0)
|
|
; get all reactions
|
|
"RTN","NHINVART",24,0)
|
|
I 'GMRAL S NHITM("assessment")=$S(GMRAL=0:"nka",1:"not done") D XML(.NHITM) Q
|
|
"RTN","NHINVART",25,0)
|
|
S NHI=0 F S NHI=+$O(GMRAL(NHI)) Q:NHI<1 D Q:NHICNT'<MAX
|
|
"RTN","NHINVART",26,0)
|
|
. K NHITM D EN1(NHI,.NHITM) Q:'$D(NHITM)
|
|
"RTN","NHINVART",27,0)
|
|
. D XML(.NHITM) S NHICNT=NHICNT+1
|
|
"RTN","NHINVART",28,0)
|
|
Q
|
|
"RTN","NHINVART",29,0)
|
|
;
|
|
"RTN","NHINVART",30,0)
|
|
EN1(ID,REAC) ; -- return a reaction in REAC("attribute")=value
|
|
"RTN","NHINVART",31,0)
|
|
; from EN: expects GMRAL(ID)
|
|
"RTN","NHINVART",32,0)
|
|
N NHY,GMRA,I,J,X,Y,SEV,TXT,NM,SEV K REAC
|
|
"RTN","NHINVART",33,0)
|
|
S GMRA=$G(GMRAL(ID)) D EN1^GMRAOR2(ID,"NHY")
|
|
"RTN","NHINVART",34,0)
|
|
S X=$P(NHY,U,10) I $L(X) S X=$$DATE(X) Q:X<BEG Q:X>END S REAC("entered")=X
|
|
"RTN","NHINVART",35,0)
|
|
S REAC("facility")=$$FAC^NHINV ;local stn#^name
|
|
"RTN","NHINVART",36,0)
|
|
S REAC("id")=ID,REAC("name")=$P(NHY,U) I $P(GMRA,U,9) D
|
|
"RTN","NHINVART",37,0)
|
|
. S X=$P(GMRA,U,9),Y=+$P(X,"(",2) I 'Y,X["PSDRUG" S Y=50
|
|
"RTN","NHINVART",38,0)
|
|
. S REAC("localCode")=X,REAC("vuid")=$$VUID^NHINV(+X,Y)
|
|
"RTN","NHINVART",39,0)
|
|
S X=$P(NHY,U,6) S:$L(X) REAC("mechanism")=X
|
|
"RTN","NHINVART",40,0)
|
|
S X=$P(NHY,U,5),REAC("source")=$E(X)
|
|
"RTN","NHINVART",41,0)
|
|
S REAC("adverseEventType")=$S($L(GMRA):$P(GMRA,U,7),1:$$DFO($P(NHY,U,7)))
|
|
"RTN","NHINVART",42,0)
|
|
I $P(NHY,U,4)="VERIFIED",$P(NHY,U,9) S REAC("verified")=$P(NHY,U,9)
|
|
"RTN","NHINVART",43,0)
|
|
S I=0,SEV="" F S I=$O(NHY("O",I)) Q:I<1 S X=$P(NHY("O",I),U,2) S:X]SEV SEV=X ;find highest severity
|
|
"RTN","NHINVART",44,0)
|
|
S:$L(SEV) REAC("severity")=SEV
|
|
"RTN","NHINVART",45,0)
|
|
; reactions
|
|
"RTN","NHINVART",46,0)
|
|
S I=0 F S I=$O(NHY("S",I)) Q:I<1 D
|
|
"RTN","NHINVART",47,0)
|
|
. S X=NHY("S",I),NM=$P(X," (") S:NM="" NM="OTHER REACTION"
|
|
"RTN","NHINVART",48,0)
|
|
. S Y=+$$FIND1^DIC(120.83,,"QX",NM)
|
|
"RTN","NHINVART",49,0)
|
|
. S REAC("reaction",I)=NM_U_$$VUID^NHINV(Y,120.83)
|
|
"RTN","NHINVART",50,0)
|
|
; comments
|
|
"RTN","NHINVART",51,0)
|
|
S I=0 F S I=$O(NHY("C",I)) Q:I<1 D
|
|
"RTN","NHINVART",52,0)
|
|
. S X=$G(NHY("C",I)) K TXT
|
|
"RTN","NHINVART",53,0)
|
|
. S Y=$$VA200($P(X,U,3))_U_$P(X,U)
|
|
"RTN","NHINVART",54,0)
|
|
. S Y=Y_U_$S($L($P(X,U,2)):$E($P(X,U,2)),1:"E")
|
|
"RTN","NHINVART",55,0)
|
|
. S J=0 F S J=$O(NHY("C",I,J)) Q:J<1 S X=$G(NHY("C",I,J,0)),TXT(J)=X
|
|
"RTN","NHINVART",56,0)
|
|
. K X S X=$$STRING^NHINV(.TXT)
|
|
"RTN","NHINVART",57,0)
|
|
. S REAC("comment",I)=Y_U_X ;ien^name^date^type^text
|
|
"RTN","NHINVART",58,0)
|
|
; drug info
|
|
"RTN","NHINVART",59,0)
|
|
I $D(NHY("I")) D
|
|
"RTN","NHINVART",60,0)
|
|
. N ROOT S ROOT=$$B^PSN50P41
|
|
"RTN","NHINVART",61,0)
|
|
. S I=0 F S I=$O(NHY("I",I)) Q:I<1 S X=$G(NHY("I",I)) D
|
|
"RTN","NHINVART",62,0)
|
|
.. N IEN S IEN=$O(@ROOT@(X,0))
|
|
"RTN","NHINVART",63,0)
|
|
.. S REAC("drugIngredient",I)=X_U_$$VUID^NHINV(IEN,50.416)
|
|
"RTN","NHINVART",64,0)
|
|
I $D(NHY("V")) D
|
|
"RTN","NHINVART",65,0)
|
|
. S I=0 F S I=$O(NHY("V",I)) Q:I<1 S X=$G(NHY("V",I)) D
|
|
"RTN","NHINVART",66,0)
|
|
.. D C^PSN50P65("",$P(X,U,2),"PSN")
|
|
"RTN","NHINVART",67,0)
|
|
.. N IEN S IEN=+$O(^TMP($J,"PSN","C",$P(X,U),0))
|
|
"RTN","NHINVART",68,0)
|
|
.. S REAC("drugClass",I)=$P(X,U,2)_U_$$VUID^NHINV(IEN,50.605)
|
|
"RTN","NHINVART",69,0)
|
|
I GMRA="" S REAC("removed")=1 ;entered in error
|
|
"RTN","NHINVART",70,0)
|
|
Q
|
|
"RTN","NHINVART",71,0)
|
|
;
|
|
"RTN","NHINVART",72,0)
|
|
VA200(NAME) ; -- Return ien^name from #200
|
|
"RTN","NHINVART",73,0)
|
|
N Y S NAME=$G(NAME),Y="^"
|
|
"RTN","NHINVART",74,0)
|
|
I $L(NAME) S Y=+$O(^VA(200,"B",NAME,0))_U_NAME
|
|
"RTN","NHINVART",75,0)
|
|
Q Y
|
|
"RTN","NHINVART",76,0)
|
|
;
|
|
"RTN","NHINVART",77,0)
|
|
DATE(X) ; -- Return internal form of date X
|
|
"RTN","NHINVART",78,0)
|
|
N %DT,Y
|
|
"RTN","NHINVART",79,0)
|
|
S %DT="TX" D ^%DT
|
|
"RTN","NHINVART",80,0)
|
|
Q Y
|
|
"RTN","NHINVART",81,0)
|
|
;
|
|
"RTN","NHINVART",82,0)
|
|
DFO(X) ; -- Return 'DFO' string for mechanism name(s)
|
|
"RTN","NHINVART",83,0)
|
|
N I,P,Y S Y=""
|
|
"RTN","NHINVART",84,0)
|
|
F I=1:1:$L(X,",") S P=$P(X,",",I),Y=Y_$S($E(P)=" ":$E(P,2),1:$E(P))
|
|
"RTN","NHINVART",85,0)
|
|
S:Y="" Y=$G(X)
|
|
"RTN","NHINVART",86,0)
|
|
Q Y
|
|
"RTN","NHINVART",87,0)
|
|
;
|
|
"RTN","NHINVART",88,0)
|
|
; ------------ Return data to middle tier ------------
|
|
"RTN","NHINVART",89,0)
|
|
;
|
|
"RTN","NHINVART",90,0)
|
|
XML(REAC) ; -- Return patient reaction as XML
|
|
"RTN","NHINVART",91,0)
|
|
; as <element code='123' displayName='ABC' />
|
|
"RTN","NHINVART",92,0)
|
|
N ATT,X,Y,I,P,NM,TAG
|
|
"RTN","NHINVART",93,0)
|
|
D ADD("<allergy>") S NHINTOTL=$G(NHINTOTL)+1
|
|
"RTN","NHINVART",94,0)
|
|
S ATT="" F S ATT=$O(REAC(ATT)) Q:ATT="" D D:$L(Y) ADD(Y)
|
|
"RTN","NHINVART",95,0)
|
|
. I ATT="comment" D S Y="" Q
|
|
"RTN","NHINVART",96,0)
|
|
.. S I=0,Y="<comments>" D ADD(Y)
|
|
"RTN","NHINVART",97,0)
|
|
.. F S I=$O(REAC(ATT,I)) Q:I<1 S X=$G(REAC(ATT,I)) D
|
|
"RTN","NHINVART",98,0)
|
|
... S Y="<comment id='"_I
|
|
"RTN","NHINVART",99,0)
|
|
... S:$L($P(X,U,3)) Y=Y_"' entered='"_$P(X,U,3)
|
|
"RTN","NHINVART",100,0)
|
|
... S:$L($P(X,U,2)) Y=Y_"' enteredBy='"_$$ESC^NHINV($P(X,U,2))
|
|
"RTN","NHINVART",101,0)
|
|
... S:$L($P(X,U,4)) Y=Y_"' commentType='"_$P(X,U,4)
|
|
"RTN","NHINVART",102,0)
|
|
... S:$L($P(X,U,5)) Y=Y_"' commentText='"_$$ESC^NHINV($P(X,U,5))
|
|
"RTN","NHINVART",103,0)
|
|
... S Y=Y_"' />" D ADD(Y)
|
|
"RTN","NHINVART",104,0)
|
|
.. D ADD("</comments>")
|
|
"RTN","NHINVART",105,0)
|
|
. I $O(REAC(ATT,0)) D S Y="" Q
|
|
"RTN","NHINVART",106,0)
|
|
.. S NM=ATT_$S($E(ATT,$L(ATT))="s":"es",1:"s") D ADD("<"_NM_">")
|
|
"RTN","NHINVART",107,0)
|
|
.. S I=0 F S I=$O(REAC(ATT,I)) Q:I<1 D
|
|
"RTN","NHINVART",108,0)
|
|
... S X=$G(REAC(ATT,I)),Y="<"_ATT_" "
|
|
"RTN","NHINVART",109,0)
|
|
... F P=1:1 S TAG=$P("name^vuid^severity^Z",U,P) Q:TAG="Z" I $L($P(X,U,P)) S Y=Y_TAG_"='"_$$ESC^NHINV($P(X,U,P))_"' "
|
|
"RTN","NHINVART",110,0)
|
|
... S Y=Y_"/>" D ADD(Y)
|
|
"RTN","NHINVART",111,0)
|
|
.. D ADD("</"_NM_">")
|
|
"RTN","NHINVART",112,0)
|
|
. S X=$G(REAC(ATT)),Y="" Q:'$L(X)
|
|
"RTN","NHINVART",113,0)
|
|
. I X'["^" S Y="<"_ATT_" value='"_$$ESC^NHINV(X)_"' />" Q
|
|
"RTN","NHINVART",114,0)
|
|
. I $L(X)>1 D S Y=""
|
|
"RTN","NHINVART",115,0)
|
|
.. S Y="<"_ATT_" "
|
|
"RTN","NHINVART",116,0)
|
|
.. F P=1:1 S TAG=$P("code^name^Z",U,P) Q:TAG="Z" I $L($P(X,U,P)) S Y=Y_TAG_"='"_$$ESC^NHINV($P(X,U,P))_"' "
|
|
"RTN","NHINVART",117,0)
|
|
.. S Y=Y_"/>" D ADD(Y)
|
|
"RTN","NHINVART",118,0)
|
|
D ADD("</allergy>")
|
|
"RTN","NHINVART",119,0)
|
|
Q
|
|
"RTN","NHINVART",120,0)
|
|
;
|
|
"RTN","NHINVART",121,0)
|
|
ADD(X) ; Add a line @NHIN@(n)=X
|
|
"RTN","NHINVART",122,0)
|
|
S NHINI=$G(NHINI)+1
|
|
"RTN","NHINVART",123,0)
|
|
S @NHIN@(NHINI)=X
|
|
"RTN","NHINVART",124,0)
|
|
Q
|
|
"RTN","NHINVART",125,0)
|
|
;
|
|
"RTN","NHINVART",126,0)
|
|
C32(REAC) ; -- convert iens to C32 codes
|
|
"RTN","NHINVART",127,0)
|
|
N X,Y,I
|
|
"RTN","NHINVART",128,0)
|
|
S X=$G(REAC("product")) I X S $P(REAC("product"),U)=$$VUID^NHINV(+X,120.82)
|
|
"RTN","NHINVART",129,0)
|
|
S X=$P($G(REAC("type")),U),Y=$P($G(REAC("mechanism")),U)
|
|
"RTN","NHINVART",130,0)
|
|
I $L(X) D S $P(REAC("type"),U)=I
|
|
"RTN","NHINVART",131,0)
|
|
. I Y="A" S I=$S(X["D":416098002,X["F":414285001,1:419199007) Q
|
|
"RTN","NHINVART",132,0)
|
|
. I Y="P" S I=$S(X["D":59037007,X["F":235719002,1:420134006) Q
|
|
"RTN","NHINVART",133,0)
|
|
. S I=$S(X["D":419511003,X["F":418471000,1:418038007)
|
|
"RTN","NHINVART",134,0)
|
|
S X=+$G(REAC("severity")) I X D
|
|
"RTN","NHINVART",135,0)
|
|
. S X=$S(X=1:255604002,X=2:6736007,X=3:24484000,1:X)
|
|
"RTN","NHINVART",136,0)
|
|
. S $P(REAC("severity"),U)=X
|
|
"RTN","NHINVART",137,0)
|
|
S I=0 F S I=$O(REAC("reaction",I)) Q:I<1 D
|
|
"RTN","NHINVART",138,0)
|
|
. S X=$G(REAC("reaction",I)) Q:'X
|
|
"RTN","NHINVART",139,0)
|
|
. S $P(REAC("reaction",I),U)=$$VUID^NHINV(+X,120.83)
|
|
"RTN","NHINVART",140,0)
|
|
S I=0 F S I=$O(REAC("drugClass",I)) Q:I<1 D
|
|
"RTN","NHINVART",141,0)
|
|
. S X=$G(REAC("drugClass",I)) Q:'X
|
|
"RTN","NHINVART",142,0)
|
|
. S $P(REAC("drugClass",I),U)=$$VUID^NHINV(+X,50.605)
|
|
"RTN","NHINVART",143,0)
|
|
S I=0 F S I=$O(REAC("drugIngredient",I)) Q:I<1 D
|
|
"RTN","NHINVART",144,0)
|
|
. S X=$G(REAC("drugIngredient",I)) Q:'X
|
|
"RTN","NHINVART",145,0)
|
|
. S $P(REAC("drugIngredient",I),U)=$$VUID^NHINV(+X,50.416)
|
|
"RTN","NHINVART",146,0)
|
|
Q
|
|
"RTN","NHINVIMM")
|
|
0^14^B9313203^n/a
|
|
"RTN","NHINVIMM",1,0)
|
|
NHINVIMM ;SLC/MKB -- Immunizations extract
|
|
"RTN","NHINVIMM",2,0)
|
|
;;1.0;NHIN;**1**;Oct 25, 2010;Build 11
|
|
"RTN","NHINVIMM",3,0)
|
|
;
|
|
"RTN","NHINVIMM",4,0)
|
|
; External References DBIA#
|
|
"RTN","NHINVIMM",5,0)
|
|
; ------------------- -----
|
|
"RTN","NHINVIMM",6,0)
|
|
; ^DIC(4 10090
|
|
"RTN","NHINVIMM",7,0)
|
|
; ^VA(200 10060
|
|
"RTN","NHINVIMM",8,0)
|
|
; DIC 2051
|
|
"RTN","NHINVIMM",9,0)
|
|
; DIQ 2056
|
|
"RTN","NHINVIMM",10,0)
|
|
; PXRHS03,^TMP("PXI",$J) 1239
|
|
"RTN","NHINVIMM",11,0)
|
|
; XUAF4 2171
|
|
"RTN","NHINVIMM",12,0)
|
|
;
|
|
"RTN","NHINVIMM",13,0)
|
|
; ------------ Get immunizations from VistA ------------
|
|
"RTN","NHINVIMM",14,0)
|
|
;
|
|
"RTN","NHINVIMM",15,0)
|
|
EN(DFN,BEG,END,MAX,IFN) ; -- find patient's immunizations
|
|
"RTN","NHINVIMM",16,0)
|
|
N NHITM,NHICNT,NM,IDT,X
|
|
"RTN","NHINVIMM",17,0)
|
|
S DFN=+$G(DFN) Q:DFN<1 ;invalid patient
|
|
"RTN","NHINVIMM",18,0)
|
|
S BEG=$G(BEG,1410101),END=$G(END,9999998),MAX=$G(MAX,999999),NHICNT=0
|
|
"RTN","NHINVIMM",19,0)
|
|
K ^TMP("PXI",$J) D IMMUN^PXRHS03(DFN)
|
|
"RTN","NHINVIMM",20,0)
|
|
;
|
|
"RTN","NHINVIMM",21,0)
|
|
; get one immunization
|
|
"RTN","NHINVIMM",22,0)
|
|
I $G(IFN) D Q
|
|
"RTN","NHINVIMM",23,0)
|
|
. N DONE S DONE=0
|
|
"RTN","NHINVIMM",24,0)
|
|
. S NM="" F S NM=$O(^TMP("PXI",$J,NM)) Q:NM="" D Q:DONE
|
|
"RTN","NHINVIMM",25,0)
|
|
.. S IDT=0 F S IDT=$O(^TMP("PXI",$J,NM,IDT)) Q:IDT<1 I $D(^(IDT,IFN)) D Q
|
|
"RTN","NHINVIMM",26,0)
|
|
... D EN1(.NHITM),XML(.NHITM)
|
|
"RTN","NHINVIMM",27,0)
|
|
... S DONE=1
|
|
"RTN","NHINVIMM",28,0)
|
|
. K ^TMP("PXI",$J)
|
|
"RTN","NHINVIMM",29,0)
|
|
;
|
|
"RTN","NHINVIMM",30,0)
|
|
; get all immunizations
|
|
"RTN","NHINVIMM",31,0)
|
|
S X=BEG,BEG=9999999-END-.000001,END=9999999-X I $L(END,".")<2 S END=END_".2359"
|
|
"RTN","NHINVIMM",32,0)
|
|
S NM="" F S NM=$O(^TMP("PXI",$J,NM)) Q:NM="" D
|
|
"RTN","NHINVIMM",33,0)
|
|
. S IDT=BEG F S IDT=$O(^TMP("PXI",$J,NM,IDT)) Q:IDT<1!(IDT>END) D
|
|
"RTN","NHINVIMM",34,0)
|
|
.. S IFN=0 F S IFN=$O(^TMP("PXI",$J,NM,IDT,IFN)) Q:IFN<1 D Q:NHICNT'<MAX
|
|
"RTN","NHINVIMM",35,0)
|
|
... K NHITM D EN1(.NHITM),XML(.NHITM)
|
|
"RTN","NHINVIMM",36,0)
|
|
... S NHICNT=NHICNT+1
|
|
"RTN","NHINVIMM",37,0)
|
|
K ^TMP("PXI",$J)
|
|
"RTN","NHINVIMM",38,0)
|
|
Q
|
|
"RTN","NHINVIMM",39,0)
|
|
;
|
|
"RTN","NHINVIMM",40,0)
|
|
EN1(IMM) ; -- return an immunization in IMM("attribute")=value
|
|
"RTN","NHINVIMM",41,0)
|
|
; Expects ^TMP("PXI",$J,NM,IDT,IFN) from IMMUN^PXRHS03
|
|
"RTN","NHINVIMM",42,0)
|
|
N X0,X1,CPT,DA,X,Y K IMM
|
|
"RTN","NHINVIMM",43,0)
|
|
S X0=$G(^TMP("PXI",$J,NM,IDT,IFN,0)),X1=$G(^(1)),X=$G(^("COM"))
|
|
"RTN","NHINVIMM",44,0)
|
|
S:$L(X) IMM("comment")=X
|
|
"RTN","NHINVIMM",45,0)
|
|
S IMM("id")=IFN,IMM("name")=$P(X0,U)
|
|
"RTN","NHINVIMM",46,0)
|
|
S IMM("administered")=+$P(X0,U,3)
|
|
"RTN","NHINVIMM",47,0)
|
|
S IMM("series")=$P(X0,U,5)
|
|
"RTN","NHINVIMM",48,0)
|
|
S IMM("reaction")=$P(X0,U,6)
|
|
"RTN","NHINVIMM",49,0)
|
|
S IMM("contraindicated")=+$P(X0,U,7)
|
|
"RTN","NHINVIMM",50,0)
|
|
S IMM("location")=$P(X1,U)
|
|
"RTN","NHINVIMM",51,0)
|
|
S X=$P(X1,U,3) I $L(X) D
|
|
"RTN","NHINVIMM",52,0)
|
|
. S Y=$$LKUP^XUAF4(X) ;ien
|
|
"RTN","NHINVIMM",53,0)
|
|
. I Y<1 S Y=+$O(^DIC(4,"B",X,0)) ;dupl -> get 1st
|
|
"RTN","NHINVIMM",54,0)
|
|
. S IMM("facility")=$$STA^XUAF4(Y)_U_X
|
|
"RTN","NHINVIMM",55,0)
|
|
I '$D(IMM("facility")) S IMM("facility")=$$FAC^NHINV
|
|
"RTN","NHINVIMM",56,0)
|
|
S X=$P(X0,U,9) S:'$L(X) X=$P(X0,U,8)
|
|
"RTN","NHINVIMM",57,0)
|
|
I $L(X) S IMM("provider")=+$O(^VA(200,"B",X,0))_U_X
|
|
"RTN","NHINVIMM",58,0)
|
|
;
|
|
"RTN","NHINVIMM",59,0)
|
|
S DA=+$$GET1^DIQ(9000010.11,IFN_",",.01,"I") Q:'DA
|
|
"RTN","NHINVIMM",60,0)
|
|
S X=+$$FIND1^DIC(811.1,,"QX",DA_";AUTTIMM(","B") I X>0 D
|
|
"RTN","NHINVIMM",61,0)
|
|
. S Y=$$GET1^DIQ(811.1,X_",",.02,"I") Q:Y<1
|
|
"RTN","NHINVIMM",62,0)
|
|
. S CPT=$G(@(U_$P(Y,";",2)_+Y_",0)"))
|
|
"RTN","NHINVIMM",63,0)
|
|
. S IMM("cpt")=$P(CPT,U,1,2)
|
|
"RTN","NHINVIMM",64,0)
|
|
Q
|
|
"RTN","NHINVIMM",65,0)
|
|
;
|
|
"RTN","NHINVIMM",66,0)
|
|
; ------------ Return data to middle tier ------------
|
|
"RTN","NHINVIMM",67,0)
|
|
;
|
|
"RTN","NHINVIMM",68,0)
|
|
XML(IMM) ; -- Return immunizations as XML
|
|
"RTN","NHINVIMM",69,0)
|
|
N ATT,X,Y,I,P,NAMES,TAG
|
|
"RTN","NHINVIMM",70,0)
|
|
D ADD("<immunization>") S NHINTOTL=$G(NHINTOTL)+1
|
|
"RTN","NHINVIMM",71,0)
|
|
S ATT="" F S ATT=$O(IMM(ATT)) Q:ATT="" D
|
|
"RTN","NHINVIMM",72,0)
|
|
. S X=$G(IMM(ATT)),Y="" Q:'$L(X)
|
|
"RTN","NHINVIMM",73,0)
|
|
. I X'["^" S Y="<"_ATT_" value='"_$$ESC^NHINV(X)_"' />" D ADD(Y) Q
|
|
"RTN","NHINVIMM",74,0)
|
|
. I $L(X)>1 D
|
|
"RTN","NHINVIMM",75,0)
|
|
.. S Y="<"_ATT_" "
|
|
"RTN","NHINVIMM",76,0)
|
|
.. F P=1:1 S TAG=$P("code^name^Z",U,P) Q:TAG="Z" I $L($P(X,U,P)) S Y=Y_TAG_"='"_$$ESC^NHINV($P(X,U,P))_"' "
|
|
"RTN","NHINVIMM",77,0)
|
|
.. S Y=Y_"/>" D ADD(Y)
|
|
"RTN","NHINVIMM",78,0)
|
|
D ADD("</immunization>")
|
|
"RTN","NHINVIMM",79,0)
|
|
Q
|
|
"RTN","NHINVIMM",80,0)
|
|
;
|
|
"RTN","NHINVIMM",81,0)
|
|
ADD(X) ; -- Add a line @NHIN@(n)=X
|
|
"RTN","NHINVIMM",82,0)
|
|
S NHINI=$G(NHINI)+1
|
|
"RTN","NHINVIMM",83,0)
|
|
S @NHIN@(NHINI)=X
|
|
"RTN","NHINVIMM",84,0)
|
|
Q
|
|
"RTN","NHINVIT")
|
|
0^4^B33591565^n/a
|
|
"RTN","NHINVIT",1,0)
|
|
NHINVIT ;SLC/MKB -- Vitals extract
|
|
"RTN","NHINVIT",2,0)
|
|
;;1.0;NHIN;**1**;Oct 25, 2010;Build 11
|
|
"RTN","NHINVIT",3,0)
|
|
;
|
|
"RTN","NHINVIT",4,0)
|
|
; External References DBIA#
|
|
"RTN","NHINVIT",5,0)
|
|
; ------------------- -----
|
|
"RTN","NHINVIT",6,0)
|
|
; ^SC 10040
|
|
"RTN","NHINVIT",7,0)
|
|
; ^VA(200 10060
|
|
"RTN","NHINVIT",8,0)
|
|
; DIC 2051
|
|
"RTN","NHINVIT",9,0)
|
|
; DIQ 2056
|
|
"RTN","NHINVIT",10,0)
|
|
; GMRVUT0,^UTILITY($J,"GMRVD") 1446
|
|
"RTN","NHINVIT",11,0)
|
|
; GMVPXRM 3647
|
|
"RTN","NHINVIT",12,0)
|
|
;
|
|
"RTN","NHINVIT",13,0)
|
|
; ------------ Get vitals from VistA ------------
|
|
"RTN","NHINVIT",14,0)
|
|
;
|
|
"RTN","NHINVIT",15,0)
|
|
EN(DFN,BEG,END,MAX,IFN) ; -- find patient's vitals
|
|
"RTN","NHINVIT",16,0)
|
|
N NHITM,NHIPRM,GMRVSTR,IDT,TYPE,VIT,CNT,X0,X,Y,I,N
|
|
"RTN","NHINVIT",17,0)
|
|
S DFN=+$G(DFN) Q:DFN<1
|
|
"RTN","NHINVIT",18,0)
|
|
;
|
|
"RTN","NHINVIT",19,0)
|
|
; get one measurement
|
|
"RTN","NHINVIT",20,0)
|
|
I $G(IFN) D EN1(IFN,.NHITM),XML(.NHITM) Q
|
|
"RTN","NHINVIT",21,0)
|
|
;
|
|
"RTN","NHINVIT",22,0)
|
|
; get all measurements
|
|
"RTN","NHINVIT",23,0)
|
|
S BEG=$G(BEG,1410101),END=$G(END,9999998),MAX=$G(MAX,999999)
|
|
"RTN","NHINVIT",24,0)
|
|
S GMRVSTR="BP;T;R;P;HT;WT;CVP;CG;PO2;PN",GMRVSTR(0)=BEG_U_END_U_MAX_"^1"
|
|
"RTN","NHINVIT",25,0)
|
|
K ^UTILITY($J,"GMRVD") D EN1^GMRVUT0
|
|
"RTN","NHINVIT",26,0)
|
|
S (IDT,CNT)=0 F S IDT=$O(^UTILITY($J,"GMRVD",IDT)) Q:IDT<1 D Q:CNT'<MAX
|
|
"RTN","NHINVIT",27,0)
|
|
. K VIT S VIT("taken")=9999999-IDT,CNT=CNT+1,N=0
|
|
"RTN","NHINVIT",28,0)
|
|
. S TYPE="" F S TYPE=$O(^UTILITY($J,"GMRVD",IDT,TYPE)) Q:TYPE="" D
|
|
"RTN","NHINVIT",29,0)
|
|
.. N NAME,VUID,RESULT,UNIT,MRES,MUNT,HIGH,LOW,QUAL
|
|
"RTN","NHINVIT",30,0)
|
|
.. S IFN=+$O(^UTILITY($J,"GMRVD",IDT,TYPE,0)),X0=$G(^(IFN))
|
|
"RTN","NHINVIT",31,0)
|
|
.. S X=+$P(X0,U,3),NAME=$$GET1^DIQ(120.5,IFN_",",.03)
|
|
"RTN","NHINVIT",32,0)
|
|
.. S VUID=$$VUID^NHINV(X,120.51),RESULT=$P(X0,U,8)
|
|
"RTN","NHINVIT",33,0)
|
|
.. S UNIT=$S(TYPE="T":"F",TYPE="HT":"in",TYPE="WT":"lb",TYPE="CVP":"cmH2O",TYPE="CG":"in",1:"")
|
|
"RTN","NHINVIT",34,0)
|
|
.. S (MRES,MUNT)="" I $L($P(X0,U,13)) D
|
|
"RTN","NHINVIT",35,0)
|
|
... S X=$S(TYPE="T":"C",TYPE="HT":"cm",TYPE="WT":"kg",TYPE="CG":"cm",1:"")
|
|
"RTN","NHINVIT",36,0)
|
|
... S MRES=$P(X0,U,13) S:$L(X) MUNT=X
|
|
"RTN","NHINVIT",37,0)
|
|
.. S X=$$RANGE(TYPE),(HIGH,LOW)="" I $L(X) S HIGH=$P(X,U),LOW=$P(X,U,2)
|
|
"RTN","NHINVIT",38,0)
|
|
.. S N=N+1,VIT("measurement",N)=IFN_U_VUID_U_NAME_U_RESULT_U_UNIT_U_MRES_U_MUNT_U_HIGH_U_LOW
|
|
"RTN","NHINVIT",39,0)
|
|
.. S QUAL=$P(X0,U,17) I $L(QUAL) F I=1:1:$L(QUAL,";") D
|
|
"RTN","NHINVIT",40,0)
|
|
... S X=$P(QUAL,";",I),Y=$$FIND1^DIC(120.52,,"QX",X)
|
|
"RTN","NHINVIT",41,0)
|
|
... I Y S VIT("measurement",N,"qualifier",I)=X_U_$$VUID^NHINV(Y,120.52)
|
|
"RTN","NHINVIT",42,0)
|
|
. S VIT("entered")=$P($G(X0),U,4) ;use last one
|
|
"RTN","NHINVIT",43,0)
|
|
. S X=+$P($G(X0),U,5) S:X VIT("location")=$$LOC(X)
|
|
"RTN","NHINVIT",44,0)
|
|
. S VIT("facility")=$$FAC^NHINV(X)
|
|
"RTN","NHINVIT",45,0)
|
|
. D XML(.VIT)
|
|
"RTN","NHINVIT",46,0)
|
|
K ^UTILITY($J,"GMRVD")
|
|
"RTN","NHINVIT",47,0)
|
|
Q
|
|
"RTN","NHINVIT",48,0)
|
|
;
|
|
"RTN","NHINVIT",49,0)
|
|
EN1(ID,VIT) ; -- return a vital/measurement in VIT("attribute")
|
|
"RTN","NHINVIT",50,0)
|
|
K VIT S ID=+$G(ID) Q:ID<1 ;invalid ien
|
|
"RTN","NHINVIT",51,0)
|
|
N NHY,DFN,TYPE,X,Y,NAME,VUID,RESULT,UNIT,MRES,MUNT,HIGH,LOW,I
|
|
"RTN","NHINVIT",52,0)
|
|
D EN^GMVPXRM(.NHY,ID,"B")
|
|
"RTN","NHINVIT",53,0)
|
|
S DFN=+$G(NHY(2)) Q:DFN<1
|
|
"RTN","NHINVIT",54,0)
|
|
S TYPE=$$GET1^DIQ(120.51,+NHY(3)_",",1)
|
|
"RTN","NHINVIT",55,0)
|
|
S VIT("facility")=$$FAC^NHINV(+NHY(5)),VIT("location")=NHY(5)
|
|
"RTN","NHINVIT",56,0)
|
|
S NAME=$P(NHY(3),U,2),VUID=$$VUID^NHINV(+NHY(3),120.51)
|
|
"RTN","NHINVIT",57,0)
|
|
S X=$P(NHY(7),U,2),RESULT=X,(UNIT,MRES,MUNT)=""
|
|
"RTN","NHINVIT",58,0)
|
|
I TYPE="T" S UNIT="F",MUNT="C" S MRES=$J(X-32*5/9,0,1) ; EN1^GMRVUTL
|
|
"RTN","NHINVIT",59,0)
|
|
I TYPE="HT" S UNIT="in",MUNT="cm" S MRES=$J(2.54*X,0,2) ; EN2^GMRVUTL
|
|
"RTN","NHINVIT",60,0)
|
|
I TYPE="WT" S UNIT="lb",MUNT="kg" S MRES=$J(X/2.2,0,2) ; EN3^GMRVUTL
|
|
"RTN","NHINVIT",61,0)
|
|
I TYPE="CG" S UNIT="in",MUNT="cm" S MRES=$J(2.54*X,0,2)
|
|
"RTN","NHINVIT",62,0)
|
|
I TYPE="CVP" S UNIT="cmH2O"
|
|
"RTN","NHINVIT",63,0)
|
|
S VIT("taken")=+NHY(1),VIT("entered")=+NHY(4),(HIGH,LOW)=""
|
|
"RTN","NHINVIT",64,0)
|
|
S X=$$RANGE(TYPE) I $L(X) S HIGH=$P(X,U),LOW=$P(X,U,2)
|
|
"RTN","NHINVIT",65,0)
|
|
S VIT("measurement",1)=ID_U_VUID_U_NAME_U_RESULT_U_UNIT_U_MRES_U_MUNT_U_HIGH_U_LOW
|
|
"RTN","NHINVIT",66,0)
|
|
S I=0 F S I=$O(NHY(12,I)) Q:I<1 S X=$G(NHY(12,I)),VIT("measurement",1,"qualifier",I)=$P(X,U,2)_U_$$VUID^NHINV(+X,120.52)
|
|
"RTN","NHINVIT",67,0)
|
|
I $G(NHY(9)) D ;entered in error/reasons
|
|
"RTN","NHINVIT",68,0)
|
|
. S I=0 F S I=$O(NHY(11,I)) Q:I<1 S VIT("removed",I)=$P(NHY(11,I),U,2)
|
|
"RTN","NHINVIT",69,0)
|
|
Q
|
|
"RTN","NHINVIT",70,0)
|
|
;
|
|
"RTN","NHINVIT",71,0)
|
|
USER(X) ; -- Return ien^name for person# X
|
|
"RTN","NHINVIT",72,0)
|
|
N Y S X=+$G(X)
|
|
"RTN","NHINVIT",73,0)
|
|
S Y=$S(X:X_U_$P($G(^VA(200,X,0)),U),1:"^")
|
|
"RTN","NHINVIT",74,0)
|
|
Q Y
|
|
"RTN","NHINVIT",75,0)
|
|
;
|
|
"RTN","NHINVIT",76,0)
|
|
LOC(X) ; -- Return ien^name for hospital location X
|
|
"RTN","NHINVIT",77,0)
|
|
N Y S X=+$G(X)
|
|
"RTN","NHINVIT",78,0)
|
|
S Y=$S(X:X_U_$P($G(^SC(X,0)),U),1:"^")
|
|
"RTN","NHINVIT",79,0)
|
|
Q Y
|
|
"RTN","NHINVIT",80,0)
|
|
;
|
|
"RTN","NHINVIT",81,0)
|
|
RANGE(TYPE) ; -- return high^low range of values for TYPE
|
|
"RTN","NHINVIT",82,0)
|
|
N Y S Y="" I '$D(NHIPRM) D ;get parameter values
|
|
"RTN","NHINVIT",83,0)
|
|
. N VAL D GETS^DIQ(120.57,"1,","5:7","","VAL")
|
|
"RTN","NHINVIT",84,0)
|
|
. M NHIPRM=VAL(120.57,"1,")
|
|
"RTN","NHINVIT",85,0)
|
|
I TYPE="T" S Y=$G(NHIPRM(5.1))_U_$G(NHIPRM(5.2))
|
|
"RTN","NHINVIT",86,0)
|
|
I TYPE="P" S Y=$G(NHIPRM(5.3))_U_$G(NHIPRM(5.4))
|
|
"RTN","NHINVIT",87,0)
|
|
I TYPE="R" S Y=$G(NHIPRM(5.5))_U_$G(NHIPRM(5.6))
|
|
"RTN","NHINVIT",88,0)
|
|
I TYPE="CVP" S Y=$G(NHIPRM(6.1))_U_$G(NHIPRM(6.2))
|
|
"RTN","NHINVIT",89,0)
|
|
I TYPE="PO2" S Y="100^"_$G(NHIPRM(6.3))
|
|
"RTN","NHINVIT",90,0)
|
|
I TYPE="BP" D
|
|
"RTN","NHINVIT",91,0)
|
|
. S Y=$G(NHIPRM(5.7))_"/"_$G(NHIPRM(5.71))_U
|
|
"RTN","NHINVIT",92,0)
|
|
. S Y=Y_$G(NHIPRM(5.8))_"/"_$G(NHIPRM(5.81))
|
|
"RTN","NHINVIT",93,0)
|
|
Q Y
|
|
"RTN","NHINVIT",94,0)
|
|
;
|
|
"RTN","NHINVIT",95,0)
|
|
; ------------ Return data to middle tier ------------
|
|
"RTN","NHINVIT",96,0)
|
|
;
|
|
"RTN","NHINVIT",97,0)
|
|
NAME(X) ; -- Return name of measurement type X for XML element
|
|
"RTN","NHINVIT",98,0)
|
|
N Y S X=$G(X),Y=""
|
|
"RTN","NHINVIT",99,0)
|
|
S Y=$S(X="BP":"bloodPressure",X="T":"temperature",X="R":"respiration",X="P":"pulse",X="HT":"height",X="WT":"weight",X="CVP":"centralVenousPressure",X="CG":"circumferenceGirth",X="PO2":"pulseOximetry",X="PN":"pain",1:"")
|
|
"RTN","NHINVIT",100,0)
|
|
Q Y
|
|
"RTN","NHINVIT",101,0)
|
|
;
|
|
"RTN","NHINVIT",102,0)
|
|
XML(VIT) ; -- Return vital measurement as XML in @NHIN@(#)
|
|
"RTN","NHINVIT",103,0)
|
|
N ATT,X,Y,I,J,P,NAMES,TAG
|
|
"RTN","NHINVIT",104,0)
|
|
D ADD("<vital>") S NHINTOTL=$G(NHINTOTL)+1
|
|
"RTN","NHINVIT",105,0)
|
|
S ATT="" F S ATT=$O(VIT(ATT)) Q:ATT="" D
|
|
"RTN","NHINVIT",106,0)
|
|
. I ATT="measurement" D Q
|
|
"RTN","NHINVIT",107,0)
|
|
.. D ADD("<measurements>")
|
|
"RTN","NHINVIT",108,0)
|
|
.. S NAMES="id^vuid^name^value^units^metricValue^metricUnits^high^low^Z"
|
|
"RTN","NHINVIT",109,0)
|
|
.. S I=0 F S I=$O(VIT(ATT,I)) Q:I<1 D
|
|
"RTN","NHINVIT",110,0)
|
|
... S X=$G(VIT(ATT,I)),Y="<"_ATT_" "
|
|
"RTN","NHINVIT",111,0)
|
|
... F P=1:1 S TAG=$P(NAMES,U,P) Q:TAG="Z" I $L($P(X,U,P)) S Y=Y_TAG_"='"_$$ESC^NHINV($P(X,U,P))_"' "
|
|
"RTN","NHINVIT",112,0)
|
|
... I '$D(VIT(ATT,I,"qualifier")) S Y=Y_"/>" D ADD(Y) Q
|
|
"RTN","NHINVIT",113,0)
|
|
... S Y=Y_">" D ADD(Y),ADD("<qualifiers>")
|
|
"RTN","NHINVIT",114,0)
|
|
... S J=0 F S J=$O(VIT(ATT,I,"qualifier",J)) Q:J<1 D
|
|
"RTN","NHINVIT",115,0)
|
|
.... S Y="<qualifier ",X=$G(VIT(ATT,I,"qualifier",J))
|
|
"RTN","NHINVIT",116,0)
|
|
.... F P=1:1 S TAG=$P("name^vuid^Z",U,P) Q:TAG="Z" I $L($P(X,U,P)) S Y=Y_TAG_"='"_$$ESC^NHINV($P(X,U,P))_"' "
|
|
"RTN","NHINVIT",117,0)
|
|
.... S Y=Y_"/>" D ADD(Y)
|
|
"RTN","NHINVIT",118,0)
|
|
... D ADD("</qualifiers>"),ADD("</measurement>")
|
|
"RTN","NHINVIT",119,0)
|
|
.. D ADD("</measurements>")
|
|
"RTN","NHINVIT",120,0)
|
|
. I ATT="removed" D Q
|
|
"RTN","NHINVIT",121,0)
|
|
.. D ADD("<removed>")
|
|
"RTN","NHINVIT",122,0)
|
|
.. S I=0 F S I=$O(VIT(ATT,I)) Q:I<1 S Y="<reason value='"_$G(VIT(ATT,I))_"' />" D ADD(Y)
|
|
"RTN","NHINVIT",123,0)
|
|
.. D ADD("</removed>")
|
|
"RTN","NHINVIT",124,0)
|
|
. S X=$G(VIT(ATT)),Y="" Q:'$L(X)
|
|
"RTN","NHINVIT",125,0)
|
|
. I X'["^" S Y="<"_ATT_" value='"_$$ESC^NHINV(X)_"' />" D ADD(Y) Q
|
|
"RTN","NHINVIT",126,0)
|
|
. I $L(X)>1 D
|
|
"RTN","NHINVIT",127,0)
|
|
.. S Y="<"_ATT_" "
|
|
"RTN","NHINVIT",128,0)
|
|
.. F P=1:1 S TAG=$P("code^name^Z",U,P) Q:TAG="Z" I $L($P(X,U,P)) S Y=Y_TAG_"='"_$$ESC^NHINV($P(X,U,P))_"' "
|
|
"RTN","NHINVIT",129,0)
|
|
.. S Y=Y_"/>" D ADD(Y)
|
|
"RTN","NHINVIT",130,0)
|
|
D ADD("</vital>")
|
|
"RTN","NHINVIT",131,0)
|
|
Q
|
|
"RTN","NHINVIT",132,0)
|
|
;
|
|
"RTN","NHINVIT",133,0)
|
|
ADD(X) ; Add a line @NHIN@(n)=X
|
|
"RTN","NHINVIT",134,0)
|
|
S NHINI=$G(NHINI)+1
|
|
"RTN","NHINVIT",135,0)
|
|
S @NHIN@(NHINI)=X
|
|
"RTN","NHINVIT",136,0)
|
|
Q
|
|
"RTN","NHINVLR")
|
|
0^5^B25540846^n/a
|
|
"RTN","NHINVLR",1,0)
|
|
NHINVLR ;SLC/MKB -- Laboratory extract
|
|
"RTN","NHINVLR",2,0)
|
|
;;1.0;NHIN;**1**;Oct 25, 2010;Build 11
|
|
"RTN","NHINVLR",3,0)
|
|
;
|
|
"RTN","NHINVLR",4,0)
|
|
; External References DBIA#
|
|
"RTN","NHINVLR",5,0)
|
|
; ------------------- -----
|
|
"RTN","NHINVLR",6,0)
|
|
; ^DPT 10035
|
|
"RTN","NHINVLR",7,0)
|
|
; ^LAB(60 10054
|
|
"RTN","NHINVLR",8,0)
|
|
; ^LRO(69 2407
|
|
"RTN","NHINVLR",9,0)
|
|
; ^LR 525
|
|
"RTN","NHINVLR",10,0)
|
|
; DIC 2051
|
|
"RTN","NHINVLR",11,0)
|
|
; DIQ 2056
|
|
"RTN","NHINVLR",12,0)
|
|
; LR7OR1,^TMP("LRRR",$J) 2503
|
|
"RTN","NHINVLR",13,0)
|
|
;
|
|
"RTN","NHINVLR",14,0)
|
|
; ------------ Get results from VistA ------------
|
|
"RTN","NHINVLR",15,0)
|
|
;
|
|
"RTN","NHINVLR",16,0)
|
|
EN(DFN,BEG,END,MAX,ID) ; -- find patient's lab results
|
|
"RTN","NHINVLR",17,0)
|
|
N NHSUB,NHIDT,NHI,NHITM,LRDFN,SUB
|
|
"RTN","NHINVLR",18,0)
|
|
S DFN=+$G(DFN) Q:$G(DFN)<1
|
|
"RTN","NHINVLR",19,0)
|
|
S BEG=$G(BEG,1410101),END=$G(END,9999998),MAX=$G(MAX,999999)
|
|
"RTN","NHINVLR",20,0)
|
|
K ^TMP("LRRR",$J,DFN) S LRDFN=$G(^DPT(DFN,"LR")),NHSUB="CH"
|
|
"RTN","NHINVLR",21,0)
|
|
;
|
|
"RTN","NHINVLR",22,0)
|
|
; get result(s)
|
|
"RTN","NHINVLR",23,0)
|
|
I $L($G(ID)) D Q:NHI ;done
|
|
"RTN","NHINVLR",24,0)
|
|
. S NHSUB=$P(ID,";"),NHIDT=+$P(ID,";",2),(BEG,END)=9999999-NHIDT
|
|
"RTN","NHINVLR",25,0)
|
|
. S NHI=$P(ID,";",3) I NHI D ;skip loop - single result
|
|
"RTN","NHINVLR",26,0)
|
|
.. D RR^LR7OR1(DFN,,BEG,END,NHSUB)
|
|
"RTN","NHINVLR",27,0)
|
|
.. S SUB=$S("CH^MI"[NHSUB:NHSUB,1:"AP")_"(.NHITM)"
|
|
"RTN","NHINVLR",28,0)
|
|
.. D @SUB,XML(.NHITM)
|
|
"RTN","NHINVLR",29,0)
|
|
.. K ^TMP("LRRR",$J,DFN)
|
|
"RTN","NHINVLR",30,0)
|
|
;
|
|
"RTN","NHINVLR",31,0)
|
|
D RR^LR7OR1(DFN,,BEG,END,NHSUB,,,MAX)
|
|
"RTN","NHINVLR",32,0)
|
|
S NHSUB="" F S NHSUB=$O(^TMP("LRRR",$J,DFN,NHSUB)) Q:NHSUB="" D
|
|
"RTN","NHINVLR",33,0)
|
|
. S NHIDT=0 F S NHIDT=$O(^TMP("LRRR",$J,DFN,NHSUB,NHIDT)) Q:NHIDT<1 D
|
|
"RTN","NHINVLR",34,0)
|
|
.. S NHI=0 F S NHI=$O(^TMP("LRRR",$J,DFN,NHSUB,NHIDT,NHI)) Q:NHI<1 D
|
|
"RTN","NHINVLR",35,0)
|
|
... K NHITM S SUB=$S("CH^MI"[NHSUB:NHSUB,1:"AP")_"(.NHITM)"
|
|
"RTN","NHINVLR",36,0)
|
|
... D @SUB,XML(.NHITM)
|
|
"RTN","NHINVLR",37,0)
|
|
K ^TMP("LRRR",$J,DFN)
|
|
"RTN","NHINVLR",38,0)
|
|
Q
|
|
"RTN","NHINVLR",39,0)
|
|
;
|
|
"RTN","NHINVLR",40,0)
|
|
CH(LAB) ; -- return a Chemistry result in LAB("attribute")=value
|
|
"RTN","NHINVLR",41,0)
|
|
; Expects ^TMP("LRRR",$J,DFN,"CH",NHIDT,NHI),LRDFN
|
|
"RTN","NHINVLR",42,0)
|
|
N CDT,LR0,LRI,X0,X,LOINC,ORD,CMMT K LAB
|
|
"RTN","NHINVLR",43,0)
|
|
S LAB("id")="CH;"_NHIDT_";"_NHI,LAB("type")="CH"
|
|
"RTN","NHINVLR",44,0)
|
|
S CDT=9999999-NHIDT,LAB("collected")=CDT
|
|
"RTN","NHINVLR",45,0)
|
|
S LR0=$G(^LR(LRDFN,"CH",NHIDT,0)),LRI=$G(^(NHI))
|
|
"RTN","NHINVLR",46,0)
|
|
S LAB("status")="completed",LAB("resulted")=$P(LR0,U,3)
|
|
"RTN","NHINVLR",47,0)
|
|
S X0=$G(^TMP("LRRR",$J,DFN,"CH",NHIDT,NHI))
|
|
"RTN","NHINVLR",48,0)
|
|
S LAB("test")=$P($G(^LAB(60,+X0,0)),U) ;$P(X0,U,10)?
|
|
"RTN","NHINVLR",49,0)
|
|
S:$L($P(X0,U,2)) LAB("result")=$P(X0,U,2)
|
|
"RTN","NHINVLR",50,0)
|
|
S:$L($P(X0,U,4)) LAB("units")=$P(X0,U,4)
|
|
"RTN","NHINVLR",51,0)
|
|
S:$L($P(X0,U,3)) LAB("interpretation")=$P(X0,U,3)
|
|
"RTN","NHINVLR",52,0)
|
|
S X=$P(X0,U,5) I $L(X),X["-" S LAB("low")=$P(X,"-"),LAB("high")=$P(X,"-",2)
|
|
"RTN","NHINVLR",53,0)
|
|
S LAB("localName")=$S($L($P(X0,U,15)):$P(X0,U,15),1:LAB("test"))
|
|
"RTN","NHINVLR",54,0)
|
|
S LAB("groupName")=$P(X0,U,16) ;accession#
|
|
"RTN","NHINVLR",55,0)
|
|
S X=$P($P(LRI,U,3),"!",3) S:X LOINC=$$GET1^DIQ(95.3,X_",",.01)
|
|
"RTN","NHINVLR",56,0)
|
|
S X=+$P(X0,U,19) I X D ;specimen
|
|
"RTN","NHINVLR",57,0)
|
|
. N VUID,IENS,NHY S VUID="",IENS=X_","
|
|
"RTN","NHINVLR",58,0)
|
|
. D GETS^DIQ(61,IENS,".01;2",,"NHY")
|
|
"RTN","NHINVLR",59,0)
|
|
. S LAB("specimen")=$G(NHY(61,IENS,2))_U_$G(NHY(61,IENS,.01)) ;SNOMED^name
|
|
"RTN","NHINVLR",60,0)
|
|
. S LAB("sample")=$$GET1^DIQ(61,X_",",4.1) ;name
|
|
"RTN","NHINVLR",61,0)
|
|
. ; LOINC=+$G(^LAB(60,+X0,1,X,95.3))
|
|
"RTN","NHINVLR",62,0)
|
|
. S:'$G(LOINC) LOINC=$$GET1^DIQ(60.01,X_","_+X0_",",95.3)
|
|
"RTN","NHINVLR",63,0)
|
|
. I LOINC S LAB("loinc")=LOINC,VUID=$$VUID^NHINV(+LOINC,95.3)
|
|
"RTN","NHINVLR",64,0)
|
|
. S:VUID LAB("vuid")=VUID
|
|
"RTN","NHINVLR",65,0)
|
|
S ORD=+$P(X0,U,17) S:ORD LAB("labOrderID")=ORD
|
|
"RTN","NHINVLR",66,0)
|
|
S X=$$ORDER(ORD,+X0) S:X LAB("orderID")=X
|
|
"RTN","NHINVLR",67,0)
|
|
S X=$P(LR0,U,14)
|
|
"RTN","NHINVLR",68,0)
|
|
S:X LAB("facility")=$$STA^XUAF4(X)_U_$P($$NS^XUAF4(X),U)
|
|
"RTN","NHINVLR",69,0)
|
|
I 'X S LAB("facility")=$$FAC^NHINV ;local stn#^name
|
|
"RTN","NHINVLR",70,0)
|
|
I $D(^TMP("LRRR",$J,DFN,"CH",NHIDT,"N")) M CMMT=^("N") S LAB("comment")=$$STRING^NHINV(.CMMT)
|
|
"RTN","NHINVLR",71,0)
|
|
Q
|
|
"RTN","NHINVLR",72,0)
|
|
;
|
|
"RTN","NHINVLR",73,0)
|
|
ORDER(LABORD,TEST) ; -- return #100 order for Lab order# & Test
|
|
"RTN","NHINVLR",74,0)
|
|
N Y,D,S,T S Y=""
|
|
"RTN","NHINVLR",75,0)
|
|
S D=$O(^LRO(69,"C",LABORD,0)) I D D
|
|
"RTN","NHINVLR",76,0)
|
|
. S S=0 F S S=$O(^LRO(69,"C",LABORD,D,S)) Q:S<1 D
|
|
"RTN","NHINVLR",77,0)
|
|
.. S T=0 F S T=$O(^LRO(69,D,1,S,2,T)) Q:T<1 I +$G(^(T,0))=TEST S Y=+$P(^(0),U,7)
|
|
"RTN","NHINVLR",78,0)
|
|
Q Y
|
|
"RTN","NHINVLR",79,0)
|
|
;
|
|
"RTN","NHINVLR",80,0)
|
|
MI(LAB) ; -- return a Microbiology result in LAB("attribute")=value
|
|
"RTN","NHINVLR",81,0)
|
|
; Expects ^TMP("LRRR",$J,DFN,"MI",NHIDT,NHI),LRDFN
|
|
"RTN","NHINVLR",82,0)
|
|
N ID,CDT,X0,X,CMMT,LR0 K LAB
|
|
"RTN","NHINVLR",83,0)
|
|
S X0=$G(^TMP("LRRR",$J,DFN,"MI",NHIDT,NHI)) Q:$L($P(X0,U))'>1
|
|
"RTN","NHINVLR",84,0)
|
|
S LAB("id")="MI;"_NHIDT_"#"_NHI,LAB("status")="completed"
|
|
"RTN","NHINVLR",85,0)
|
|
S LAB("type")="MI",CDT=9999999-NHIDT,LAB("collected")=CDT
|
|
"RTN","NHINVLR",86,0)
|
|
S LR0=$G(^LR(LRDFN,"MI",NHIDT,0)),LAB("resulted")=$P(LR0,U,3)
|
|
"RTN","NHINVLR",87,0)
|
|
S:$L($P(X0,U,2)) LAB("result")=$P(X0,U,2)
|
|
"RTN","NHINVLR",88,0)
|
|
S:$L($P(X0,U,4)) LAB("units")=$P(X0,U,4)
|
|
"RTN","NHINVLR",89,0)
|
|
S:$L($P(X0,U,3)) LAB("interpretation")=$P(X0,U,3)
|
|
"RTN","NHINVLR",90,0)
|
|
S (LAB("test"),LAB("localName"))=$P(X0,U,15)
|
|
"RTN","NHINVLR",91,0)
|
|
S X=+$P(X0,U,19) I X D ;specimen
|
|
"RTN","NHINVLR",92,0)
|
|
. N IENS,NHY S IENS=X_","
|
|
"RTN","NHINVLR",93,0)
|
|
. D GETS^DIQ(61,IENS,".01;2",,"NHY")
|
|
"RTN","NHINVLR",94,0)
|
|
. S LAB("specimen")=$G(NHY(61,IENS,2))_U_$G(NHY(61,IENS,.01)) ;SNOMED^name
|
|
"RTN","NHINVLR",95,0)
|
|
. S LAB("sample")=$$GET1^DIQ(61,X_",",4.1) ;name
|
|
"RTN","NHINVLR",96,0)
|
|
S X=$P(LR0,U,14)
|
|
"RTN","NHINVLR",97,0)
|
|
S:X LAB("facility")=$$STA^XUAF4(X)_U_$P($$NS^XUAF4(X),U)
|
|
"RTN","NHINVLR",98,0)
|
|
I 'X S LAB("facility")=$$FAC^NHINV ;local stn#^name
|
|
"RTN","NHINVLR",99,0)
|
|
I $D(^TMP("LRRR",$J,DFN,"MI",NHIDT,"N")) M CMMT=^("N") S LAB("comment")=$$STRING^NHINV(.CMMT)
|
|
"RTN","NHINVLR",100,0)
|
|
Q
|
|
"RTN","NHINVLR",101,0)
|
|
;
|
|
"RTN","NHINVLR",102,0)
|
|
AP(LAB) ; -- return a Pathology result in LAB("attribute")=value
|
|
"RTN","NHINVLR",103,0)
|
|
K LAB ;not implemented yet
|
|
"RTN","NHINVLR",104,0)
|
|
Q
|
|
"RTN","NHINVLR",105,0)
|
|
;
|
|
"RTN","NHINVLR",106,0)
|
|
TYPE(X) ; -- Return name of lab section
|
|
"RTN","NHINVLR",107,0)
|
|
N NHIY,Y S Y=X
|
|
"RTN","NHINVLR",108,0)
|
|
D FIND^DIC(68,,.01,"PQX",X,,"B",,,"NHIY")
|
|
"RTN","NHINVLR",109,0)
|
|
S:$G(NHIY("DILIST",1,0)) Y=$P(NHIY("DILIST",1,0),U,2) ;name
|
|
"RTN","NHINVLR",110,0)
|
|
Q Y
|
|
"RTN","NHINVLR",111,0)
|
|
;
|
|
"RTN","NHINVLR",112,0)
|
|
; ------------ Return data to middle tier ------------
|
|
"RTN","NHINVLR",113,0)
|
|
;
|
|
"RTN","NHINVLR",114,0)
|
|
XML(LAB) ; -- Return result as XML in @NHIN@(#)
|
|
"RTN","NHINVLR",115,0)
|
|
N ATT,X,Y,P,NAMES,TAG
|
|
"RTN","NHINVLR",116,0)
|
|
D ADD("<lab>") S NHINTOTL=$G(NHINTOTL)+1
|
|
"RTN","NHINVLR",117,0)
|
|
S ATT="" F S ATT=$O(LAB(ATT)) Q:ATT="" D D:$L(Y) ADD(Y)
|
|
"RTN","NHINVLR",118,0)
|
|
. S X=$G(LAB(ATT)),Y="" Q:'$L(X)
|
|
"RTN","NHINVLR",119,0)
|
|
. I ATT="comment" S Y="<"_ATT_" xml:space='preserve'>"_$$ESC^NHINV(X)_"</"_ATT_">" Q
|
|
"RTN","NHINVLR",120,0)
|
|
. I X'["^" S Y="<"_ATT_" value='"_$$ESC^NHINV(X)_"' />" Q
|
|
"RTN","NHINVLR",121,0)
|
|
. I $L(X)>1 D S Y=""
|
|
"RTN","NHINVLR",122,0)
|
|
.. S Y="<"_ATT_" ",NAMES="code^name^Z"
|
|
"RTN","NHINVLR",123,0)
|
|
.. F P=1:1 S TAG=$P(NAMES,U,P) Q:TAG="Z" I $L($P(X,U,P)) S Y=Y_TAG_"='"_$$ESC^NHINV($P(X,U,P))_"' "
|
|
"RTN","NHINVLR",124,0)
|
|
.. S Y=Y_"/>" D ADD(Y)
|
|
"RTN","NHINVLR",125,0)
|
|
D ADD("</lab>")
|
|
"RTN","NHINVLR",126,0)
|
|
Q
|
|
"RTN","NHINVLR",127,0)
|
|
;
|
|
"RTN","NHINVLR",128,0)
|
|
ADD(X) ; -- Add a line @NHIN@(n)=X
|
|
"RTN","NHINVLR",129,0)
|
|
S NHINI=$G(NHINI)+1
|
|
"RTN","NHINVLR",130,0)
|
|
S @NHIN@(NHINI)=X
|
|
"RTN","NHINVLR",131,0)
|
|
Q
|
|
"RTN","NHINVLRA")
|
|
0^21^B45252098^n/a
|
|
"RTN","NHINVLRA",1,0)
|
|
NHINVLRA ;SLC/MKB -- Laboratory extract by accession
|
|
"RTN","NHINVLRA",2,0)
|
|
;;1.0;NHIN;**1**;Oct 25, 2010;Build 11
|
|
"RTN","NHINVLRA",3,0)
|
|
;
|
|
"RTN","NHINVLRA",4,0)
|
|
; External References DBIA#
|
|
"RTN","NHINVLRA",5,0)
|
|
; ------------------- -----
|
|
"RTN","NHINVLRA",6,0)
|
|
; ^DPT 10035
|
|
"RTN","NHINVLRA",7,0)
|
|
; ^LAB(60 10054
|
|
"RTN","NHINVLRA",8,0)
|
|
; ^LRO(69 2407
|
|
"RTN","NHINVLRA",9,0)
|
|
; ^LR 525
|
|
"RTN","NHINVLRA",10,0)
|
|
; ^VA(200 10060
|
|
"RTN","NHINVLRA",11,0)
|
|
; DIC 2051
|
|
"RTN","NHINVLRA",12,0)
|
|
; DIQ 2056
|
|
"RTN","NHINVLRA",13,0)
|
|
; LR7OR1,^TMP("LRRR",$J) 2503
|
|
"RTN","NHINVLRA",14,0)
|
|
; LR7OSUM,^TMP("LRC") 2766
|
|
"RTN","NHINVLRA",15,0)
|
|
; PXAPI 1894
|
|
"RTN","NHINVLRA",16,0)
|
|
; XUAF4 2171
|
|
"RTN","NHINVLRA",17,0)
|
|
;
|
|
"RTN","NHINVLRA",18,0)
|
|
; ------------ Get results from VistA ------------
|
|
"RTN","NHINVLRA",19,0)
|
|
;
|
|
"RTN","NHINVLRA",20,0)
|
|
EN(DFN,BEG,END,MAX,ID) ; -- find patient's lab results
|
|
"RTN","NHINVLRA",21,0)
|
|
N NHSUB,NHIDT,NHI,NHITM,LRDFN,LR0,ORD,X
|
|
"RTN","NHINVLRA",22,0)
|
|
S DFN=+$G(DFN) Q:$G(DFN)<1
|
|
"RTN","NHINVLRA",23,0)
|
|
S BEG=$G(BEG,1410101),END=$G(END,9999998),MAX=$G(MAX,999999)
|
|
"RTN","NHINVLRA",24,0)
|
|
S LRDFN=$G(^DPT(DFN,"LR")),NHSUB=""
|
|
"RTN","NHINVLRA",25,0)
|
|
K ^TMP("LRRR",$J,DFN)
|
|
"RTN","NHINVLRA",26,0)
|
|
;
|
|
"RTN","NHINVLRA",27,0)
|
|
; get result(s)
|
|
"RTN","NHINVLRA",28,0)
|
|
I $L($G(ID)) D ;reset search parameters
|
|
"RTN","NHINVLRA",29,0)
|
|
. S NHSUB=$P(ID,";"),NHIDT=+$P(ID,";",2)
|
|
"RTN","NHINVLRA",30,0)
|
|
. S:NHIDT (BEG,END)=9999999-NHIDT
|
|
"RTN","NHINVLRA",31,0)
|
|
;
|
|
"RTN","NHINVLRA",32,0)
|
|
D RR^LR7OR1(DFN,,BEG,END,NHSUB,,,MAX)
|
|
"RTN","NHINVLRA",33,0)
|
|
S NHSUB="" F S NHSUB=$O(^TMP("LRRR",$J,DFN,NHSUB)) Q:NHSUB="" D
|
|
"RTN","NHINVLRA",34,0)
|
|
. S NHIDT=0 F S NHIDT=$O(^TMP("LRRR",$J,DFN,NHSUB,NHIDT)) Q:NHIDT<1 I $O(^(NHIDT,0)) D
|
|
"RTN","NHINVLRA",35,0)
|
|
.. K NHITM,CMMT I "CH^MI"'[NHSUB D AP(.NHITM),XML(.NHITM) Q
|
|
"RTN","NHINVLRA",36,0)
|
|
.. S NHITM("type")=NHSUB,NHITM("id")=NHSUB_";"_NHIDT
|
|
"RTN","NHINVLRA",37,0)
|
|
.. S NHITM("collected")=9999999-NHIDT,NHITM("status")="completed"
|
|
"RTN","NHINVLRA",38,0)
|
|
.. S LR0=$G(^LR(LRDFN,NHSUB,NHIDT,0))
|
|
"RTN","NHINVLRA",39,0)
|
|
.. S NHITM("resulted")=$P(LR0,U,3),X=+$P(LR0,U,5) I X D
|
|
"RTN","NHINVLRA",40,0)
|
|
... N IENS,NHY S IENS=X_","
|
|
"RTN","NHINVLRA",41,0)
|
|
... D GETS^DIQ(61,IENS,".01:2",,"NHY")
|
|
"RTN","NHINVLRA",42,0)
|
|
... S NHITM("specimen")=$G(NHY(61,IENS,2))_U_$G(NHY(61,IENS,.01)) ;SNOMED^name
|
|
"RTN","NHINVLRA",43,0)
|
|
... S NHITM("sample")=$$GET1^DIQ(61,X_",",4.1) ;name
|
|
"RTN","NHINVLRA",44,0)
|
|
.. S NHITM("groupName")=$P(LR0,U,6),X=+$P(LR0,U,14)
|
|
"RTN","NHINVLRA",45,0)
|
|
.. S:X NHITM("facility")=$$STA^XUAF4(X)_U_$P($$NS^XUAF4(X),U)
|
|
"RTN","NHINVLRA",46,0)
|
|
.. I 'X S NHITM("facility")=$$FAC^NHINV ;local stn#^name
|
|
"RTN","NHINVLRA",47,0)
|
|
.. S:NHSUB="MI" NHITM("content")=$$TEXT(DFN,NHSUB,NHIDT)
|
|
"RTN","NHINVLRA",48,0)
|
|
.. S NHI=0 F S NHI=$O(^TMP("LRRR",$J,DFN,NHSUB,NHIDT,NHI)) Q:NHI<1 D
|
|
"RTN","NHINVLRA",49,0)
|
|
... S X=$S(NHSUB="MI":$$MI,1:$$CH)
|
|
"RTN","NHINVLRA",50,0)
|
|
... S:$L(X) NHITM("lab",NHI)=X
|
|
"RTN","NHINVLRA",51,0)
|
|
... S:$G(ORD) NHITM("labOrderID")=ORD
|
|
"RTN","NHINVLRA",52,0)
|
|
.. I $D(^TMP("LRRR",$J,DFN,NHSUB,NHIDT,"N")) M CMMT=^("N") S NHITM("comment")=$$STRING^NHINV(.CMMT)
|
|
"RTN","NHINVLRA",53,0)
|
|
.. D XML(.NHITM)
|
|
"RTN","NHINVLRA",54,0)
|
|
K ^TMP("LRRR",$J,DFN)
|
|
"RTN","NHINVLRA",55,0)
|
|
Q
|
|
"RTN","NHINVLRA",56,0)
|
|
;
|
|
"RTN","NHINVLRA",57,0)
|
|
CH() ; -- return a Chemistry result as:
|
|
"RTN","NHINVLRA",58,0)
|
|
; id^test^result^interpretation^units^low^high^loinc^vuid^order
|
|
"RTN","NHINVLRA",59,0)
|
|
; Expects ^TMP("LRRR",$J,DFN,"CH",NHIDT,NHI),LRDFN
|
|
"RTN","NHINVLRA",60,0)
|
|
N X,Y,X0,NODE,CMMT,LOINC
|
|
"RTN","NHINVLRA",61,0)
|
|
S X0=$G(^TMP("LRRR",$J,DFN,"CH",NHIDT,NHI)),NODE=$G(^LR(LRDFN,"CH",NHIDT,NHI))
|
|
"RTN","NHINVLRA",62,0)
|
|
S X=$P($G(^LAB(60,+X0,0)),U)
|
|
"RTN","NHINVLRA",63,0)
|
|
S Y="CH;"_NHIDT_";"_NHI_U_X_U_$P(X0,U,2,4)
|
|
"RTN","NHINVLRA",64,0)
|
|
S X=$P(X0,U,5) I $L(X),X["-" S X=$TR(X,"- ","^"),$P(Y,U,6,7)=X
|
|
"RTN","NHINVLRA",65,0)
|
|
S X=$P($P(NODE,U,3),"!",3) S:X LOINC=$$GET1^DIQ(95.3,X_",",.01)
|
|
"RTN","NHINVLRA",66,0)
|
|
I '$G(LOINC) S X=+$P(X0,U,19) S:X LOINC=$$LOINC(+X0,X)
|
|
"RTN","NHINVLRA",67,0)
|
|
S $P(Y,U,8,9)=$G(LOINC)_U_$$VUID^NHINV(+LOINC,95.3)
|
|
"RTN","NHINVLRA",68,0)
|
|
S ORD=+$P(X0,U,17),X=$$ORDER(ORD,+X0) S:X $P(Y,U,10)=X
|
|
"RTN","NHINVLRA",69,0)
|
|
Q Y
|
|
"RTN","NHINVLRA",70,0)
|
|
;
|
|
"RTN","NHINVLRA",71,0)
|
|
MI() ; -- return a Microbiology result as:
|
|
"RTN","NHINVLRA",72,0)
|
|
; id^test^result^interpretation^units
|
|
"RTN","NHINVLRA",73,0)
|
|
; Expects ^TMP("LRRR",$J,DFN,"MI",NHIDT,NHI)
|
|
"RTN","NHINVLRA",74,0)
|
|
N Y,X0
|
|
"RTN","NHINVLRA",75,0)
|
|
S X0=$G(^TMP("LRRR",$J,DFN,"MI",NHIDT,NHI)),Y=""
|
|
"RTN","NHINVLRA",76,0)
|
|
S:$L($P(X0,U))>1 Y="MI;"_NHIDT_";"_NHI_U_$P(X0,U,1,4)
|
|
"RTN","NHINVLRA",77,0)
|
|
Q Y
|
|
"RTN","NHINVLRA",78,0)
|
|
;
|
|
"RTN","NHINVLRA",79,0)
|
|
AP(LAB) ; -- return a Pathology result in LAB("attribute")=value
|
|
"RTN","NHINVLRA",80,0)
|
|
N LR0,X,I,NODE
|
|
"RTN","NHINVLRA",81,0)
|
|
S LR0=$G(^LR(LRDFN,NHSUB,NHIDT,0))
|
|
"RTN","NHINVLRA",82,0)
|
|
S LAB("type")=NHSUB,LAB("id")=NHSUB_";"_NHIDT
|
|
"RTN","NHINVLRA",83,0)
|
|
S LAB("collected")=9999999-NHIDT,LAB("status")="completed"
|
|
"RTN","NHINVLRA",84,0)
|
|
S LAB("resulted")=$P(LR0,U,11),LAB("groupName")=$P(LR0,U,6)
|
|
"RTN","NHINVLRA",85,0)
|
|
S X="",I=0 F S I=$O(^LR(LRDFN,NHSUB,NHIDT,.1,I)) Q:I<1 S X=X_$S($L(X):", ",1:"")_$P($G(^(I,0)),U)
|
|
"RTN","NHINVLRA",86,0)
|
|
S:$L(X) LAB("specimen")=U_X
|
|
"RTN","NHINVLRA",87,0)
|
|
S LAB("facility")=$$FAC^NHINV
|
|
"RTN","NHINVLRA",88,0)
|
|
S NODE=$S(NHSUB="AU":$NA(^LR(LRDFN,101)),1:$NA(^LR(LRDFN,NHSUB,NHIDT,.05)))
|
|
"RTN","NHINVLRA",89,0)
|
|
S I=0 F S I=$O(@NODE@(I)) Q:I<1 S X=+$P($G(@NODE@(I,0)),U,2) I X D
|
|
"RTN","NHINVLRA",90,0)
|
|
. N LT,NT
|
|
"RTN","NHINVLRA",91,0)
|
|
. S LT=$$GET1^DIQ(8925,+X_",",.01) Q:$P(LT," ")="Addendum"
|
|
"RTN","NHINVLRA",92,0)
|
|
. S NT=$$GET1^DIQ(8925,+X_",",".01:1501")
|
|
"RTN","NHINVLRA",93,0)
|
|
. S LAB("document",I)=+X_U_LT_U_NT
|
|
"RTN","NHINVLRA",94,0)
|
|
I '$O(NHITM("document",0)) S NHITM("content")=$$TEXT(DFN,NHSUB,NHIDT)
|
|
"RTN","NHINVLRA",95,0)
|
|
Q
|
|
"RTN","NHINVLRA",96,0)
|
|
;
|
|
"RTN","NHINVLRA",97,0)
|
|
LOINC(TEST,SPEC) ; -- Look up LOINC code, if not mapped
|
|
"RTN","NHINVLRA",98,0)
|
|
N Y,LAM,NHIN,IENS S Y=""
|
|
"RTN","NHINVLRA",99,0)
|
|
S TEST=+$G(TEST),SPEC=+$G(SPEC)
|
|
"RTN","NHINVLRA",100,0)
|
|
S LAM=$G(^LAB(60,TEST,64)),LAM=$S($P(LAM,U,2):$P(LAM,U,2),1:+LAM)
|
|
"RTN","NHINVLRA",101,0)
|
|
D GETS^DIQ(64.01,SPEC_","_LAM_",","30*",,"NHIN")
|
|
"RTN","NHINVLRA",102,0)
|
|
S IENS=$O(NHIN(64.02,"")) S:IENS Y=$G(NHIN(64.02,IENS,4))
|
|
"RTN","NHINVLRA",103,0)
|
|
S:'Y Y=$$GET1^DIQ(60.01,SPEC_","_TEST_",",95.3)
|
|
"RTN","NHINVLRA",104,0)
|
|
Q Y
|
|
"RTN","NHINVLRA",105,0)
|
|
;
|
|
"RTN","NHINVLRA",106,0)
|
|
ORDER(LABORD,TEST) ; -- return #100 order for Lab order# & Test
|
|
"RTN","NHINVLRA",107,0)
|
|
N Y,D,S,T S Y=""
|
|
"RTN","NHINVLRA",108,0)
|
|
S D=$O(^LRO(69,"C",LABORD,0)) I D D
|
|
"RTN","NHINVLRA",109,0)
|
|
. S S=0 F S S=$O(^LRO(69,"C",LABORD,D,S)) Q:S<1 D
|
|
"RTN","NHINVLRA",110,0)
|
|
.. S T=0 F S T=$O(^LRO(69,D,1,S,2,T)) Q:T<1 I +$G(^(T,0))=TEST S Y=+$P(^(0),U,7)
|
|
"RTN","NHINVLRA",111,0)
|
|
Q Y
|
|
"RTN","NHINVLRA",112,0)
|
|
;
|
|
"RTN","NHINVLRA",113,0)
|
|
NAME(X) ; -- Return name of subscript X
|
|
"RTN","NHINVLRA",114,0)
|
|
I X="AU" Q "AUTOPSY"
|
|
"RTN","NHINVLRA",115,0)
|
|
I X="BB" Q "BLOOD BANK"
|
|
"RTN","NHINVLRA",116,0)
|
|
I X="CH" Q "CHEM,HEM,TOX,RIA,SER,etc."
|
|
"RTN","NHINVLRA",117,0)
|
|
I X="CY" Q "CYTOLOGY"
|
|
"RTN","NHINVLRA",118,0)
|
|
I X="EM" Q "ELECTRON MICROSCOPY"
|
|
"RTN","NHINVLRA",119,0)
|
|
I X="MI" Q "MICROBIOLOGY"
|
|
"RTN","NHINVLRA",120,0)
|
|
I X="SP" Q "SURGICAL PATHOLOGY"
|
|
"RTN","NHINVLRA",121,0)
|
|
Q "ANATOMIC PATHOLOGY"
|
|
"RTN","NHINVLRA",122,0)
|
|
;
|
|
"RTN","NHINVLRA",123,0)
|
|
RPT(DFN,ID,RPT) ; -- return report as a TIU document
|
|
"RTN","NHINVLRA",124,0)
|
|
S DFN=+$G(DFN),ID=$G(ID) Q:DFN<1 Q:'$L(ID)
|
|
"RTN","NHINVLRA",125,0)
|
|
N SUB,IDT,LRDFN,LR0,X
|
|
"RTN","NHINVLRA",126,0)
|
|
S SUB=$P(ID,";"),IDT=+$P(ID,";",2)
|
|
"RTN","NHINVLRA",127,0)
|
|
S LRDFN=$G(^DPT(DFN,"LR")),LR0=$G(^LR(LRDFN,SUB,IDT,0))
|
|
"RTN","NHINVLRA",128,0)
|
|
S RPT("id")=ID,RPT("referenceDateTime")=9999999-IDT
|
|
"RTN","NHINVLRA",129,0)
|
|
S RPT("localTitle")=$$NAME(SUB),RPT("status")="COMPLETED"
|
|
"RTN","NHINVLRA",130,0)
|
|
S X=+$P(LR0,U,14),RPT("facility")=$$FAC^NHINV(X)
|
|
"RTN","NHINVLRA",131,0)
|
|
S X=$P(LR0,U,13) I X["SC(" D
|
|
"RTN","NHINVLRA",132,0)
|
|
. N CDT,HLOC S HLOC=+X,CDT=9999999-IDT
|
|
"RTN","NHINVLRA",133,0)
|
|
. S X=$$GETENC^PXAPI(DFN,CDT,HLOC)
|
|
"RTN","NHINVLRA",134,0)
|
|
. S:X RPT("encounter")=+X
|
|
"RTN","NHINVLRA",135,0)
|
|
S X=+$P(LR0,U,4) S:X RPT("clinician",1)=X_U_$P($G(^VA(200,X,0)),U)
|
|
"RTN","NHINVLRA",136,0)
|
|
S RPT("content")=$$TEXT(DFN,SUB,IDT)
|
|
"RTN","NHINVLRA",137,0)
|
|
Q
|
|
"RTN","NHINVLRA",138,0)
|
|
;
|
|
"RTN","NHINVLRA",139,0)
|
|
TEXT(DFN,SUB,IDT) ; -- return report text as a string
|
|
"RTN","NHINVLRA",140,0)
|
|
N LRDFN,DATE,NAME,NHS,NHY,I,X,Y
|
|
"RTN","NHINVLRA",141,0)
|
|
K ^TMP("LRC",$J),^TMP("LRH",$J),^TMP("LRT",$J)
|
|
"RTN","NHINVLRA",142,0)
|
|
S DATE=9999999-+$G(IDT),NAME=$$NAME(SUB),NHS(NAME)=""
|
|
"RTN","NHINVLRA",143,0)
|
|
D EN^LR7OSUM(.NHY,DFN,DATE,DATE,,,.NHS)
|
|
"RTN","NHINVLRA",144,0)
|
|
S I=+$G(^TMP("LRH",$J,NAME))+1,Y=$G(^TMP("LRC",$J,I,0)) ;LRH=header: Y=1st line
|
|
"RTN","NHINVLRA",145,0)
|
|
F S I=$O(^TMP("LRC",$J,I)) Q:I<1 S X=$G(^(I,0)) Q:X?1."=" S Y=Y_$C(13,10)_X
|
|
"RTN","NHINVLRA",146,0)
|
|
K ^TMP("LRC",$J),^TMP("LRH",$J),^TMP("LRT",$J)
|
|
"RTN","NHINVLRA",147,0)
|
|
Q Y
|
|
"RTN","NHINVLRA",148,0)
|
|
;
|
|
"RTN","NHINVLRA",149,0)
|
|
; ------------ Return data to middle tier ------------
|
|
"RTN","NHINVLRA",150,0)
|
|
;
|
|
"RTN","NHINVLRA",151,0)
|
|
XML(LAB) ; -- Return result as XML in @NHIN@(#)
|
|
"RTN","NHINVLRA",152,0)
|
|
N ATT,X,Y,NAMES
|
|
"RTN","NHINVLRA",153,0)
|
|
D ADD("<accession>") S NHINTOTL=$G(NHINTOTL)+1
|
|
"RTN","NHINVLRA",154,0)
|
|
S ATT="" F S ATT=$O(LAB(ATT)) Q:ATT="" D D:$L(Y) ADD(Y)
|
|
"RTN","NHINVLRA",155,0)
|
|
. I $O(LAB(ATT,0)) D S Y="" Q
|
|
"RTN","NHINVLRA",156,0)
|
|
.. D ADD("<"_ATT_"s>")
|
|
"RTN","NHINVLRA",157,0)
|
|
.. S NAMES=$S(ATT="document":"id^localTitle^nationalTitle^Z",ATT="lab":"id^test^result^interpretation^units^low^high^loinc^vuid^order^Z",1:"code^name^Z")
|
|
"RTN","NHINVLRA",158,0)
|
|
.. S I=0 F S I=$O(LAB(ATT,I)) Q:I<1 D
|
|
"RTN","NHINVLRA",159,0)
|
|
... S X=$G(LAB(ATT,I))
|
|
"RTN","NHINVLRA",160,0)
|
|
... S Y="<"_ATT_" "_$$LOOP_"/>" D ADD(Y)
|
|
"RTN","NHINVLRA",161,0)
|
|
.. D ADD("</"_ATT_"s>")
|
|
"RTN","NHINVLRA",162,0)
|
|
. S X=$G(LAB(ATT)),Y="" Q:'$L(X)
|
|
"RTN","NHINVLRA",163,0)
|
|
. I ATT="comment" S Y="<"_ATT_" xml:space='preserve'>"_$$ESC^NHINV(X)_"</"_ATT_">" Q
|
|
"RTN","NHINVLRA",164,0)
|
|
. I ATT="content" S Y="<"_ATT_" xml:space='preserve'>"_$$ESC^NHINV(X)_"</"_ATT_">" Q
|
|
"RTN","NHINVLRA",165,0)
|
|
. I X'["^" S Y="<"_ATT_" value='"_$$ESC^NHINV(X)_"' />" Q
|
|
"RTN","NHINVLRA",166,0)
|
|
. I $L(X)>1 D S Y=""
|
|
"RTN","NHINVLRA",167,0)
|
|
.. S NAMES="code^name^Z"
|
|
"RTN","NHINVLRA",168,0)
|
|
.. S Y="<"_ATT_" "_$$LOOP_"/>" D ADD(Y)
|
|
"RTN","NHINVLRA",169,0)
|
|
D ADD("</accession>")
|
|
"RTN","NHINVLRA",170,0)
|
|
Q
|
|
"RTN","NHINVLRA",171,0)
|
|
;
|
|
"RTN","NHINVLRA",172,0)
|
|
LOOP() ; -- build sub-items string from NAMES and X
|
|
"RTN","NHINVLRA",173,0)
|
|
N STR,P,TAG S STR=""
|
|
"RTN","NHINVLRA",174,0)
|
|
F P=1:1 S TAG=$P(NAMES,U,P) Q:TAG="Z" I $L($P(X,U,P)) S STR=STR_TAG_"='"_$$ESC^NHINV($P(X,U,P))_"' "
|
|
"RTN","NHINVLRA",175,0)
|
|
Q STR
|
|
"RTN","NHINVLRA",176,0)
|
|
;
|
|
"RTN","NHINVLRA",177,0)
|
|
ADD(X) ; -- Add a line @NHIN@(n)=X
|
|
"RTN","NHINVLRA",178,0)
|
|
S NHINI=$G(NHINI)+1
|
|
"RTN","NHINVLRA",179,0)
|
|
S @NHIN@(NHINI)=X
|
|
"RTN","NHINVLRA",180,0)
|
|
Q
|
|
"RTN","NHINVLRO")
|
|
0^22^B32647424^n/a
|
|
"RTN","NHINVLRO",1,0)
|
|
NHINVLRO ;SLC/MKB -- Laboratory extract by order/panel
|
|
"RTN","NHINVLRO",2,0)
|
|
;;1.0;NHIN;**1**;Oct 25, 2010;Build 11
|
|
"RTN","NHINVLRO",3,0)
|
|
;
|
|
"RTN","NHINVLRO",4,0)
|
|
; External References DBIA#
|
|
"RTN","NHINVLRO",5,0)
|
|
; ------------------- -----
|
|
"RTN","NHINVLRO",6,0)
|
|
; ^DPT 10035
|
|
"RTN","NHINVLRO",7,0)
|
|
; ^LAB(60 67,91,10054
|
|
"RTN","NHINVLRO",8,0)
|
|
; ^LRO(69 2407
|
|
"RTN","NHINVLRO",9,0)
|
|
; ^LR 525
|
|
"RTN","NHINVLRO",10,0)
|
|
; DIQ 2056
|
|
"RTN","NHINVLRO",11,0)
|
|
; LR7OR1,^TMP("LRRR",$J) 2503
|
|
"RTN","NHINVLRO",12,0)
|
|
; XUAF4 2171
|
|
"RTN","NHINVLRO",13,0)
|
|
;
|
|
"RTN","NHINVLRO",14,0)
|
|
; ------------ Get results from VistA ------------
|
|
"RTN","NHINVLRO",15,0)
|
|
;
|
|
"RTN","NHINVLRO",16,0)
|
|
EN(DFN,BEG,END,MAX,ID) ; -- find patient's lab results
|
|
"RTN","NHINVLRO",17,0)
|
|
N NHSUB,NHIDT,NHI,NHT,NHITM,CMMT,LRDFN,LR0,X
|
|
"RTN","NHINVLRO",18,0)
|
|
S DFN=+$G(DFN) Q:$G(DFN)<1
|
|
"RTN","NHINVLRO",19,0)
|
|
S BEG=$G(BEG,1410101),END=$G(END,9999998),MAX=$G(MAX,999999)
|
|
"RTN","NHINVLRO",20,0)
|
|
S LRDFN=$G(^DPT(DFN,"LR")),NHSUB="CH"
|
|
"RTN","NHINVLRO",21,0)
|
|
K ^TMP("LRRR",$J,DFN)
|
|
"RTN","NHINVLRO",22,0)
|
|
;
|
|
"RTN","NHINVLRO",23,0)
|
|
; get result(s)
|
|
"RTN","NHINVLRO",24,0)
|
|
I $G(ID) D RR^LR7OR1(DFN,ID)
|
|
"RTN","NHINVLRO",25,0)
|
|
I '$G(ID) D ;no id, or accession format (no lab order)
|
|
"RTN","NHINVLRO",26,0)
|
|
. S:$G(ID)'="" NHSUB=$P(ID,";"),(BEG,END)=9999999-$P(ID,";",2)
|
|
"RTN","NHINVLRO",27,0)
|
|
. D RR^LR7OR1(DFN,,BEG,END,NHSUB,,,MAX)
|
|
"RTN","NHINVLRO",28,0)
|
|
;
|
|
"RTN","NHINVLRO",29,0)
|
|
S NHSUB="" F S NHSUB=$O(^TMP("LRRR",$J,DFN,NHSUB)) Q:NHSUB="" D
|
|
"RTN","NHINVLRO",30,0)
|
|
. S NHIDT=0 F S NHIDT=$O(^TMP("LRRR",$J,DFN,NHSUB,NHIDT)) Q:NHIDT<1 I $O(^(NHIDT,0)) D
|
|
"RTN","NHINVLRO",31,0)
|
|
.. I "CH^MI"'[NHSUB Q
|
|
"RTN","NHINVLRO",32,0)
|
|
.. D SORT ;group accession by lab orders > NHLRO(panel,NHI)=data node
|
|
"RTN","NHINVLRO",33,0)
|
|
.. S NHT="" F S NHT=$O(NHLRO(NHT)) Q:NHT="" D
|
|
"RTN","NHINVLRO",34,0)
|
|
... K NHITM,CMMT S X=$G(NHLRO(NHT))
|
|
"RTN","NHINVLRO",35,0)
|
|
... I $G(ID),ID'=$P(X,U,3) Q ;single order only
|
|
"RTN","NHINVLRO",36,0)
|
|
... S NHITM("id")=$P(X,U,3),NHITM("order")=$P(X,U,1,2)
|
|
"RTN","NHINVLRO",37,0)
|
|
... S NHITM("type")=NHSUB,NHITM("status")="completed"
|
|
"RTN","NHINVLRO",38,0)
|
|
... S NHITM("collected")=9999999-NHIDT
|
|
"RTN","NHINVLRO",39,0)
|
|
... S LR0=$G(^LR(LRDFN,NHSUB,NHIDT,0))
|
|
"RTN","NHINVLRO",40,0)
|
|
... S NHITM("resulted")=$P(LR0,U,3),X=+$P(LR0,U,5) I X D ;specimen
|
|
"RTN","NHINVLRO",41,0)
|
|
.... N IENS,NHY S IENS=X_","
|
|
"RTN","NHINVLRO",42,0)
|
|
.... D GETS^DIQ(61,IENS,".01:2",,"NHY")
|
|
"RTN","NHINVLRO",43,0)
|
|
.... S NHITM("specimen")=$G(NHY(61,IENS,2))_U_$G(NHY(61,IENS,.01)) ;SNOMED^name
|
|
"RTN","NHINVLRO",44,0)
|
|
.... S NHITM("sample")=$$GET1^DIQ(61,X_",",4.1) ;name
|
|
"RTN","NHINVLRO",45,0)
|
|
... S NHITM("groupName")=$P(LR0,U,6),X=+$P(LR0,U,14)
|
|
"RTN","NHINVLRO",46,0)
|
|
... S:X NHITM("facility")=$$STA^XUAF4(X)_U_$P($$NS^XUAF4(X),U)
|
|
"RTN","NHINVLRO",47,0)
|
|
... I 'X S NHITM("facility")=$$FAC^NHINV ;local stn#^name
|
|
"RTN","NHINVLRO",48,0)
|
|
... S NHI=0 F S NHI=$O(NHLRO(NHT,NHI)) Q:NHI<1 D
|
|
"RTN","NHINVLRO",49,0)
|
|
.... S X=$G(NHLRO(NHT,NHI))
|
|
"RTN","NHINVLRO",50,0)
|
|
.... S:NHSUB="CH" NHITM("value",NHI)=$$CH(X)
|
|
"RTN","NHINVLRO",51,0)
|
|
.... S:NHSUB="MI" NHITM("value",NHI)=$$MI(X)
|
|
"RTN","NHINVLRO",52,0)
|
|
... I $D(^TMP("LRRR",$J,DFN,NHSUB,NHIDT,"N")) M CMMT=^("N") S NHITM("comment")=$$STRING^NHINV(.CMMT)
|
|
"RTN","NHINVLRO",53,0)
|
|
... D XML(.NHITM)
|
|
"RTN","NHINVLRO",54,0)
|
|
K ^TMP("LRRR",$J,DFN)
|
|
"RTN","NHINVLRO",55,0)
|
|
Q
|
|
"RTN","NHINVLRO",56,0)
|
|
;
|
|
"RTN","NHINVLRO",57,0)
|
|
SORT ; -- return NHLRO(PANEL) = CPRS order# ^ panel/test name ^ Lab Order string
|
|
"RTN","NHINVLRO",58,0)
|
|
; NHLRO(PANEL,NHI) = result node
|
|
"RTN","NHINVLRO",59,0)
|
|
N X0,NUM,ORD,ODT,SN,T,T0,I,NHY,NHLRT K NHLRO
|
|
"RTN","NHINVLRO",60,0)
|
|
S NHI=$O(^TMP("LRRR",$J,DFN,NHSUB,NHIDT,0)),X0=$G(^(NHI)) ;first
|
|
"RTN","NHINVLRO",61,0)
|
|
S NUM=$P(X0,U,16),ORD=$P(X0,U,17),ODT=+$P(9999999-NHIDT,".")
|
|
"RTN","NHINVLRO",62,0)
|
|
; - build NHLRT list of result nodes for each test/panel
|
|
"RTN","NHINVLRO",63,0)
|
|
I ORD S SN=0 F S SN=$O(^LRO(69,"C",ORD,ODT,SN)) Q:SN<1 D Q:$D(NHLRT)
|
|
"RTN","NHINVLRO",64,0)
|
|
. I $G(ID),$P(ID,";",3)'=SN Q
|
|
"RTN","NHINVLRO",65,0)
|
|
. S T=0 F S T=+$O(^LRO(69,ODT,1,SN,2,T)) Q:T<1 D
|
|
"RTN","NHINVLRO",66,0)
|
|
.. I $G(ID),T'=$P(ID,";",4) Q
|
|
"RTN","NHINVLRO",67,0)
|
|
.. S T0=$G(^LRO(69,ODT,1,SN,2,T,0))
|
|
"RTN","NHINVLRO",68,0)
|
|
.. ; is test/panel part of same accession?
|
|
"RTN","NHINVLRO",69,0)
|
|
.. Q:$P(T0,U,5)'=+$P(NUM," ",3)
|
|
"RTN","NHINVLRO",70,0)
|
|
.. Q:$$GET1^DIQ(68,$P(T0,U,4)_",",.09)'=$P(NUM," ")
|
|
"RTN","NHINVLRO",71,0)
|
|
.. ; expand panel into unit tests
|
|
"RTN","NHINVLRO",72,0)
|
|
.. K NHY D EXPAND(+T0,.NHY)
|
|
"RTN","NHINVLRO",73,0)
|
|
.. S I=0 F S I=$O(NHY(I)) Q:I<1 S NHLRT(I,+T0)="" ;NHLRT(test,panel)=""
|
|
"RTN","NHINVLRO",74,0)
|
|
.. S NHLRO(+T0)=$P(T0,U,7)_U_$P($G(^LAB(60,+T0,0)),U)_U_ORD_";"_ODT_";"_SN_";"_T
|
|
"RTN","NHINVLRO",75,0)
|
|
S:'$D(NHLRO) NHLRO(0)=$S(NHSUB="MI":"^MICROBIOLOGY^MI;",1:"^ACCESSION^CH;")_NHIDT ;no Lab Order
|
|
"RTN","NHINVLRO",76,0)
|
|
; - build NHLRO(panel#,NHI) = ^TMP node
|
|
"RTN","NHINVLRO",77,0)
|
|
S NHI=0 F S NHI=$O(^TMP("LRRR",$J,DFN,"CH",NHIDT,NHI)) Q:NHI<1 S X0=$G(^(NHI)) D
|
|
"RTN","NHINVLRO",78,0)
|
|
. I '$D(NHLRT(+X0)) S NHLRO(0,NHI)=X0 Q ;no Lab Order
|
|
"RTN","NHINVLRO",79,0)
|
|
. S T=0 F S T=$O(NHLRT(+X0,T)) Q:T<1 S NHLRO(T,NHI)=X0
|
|
"RTN","NHINVLRO",80,0)
|
|
Q
|
|
"RTN","NHINVLRO",81,0)
|
|
;
|
|
"RTN","NHINVLRO",82,0)
|
|
EXPAND(TEST,ARAY) ;Expand a lab test panel [LR7OU1]
|
|
"RTN","NHINVLRO",83,0)
|
|
;TEST=Test ptr to file 60
|
|
"RTN","NHINVLRO",84,0)
|
|
;Expanded panel returned in ARAY(TEST)
|
|
"RTN","NHINVLRO",85,0)
|
|
N INARAY
|
|
"RTN","NHINVLRO",86,0)
|
|
D EX(TEST)
|
|
"RTN","NHINVLRO",87,0)
|
|
M ARAY=INARAY
|
|
"RTN","NHINVLRO",88,0)
|
|
Q
|
|
"RTN","NHINVLRO",89,0)
|
|
EX(TST) ;
|
|
"RTN","NHINVLRO",90,0)
|
|
N J,X,SUB
|
|
"RTN","NHINVLRO",91,0)
|
|
Q:'$D(^LAB(60,TST,0)) S SUB=$P(^(0),"^",5)
|
|
"RTN","NHINVLRO",92,0)
|
|
I $L(SUB) S:'$D(INARAY(+TST)) INARAY(+TST)="" Q
|
|
"RTN","NHINVLRO",93,0)
|
|
S J=0 F S J=$O(^LAB(60,+TST,2,J)) Q:J<1 S X=^(J,0) D EX(+X)
|
|
"RTN","NHINVLRO",94,0)
|
|
Q
|
|
"RTN","NHINVLRO",95,0)
|
|
;
|
|
"RTN","NHINVLRO",96,0)
|
|
ACC(NUM,ODT,SN) ; -- Return 1 or 0, if Specimen entry matches accession
|
|
"RTN","NHINVLRO",97,0)
|
|
N T,T0,Y S Y=0
|
|
"RTN","NHINVLRO",98,0)
|
|
S T=+$O(^LRO(69,ODT,1,SN,2,0)),T0=$G(^(T,0))
|
|
"RTN","NHINVLRO",99,0)
|
|
I $P(T0,U,5)=+$P(NUM," ",3),$$GET1^DIQ(68,$P(T0,U,4)_",",.09)=$P(NUM," ") S Y=1
|
|
"RTN","NHINVLRO",100,0)
|
|
Q Y
|
|
"RTN","NHINVLRO",101,0)
|
|
;
|
|
"RTN","NHINVLRO",102,0)
|
|
CH(X0) ; -- return a Chemistry result as:
|
|
"RTN","NHINVLRO",103,0)
|
|
; id^test^result^interpretation^units^low^high^loinc^vuid
|
|
"RTN","NHINVLRO",104,0)
|
|
; Expects X0=^TMP("LRRR",$J,DFN,"CH",NHIDT,NHI),LRDFN
|
|
"RTN","NHINVLRO",105,0)
|
|
N X,Y,NODE,LOINC
|
|
"RTN","NHINVLRO",106,0)
|
|
S NODE=$G(^LR(LRDFN,"CH",NHIDT,NHI))
|
|
"RTN","NHINVLRO",107,0)
|
|
S X=$P($G(^LAB(60,+X0,0)),U)
|
|
"RTN","NHINVLRO",108,0)
|
|
S Y="CH;"_NHIDT_";"_NHI_U_X_U_$P(X0,U,2,4)
|
|
"RTN","NHINVLRO",109,0)
|
|
S X=$P(X0,U,5) I $L(X),X["-" S X=$TR(X,"- ","^"),$P(Y,U,6,7)=X
|
|
"RTN","NHINVLRO",110,0)
|
|
S X=$P($P(NODE,U,3),"!",3) S:X LOINC=$$GET1^DIQ(95.3,X_",",.01)
|
|
"RTN","NHINVLRO",111,0)
|
|
I '$G(LOINC) S X=+$P(X0,U,19) S:X LOINC=$$LOINC(+X0,X)
|
|
"RTN","NHINVLRO",112,0)
|
|
S $P(Y,U,8,9)=$G(LOINC)_U_$$VUID^NHINV(+$G(LOINC),95.3)
|
|
"RTN","NHINVLRO",113,0)
|
|
Q Y
|
|
"RTN","NHINVLRO",114,0)
|
|
;
|
|
"RTN","NHINVLRO",115,0)
|
|
LOINC(TEST,SPEC) ; -- Look up LOINC code, if not mapped
|
|
"RTN","NHINVLRO",116,0)
|
|
N Y,LAM,NHIN,IENS S Y=""
|
|
"RTN","NHINVLRO",117,0)
|
|
S TEST=+$G(TEST),SPEC=+$G(SPEC)
|
|
"RTN","NHINVLRO",118,0)
|
|
S LAM=$G(^LAB(60,TEST,64)),LAM=$S($P(LAM,U,2):$P(LAM,U,2),1:+LAM)
|
|
"RTN","NHINVLRO",119,0)
|
|
D GETS^DIQ(64.01,SPEC_","_LAM_",","30*",,"NHIN")
|
|
"RTN","NHINVLRO",120,0)
|
|
S IENS=$O(NHIN(64.02,"")) S:IENS Y=$G(NHIN(64.02,IENS,4))
|
|
"RTN","NHINVLRO",121,0)
|
|
S:'Y Y=$$GET1^DIQ(60.01,SPEC_","_TEST_",",95.3)
|
|
"RTN","NHINVLRO",122,0)
|
|
Q Y
|
|
"RTN","NHINVLRO",123,0)
|
|
;
|
|
"RTN","NHINVLRO",124,0)
|
|
MI(X0) ; -- return a Microbiology result as:
|
|
"RTN","NHINVLRO",125,0)
|
|
; id^test^result^interpretation^units
|
|
"RTN","NHINVLRO",126,0)
|
|
; Expects X0=^TMP("LRRR",$J,DFN,"MI",NHIDT,NHI)
|
|
"RTN","NHINVLRO",127,0)
|
|
N Y S Y=""
|
|
"RTN","NHINVLRO",128,0)
|
|
S:$L($P(X0,U))>1 Y="MI;"_NHIDT_";"_NHI_U_$P(X0,U,1,4)
|
|
"RTN","NHINVLRO",129,0)
|
|
Q Y
|
|
"RTN","NHINVLRO",130,0)
|
|
;
|
|
"RTN","NHINVLRO",131,0)
|
|
; ------------ Return data to middle tier ------------
|
|
"RTN","NHINVLRO",132,0)
|
|
;
|
|
"RTN","NHINVLRO",133,0)
|
|
XML(LAB) ; -- Return result as XML in @NHIN@(#)
|
|
"RTN","NHINVLRO",134,0)
|
|
N ATT,X,Y,I,J,P,NAMES,TAG
|
|
"RTN","NHINVLRO",135,0)
|
|
D ADD("<panel>") S NHINTOTL=$G(NHINTOTL)+1
|
|
"RTN","NHINVLRO",136,0)
|
|
S ATT="" F S ATT=$O(LAB(ATT)) Q:ATT="" D D:$L(Y) ADD(Y)
|
|
"RTN","NHINVLRO",137,0)
|
|
. I $O(LAB(ATT,0)) D S Y="" Q
|
|
"RTN","NHINVLRO",138,0)
|
|
.. D ADD("<"_ATT_"s>")
|
|
"RTN","NHINVLRO",139,0)
|
|
.. I ATT="value" S NAMES="id^test^result^interpretation^units^low^high^loinc^vuid^Z"
|
|
"RTN","NHINVLRO",140,0)
|
|
.. E S NAMES="code^name^Z"
|
|
"RTN","NHINVLRO",141,0)
|
|
.. S I=0 F S I=$O(LAB(ATT,I)) Q:I<1 D
|
|
"RTN","NHINVLRO",142,0)
|
|
... S X=$G(LAB(ATT,I)),Y="<"_ATT_" "_$$LOOP_"/>" D ADD(Y)
|
|
"RTN","NHINVLRO",143,0)
|
|
.. D ADD("</"_ATT_"s>")
|
|
"RTN","NHINVLRO",144,0)
|
|
. S X=$G(LAB(ATT)),Y="" Q:'$L(X)
|
|
"RTN","NHINVLRO",145,0)
|
|
. I ATT="comment" S Y="<"_ATT_" xml:space='preserve'>"_$$ESC^NHINV(X)_"</"_ATT_">" Q
|
|
"RTN","NHINVLRO",146,0)
|
|
. I X'["^" S Y="<"_ATT_" value='"_$$ESC^NHINV(X)_"' />" Q
|
|
"RTN","NHINVLRO",147,0)
|
|
. I $L(X)>1 S NAMES="code^name^Z",Y="<"_ATT_" "_$$LOOP_"/>"
|
|
"RTN","NHINVLRO",148,0)
|
|
D ADD("</panel>")
|
|
"RTN","NHINVLRO",149,0)
|
|
Q
|
|
"RTN","NHINVLRO",150,0)
|
|
;
|
|
"RTN","NHINVLRO",151,0)
|
|
LOOP() ; -- build sub-items string from NAMES and X
|
|
"RTN","NHINVLRO",152,0)
|
|
N STR,P,TAG S STR=""
|
|
"RTN","NHINVLRO",153,0)
|
|
F P=1:1 S TAG=$P(NAMES,U,P) Q:TAG="Z" I $L($P(X,U,P)) S STR=STR_TAG_"='"_$$ESC^NHINV($P(X,U,P))_"' "
|
|
"RTN","NHINVLRO",154,0)
|
|
Q STR
|
|
"RTN","NHINVLRO",155,0)
|
|
;
|
|
"RTN","NHINVLRO",156,0)
|
|
ADD(X) ; -- Add a line @NHIN@(n)=X
|
|
"RTN","NHINVLRO",157,0)
|
|
S NHINI=$G(NHINI)+1
|
|
"RTN","NHINVLRO",158,0)
|
|
S @NHIN@(NHINI)=X
|
|
"RTN","NHINVLRO",159,0)
|
|
Q
|
|
"RTN","NHINVPL")
|
|
0^26^B19846807^n/a
|
|
"RTN","NHINVPL",1,0)
|
|
NHINVPL ;SLC/MKB -- Problem extract
|
|
"RTN","NHINVPL",2,0)
|
|
;;1.0;NHIN;**1**;Dec 01, 2009;Build 11
|
|
"RTN","NHINVPL",3,0)
|
|
;
|
|
"RTN","NHINVPL",4,0)
|
|
; External References DBIA#
|
|
"RTN","NHINVPL",5,0)
|
|
; ------------------- -----
|
|
"RTN","NHINVPL",6,0)
|
|
; ^VA(200 10060
|
|
"RTN","NHINVPL",7,0)
|
|
; %DT 10003
|
|
"RTN","NHINVPL",8,0)
|
|
; DIQ 2056
|
|
"RTN","NHINVPL",9,0)
|
|
; GMPLUTL2 2741
|
|
"RTN","NHINVPL",10,0)
|
|
; XUAF4 2171
|
|
"RTN","NHINVPL",11,0)
|
|
;
|
|
"RTN","NHINVPL",12,0)
|
|
; ------------ Get problems from VistA ------------
|
|
"RTN","NHINVPL",13,0)
|
|
;
|
|
"RTN","NHINVPL",14,0)
|
|
EN(DFN,BEG,END,MAX,IFN) ; -- find patient's problems
|
|
"RTN","NHINVPL",15,0)
|
|
N NHIPROB,NHI,NHITM,NHICNT,X
|
|
"RTN","NHINVPL",16,0)
|
|
;
|
|
"RTN","NHINVPL",17,0)
|
|
; get one problem
|
|
"RTN","NHINVPL",18,0)
|
|
I $G(IFN) D EN1(IFN,.NHITM),XML(.NHITM) Q
|
|
"RTN","NHINVPL",19,0)
|
|
;
|
|
"RTN","NHINVPL",20,0)
|
|
; get all patient problems
|
|
"RTN","NHINVPL",21,0)
|
|
S DFN=+$G(DFN) Q:DFN<1
|
|
"RTN","NHINVPL",22,0)
|
|
S BEG=$G(BEG,1410101),END=$G(END,9999998),MAX=$G(MAX,999999),NHICNT=0
|
|
"RTN","NHINVPL",23,0)
|
|
D LIST^GMPLUTL2(.NHIPROB,DFN,"") ;all problems
|
|
"RTN","NHINVPL",24,0)
|
|
S NHI=0 F S NHI=$O(NHIPROB(NHI)) Q:(NHI<1)!(NHICNT'<MAX) D
|
|
"RTN","NHINVPL",25,0)
|
|
. S X=$P(NHIPROB(NHI),U,5) I X,(X<BEG)!(X>END) Q ;onset
|
|
"RTN","NHINVPL",26,0)
|
|
. S X=+NHIPROB(NHI) K NHITM ;ien
|
|
"RTN","NHINVPL",27,0)
|
|
. D EN1(X,.NHITM),XML(.NHITM)
|
|
"RTN","NHINVPL",28,0)
|
|
. S NHICNT=NHICNT+1
|
|
"RTN","NHINVPL",29,0)
|
|
Q
|
|
"RTN","NHINVPL",30,0)
|
|
;
|
|
"RTN","NHINVPL",31,0)
|
|
EN1(ID,PROB) ; -- return a problem in PROB("attribute")=value
|
|
"RTN","NHINVPL",32,0)
|
|
N NHPL,X,I,J K PROB
|
|
"RTN","NHINVPL",33,0)
|
|
S ID=+$G(ID) Q:ID<1 ;invalid ien
|
|
"RTN","NHINVPL",34,0)
|
|
D DETAIL^GMPLUTL2(ID,.NHPL) Q:'$D(NHPL) ;doesn't exist
|
|
"RTN","NHINVPL",35,0)
|
|
S PROB("id")=ID ;,PROB("lexiconID")=+X1 ;SNOMED?
|
|
"RTN","NHINVPL",36,0)
|
|
S PROB("name")=$G(NHPL("NARRATIVE"))
|
|
"RTN","NHINVPL",37,0)
|
|
S X=$G(NHPL("MODIFIED")) S:$L(X) PROB("updated")=$$DATE(X)
|
|
"RTN","NHINVPL",38,0)
|
|
S PROB("icd")=$G(NHPL("DIAGNOSIS"))
|
|
"RTN","NHINVPL",39,0)
|
|
S X=$G(NHPL("STATUS")) S:$L(X) PROB("status")=$E(X)
|
|
"RTN","NHINVPL",40,0)
|
|
S X=$G(NHPL("HISTORY")) S:$L(X) PROB("history")=$E(X)
|
|
"RTN","NHINVPL",41,0)
|
|
S X=$G(NHPL("PRIORITY")) S:$L(X) PROB("acuity")=$E(X)
|
|
"RTN","NHINVPL",42,0)
|
|
S X=$G(NHPL("ONSET")) S:$L(X) PROB("onset")=$$DATE(X)
|
|
"RTN","NHINVPL",43,0)
|
|
S X=$$GET1^DIQ(9000011,ID_",",1.07,"I") S:X PROB("resolved")=X
|
|
"RTN","NHINVPL",44,0)
|
|
S X=$P($G(NHPL("ENTERED")),U) S:$L(X) PROB("entered")=$$DATE(X)
|
|
"RTN","NHINVPL",45,0)
|
|
S X=$$GET1^DIQ(9000011,ID_",",1.02,"I")
|
|
"RTN","NHINVPL",46,0)
|
|
S:X="P" PROB("unverified")=0,PROB("removed")=0
|
|
"RTN","NHINVPL",47,0)
|
|
S:X="T" PROB("unverified")=1,PROB("removed")=0
|
|
"RTN","NHINVPL",48,0)
|
|
S:X="H" PROB("unverified")=0,PROB("removed")=1
|
|
"RTN","NHINVPL",49,0)
|
|
S X=$G(NHPL("SC")),X=$S(X="YES":1,X="NO":0,1:"")
|
|
"RTN","NHINVPL",50,0)
|
|
S:$L(X) PROB("sc")=X I $G(NHPL("EXPOSURE")) D ;ao^rad^pgulf^hnc^mst^cv
|
|
"RTN","NHINVPL",51,0)
|
|
. S I=0 F S I=$O(NHPL("EXPOSURE",I)) Q:I<1 D
|
|
"RTN","NHINVPL",52,0)
|
|
.. S X=$G(NHPL("EXPOSURE",I))
|
|
"RTN","NHINVPL",53,0)
|
|
.. S PROB("exposure",I)=$$EXP(X)
|
|
"RTN","NHINVPL",54,0)
|
|
S X=$G(NHPL("PROVIDER")) S:$L(X) PROB("provider")=$$VA200(X)_U_X
|
|
"RTN","NHINVPL",55,0)
|
|
S X=$$GET1^DIQ(9000011,ID_",",1.06) S:$L(X) PROB("service")=X
|
|
"RTN","NHINVPL",56,0)
|
|
S X=$G(NHPL("CLINIC")) S:$L(X) PROB("location")=X
|
|
"RTN","NHINVPL",57,0)
|
|
S X=+$$GET1^DIQ(9000011,ID_",",.06,"I")
|
|
"RTN","NHINVPL",58,0)
|
|
S:X PROB("facility")=$$STA^XUAF4(X)_U_$P($$NS^XUAF4(X),U)
|
|
"RTN","NHINVPL",59,0)
|
|
I 'X S PROB("facility")=$$FAC^NHINV ;local stn#^name
|
|
"RTN","NHINVPL",60,0)
|
|
CMT ; comments
|
|
"RTN","NHINVPL",61,0)
|
|
Q:'$G(NHPL("COMMENT"))
|
|
"RTN","NHINVPL",62,0)
|
|
S I=0 F S I=$O(NHPL("COMMENT",I)) Q:I<1 D
|
|
"RTN","NHINVPL",63,0)
|
|
. S X=$G(NHPL("COMMENT",I))
|
|
"RTN","NHINVPL",64,0)
|
|
. S PROB("comment",I)=$$DATE($P(X,U))_U_$P(X,U,2,3)
|
|
"RTN","NHINVPL",65,0)
|
|
. ; = date ^ name of author ^ text
|
|
"RTN","NHINVPL",66,0)
|
|
Q
|
|
"RTN","NHINVPL",67,0)
|
|
;
|
|
"RTN","NHINVPL",68,0)
|
|
DATE(X) ; -- Return internal form of date X
|
|
"RTN","NHINVPL",69,0)
|
|
N %DT,Y
|
|
"RTN","NHINVPL",70,0)
|
|
S %DT="" D ^%DT S:Y<1 Y=X
|
|
"RTN","NHINVPL",71,0)
|
|
Q Y
|
|
"RTN","NHINVPL",72,0)
|
|
;
|
|
"RTN","NHINVPL",73,0)
|
|
VA200(X) ; -- Return ien of New Person X
|
|
"RTN","NHINVPL",74,0)
|
|
N Y S Y=$S($L($G(X)):+$O(^VA(200,"B",X,0)),1:"")
|
|
"RTN","NHINVPL",75,0)
|
|
Q Y
|
|
"RTN","NHINVPL",76,0)
|
|
;
|
|
"RTN","NHINVPL",77,0)
|
|
EXP(X) ; -- Return code for exposure name X
|
|
"RTN","NHINVPL",78,0)
|
|
N Y S Y="",X=$E($G(X))
|
|
"RTN","NHINVPL",79,0)
|
|
I X="A" S Y="AO" ;agent orange
|
|
"RTN","NHINVPL",80,0)
|
|
I X="R" S Y="IR" ;ionizing radiation
|
|
"RTN","NHINVPL",81,0)
|
|
I X="E" S Y="PG" ;persian gulf
|
|
"RTN","NHINVPL",82,0)
|
|
I X="H" S Y="HNC" ;head/neck cancer
|
|
"RTN","NHINVPL",83,0)
|
|
I X="M" S Y="MST" ;military sexual trauma
|
|
"RTN","NHINVPL",84,0)
|
|
I X="C" S Y="CV" ;combat vet
|
|
"RTN","NHINVPL",85,0)
|
|
I X="S" S Y="SHAD"
|
|
"RTN","NHINVPL",86,0)
|
|
Q Y
|
|
"RTN","NHINVPL",87,0)
|
|
;
|
|
"RTN","NHINVPL",88,0)
|
|
; ------------ Return data to middle tier ------------
|
|
"RTN","NHINVPL",89,0)
|
|
;
|
|
"RTN","NHINVPL",90,0)
|
|
XML(PROB) ; -- Return patient problem as XML in @NHIN@(I)
|
|
"RTN","NHINVPL",91,0)
|
|
N ATT,I,X,Y,P,TAG
|
|
"RTN","NHINVPL",92,0)
|
|
D ADD("<problem>") S NHINTOTL=$G(NHINTOTL)+1
|
|
"RTN","NHINVPL",93,0)
|
|
S ATT="" F S ATT=$O(PROB(ATT)) Q:ATT="" D D:$L(Y) ADD(Y)
|
|
"RTN","NHINVPL",94,0)
|
|
. I ATT="exposure" D S Y="" Q
|
|
"RTN","NHINVPL",95,0)
|
|
.. S Y="<exposures>" D ADD(Y)
|
|
"RTN","NHINVPL",96,0)
|
|
.. S I=0 F S I=$O(PROB(ATT,I)) Q:I<1 S X=$G(PROB(ATT,I)) S:$L(X) Y="<exposure value='"_X_"' />" D ADD(Y)
|
|
"RTN","NHINVPL",97,0)
|
|
.. D ADD("</exposures>")
|
|
"RTN","NHINVPL",98,0)
|
|
. I ATT="comment" D S Y="" Q
|
|
"RTN","NHINVPL",99,0)
|
|
.. D ADD("<comments>")
|
|
"RTN","NHINVPL",100,0)
|
|
.. S I=0 F S I=$O(PROB(ATT,I)) Q:I<1 S X=$G(PROB(ATT,I)) D
|
|
"RTN","NHINVPL",101,0)
|
|
... S Y="<comment id='"_I
|
|
"RTN","NHINVPL",102,0)
|
|
... S:$L($P(X,U,1)) Y=Y_"' entered='"_$P(X,U)
|
|
"RTN","NHINVPL",103,0)
|
|
... S:$L($P(X,U,2)) Y=Y_"' enteredBy='"_$$ESC^NHINV($P(X,U,2))
|
|
"RTN","NHINVPL",104,0)
|
|
... S:$L($P(X,U,3)) Y=Y_"' commentText='"_$$ESC^NHINV($P(X,U,3))
|
|
"RTN","NHINVPL",105,0)
|
|
... S Y=Y_"' />" D ADD(Y)
|
|
"RTN","NHINVPL",106,0)
|
|
.. D ADD("</comments>")
|
|
"RTN","NHINVPL",107,0)
|
|
. S X=$G(PROB(ATT)),Y="" Q:'$L(X)
|
|
"RTN","NHINVPL",108,0)
|
|
. I X'["^" S Y="<"_ATT_" value='"_$$ESC^NHINV(X)_"' />" Q
|
|
"RTN","NHINVPL",109,0)
|
|
. I $L(X)>1 D S Y=""
|
|
"RTN","NHINVPL",110,0)
|
|
.. S Y="<"_ATT_" "
|
|
"RTN","NHINVPL",111,0)
|
|
.. F P=1:1 S TAG=$P("code^name^Z",U,P) Q:TAG="Z" I $L($P(X,U,P)) S Y=Y_TAG_"='"_$$ESC^NHINV($P(X,U,P))_"' "
|
|
"RTN","NHINVPL",112,0)
|
|
.. S Y=Y_"/>" D ADD(Y)
|
|
"RTN","NHINVPL",113,0)
|
|
D ADD("</problem>")
|
|
"RTN","NHINVPL",114,0)
|
|
Q
|
|
"RTN","NHINVPL",115,0)
|
|
;
|
|
"RTN","NHINVPL",116,0)
|
|
ADD(X) ; Add a line @NHIN@(n)=X
|
|
"RTN","NHINVPL",117,0)
|
|
S NHINI=$G(NHINI)+1
|
|
"RTN","NHINVPL",118,0)
|
|
S @NHIN@(NHINI)=X
|
|
"RTN","NHINVPL",119,0)
|
|
Q
|
|
"RTN","NHINVPRC")
|
|
0^16^B6896734^n/a
|
|
"RTN","NHINVPRC",1,0)
|
|
NHINVPRC ;SLC/MKB -- Procedure extract
|
|
"RTN","NHINVPRC",2,0)
|
|
;;1.0;NHIN;**1**;Oct 25, 2010;Build 11
|
|
"RTN","NHINVPRC",3,0)
|
|
;
|
|
"RTN","NHINVPRC",4,0)
|
|
; External References DBIA#
|
|
"RTN","NHINVPRC",5,0)
|
|
; ------------------- -----
|
|
"RTN","NHINVPRC",6,0)
|
|
; RAO7PC1 2043
|
|
"RTN","NHINVPRC",7,0)
|
|
; SROESTV 3533
|
|
"RTN","NHINVPRC",8,0)
|
|
;
|
|
"RTN","NHINVPRC",9,0)
|
|
; ------------ Get procedure(s) from VistA ------------
|
|
"RTN","NHINVPRC",10,0)
|
|
;
|
|
"RTN","NHINVPRC",11,0)
|
|
EN(DFN,BEG,END,MAX,ID) ; -- find patient's procedures
|
|
"RTN","NHINVPRC",12,0)
|
|
S DFN=+$G(DFN) Q:DFN<1
|
|
"RTN","NHINVPRC",13,0)
|
|
S BEG=$G(BEG,1410101),END=$G(END,9999998),MAX=$G(MAX,999999)
|
|
"RTN","NHINVPRC",14,0)
|
|
;
|
|
"RTN","NHINVPRC",15,0)
|
|
N NHI,NHICNT,NHITM,NHY
|
|
"RTN","NHINVPRC",16,0)
|
|
;
|
|
"RTN","NHINVPRC",17,0)
|
|
; get one procedure
|
|
"RTN","NHINVPRC",18,0)
|
|
I $G(ID) D D:$D(NHITM) XML(.NHITM) Q
|
|
"RTN","NHINVPRC",19,0)
|
|
. I ID'["-" D EN1^NHINVSR(ID,.NHITM) Q
|
|
"RTN","NHINVPRC",20,0)
|
|
. S (BEG,END)=9999999.9999=+ID
|
|
"RTN","NHINVPRC",21,0)
|
|
. D EN1^RAO7PC1(DFN,BEG,END),EN1^NHINVRA(ID,.NHITM)
|
|
"RTN","NHINVPRC",22,0)
|
|
;
|
|
"RTN","NHINVPRC",23,0)
|
|
; get all surgeries
|
|
"RTN","NHINVPRC",24,0)
|
|
N SHOWADD S SHOWADD=1 ;to omit leading '+' with note titles
|
|
"RTN","NHINVPRC",25,0)
|
|
D LIST^SROESTV(.NHY,DFN,BEG,END,MAX,1)
|
|
"RTN","NHINVPRC",26,0)
|
|
S NHI=0 F S NHI=$O(@NHY@(NHI)) Q:NHI<1 D
|
|
"RTN","NHINVPRC",27,0)
|
|
. K NHITM D ONE^NHINVSR(NHI,.NHITM) Q:'$D(NHITM)
|
|
"RTN","NHINVPRC",28,0)
|
|
. ;Q:$G(NHITM("status"))'?1"COMP".E
|
|
"RTN","NHINVPRC",29,0)
|
|
. D XML(.NHITM)
|
|
"RTN","NHINVPRC",30,0)
|
|
K @NHY
|
|
"RTN","NHINVPRC",31,0)
|
|
;
|
|
"RTN","NHINVPRC",32,0)
|
|
; get all radiology exams
|
|
"RTN","NHINVPRC",33,0)
|
|
K ^TMP($J,"RAE1") D EN1^RAO7PC1(DFN,BEG,END,MAX)
|
|
"RTN","NHINVPRC",34,0)
|
|
S NHICNT=0,NHI=""
|
|
"RTN","NHINVPRC",35,0)
|
|
F S NHI=$O(^TMP($J,"RAE1",DFN,NHI)) Q:NHI="" D Q:NHICNT'<MAX ;I $P($P($G(^(NHI)),U,6),"~",2)?1"COMP".E
|
|
"RTN","NHINVPRC",36,0)
|
|
. K NHITM D EN1^NHINVRA(NHI,.NHITM) Q:'$D(NHITM)
|
|
"RTN","NHINVPRC",37,0)
|
|
. D XML(.NHITM) S NHICNT=NHICNT+1
|
|
"RTN","NHINVPRC",38,0)
|
|
K ^TMP($J,"RAE1")
|
|
"RTN","NHINVPRC",39,0)
|
|
;
|
|
"RTN","NHINVPRC",40,0)
|
|
; Consults/ClinProc
|
|
"RTN","NHINVPRC",41,0)
|
|
; V-files [CPT, Exam, Treatment, Patient ED]
|
|
"RTN","NHINVPRC",42,0)
|
|
;
|
|
"RTN","NHINVPRC",43,0)
|
|
Q
|
|
"RTN","NHINVPRC",44,0)
|
|
;
|
|
"RTN","NHINVPRC",45,0)
|
|
; ------------ Return data to middle tier ------------
|
|
"RTN","NHINVPRC",46,0)
|
|
;
|
|
"RTN","NHINVPRC",47,0)
|
|
XML(PRC) ; -- Return procedures as XML
|
|
"RTN","NHINVPRC",48,0)
|
|
N ATT,X,Y,I,NAMES
|
|
"RTN","NHINVPRC",49,0)
|
|
D ADD("<procedure>") S NHINTOTL=$G(NHINTOTL)+1
|
|
"RTN","NHINVPRC",50,0)
|
|
S ATT="" F S ATT=$O(PRC(ATT)) Q:ATT="" D D:$L(Y) ADD(Y)
|
|
"RTN","NHINVPRC",51,0)
|
|
. S NAMES=$S(ATT="document"!(ATT="opReport"):"id^localTitle^nationalTitle^status^Z",1:"code^name^Z")
|
|
"RTN","NHINVPRC",52,0)
|
|
. I $O(PRC(ATT,0)) D S Y="" Q ;multiples
|
|
"RTN","NHINVPRC",53,0)
|
|
.. D ADD("<"_ATT_"s>")
|
|
"RTN","NHINVPRC",54,0)
|
|
.. S I=0 F S I=$O(PRC(ATT,I)) Q:I<1 D
|
|
"RTN","NHINVPRC",55,0)
|
|
... S X=$G(PRC(ATT,I))
|
|
"RTN","NHINVPRC",56,0)
|
|
... S Y="<"_ATT_" "_$$LOOP_"/>" D ADD(Y)
|
|
"RTN","NHINVPRC",57,0)
|
|
.. D ADD("</"_ATT_"s>")
|
|
"RTN","NHINVPRC",58,0)
|
|
. S X=$G(PRC(ATT)),Y="" Q:'$L(X)
|
|
"RTN","NHINVPRC",59,0)
|
|
. I X'["^" S Y="<"_ATT_" value='"_$$ESC^NHINV(X)_"' />" Q
|
|
"RTN","NHINVPRC",60,0)
|
|
. I $L(X)>1 S Y="<"_ATT_" "_$$LOOP_"/>"
|
|
"RTN","NHINVPRC",61,0)
|
|
D ADD("</procedure>")
|
|
"RTN","NHINVPRC",62,0)
|
|
Q
|
|
"RTN","NHINVPRC",63,0)
|
|
;
|
|
"RTN","NHINVPRC",64,0)
|
|
LOOP() ; -- build sub-items string from NAMES and X
|
|
"RTN","NHINVPRC",65,0)
|
|
N STR,P,TAG S STR=""
|
|
"RTN","NHINVPRC",66,0)
|
|
F P=1:1 S TAG=$P(NAMES,U,P) Q:TAG="Z" I $L($P(X,U,P)) S STR=STR_TAG_"='"_$$ESC^NHINV($P(X,U,P))_"' "
|
|
"RTN","NHINVPRC",67,0)
|
|
Q STR
|
|
"RTN","NHINVPRC",68,0)
|
|
;
|
|
"RTN","NHINVPRC",69,0)
|
|
ADD(X) ; -- Add a line @NHIN@(n)=X
|
|
"RTN","NHINVPRC",70,0)
|
|
S NHINI=$G(NHINI)+1
|
|
"RTN","NHINVPRC",71,0)
|
|
S @NHIN@(NHINI)=X
|
|
"RTN","NHINVPRC",72,0)
|
|
Q
|
|
"RTN","NHINVPS")
|
|
0^27^B14129801^n/a
|
|
"RTN","NHINVPS",1,0)
|
|
NHINVPS ;SLC/MKB -- Pharmacy extract
|
|
"RTN","NHINVPS",2,0)
|
|
;;1.0;NHIN;**1**;Dec 01, 2009;Build 11
|
|
"RTN","NHINVPS",3,0)
|
|
;
|
|
"RTN","NHINVPS",4,0)
|
|
; External References DBIA#
|
|
"RTN","NHINVPS",5,0)
|
|
; ------------------- -----
|
|
"RTN","NHINVPS",6,0)
|
|
; DIQ 2056
|
|
"RTN","NHINVPS",7,0)
|
|
; PSOORRL,^TMP("PS",$J) 2400
|
|
"RTN","NHINVPS",8,0)
|
|
; PSS50,^TMP($J 4483
|
|
"RTN","NHINVPS",9,0)
|
|
;
|
|
"RTN","NHINVPS",10,0)
|
|
; ------------ Get medications from VistA ------------
|
|
"RTN","NHINVPS",11,0)
|
|
;
|
|
"RTN","NHINVPS",12,0)
|
|
EN(DFN,BEG,END,MAX,ID) ; -- find patient's meds
|
|
"RTN","NHINVPS",13,0)
|
|
N PS0,NHI,NHITM,IV K ^TMP("PS",$J)
|
|
"RTN","NHINVPS",14,0)
|
|
S DFN=+$G(DFN) Q:DFN<1
|
|
"RTN","NHINVPS",15,0)
|
|
S BEG=$G(BEG,1410101),END=$G(END,9999998),MAX=$G(MAX,999999)
|
|
"RTN","NHINVPS",16,0)
|
|
;
|
|
"RTN","NHINVPS",17,0)
|
|
; get one med
|
|
"RTN","NHINVPS",18,0)
|
|
I $G(ID) D D:$D(NHITM)>9 XML(.NHITM) K ^TMP("PS",$J) Q
|
|
"RTN","NHINVPS",19,0)
|
|
. I ID["N" D NVA^NHINVPSO(ID,.NHITM) Q
|
|
"RTN","NHINVPS",20,0)
|
|
. I ID["O",(ID'["P")&(ID'["S") D RX^NHINVPSO(ID,.NHITM) Q
|
|
"RTN","NHINVPS",21,0)
|
|
. D OEL^PSOORRL(DFN,ID)
|
|
"RTN","NHINVPS",22,0)
|
|
. I ID["O",(ID["P")!(ID["S") D PEN1^NHINVPSO(ID,.NHITM) Q
|
|
"RTN","NHINVPS",23,0)
|
|
. S IV=$S(ID["V":1,$G(^TMP("PS",$J,"B",0)):1,1:0)
|
|
"RTN","NHINVPS",24,0)
|
|
. D @($S(IV:"IV1",1:"IN1")_"^NHINVPSI(ID,.NHITM)")
|
|
"RTN","NHINVPS",25,0)
|
|
;
|
|
"RTN","NHINVPS",26,0)
|
|
; get all meds
|
|
"RTN","NHINVPS",27,0)
|
|
D OCL^PSOORRL(DFN,BEG,END)
|
|
"RTN","NHINVPS",28,0)
|
|
S NHI=0 F S NHI=$O(^TMP("PS",$J,NHI)) Q:NHI<1!(NHI>MAX) S PS0=$G(^(NHI,0)) D I $D(NHITM)>9 D XML(.NHITM)
|
|
"RTN","NHINVPS",29,0)
|
|
. S ID=$P(PS0,U) K NHITM
|
|
"RTN","NHINVPS",30,0)
|
|
. I ID["N" D NVA^NHINVPSO(ID,.NHITM) Q
|
|
"RTN","NHINVPS",31,0)
|
|
. I ID["O" D RX^NHINVPSO(ID,.NHITM) Q
|
|
"RTN","NHINVPS",32,0)
|
|
. S IV=$S(ID["V":1,$G(^TMP("PS",$J,NHI,"B",0)):1,1:0)
|
|
"RTN","NHINVPS",33,0)
|
|
. D @($S(IV:"IV",1:"IN")_"^NHINVPSI(ID,.NHITM)")
|
|
"RTN","NHINVPS",34,0)
|
|
K ^TMP("PS",$J)
|
|
"RTN","NHINVPS",35,0)
|
|
Q
|
|
"RTN","NHINVPS",36,0)
|
|
;
|
|
"RTN","NHINVPS",37,0)
|
|
NDF(DRUG,I) ; -- Set NDF data for dispense DRUG ien
|
|
"RTN","NHINVPS",38,0)
|
|
N VUID,X
|
|
"RTN","NHINVPS",39,0)
|
|
S DRUG=+$G(DRUG) Q:'DRUG
|
|
"RTN","NHINVPS",40,0)
|
|
D NDF^PSS50(DRUG,,,,,"NDF") S I=+$G(I)+1
|
|
"RTN","NHINVPS",41,0)
|
|
S MED("product",I)=DRUG_U_$G(^TMP($J,"NDF",DRUG,.01))_"^^D" ;Drug
|
|
"RTN","NHINVPS",42,0)
|
|
S X=$G(^TMP($J,"NDF",DRUG,20)),VUID=$$GET1^DIQ(50.6,+X_",",99.99)
|
|
"RTN","NHINVPS",43,0)
|
|
S MED("product",I,"G")=X_U_VUID ;VA Generic
|
|
"RTN","NHINVPS",44,0)
|
|
S X=$G(^TMP($J,"NDF",DRUG,22)),VUID=$$GET1^DIQ(50.68,+X_",",99.99)
|
|
"RTN","NHINVPS",45,0)
|
|
S MED("product",I,"P")=X_U_VUID ;VA Product
|
|
"RTN","NHINVPS",46,0)
|
|
S MED("product",I,"C")=$P($G(^TMP($J,"NDF",+DRUG,25)),U,3) ;display name
|
|
"RTN","NHINVPS",47,0)
|
|
K ^TMP($J,"NDF",DRUG)
|
|
"RTN","NHINVPS",48,0)
|
|
Q
|
|
"RTN","NHINVPS",49,0)
|
|
;
|
|
"RTN","NHINVPS",50,0)
|
|
; ------------ Return data to middle tier ------------
|
|
"RTN","NHINVPS",51,0)
|
|
;
|
|
"RTN","NHINVPS",52,0)
|
|
XML(MED) ; -- Return patient meds as XML
|
|
"RTN","NHINVPS",53,0)
|
|
N ATT,X,Y,I,NAMES
|
|
"RTN","NHINVPS",54,0)
|
|
D ADD("<med>") S NHINTOTL=$G(NHINTOTL)+1
|
|
"RTN","NHINVPS",55,0)
|
|
S ATT="" F S ATT=$O(MED(ATT)) Q:ATT="" D I $L(Y) D ADD(Y)
|
|
"RTN","NHINVPS",56,0)
|
|
. I $O(MED(ATT,0)) D S Y="" Q ;multiples
|
|
"RTN","NHINVPS",57,0)
|
|
.. D ADD("<"_ATT_"s>")
|
|
"RTN","NHINVPS",58,0)
|
|
.. S I=0 F S I=$O(MED(ATT,I)) Q:I<1 D
|
|
"RTN","NHINVPS",59,0)
|
|
... S X=$G(MED(ATT,I)),NAMES=""
|
|
"RTN","NHINVPS",60,0)
|
|
... I ATT="dose" S NAMES="dose^units^unitsPerDose^noun^route^schedule^duration^conjunction^doseStart^doseStop^Z"
|
|
"RTN","NHINVPS",61,0)
|
|
... I ATT="fill" S NAMES="fillDate^fillRouting^releaseDate^fillQuantity^fillDaysSupply^partial^Z"
|
|
"RTN","NHINVPS",62,0)
|
|
... I ATT="product" S NAMES="code^name^vuid^role^concentration^Z"
|
|
"RTN","NHINVPS",63,0)
|
|
... S Y="<"_ATT_" "_$$LOOP_$S(ATT'="product":"/>",1:">") D ADD(Y)
|
|
"RTN","NHINVPS",64,0)
|
|
... Q:ATT'="product"
|
|
"RTN","NHINVPS",65,0)
|
|
... S X=$G(MED(ATT,I,"C")) I $L(X) S Y="<class "_$$LOOP_"/>" D ADD(Y)
|
|
"RTN","NHINVPS",66,0)
|
|
... S X=$G(MED(ATT,I,"G")) I $L(X) S Y="<vaGeneric "_$$LOOP_"/>" D ADD(Y)
|
|
"RTN","NHINVPS",67,0)
|
|
... S X=$G(MED(ATT,I,"P")) I $L(X) S Y="<vaProduct "_$$LOOP_"/>" D ADD(Y)
|
|
"RTN","NHINVPS",68,0)
|
|
... D ADD("</product>")
|
|
"RTN","NHINVPS",69,0)
|
|
.. D ADD("</"_ATT_"s>")
|
|
"RTN","NHINVPS",70,0)
|
|
. S X=$G(MED(ATT)),Y="" Q:'$L(X)
|
|
"RTN","NHINVPS",71,0)
|
|
. I ATT="sig"!(ATT?1"ptIn"1.A) S Y="<"_ATT_" xml:space='preserve'>"_$$ESC^NHINV(X)_"</"_ATT_">" Q
|
|
"RTN","NHINVPS",72,0)
|
|
. I X'["^" S Y="<"_ATT_" value='"_$$ESC^NHINV(X)_"' />" Q
|
|
"RTN","NHINVPS",73,0)
|
|
. I $L(X)>1 S NAMES="code^name^Z",Y="<"_ATT_" "_$$LOOP_"/>"
|
|
"RTN","NHINVPS",74,0)
|
|
D ADD("</med>")
|
|
"RTN","NHINVPS",75,0)
|
|
Q
|
|
"RTN","NHINVPS",76,0)
|
|
;
|
|
"RTN","NHINVPS",77,0)
|
|
LOOP() ; -- build sub-items string from NAMES and X
|
|
"RTN","NHINVPS",78,0)
|
|
N STR,P,TAG S STR=""
|
|
"RTN","NHINVPS",79,0)
|
|
F P=1:1 S TAG=$P(NAMES,U,P) Q:TAG="Z" I $L($P(X,U,P)) S STR=STR_TAG_"='"_$$ESC^NHINV($P(X,U,P))_"' "
|
|
"RTN","NHINVPS",80,0)
|
|
Q STR
|
|
"RTN","NHINVPS",81,0)
|
|
;
|
|
"RTN","NHINVPS",82,0)
|
|
ADD(X) ; Add a line @NHIN@(n)=X
|
|
"RTN","NHINVPS",83,0)
|
|
S NHINI=$G(NHINI)+1
|
|
"RTN","NHINVPS",84,0)
|
|
S @NHIN@(NHINI)=X
|
|
"RTN","NHINVPS",85,0)
|
|
Q
|
|
"RTN","NHINVPSI")
|
|
0^24^B41411886^n/a
|
|
"RTN","NHINVPSI",1,0)
|
|
NHINVPSI ;SLC/MKB -- Inpatient Pharmacy extract
|
|
"RTN","NHINVPSI",2,0)
|
|
;;1.0;NHIN;**1**;Oct 25, 2010;Build 11
|
|
"RTN","NHINVPSI",3,0)
|
|
;
|
|
"RTN","NHINVPSI",4,0)
|
|
; External References DBIA#
|
|
"RTN","NHINVPSI",5,0)
|
|
; ------------------- -----
|
|
"RTN","NHINVPSI",6,0)
|
|
; ^SC 10040
|
|
"RTN","NHINVPSI",7,0)
|
|
; DIQ 2056
|
|
"RTN","NHINVPSI",8,0)
|
|
; ORX8 2467
|
|
"RTN","NHINVPSI",9,0)
|
|
; PSOORRL,^TMP("PS",$J) 2400
|
|
"RTN","NHINVPSI",10,0)
|
|
; PSS50P7 4662
|
|
"RTN","NHINVPSI",11,0)
|
|
; XLFSTR 10104
|
|
"RTN","NHINVPSI",12,0)
|
|
;
|
|
"RTN","NHINVPSI",13,0)
|
|
; ------------ Get medications from VistA ------------
|
|
"RTN","NHINVPSI",14,0)
|
|
;
|
|
"RTN","NHINVPSI",15,0)
|
|
EN(DFN,BEG,END,MAX,ID) ; -- find patient's UD/IV meds
|
|
"RTN","NHINVPSI",16,0)
|
|
N PS0,NHI,NHITM,IV K ^TMP("PS",$J)
|
|
"RTN","NHINVPSI",17,0)
|
|
S DFN=+$G(DFN) Q:DFN<1
|
|
"RTN","NHINVPSI",18,0)
|
|
S BEG=$G(BEG,1410101),END=$G(END,9999998),MAX=$G(MAX,999999)
|
|
"RTN","NHINVPSI",19,0)
|
|
;
|
|
"RTN","NHINVPSI",20,0)
|
|
; get one med
|
|
"RTN","NHINVPSI",21,0)
|
|
I $G(ID) D Q
|
|
"RTN","NHINVPSI",22,0)
|
|
. Q:ID["N" Q:ID["O" ;inpatient only
|
|
"RTN","NHINVPSI",23,0)
|
|
. D OEL^PSOORRL(DFN,ID)
|
|
"RTN","NHINVPSI",24,0)
|
|
. S IV=$S(ID["V":1,$G(^TMP("PS",$J,"B",0)):1,1:0)
|
|
"RTN","NHINVPSI",25,0)
|
|
. D @($S(IV:"IV1",1:"IN1")_"(ID,.NHITM)")
|
|
"RTN","NHINVPSI",26,0)
|
|
. I $D(NHITM)>9 D XML^NHINVPS(.NHITM)
|
|
"RTN","NHINVPSI",27,0)
|
|
. K ^TMP("PS",$J)
|
|
"RTN","NHINVPSI",28,0)
|
|
;
|
|
"RTN","NHINVPSI",29,0)
|
|
; get all meds
|
|
"RTN","NHINVPSI",30,0)
|
|
D OCL^PSOORRL(DFN,BEG,END)
|
|
"RTN","NHINVPSI",31,0)
|
|
S NHI=0 F S NHI=$O(^TMP("PS",$J,NHI)) Q:NHI<1!(NHI>MAX) S PS0=$G(^(NHI,0)) D
|
|
"RTN","NHINVPSI",32,0)
|
|
. S ID=$P(PS0,U) K NHITM
|
|
"RTN","NHINVPSI",33,0)
|
|
. Q:ID["N" Q:ID["O" ;inpatient only
|
|
"RTN","NHINVPSI",34,0)
|
|
. S IV=$S(ID["V":1,$G(^TMP("PS",$J,NHI,"B",0)):1,1:0)
|
|
"RTN","NHINVPSI",35,0)
|
|
. D @($S(IV:"IV",1:"IN")_"(ID,.NHITM)")
|
|
"RTN","NHINVPSI",36,0)
|
|
. I $D(NHITM)>9 D XML^NHINVPS(.NHITM)
|
|
"RTN","NHINVPSI",37,0)
|
|
K ^TMP("PS",$J)
|
|
"RTN","NHINVPSI",38,0)
|
|
Q
|
|
"RTN","NHINVPSI",39,0)
|
|
;
|
|
"RTN","NHINVPSI",40,0)
|
|
IN(ID,MED) ; -- return a medication in MED("attribute")=value
|
|
"RTN","NHINVPSI",41,0)
|
|
; [expects PS0,OCL^PSOORRL data]
|
|
"RTN","NHINVPSI",42,0)
|
|
N X,PS,ORDER,DOSE,UNTS,RTE,SCH,OI,PSOI,LOC K MED
|
|
"RTN","NHINVPSI",43,0)
|
|
M PS=^TMP("PS",$J,NHI)
|
|
"RTN","NHINVPSI",44,0)
|
|
S MED("id")=ID,MED("vaType")="I"
|
|
"RTN","NHINVPSI",45,0)
|
|
S X=$P(PS0,U,15) S:X MED("start")=X
|
|
"RTN","NHINVPSI",46,0)
|
|
S X=$P(PS0,U,4) S:X MED("stop")=X
|
|
"RTN","NHINVPSI",47,0)
|
|
S MED("name")=$P(PS0,U,2),X=$P(PS0,U,9),MED("vaStatus")=X,X=$E(X,1,3)
|
|
"RTN","NHINVPSI",48,0)
|
|
S MED("status")=$S(X="DIS"!(X="PEN"):"not active",X="EXP"!(X="REN"):"historical",X="REI":"active",1:$$LOW^XLFSTR($P(PS0,U,9)))
|
|
"RTN","NHINVPSI",49,0)
|
|
S DOSE=$P(PS0,U,6) S:DOSE="" DOSE=$G(PS("SIG",1,0))
|
|
"RTN","NHINVPSI",50,0)
|
|
S RTE=$G(PS("MDR",1,0)),SCH=$P($G(PS("SCH",1,0)),U)
|
|
"RTN","NHINVPSI",51,0)
|
|
S MED("dose",1)=DOSE_"^^^^"_RTE_U_SCH
|
|
"RTN","NHINVPSI",52,0)
|
|
S MED("sig")="Give: "_DOSE_" "_RTE_" "_SCH I $G(PS("SIO",0)) D
|
|
"RTN","NHINVPSI",53,0)
|
|
. N SIO M SIO=PS("SIO")
|
|
"RTN","NHINVPSI",54,0)
|
|
. S MED("sig")=MED("sig")_$C(13,10)_$$STRING^NHINV(.SIO)
|
|
"RTN","NHINVPSI",55,0)
|
|
I $D(PS("P",0)) S MED("orderingProvider")=PS("P",0)
|
|
"RTN","NHINVPSI",56,0)
|
|
I $G(PS("CLINIC",0)) S MED("IMO")=1
|
|
"RTN","NHINVPSI",57,0)
|
|
S MED("facility")=$$FAC^NHINV ;local stn#^name
|
|
"RTN","NHINVPSI",58,0)
|
|
S ORDER=+$P(PS0,U,8) D:ORDER ORD
|
|
"RTN","NHINVPSI",59,0)
|
|
Q
|
|
"RTN","NHINVPSI",60,0)
|
|
;
|
|
"RTN","NHINVPSI",61,0)
|
|
IN1(ID,MED) ; -- return a medication in MED("attribute")=value
|
|
"RTN","NHINVPSI",62,0)
|
|
; [expects OEL^PSOORRL data]
|
|
"RTN","NHINVPSI",63,0)
|
|
N X,PS,PS0,ORDER,DOSE,UNTS,RTE,SCH,OI,PSOI,DRUG,LOC K MED
|
|
"RTN","NHINVPSI",64,0)
|
|
M PS=^TMP("PS",$J) S PS0=PS(0)
|
|
"RTN","NHINVPSI",65,0)
|
|
S MED("id")=ID,MED("vaType")="I"
|
|
"RTN","NHINVPSI",66,0)
|
|
S X=$P(PS0,U,5) S:X MED("start")=X
|
|
"RTN","NHINVPSI",67,0)
|
|
S X=$P(PS0,U,3) S:X MED("stop")=X
|
|
"RTN","NHINVPSI",68,0)
|
|
S MED("name")=$P(PS0,U),X=$P(PS0,U,6),MED("vaStatus")=X,X=$E(X,1,3)
|
|
"RTN","NHINVPSI",69,0)
|
|
S MED("status")=$S(X="DIS"!(X="PEN"):"not active",X="EXP"!(X="REN"):"historical",X="REI":"active",1:$$LOW^XLFSTR($P(PS0,U,9)))
|
|
"RTN","NHINVPSI",70,0)
|
|
S DOSE=$P(PS0,U,9) S:DOSE="" DOSE=$G(PS("SIG",1,0))
|
|
"RTN","NHINVPSI",71,0)
|
|
S RTE=$G(PS("MDR",1,0)),SCH=$P($G(PS("SCH",1,0)),U)
|
|
"RTN","NHINVPSI",72,0)
|
|
S MED("dose",1)=DOSE_"^^^^"_RTE_U_SCH
|
|
"RTN","NHINVPSI",73,0)
|
|
S MED("sig")="Give: "_DOSE_" "_RTE_" "_SCH I $G(PS("SIO",0)) D
|
|
"RTN","NHINVPSI",74,0)
|
|
. N SIO M SIO=PS("SIO")
|
|
"RTN","NHINVPSI",75,0)
|
|
. S MED("sig")=MED("sig")_$C(13,10)_$$STRING^NHINV(.SIO)
|
|
"RTN","NHINVPSI",76,0)
|
|
I $D(PS("P",0)) S MED("orderingProvider")=PS("P",0)
|
|
"RTN","NHINVPSI",77,0)
|
|
S MED("facility")=$$FAC^NHINV ;local stn#^name
|
|
"RTN","NHINVPSI",78,0)
|
|
S ORDER=+$P(PS0,U,11) D:ORDER ORD
|
|
"RTN","NHINVPSI",79,0)
|
|
I $D(^SC("AE",1,+$G(LOC))) S MED("IMO")=1
|
|
"RTN","NHINVPSI",80,0)
|
|
Q
|
|
"RTN","NHINVPSI",81,0)
|
|
;
|
|
"RTN","NHINVPSI",82,0)
|
|
ORD ; get rest of inpatient data from ORDER
|
|
"RTN","NHINVPSI",83,0)
|
|
S OI=$$OI^ORX8(ORDER),PSOI=+$P(OI,U,3)
|
|
"RTN","NHINVPSI",84,0)
|
|
S MED("name")=$P(OI,U,2) I PSOI D
|
|
"RTN","NHINVPSI",85,0)
|
|
. D ZERO^PSS50P7(PSOI,,,"OI")
|
|
"RTN","NHINVPSI",86,0)
|
|
. S MED("form")=$P($G(^TMP($J,"OI",PSOI,.02)),U,2)
|
|
"RTN","NHINVPSI",87,0)
|
|
S X=$$VALUE^ORX8(ORDER,"DOSE"),DOSE=DOSE_"^^^"
|
|
"RTN","NHINVPSI",88,0)
|
|
S DRUG="" I X'="",X["&" D
|
|
"RTN","NHINVPSI",89,0)
|
|
. S DRUG=+$P(X,"&",6)
|
|
"RTN","NHINVPSI",90,0)
|
|
. S DOSE=$TR($P(X,"&",1,4),"&","^")
|
|
"RTN","NHINVPSI",91,0)
|
|
. S $P(MED("dose",1),U,1,4)=DOSE
|
|
"RTN","NHINVPSI",92,0)
|
|
S:'DRUG DRUG=+$$VALUE^ORX8(ORDER,"DRUG")
|
|
"RTN","NHINVPSI",93,0)
|
|
D:DRUG NDF^NHINVPS(DRUG)
|
|
"RTN","NHINVPSI",94,0)
|
|
K ^TMP($J,"OI")
|
|
"RTN","NHINVPSI",95,0)
|
|
ORDLOC ; enter here for just order# and location
|
|
"RTN","NHINVPSI",96,0)
|
|
S MED("orderID")=ORDER
|
|
"RTN","NHINVPSI",97,0)
|
|
S LOC=+$$GET1^DIQ(100,ORDER_",",6,"I") I LOC D
|
|
"RTN","NHINVPSI",98,0)
|
|
. S MED("location")=LOC_U_$P($G(^SC(LOC,0)),U)
|
|
"RTN","NHINVPSI",99,0)
|
|
. S MED("facility")=$$FAC^NHINV(LOC)
|
|
"RTN","NHINVPSI",100,0)
|
|
Q
|
|
"RTN","NHINVPSI",101,0)
|
|
;
|
|
"RTN","NHINVPSI",102,0)
|
|
IV(ID,MED) ; -- return an infusion in MED("attribute")=value
|
|
"RTN","NHINVPSI",103,0)
|
|
; [expects PS0,OCL^PSOORRL data]
|
|
"RTN","NHINVPSI",104,0)
|
|
N PS,X,ORDER,LOC K MED
|
|
"RTN","NHINVPSI",105,0)
|
|
M PS=^TMP("PS",$J,NHI)
|
|
"RTN","NHINVPSI",106,0)
|
|
S MED("id")=ID,MED("vaType")="V",MED("name")=$P(PS0,U,2)
|
|
"RTN","NHINVPSI",107,0)
|
|
S X=$P(PS0,U,15) S:X MED("start")=X
|
|
"RTN","NHINVPSI",108,0)
|
|
S X=$P(PS0,U,4) S:X MED("stop")=X
|
|
"RTN","NHINVPSI",109,0)
|
|
S MED("vaStatus")=$P(PS0,U,9),X=$E($P(PS0,U,9),1,3)
|
|
"RTN","NHINVPSI",110,0)
|
|
S MED("status")=$S(X="DIS"!(X="PEN"):"not active",X="EXP"!(X="PUR"):"historical",X="HOL":"hold",1:"active")
|
|
"RTN","NHINVPSI",111,0)
|
|
S MED("dose",1)="^^^^"_$G(PS("MDR",1,0))_U_$P($G(PS("SCH",1,0)),U)
|
|
"RTN","NHINVPSI",112,0)
|
|
S MED("rate")=$P(PS0,U,3) D IVP
|
|
"RTN","NHINVPSI",113,0)
|
|
S X=$G(PS("IVLIM",0)) S:$L(X) MED("ivLimit")=$$IVLIM(X)
|
|
"RTN","NHINVPSI",114,0)
|
|
I $G(PS("CLINIC",0)) S MED("IMO")=1
|
|
"RTN","NHINVPSI",115,0)
|
|
I $G(PS("P",0)) S MED("orderingProvider")=PS("P",0)
|
|
"RTN","NHINVPSI",116,0)
|
|
S MED("facility")=$$FAC^NHINV ;local stn#^name
|
|
"RTN","NHINVPSI",117,0)
|
|
S ORDER=+$P(PS0,U,8) D:ORDER ORDLOC
|
|
"RTN","NHINVPSI",118,0)
|
|
Q
|
|
"RTN","NHINVPSI",119,0)
|
|
;
|
|
"RTN","NHINVPSI",120,0)
|
|
IV1(ID,MED) ; -- return an infusion in MED("attribute")=value
|
|
"RTN","NHINVPSI",121,0)
|
|
; [expects OEL^PSOORRL data]
|
|
"RTN","NHINVPSI",122,0)
|
|
N PS,PS0,X,ORDER,LOC K MED
|
|
"RTN","NHINVPSI",123,0)
|
|
M PS=^TMP("PS",$J) S PS0=PS(0)
|
|
"RTN","NHINVPSI",124,0)
|
|
S MED("id")=ID,MED("vaType")="V",MED("name")=$P(PS0,U)
|
|
"RTN","NHINVPSI",125,0)
|
|
S X=$P(PS0,U,5) S:X MED("start")=X
|
|
"RTN","NHINVPSI",126,0)
|
|
S X=$P(PS0,U,3) S:X MED("stop")=X
|
|
"RTN","NHINVPSI",127,0)
|
|
S MED("vaStatus")=$P(PS0,U,6),X=$E($P(PS0,U,6),1,3)
|
|
"RTN","NHINVPSI",128,0)
|
|
S MED("status")=$S(X="DIS"!(X="PEN"):"not active",X="EXP"!(X="PUR"):"historical",X="HOL":"hold",1:"active")
|
|
"RTN","NHINVPSI",129,0)
|
|
S MED("dose",1)="^^^^"_$G(PS("MDR",1,0))_U_$P($G(PS("SCH",1,0)),U)
|
|
"RTN","NHINVPSI",130,0)
|
|
S MED("rate")=$P(PS0,U,2) D IVP
|
|
"RTN","NHINVPSI",131,0)
|
|
S X=$G(PS("IVLIM",0)) S:$L(X) MED("ivLimit")=$$IVLIM(X)
|
|
"RTN","NHINVPSI",132,0)
|
|
I $G(PS("P",0)) S MED("orderingProvider")=PS("P",0)
|
|
"RTN","NHINVPSI",133,0)
|
|
S MED("facility")=$$FAC^NHINV ;local stn#^name
|
|
"RTN","NHINVPSI",134,0)
|
|
S ORDER=+$P(PS0,U,11) D:ORDER ORDLOC
|
|
"RTN","NHINVPSI",135,0)
|
|
I $D(^SC("AE",1,+$G(LOC))) S MED("IMO")=1
|
|
"RTN","NHINVPSI",136,0)
|
|
Q
|
|
"RTN","NHINVPSI",137,0)
|
|
;
|
|
"RTN","NHINVPSI",138,0)
|
|
IVP ; -- add IV products for ID,DFN
|
|
"RTN","NHINVPSI",139,0)
|
|
N I,N,FILE,IENS,NHIN,LIST,IEN,DRUG,STR
|
|
"RTN","NHINVPSI",140,0)
|
|
S FILE=$S(ID["P":53.157,1:55.02),N=0
|
|
"RTN","NHINVPSI",141,0)
|
|
S IENS=","_+ID_","_$S(ID["P":"",1:DFN_",")
|
|
"RTN","NHINVPSI",142,0)
|
|
F I=1:1 K NHIN D GETS^DIQ(FILE,I_IENS,"*","IE","NHIN") Q:'$D(NHIN) D
|
|
"RTN","NHINVPSI",143,0)
|
|
. K LIST M LIST=NHIN(FILE,I_IENS)
|
|
"RTN","NHINVPSI",144,0)
|
|
. S IEN=LIST(.01,"I"),DRUG=$$GET1^DIQ(52.6,IEN_",",1,"I")
|
|
"RTN","NHINVPSI",145,0)
|
|
. D:DRUG NDF^NHINVPS(DRUG,.N) S:'DRUG N=N+1
|
|
"RTN","NHINVPSI",146,0)
|
|
. S STR=$S(FILE=53.157:LIST(1,"E"),1:LIST(.02,"E"))
|
|
"RTN","NHINVPSI",147,0)
|
|
. S MED("product",N)=IEN_U_LIST(.01,"E")_"^^A^"_STR
|
|
"RTN","NHINVPSI",148,0)
|
|
S FILE=$S(ID["P":53.158,1:55.11)
|
|
"RTN","NHINVPSI",149,0)
|
|
F I=1:1 K NHIN D GETS^DIQ(FILE,I_IENS,"*","IE","NHIN") Q:'$D(NHIN) D
|
|
"RTN","NHINVPSI",150,0)
|
|
. K LIST M LIST=NHIN(FILE,I_IENS)
|
|
"RTN","NHINVPSI",151,0)
|
|
. S IEN=LIST(.01,"I"),DRUG=$$GET1^DIQ(52.7,IEN_",",1,"I")
|
|
"RTN","NHINVPSI",152,0)
|
|
. D:DRUG NDF^NHINVPS(DRUG,.N) S:'DRUG N=N+1
|
|
"RTN","NHINVPSI",153,0)
|
|
. S MED("product",N)=IEN_U_LIST(.01,"E")_"^^B^"_LIST(1,"E")
|
|
"RTN","NHINVPSI",154,0)
|
|
Q
|
|
"RTN","NHINVPSI",155,0)
|
|
;
|
|
"RTN","NHINVPSI",156,0)
|
|
IVLIM(X) ; -- Return expanded version of IV Limit X
|
|
"RTN","NHINVPSI",157,0)
|
|
I '$L($G(X)) Q ""
|
|
"RTN","NHINVPSI",158,0)
|
|
N Y,VAL,UNT,I
|
|
"RTN","NHINVPSI",159,0)
|
|
S Y="",X=$$UP^XLFSTR(X)
|
|
"RTN","NHINVPSI",160,0)
|
|
I X?1"DOSES".E S X="A"_$P(X,"DOSES",2)
|
|
"RTN","NHINVPSI",161,0)
|
|
S UNT=$E(X),VAL=0 F I=2:1:$L(X) I $E(X,I) S VAL=$E(X,I,$L(X)) Q
|
|
"RTN","NHINVPSI",162,0)
|
|
I UNT="A" S Y=+VAL_$S(+VAL>1:" doses",1:" dose")
|
|
"RTN","NHINVPSI",163,0)
|
|
I UNT="D" S Y=+VAL_$S(+VAL>1:" days",1:" day")
|
|
"RTN","NHINVPSI",164,0)
|
|
I UNT="H" S Y=+VAL_$S(+VAL>1:" hours",1:" hour")
|
|
"RTN","NHINVPSI",165,0)
|
|
I UNT="C" S Y=+VAL_" CC"
|
|
"RTN","NHINVPSI",166,0)
|
|
I UNT="M" S Y=+VAL_" ml"
|
|
"RTN","NHINVPSI",167,0)
|
|
I UNT="L" S Y=+VAL_" L"
|
|
"RTN","NHINVPSI",168,0)
|
|
Q Y
|
|
"RTN","NHINVPSO")
|
|
0^28^B65991145^n/a
|
|
"RTN","NHINVPSO",1,0)
|
|
NHINVPSO ;SLC/MKB -- Outpatient Pharmacy extract
|
|
"RTN","NHINVPSO",2,0)
|
|
;;1.0;NHIN;**1**;Dec 01, 2009;Build 11
|
|
"RTN","NHINVPSO",3,0)
|
|
;
|
|
"RTN","NHINVPSO",4,0)
|
|
; External References DBIA#
|
|
"RTN","NHINVPSO",5,0)
|
|
; ------------------- -----
|
|
"RTN","NHINVPSO",6,0)
|
|
; ^SC 10040
|
|
"RTN","NHINVPSO",7,0)
|
|
; ^VA(200) 10060
|
|
"RTN","NHINVPSO",8,0)
|
|
; DIQ 2056
|
|
"RTN","NHINVPSO",9,0)
|
|
; ORX8 2467
|
|
"RTN","NHINVPSO",10,0)
|
|
; PSO5241 4821
|
|
"RTN","NHINVPSO",11,0)
|
|
; PSOORDER,^TMP("PSOR",$J) 1878
|
|
"RTN","NHINVPSO",12,0)
|
|
; PSOORRL,^TMP("PS",$J) 2400
|
|
"RTN","NHINVPSO",13,0)
|
|
; PSS50P7 4662
|
|
"RTN","NHINVPSO",14,0)
|
|
; PSS51P2 4548
|
|
"RTN","NHINVPSO",15,0)
|
|
; XLFDT 10103
|
|
"RTN","NHINVPSO",16,0)
|
|
;
|
|
"RTN","NHINVPSO",17,0)
|
|
; ------------ Get medications from VistA ------------
|
|
"RTN","NHINVPSO",18,0)
|
|
;
|
|
"RTN","NHINVPSO",19,0)
|
|
EN(DFN,BEG,END,MAX,ID) ; -- find patient's meds
|
|
"RTN","NHINVPSO",20,0)
|
|
N PS0,NHI,NHITM K ^TMP("PS",$J)
|
|
"RTN","NHINVPSO",21,0)
|
|
S DFN=+$G(DFN) Q:DFN<1
|
|
"RTN","NHINVPSO",22,0)
|
|
S BEG=$G(BEG,1410101),END=$G(END,9999998),MAX=$G(MAX,999999)
|
|
"RTN","NHINVPSO",23,0)
|
|
;
|
|
"RTN","NHINVPSO",24,0)
|
|
; get one med
|
|
"RTN","NHINVPSO",25,0)
|
|
I $G(ID) D D:$D(NHITM)>9 XML^NHINVPS(.NHITM) Q
|
|
"RTN","NHINVPSO",26,0)
|
|
. Q:ID["I"
|
|
"RTN","NHINVPSO",27,0)
|
|
. I ID["N" D NVA(ID,.NHITM) Q
|
|
"RTN","NHINVPSO",28,0)
|
|
. I ID'["P",ID'["S" D RX(ID,.NHITM) Q
|
|
"RTN","NHINVPSO",29,0)
|
|
. D OEL^PSOORRL(DFN,ID),PEN1(ID,.NHITM)
|
|
"RTN","NHINVPSO",30,0)
|
|
. K ^TMP("PS",$J)
|
|
"RTN","NHINVPSO",31,0)
|
|
;
|
|
"RTN","NHINVPSO",32,0)
|
|
; get all meds
|
|
"RTN","NHINVPSO",33,0)
|
|
D OCL^PSOORRL(DFN,BEG,END)
|
|
"RTN","NHINVPSO",34,0)
|
|
S NHI=0 F S NHI=$O(^TMP("PS",$J,NHI)) Q:NHI<1!(NHI>MAX) S PS0=$G(^(NHI,0)) D I $D(NHITM)>9 D XML^NHINVPS(.NHITM)
|
|
"RTN","NHINVPSO",35,0)
|
|
. S ID=$P(PS0,U) K NHITM Q:ID["I"
|
|
"RTN","NHINVPSO",36,0)
|
|
. I ID["N" D NVA(ID,.NHITM) Q
|
|
"RTN","NHINVPSO",37,0)
|
|
. I ID["O" D RX(ID,.NHITM) Q
|
|
"RTN","NHINVPSO",38,0)
|
|
K ^TMP("PS",$J)
|
|
"RTN","NHINVPSO",39,0)
|
|
Q
|
|
"RTN","NHINVPSO",40,0)
|
|
;
|
|
"RTN","NHINVPSO",41,0)
|
|
RX(ID,MED) ; -- return a prescription in MED("attribute")=value
|
|
"RTN","NHINVPSO",42,0)
|
|
I ID["P"!(ID["S") G PEND ;pending order
|
|
"RTN","NHINVPSO",43,0)
|
|
N RX0,RX1,DRUG,PSOI,X,I,START,STOP,ORIFN,FILL,RFD,PRV K MED
|
|
"RTN","NHINVPSO",44,0)
|
|
K ^TMP("PSOR",$J) D EN^PSOORDER(DFN,+ID)
|
|
"RTN","NHINVPSO",45,0)
|
|
S RX0=$G(^TMP("PSOR",$J,+ID,0)),RX1=$G(^(1)),DRUG=$G(^("DRUG",0))
|
|
"RTN","NHINVPSO",46,0)
|
|
S MED("id")=ID,MED("vaType")="O",MED("type")="Prescription"
|
|
"RTN","NHINVPSO",47,0)
|
|
S ORIFN=+$P(RX1,U,8) S:ORIFN MED("orderID")=ORIFN
|
|
"RTN","NHINVPSO",48,0)
|
|
S PSOI=$G(^TMP("PSOR",$J,+ID,"DRUGOI",0)) I PSOI D
|
|
"RTN","NHINVPSO",49,0)
|
|
. S MED("name")=$P(PSOI,";",2)
|
|
"RTN","NHINVPSO",50,0)
|
|
. D ZERO^PSS50P7(+PSOI,,,"OI")
|
|
"RTN","NHINVPSO",51,0)
|
|
. S MED("form")=$P($G(^TMP($J,"OI",+PSOI,.02)),U,2)
|
|
"RTN","NHINVPSO",52,0)
|
|
D:DRUG NDF^NHINVPS(+DRUG) ;add NDF data
|
|
"RTN","NHINVPSO",53,0)
|
|
S START=$P(RX0,U) S:START MED("start")=START
|
|
"RTN","NHINVPSO",54,0)
|
|
S STOP=$P(RX0,U,12) S:STOP MED("stop")=STOP ;_".2359"?
|
|
"RTN","NHINVPSO",55,0)
|
|
S X=$$GET1^DIQ(52,+ID_",",26,"I") S:X MED("expires")=X
|
|
"RTN","NHINVPSO",56,0)
|
|
S X=$P(RX0,U,17) S:X MED("ordered")=X
|
|
"RTN","NHINVPSO",57,0)
|
|
S MED("vaStatus")=$P($P(RX0,U,4),";",2),X=$P($P(RX0,U,4),";")
|
|
"RTN","NHINVPSO",58,0)
|
|
S MED("status")=$S(X="H":"hold",X="DC":"not active",X="D"!(X="E"):"historical",1:"active")
|
|
"RTN","NHINVPSO",59,0)
|
|
S MED("quantity")=$P(RX0,U,6),MED("daysSupply")=$P(RX0,U,7)
|
|
"RTN","NHINVPSO",60,0)
|
|
S MED("fillsAllowed")=$P(RX0,U,8),MED("fillsRemaining")=$P(RX0,U,9)
|
|
"RTN","NHINVPSO",61,0)
|
|
S MED("routing")=$P($P(RX1,U,6),";"),MED("prescription")=$P(RX0,U,5)
|
|
"RTN","NHINVPSO",62,0)
|
|
S MED("lastFilled")=$P(RX0,U,3) K FILL
|
|
"RTN","NHINVPSO",63,0)
|
|
S I=0 F S I=$O(^TMP("PSOR",$J,+ID,"REF",I)) Q:I<1 S X=$G(^(I,0)),FILL(+X)=X
|
|
"RTN","NHINVPSO",64,0)
|
|
S I=0 F S I=$O(^TMP("PSOR",$J,+ID,"RPAR",I)) Q:I<1 S X=$G(^(I,0)),$P(X,U,14)=1,FILL(+X)=X
|
|
"RTN","NHINVPSO",65,0)
|
|
S (I,RFD,PRV)=0 F S RFD=$O(FILL(RFD)) Q:RFD<1 S X=$G(FILL(RFD)) D ;sort 1st
|
|
"RTN","NHINVPSO",66,0)
|
|
. N MW,REL S I=I+1
|
|
"RTN","NHINVPSO",67,0)
|
|
. S MW=$P($P(X,U,10),";"),REL=$P($P(X,U,8),".")
|
|
"RTN","NHINVPSO",68,0)
|
|
. S MED("fill",I)=$P(RFD,".")_U_MW_U_REL_U_$P(X,U,4,5)_$S($P(X,U,14):"^1",1:"")
|
|
"RTN","NHINVPSO",69,0)
|
|
. S:$P(X,U,2) PRV=$P(X,U,2) ;save last provider
|
|
"RTN","NHINVPSO",70,0)
|
|
. ; fill comments?
|
|
"RTN","NHINVPSO",71,0)
|
|
S X=$S($P(RX0,U,11):$P(RX0,U,11),$P(RX0,U,10):$P(RX0,U,10),1:0)
|
|
"RTN","NHINVPSO",72,0)
|
|
S:X MED("fillCost")=X
|
|
"RTN","NHINVPSO",73,0)
|
|
S X=$G(^TMP("PSOR",$J,+ID,"SIG",1,0)),I=1
|
|
"RTN","NHINVPSO",74,0)
|
|
F S I=$O(^TMP("PSOR",$J,+ID,"SIG",I)) Q:I<1 S X=X_$G(^(I,0))
|
|
"RTN","NHINVPSO",75,0)
|
|
S MED("sig")=X
|
|
"RTN","NHINVPSO",76,0)
|
|
S X=$G(^TMP("PSOR",$J,+ID,"PI",1,0)),I=1
|
|
"RTN","NHINVPSO",77,0)
|
|
F S I=$O(^TMP("PSOR",$J,+ID,"PI",I)) Q:I<1 S X=X_$G(^(I,0))
|
|
"RTN","NHINVPSO",78,0)
|
|
S:$L(X) MED("ptInstructions")=X
|
|
"RTN","NHINVPSO",79,0)
|
|
S I=0 F S I=$O(^TMP("PSOR",$J,+ID,"MI",I)) Q:I<1 S X=$G(^(I,0)) D
|
|
"RTN","NHINVPSO",80,0)
|
|
. N UD,NOUN,DOSE,UNIT,RTE,SCH,DUR,CONJ,END
|
|
"RTN","NHINVPSO",81,0)
|
|
. S UD=$P(X,U,2),NOUN=$P(X,U,4)
|
|
"RTN","NHINVPSO",82,0)
|
|
. S DOSE=$P(X,U),UNIT=$P($P(X,U,3),";",2)
|
|
"RTN","NHINVPSO",83,0)
|
|
. S RTE=+$P(X,U,7) D ALL^PSS51P2(RTE,,,,"MR")
|
|
"RTN","NHINVPSO",84,0)
|
|
. S RTE=$G(^TMP($J,"MR",RTE,1))
|
|
"RTN","NHINVPSO",85,0)
|
|
. S DUR=$P(X,U,5),CONJ=$P(X,U,6),SCH=$P(X,U,8)
|
|
"RTN","NHINVPSO",86,0)
|
|
. S END=$S(DUR:$$STOP(START,DUR),1:STOP)
|
|
"RTN","NHINVPSO",87,0)
|
|
. S MED("dose",I)=DOSE_U_UNIT_U_UD_U_NOUN_U_RTE_U_SCH_U_DUR_U_CONJ_U_START_U_STOP
|
|
"RTN","NHINVPSO",88,0)
|
|
. I $E(CONJ)="T",DUR S START=END
|
|
"RTN","NHINVPSO",89,0)
|
|
S:RX1 X=$TR($P(RX1,U),";","^"),MED("orderingProvider")=X,MED("currentProvider")=X
|
|
"RTN","NHINVPSO",90,0)
|
|
S:$G(PRV) MED("currentProvider")=$TR(PRV,";","^")
|
|
"RTN","NHINVPSO",91,0)
|
|
S:$P(RX1,U,9) MED("pharmacist")=$TR($P(RX1,U,9),";","^")
|
|
"RTN","NHINVPSO",92,0)
|
|
S:$P(RX1,U,4) MED("location")=$TR($P(RX1,U,4),";","^")
|
|
"RTN","NHINVPSO",93,0)
|
|
S MED("facility")=$$FAC^NHINV(+$P(RX1,U,4))
|
|
"RTN","NHINVPSO",94,0)
|
|
K ^TMP("PSOR",$J),^TMP($J,"MR"),^TMP($J,"NDF"),^TMP($J,"OI")
|
|
"RTN","NHINVPSO",95,0)
|
|
Q
|
|
"RTN","NHINVPSO",96,0)
|
|
;
|
|
"RTN","NHINVPSO",97,0)
|
|
PEND ; -- pending prescription
|
|
"RTN","NHINVPSO",98,0)
|
|
; [expects PS0,OCL^PSOORRL data]
|
|
"RTN","NHINVPSO",99,0)
|
|
N I,X,NHIN K MED
|
|
"RTN","NHINVPSO",100,0)
|
|
S MED("id")=ID,MED("vaType")="O",MED("type")="Prescription"
|
|
"RTN","NHINVPSO",101,0)
|
|
S MED("vaStatus")=$P(PS0,U,9),MED("status")="not active"
|
|
"RTN","NHINVPSO",102,0)
|
|
S X=+$P(PS0,U,8) S:X MED("orderID")=X
|
|
"RTN","NHINVPSO",103,0)
|
|
S X=+$P(PS0,U,12) S:X MED("quantity")=X
|
|
"RTN","NHINVPSO",104,0)
|
|
D GETS^DIQ(52.41,+ID_",","101;13;19;15;5;1.1","I","NHIN")
|
|
"RTN","NHINVPSO",105,0)
|
|
S X=NHIN(52.41,+ID_",",101,"I") S:X MED("daysSupply")=X
|
|
"RTN","NHINVPSO",106,0)
|
|
S X=NHIN(52.41,+ID_",",13,"I") S:X MED("fillsAllowed")=X
|
|
"RTN","NHINVPSO",107,0)
|
|
S X=NHIN(52.41,+ID_",",19,"I") S:$L(X) MED("routing")=X
|
|
"RTN","NHINVPSO",108,0)
|
|
S X=NHIN(52.41,+ID_",",15,"I") S:X MED("ordered")=X
|
|
"RTN","NHINVPSO",109,0)
|
|
S X=NHIN(52.41,+ID_",",5,"I") S:X MED("orderingProvider")=X_U_$P($G(^VA(200,X,0)),U)
|
|
"RTN","NHINVPSO",110,0)
|
|
S X=NHIN(52.41,+ID_",",1.1,"I") S:X MED("location")=X_U_$P($G(^SC(X,0)),U)
|
|
"RTN","NHINVPSO",111,0)
|
|
S MED("facility")=$$FAC^NHINV(X)
|
|
"RTN","NHINVPSO",112,0)
|
|
S X=$G(^TMP("PS",$J,NHI,"SIG",1,0)),I=1
|
|
"RTN","NHINVPSO",113,0)
|
|
F S I=$O(^TMP("PS",$J,NHI,"SIG",I)) Q:I<1 S X=X_$C(13,10)_$G(^(I,0))
|
|
"RTN","NHINVPSO",114,0)
|
|
S MED("sig")=X
|
|
"RTN","NHINVPSO",115,0)
|
|
D PEN^PSO5241(DFN,"NHIN",+ID)
|
|
"RTN","NHINVPSO",116,0)
|
|
S X=$G(^TMP($J,"NHIN",DFN,+ID,8)) I X D ;Pharmacy OI
|
|
"RTN","NHINVPSO",117,0)
|
|
. S MED("name")=$P(X,U,2)_" "_$P(X,U,4),MED("form")=$P(X,U,4)
|
|
"RTN","NHINVPSO",118,0)
|
|
S X=$G(^TMP($J,"NHIN",DFN,+ID,11)) D:X NDF^NHINVPS(+X) ;Dispense Drug
|
|
"RTN","NHINVPSO",119,0)
|
|
D PDOSE K ^TMP($J,"NHIN")
|
|
"RTN","NHINVPSO",120,0)
|
|
Q
|
|
"RTN","NHINVPSO",121,0)
|
|
;
|
|
"RTN","NHINVPSO",122,0)
|
|
PEN1(ID,MED) ; -- return a pending Rx in MED("attribute")=value
|
|
"RTN","NHINVPSO",123,0)
|
|
; [expects OEL^PSOORRL data]
|
|
"RTN","NHINVPSO",124,0)
|
|
N PS,PS0,I,X,NHIN K MED
|
|
"RTN","NHINVPSO",125,0)
|
|
M PS=^TMP("PS",$J) S PS0=PS(0)
|
|
"RTN","NHINVPSO",126,0)
|
|
S MED("id")=ID,MED("vaType")="O",MED("type")="Prescription"
|
|
"RTN","NHINVPSO",127,0)
|
|
S MED("vaStatus")=$P(PS0,U,6),MED("status")="not active"
|
|
"RTN","NHINVPSO",128,0)
|
|
S X=+$P(PS0,U,11) S:X MED("orderID")=X
|
|
"RTN","NHINVPSO",129,0)
|
|
S X=+$P(PS0,U,8) S:X MED("quantity")=X
|
|
"RTN","NHINVPSO",130,0)
|
|
S X=+$P(PS0,U,4) S:X MED("fillsAllowed")=X
|
|
"RTN","NHINVPSO",131,0)
|
|
S X=+$P(PS0,U,5) S:X MED("ordered")=X
|
|
"RTN","NHINVPSO",132,0)
|
|
S X=$G(PS("DD",1,0)) D:X NDF^NHINVPS(+X) ;Dispense Drug
|
|
"RTN","NHINVPSO",133,0)
|
|
D GETS^DIQ(52.41,+ID_",","101;19;5;1.1","I","NHIN")
|
|
"RTN","NHINVPSO",134,0)
|
|
S X=NHIN(52.41,+ID_",",101,"I") S:X MED("daysSupply")=X
|
|
"RTN","NHINVPSO",135,0)
|
|
S X=NHIN(52.41,+ID_",",19,"I") S:$L(X) MED("routing")=X
|
|
"RTN","NHINVPSO",136,0)
|
|
S X=NHIN(52.41,+ID_",",5,"I") S:X MED("orderingProvider")=X_U_$P($G(^VA(200,X,0)),U)
|
|
"RTN","NHINVPSO",137,0)
|
|
S X=NHIN(52.41,+ID_",",1.1,"I") S:X MED("location")=X_U_$P($G(^SC(X,0)),U)
|
|
"RTN","NHINVPSO",138,0)
|
|
S MED("facility")=$$FAC^NHINV(X)
|
|
"RTN","NHINVPSO",139,0)
|
|
S X=$G(PS("SIG",1,0)),I=1
|
|
"RTN","NHINVPSO",140,0)
|
|
F S I=$O(PS("SIG",I)) Q:I<1 S X=X_$C(13,10)_$G(PS("SIG",I,0))
|
|
"RTN","NHINVPSO",141,0)
|
|
S MED("sig")=X
|
|
"RTN","NHINVPSO",142,0)
|
|
D PEN^PSO5241(DFN,"NHIN",+ID)
|
|
"RTN","NHINVPSO",143,0)
|
|
S X=$G(^TMP($J,"NHIN",DFN,+ID,8)) I X D ;Pharmacy OI
|
|
"RTN","NHINVPSO",144,0)
|
|
. S MED("name")=$P(X,U,2)_" "_$P(X,U,4),MED("form")=$P(X,U,4)
|
|
"RTN","NHINVPSO",145,0)
|
|
D PDOSE K ^TMP($J,"NHIN")
|
|
"RTN","NHINVPSO",146,0)
|
|
Q
|
|
"RTN","NHINVPSO",147,0)
|
|
;
|
|
"RTN","NHINVPSO",148,0)
|
|
PDOSE ; Pending file doses
|
|
"RTN","NHINVPSO",149,0)
|
|
N QT,UNIT,UD,NOUN,DOSE,RTE,SCH,DUR,CONJ,BEG,END
|
|
"RTN","NHINVPSO",150,0)
|
|
F I=1:1 K NHIN D GETS^DIQ(52.413,I_","_+ID_",","*",,"NHIN") Q:'$D(NHIN) D
|
|
"RTN","NHINVPSO",151,0)
|
|
. K QT M QT=NHIN(52.413,I_","_+ID_",")
|
|
"RTN","NHINVPSO",152,0)
|
|
. S (UNIT,UD,NOUN)="",(DOSE,X)=QT(.01) I X["&" D
|
|
"RTN","NHINVPSO",153,0)
|
|
.. S DOSE=$P(X,"&"),UNIT=$P(X,"&",2)
|
|
"RTN","NHINVPSO",154,0)
|
|
.. S UD=$P(X,"&",3),NOUN=$P(X,"&",4)
|
|
"RTN","NHINVPSO",155,0)
|
|
. S SCH=QT(1),DUR=QT(2),CONJ=QT(6),BEG=QT(3),END=QT(4)
|
|
"RTN","NHINVPSO",156,0)
|
|
. S RTE=$$GET1^DIQ(52.413,I_","_+ID_",","10:1")
|
|
"RTN","NHINVPSO",157,0)
|
|
. S MED("dose",I)=DOSE_U_UNIT_U_UD_U_NOUN_U_RTE_U_SCH_U_DUR_U_CONJ_U_BEG_U_END
|
|
"RTN","NHINVPSO",158,0)
|
|
Q
|
|
"RTN","NHINVPSO",159,0)
|
|
;
|
|
"RTN","NHINVPSO",160,0)
|
|
STOP(BEG,X) ; -- Return date after adding X to BEG
|
|
"RTN","NHINVPSO",161,0)
|
|
N D,H,M,S,UNT,Y
|
|
"RTN","NHINVPSO",162,0)
|
|
S Y=BEG,(D,H,M,S)=0,UNT=$P(X," ",2),X=+X
|
|
"RTN","NHINVPSO",163,0)
|
|
S:UNT?1"MON".E D=30*X
|
|
"RTN","NHINVPSO",164,0)
|
|
S:UNT?1"WEE".E D=7*X
|
|
"RTN","NHINVPSO",165,0)
|
|
S:UNT?1"DAY".E D=X
|
|
"RTN","NHINVPSO",166,0)
|
|
S:UNT?1"HOU".E H=X
|
|
"RTN","NHINVPSO",167,0)
|
|
S:UNT?1"MIN".E M=X
|
|
"RTN","NHINVPSO",168,0)
|
|
S:UNT?1"SEC".E S=X
|
|
"RTN","NHINVPSO",169,0)
|
|
S Y=$$FMADD^XLFDT(BEG,D,H,M,S)
|
|
"RTN","NHINVPSO",170,0)
|
|
Q Y
|
|
"RTN","NHINVPSO",171,0)
|
|
;
|
|
"RTN","NHINVPSO",172,0)
|
|
NVA(ID,MED) ; -- return a non-VA med in MED("attribute")=value
|
|
"RTN","NHINVPSO",173,0)
|
|
N NVA,NHZ,ORIFN,DOSE,X K MED
|
|
"RTN","NHINVPSO",174,0)
|
|
D GETS^DIQ(55.05,+ID_","_DFN_",",".01:8;11:13","IE","NHZ")
|
|
"RTN","NHINVPSO",175,0)
|
|
M NVA=NHZ(55.05,+ID_","_DFN_",") K NHZ
|
|
"RTN","NHINVPSO",176,0)
|
|
S MED("id")=ID,MED("type")="OTC",MED("vaType")="N"
|
|
"RTN","NHINVPSO",177,0)
|
|
S ORIFN=+NVA(7,"I") S:ORIFN MED("orderID")=ORIFN
|
|
"RTN","NHINVPSO",178,0)
|
|
I NVA(.01,"I") D ;orderable item
|
|
"RTN","NHINVPSO",179,0)
|
|
. N FORM
|
|
"RTN","NHINVPSO",180,0)
|
|
. S X=NVA(.01,"I") D ZERO^PSS50P7(+X,,,"PSOI")
|
|
"RTN","NHINVPSO",181,0)
|
|
. S FORM=$P($G(^TMP($J,"PSOI",+X,.02)),U,2),MED("form")=FORM
|
|
"RTN","NHINVPSO",182,0)
|
|
. S MED("name")=NVA(.01,"E")_" "_FORM
|
|
"RTN","NHINVPSO",183,0)
|
|
S X=NVA(1,"I") D:X NDF^NHINVPS(+X) ;dispense drug
|
|
"RTN","NHINVPSO",184,0)
|
|
S MED("sig")=NVA(2,"E")_" BY "_NVA(3,"E")_" "_NVA(4,"E")
|
|
"RTN","NHINVPSO",185,0)
|
|
S X=NVA(2,"I"),NVA(2,"I")=+X_U_$P(X,+X,2) ;amt^unit
|
|
"RTN","NHINVPSO",186,0)
|
|
S DOSE=NVA(2,"I")_"^^" I ORIFN D ;reformat from order
|
|
"RTN","NHINVPSO",187,0)
|
|
. S X=$$VALUE^ORX8(ORIFN,"ROUTE") S:X NVA(3,"E")=$$GET1^DIQ(51.2,+X_",",1)
|
|
"RTN","NHINVPSO",188,0)
|
|
. S X=$$VALUE^ORX8(ORIFN,"SCHEDULE") S:$L(X) NVA(4,"E")=X
|
|
"RTN","NHINVPSO",189,0)
|
|
. S X=$$VALUE^ORX8(ORIFN,"DOSE"),DOSE=$TR($P(X,"&",1,4),"&","^")
|
|
"RTN","NHINVPSO",190,0)
|
|
S MED("dose",1)=DOSE_U_NVA(3,"E")_U_NVA(4,"E")
|
|
"RTN","NHINVPSO",191,0)
|
|
S:NVA(8,"I") MED("start")=NVA(8,"I")
|
|
"RTN","NHINVPSO",192,0)
|
|
S:NVA(6,"I") MED("stop")=NVA(6,"I")
|
|
"RTN","NHINVPSO",193,0)
|
|
S:NVA(11,"I") MED("ordered")=NVA(11,"I")
|
|
"RTN","NHINVPSO",194,0)
|
|
S MED("status")=$S($G(NVA(5,"E")):"not active",1:"active")
|
|
"RTN","NHINVPSO",195,0)
|
|
S:NVA(12,"I") MED("orderingProvider")=NVA(12,"I")_U_NVA(12,"E")
|
|
"RTN","NHINVPSO",196,0)
|
|
S:NVA(13,"I") MED("location")=NVA(13,"I")_U_NVA(13,"E")
|
|
"RTN","NHINVPSO",197,0)
|
|
S MED("facility")=$$FAC^NHINV(NVA(13,"I"))
|
|
"RTN","NHINVPSO",198,0)
|
|
K ^TMP($J,"PSOI"),^TMP($J,"NDF")
|
|
"RTN","NHINVPSO",199,0)
|
|
Q
|
|
"RTN","NHINVPSO",200,0)
|
|
;
|
|
"RTN","NHINVPSO",201,0)
|
|
ACTIVE(X) ; -- return 1 or 0, if X is an active status
|
|
"RTN","NHINVPSO",202,0)
|
|
N Y S Y=1
|
|
"RTN","NHINVPSO",203,0)
|
|
I X="PURGE" S Y=0
|
|
"RTN","NHINVPSO",204,0)
|
|
I X="DELETED" S Y=0
|
|
"RTN","NHINVPSO",205,0)
|
|
I X="EXPIRED" S Y=0 ;keep, to renew?
|
|
"RTN","NHINVPSO",206,0)
|
|
I $P(X," ")="DISCONTINUED" S Y=0
|
|
"RTN","NHINVPSO",207,0)
|
|
Q Y
|
|
"RTN","NHINVPT")
|
|
0^25^B59592091^n/a
|
|
"RTN","NHINVPT",1,0)
|
|
NHINVPT ;SLC/MKB -- Patient demographics extract
|
|
"RTN","NHINVPT",2,0)
|
|
;;1.0;NHIN;**1**;Dec 01, 2009;Build 11
|
|
"RTN","NHINVPT",3,0)
|
|
;
|
|
"RTN","NHINVPT",4,0)
|
|
; External References DBIA#
|
|
"RTN","NHINVPT",5,0)
|
|
; ------------------- -----
|
|
"RTN","NHINVPT",6,0)
|
|
; ^DIC(42 10039
|
|
"RTN","NHINVPT",7,0)
|
|
; ^DPT 10035
|
|
"RTN","NHINVPT",8,0)
|
|
; DGCV 4156
|
|
"RTN","NHINVPT",9,0)
|
|
; DGMSTAPI 2716
|
|
"RTN","NHINVPT",10,0)
|
|
; DGNTAPI 3457
|
|
"RTN","NHINVPT",11,0)
|
|
; DGPFAPI 3860
|
|
"RTN","NHINVPT",12,0)
|
|
; DILFD 2055
|
|
"RTN","NHINVPT",13,0)
|
|
; DIQ 2056
|
|
"RTN","NHINVPT",14,0)
|
|
; MPIF001 2701
|
|
"RTN","NHINVPT",15,0)
|
|
; SDUTL3 1252
|
|
"RTN","NHINVPT",16,0)
|
|
; VADPT 10061
|
|
"RTN","NHINVPT",17,0)
|
|
; VAFCTFU1 2990
|
|
"RTN","NHINVPT",18,0)
|
|
; VASITE 10112
|
|
"RTN","NHINVPT",19,0)
|
|
; XUAF4 2171
|
|
"RTN","NHINVPT",20,0)
|
|
;
|
|
"RTN","NHINVPT",21,0)
|
|
; ------------ Get data from VistA ------------
|
|
"RTN","NHINVPT",22,0)
|
|
;
|
|
"RTN","NHINVPT",23,0)
|
|
EN(DFN,BEG,END,MAX,ID) ; -- find current patient demographics
|
|
"RTN","NHINVPT",24,0)
|
|
; [BEG,END,MAX,ID not currently used]
|
|
"RTN","NHINVPT",25,0)
|
|
S DFN=+$G(DFN) Q:DFN<1 ;invalid patient
|
|
"RTN","NHINVPT",26,0)
|
|
N PAT,SYS S SYS=$$SITE^VASITE
|
|
"RTN","NHINVPT",27,0)
|
|
D DEM,SVC,PRF,ATC,SUPP,ALIAS,FAC
|
|
"RTN","NHINVPT",28,0)
|
|
I $D(PAT)>9 D XML(.PAT)
|
|
"RTN","NHINVPT",29,0)
|
|
Q
|
|
"RTN","NHINVPT",30,0)
|
|
;
|
|
"RTN","NHINVPT",31,0)
|
|
DEM ;-demographic data
|
|
"RTN","NHINVPT",32,0)
|
|
N VADM,VA,VAERR,X
|
|
"RTN","NHINVPT",33,0)
|
|
S X=+$$GETICN^MPIF001(DFN) S:X>1 PAT("icn")=X
|
|
"RTN","NHINVPT",34,0)
|
|
D DEM^VADPT S X=VADM(1),PAT("fullName")=X
|
|
"RTN","NHINVPT",35,0)
|
|
S PAT("familyName")=$P(X,","),PAT("givenNames")=$P(X,",",2,99)
|
|
"RTN","NHINVPT",36,0)
|
|
S PAT("ssn")=$P(VADM(2),U),PAT("id")=DFN
|
|
"RTN","NHINVPT",37,0)
|
|
S:$D(VA("BID")) PAT("bid")=$E(X)_VA("BID")
|
|
"RTN","NHINVPT",38,0)
|
|
S PAT("dob")=+$P($P(VADM(3),U),".")
|
|
"RTN","NHINVPT",39,0)
|
|
S PAT("gender")=$P(VADM(5),U)
|
|
"RTN","NHINVPT",40,0)
|
|
S PAT("lrdfn")=+$G(^DPT(DFN,"LR"))
|
|
"RTN","NHINVPT",41,0)
|
|
S X=+$P($P(VADM(6),U),".") S:X PAT("died")=X
|
|
"RTN","NHINVPT",42,0)
|
|
S X=$$GET1^DIQ(38.1,DFN_",",2,"I") S:$L(X) PAT("sensitive")=X
|
|
"RTN","NHINVPT",43,0)
|
|
S X=+VADM(9) S:X PAT("religion")=X
|
|
"RTN","NHINVPT",44,0)
|
|
S X=$P(VADM(10),U,2) S:$L(X) PAT("maritalStatus")=$E(X)
|
|
"RTN","NHINVPT",45,0)
|
|
I VADM(11) D
|
|
"RTN","NHINVPT",46,0)
|
|
. N I S I=0
|
|
"RTN","NHINVPT",47,0)
|
|
. F S I=$O(VADM(11,I)) Q:I<1 S X=+VADM(11,I),PAT("ethnicity",X)=$$GET1^DIQ(10.2,X_",",4)
|
|
"RTN","NHINVPT",48,0)
|
|
I VADM(12) D
|
|
"RTN","NHINVPT",49,0)
|
|
. N I S I=0
|
|
"RTN","NHINVPT",50,0)
|
|
. F S I=$O(VADM(12,I)) Q:I<1 S X=+VADM(12,I),PAT("race",X)=$$GET1^DIQ(10,X_",",4)
|
|
"RTN","NHINVPT",51,0)
|
|
Q
|
|
"RTN","NHINVPT",52,0)
|
|
SVC ;-service data
|
|
"RTN","NHINVPT",53,0)
|
|
N VAEL,VASV,VAERR,X,Y,I,AO,IR,PGF,HNC,MST,CV
|
|
"RTN","NHINVPT",54,0)
|
|
D 7^VADPT
|
|
"RTN","NHINVPT",55,0)
|
|
S PAT("veteran")=VAEL(4)
|
|
"RTN","NHINVPT",56,0)
|
|
S PAT("sc")=+VAEL(3) S:VAEL(3) PAT("scPercent")=+$P(VAEL(3),U,2)
|
|
"RTN","NHINVPT",57,0)
|
|
;
|
|
"RTN","NHINVPT",58,0)
|
|
; exposures
|
|
"RTN","NHINVPT",59,0)
|
|
S AO=VASV(2),IR=VASV(3)
|
|
"RTN","NHINVPT",60,0)
|
|
S X=$P($G(^DPT(DFN,.322)),U,10),PGF=$S(X="Y":1,X="N":0,1:"")
|
|
"RTN","NHINVPT",61,0)
|
|
S X=$$GETCUR^DGNTAPI(DFN,"HNC"),X=+($G(HNC("STAT")))
|
|
"RTN","NHINVPT",62,0)
|
|
S HNC=$S(X=4:1,X=5:1,X=1:0,X=6:0,1:"")
|
|
"RTN","NHINVPT",63,0)
|
|
S X=$P($$GETSTAT^DGMSTAPI(DFN),U,2),MST=$S(X="Y":1,X="N":0,1:"")
|
|
"RTN","NHINVPT",64,0)
|
|
S X=$$CVEDT^DGCV(DFN),CV=$S(+X<0:"",+X=0:0,$P(X,U,3):1,1:0)
|
|
"RTN","NHINVPT",65,0)
|
|
S PAT("exposures")=AO_U_IR_U_PGF_U_HNC_U_MST_U_CV
|
|
"RTN","NHINVPT",66,0)
|
|
;
|
|
"RTN","NHINVPT",67,0)
|
|
; rated disabilities [see DGRPDB]
|
|
"RTN","NHINVPT",68,0)
|
|
S I=0 F S I=$O(^DPT(DFN,.372,I)) Q:I<1 D
|
|
"RTN","NHINVPT",69,0)
|
|
. N DIS S DIS=$G(^DPT(DFN,.372,I,0))
|
|
"RTN","NHINVPT",70,0)
|
|
. S Y=$$GET1^DIQ(31,+DIS_",",.01)
|
|
"RTN","NHINVPT",71,0)
|
|
. S PAT("disability",+DIS)=Y_U_$P(DIS,U,2,3) ;name^%^sc
|
|
"RTN","NHINVPT",72,0)
|
|
Q
|
|
"RTN","NHINVPT",73,0)
|
|
PRF ;-patient record flags
|
|
"RTN","NHINVPT",74,0)
|
|
N NHINPF,I,NAME,TEXT
|
|
"RTN","NHINVPT",75,0)
|
|
Q:'$$GETACT^DGPFAPI(DFN,"NHINPF")
|
|
"RTN","NHINVPT",76,0)
|
|
S I=0 F S I=$O(NHINPF(I)) Q:I<1 D
|
|
"RTN","NHINVPT",77,0)
|
|
. S NAME=$P(NHINPF(I,"FLAG"),U,2)
|
|
"RTN","NHINVPT",78,0)
|
|
. M TEXT=NHINPF(I,"NARR")
|
|
"RTN","NHINVPT",79,0)
|
|
. S PAT("flag",I)=NAME_U_$$STRING^NHINV(.TEXT)
|
|
"RTN","NHINVPT",80,0)
|
|
Q
|
|
"RTN","NHINVPT",81,0)
|
|
ATC ;-address & telecom
|
|
"RTN","NHINVPT",82,0)
|
|
N VAPA,I,X
|
|
"RTN","NHINVPT",83,0)
|
|
S VAPA("P")="" D ADD^VADPT ;permanent address
|
|
"RTN","NHINVPT",84,0)
|
|
S X="" F I=1:1:4 S X=X_VAPA(I)_U
|
|
"RTN","NHINVPT",85,0)
|
|
S X=X_$P(VAPA(5),U,2)_U_$P(VAPA(11),U,2)
|
|
"RTN","NHINVPT",86,0)
|
|
S PAT("address")=X ;street1^st2^st3^city^state^zip
|
|
"RTN","NHINVPT",87,0)
|
|
S X=VAPA(8)_U_$$GET1^DIQ(2,DFN_",",.134)_U_$$GET1^DIQ(2,DFN_",",.132)
|
|
"RTN","NHINVPT",88,0)
|
|
S PAT("telecom")=X ;home^cell^work phones
|
|
"RTN","NHINVPT",89,0)
|
|
Q
|
|
"RTN","NHINVPT",90,0)
|
|
SUPP ;-support contacts
|
|
"RTN","NHINVPT",91,0)
|
|
N VAOA,A,I,X,TYPE
|
|
"RTN","NHINVPT",92,0)
|
|
F A="",1 K VAOA D
|
|
"RTN","NHINVPT",93,0)
|
|
. S:A VAOA("A")=A D OAD^VADPT Q:'$L($G(VAOA(9)))
|
|
"RTN","NHINVPT",94,0)
|
|
. S TYPE=$S(A=1:"ECON",1:"NOK")
|
|
"RTN","NHINVPT",95,0)
|
|
. S PAT("support",TYPE)=VAOA(9)_U_VAOA(10) ;name^relationship
|
|
"RTN","NHINVPT",96,0)
|
|
. S X="" F I=1:1:4 S X=X_VAOA(I)_U
|
|
"RTN","NHINVPT",97,0)
|
|
. S X=X_$P(VAOA(5),U,2)_U_$P(VAOA(11),U,2)
|
|
"RTN","NHINVPT",98,0)
|
|
. S PAT("support",TYPE,"address")=X ;street1^st2^st3^city^state^zip
|
|
"RTN","NHINVPT",99,0)
|
|
. S I=$S(A=1:.33011,1:.21011),X=VAOA(8)_U_U_$$GET1^DIQ(2,DFN_",",I)
|
|
"RTN","NHINVPT",100,0)
|
|
. S PAT("support",TYPE,"telecom")=X ;home^cell^work phones
|
|
"RTN","NHINVPT",101,0)
|
|
Q
|
|
"RTN","NHINVPT",102,0)
|
|
ALIAS ;-other names used
|
|
"RTN","NHINVPT",103,0)
|
|
N I,X
|
|
"RTN","NHINVPT",104,0)
|
|
S I=0 F S I=$O(^DPT(DFN,.01,I)) Q:I<1 S X=$G(^(I,0)) D
|
|
"RTN","NHINVPT",105,0)
|
|
. S PAT("alias",I)=$P(X,U)
|
|
"RTN","NHINVPT",106,0)
|
|
Q
|
|
"RTN","NHINVPT",107,0)
|
|
FAC ;-treating facilities [see FACLIST^ORWCIRN]
|
|
"RTN","NHINVPT",108,0)
|
|
N IFN S DFN=+$G(DFN) Q:DFN<1
|
|
"RTN","NHINVPT",109,0)
|
|
N NHINY,HOME,I,X,IEN
|
|
"RTN","NHINVPT",110,0)
|
|
I $L($T(TFL^VAFCTFU1)) D TFL^VAFCTFU1(.NHINY,DFN)
|
|
"RTN","NHINVPT",111,0)
|
|
I $P($G(NHINY(1)),U)<0 D Q ;not setup
|
|
"RTN","NHINVPT",112,0)
|
|
. S X=$$SITE^VASITE,PAT("facility",+X)=$P(X,U,3)_U_$P(X,U,2)
|
|
"RTN","NHINVPT",113,0)
|
|
S HOME=+$P($G(^DPT(DFN,"MPI")),U,3) ;home facility
|
|
"RTN","NHINVPT",114,0)
|
|
S I=0 F S I=$O(NHINY(I)) Q:I<1 D
|
|
"RTN","NHINVPT",115,0)
|
|
. S X=NHINY(I) Q:$P(X,U)="" ;unknown
|
|
"RTN","NHINVPT",116,0)
|
|
. S IEN=+$$IEN^XUAF4($P(X,U))
|
|
"RTN","NHINVPT",117,0)
|
|
. I +X=776!(+X=200) S $P(X,U,2)="DEPT. OF DEFENSE"
|
|
"RTN","NHINVPT",118,0)
|
|
. S PAT("facility",IEN)=$P(X,U,1,3) ;stn# ^ name ^ last date
|
|
"RTN","NHINVPT",119,0)
|
|
. I IEN=HOME S $P(PAT("facility",IEN),U,4)=1
|
|
"RTN","NHINVPT",120,0)
|
|
Q
|
|
"RTN","NHINVPT",121,0)
|
|
;
|
|
"RTN","NHINVPT",122,0)
|
|
INPT ;-current inpt status data
|
|
"RTN","NHINVPT",123,0)
|
|
N ADM,X
|
|
"RTN","NHINVPT",124,0)
|
|
S ADM=+$G(^DPT(DFN,.105)) I ADM D
|
|
"RTN","NHINVPT",125,0)
|
|
. N VAIN,VAERR,HLOC,SVC
|
|
"RTN","NHINVPT",126,0)
|
|
. D INP^VADPT S PAT("admitted")=ADM_U_+VAIN(7)
|
|
"RTN","NHINVPT",127,0)
|
|
. S PAT("ward")=VAIN(4),PAT("roomBed")=VAIN(5)
|
|
"RTN","NHINVPT",128,0)
|
|
. S HLOC=+$G(^DIC(42,+VAIN(4),44)),SVC=$P($G(^(0)),U,3)
|
|
"RTN","NHINVPT",129,0)
|
|
. S PAT("location")=HLOC_U_$P(VAIN(4),U,2)
|
|
"RTN","NHINVPT",130,0)
|
|
. S:$L(SVC) PAT("locSvc")=SVC_U_$$EXTERNAL^DILFD(42,.03,,SVC)
|
|
"RTN","NHINVPT",131,0)
|
|
. S PAT("specialty")=VAIN(3)
|
|
"RTN","NHINVPT",132,0)
|
|
. S PAT("attending")=VAIN(11)
|
|
"RTN","NHINVPT",133,0)
|
|
. S X=$$FAC^NHINV(HLOC),PAT("site")=X
|
|
"RTN","NHINVPT",134,0)
|
|
S PAT("inpatient")=$S(ADM:"true",1:"false")
|
|
"RTN","NHINVPT",135,0)
|
|
S X=$$OUTPTPR^SDUTL3(DFN) S:X PAT("pcProvider")=X
|
|
"RTN","NHINVPT",136,0)
|
|
S X=$$OUTPTTM^SDUTL3(DFN) S:X PAT("pcTeam")=X
|
|
"RTN","NHINVPT",137,0)
|
|
Q
|
|
"RTN","NHINVPT",138,0)
|
|
;
|
|
"RTN","NHINVPT",139,0)
|
|
; ------------ Return data to middle tier ------------
|
|
"RTN","NHINVPT",140,0)
|
|
;
|
|
"RTN","NHINVPT",141,0)
|
|
XML(ITEM) ; -- Return patient data as XML in @NHIN@(n)
|
|
"RTN","NHINVPT",142,0)
|
|
; as <element code='123' displayName='ABC' />
|
|
"RTN","NHINVPT",143,0)
|
|
N ATT,X,Y,I,ID
|
|
"RTN","NHINVPT",144,0)
|
|
D ADD("<patient>") S NHINTOTL=$G(NHINTOTL)+1
|
|
"RTN","NHINVPT",145,0)
|
|
S ATT="" F S ATT=$O(ITEM(ATT)) Q:ATT="" D D:$L(Y) ADD(Y)
|
|
"RTN","NHINVPT",146,0)
|
|
. I ATT="exposures" D:X["1" S Y="" Q
|
|
"RTN","NHINVPT",147,0)
|
|
.. S I=0,Y="<exposures>" D ADD(Y)
|
|
"RTN","NHINVPT",148,0)
|
|
.. F ID="AO","IR","PG","HNC","MST","CV" S I=I+1 I $P(X,U,I) S Y="<exposure value='"_ID_"' />" D ADD(Y)
|
|
"RTN","NHINVPT",149,0)
|
|
.. D ADD("</exposures>")
|
|
"RTN","NHINVPT",150,0)
|
|
. I $L($O(ITEM(ATT,""))) D Q ;multiples
|
|
"RTN","NHINVPT",151,0)
|
|
.. S ID=$S($E(ATT,$L(ATT))="s":ATT_"es",$E(ATT,$L(ATT))="y":$E(ATT,1,$L(ATT)-1)_"ies",1:ATT_"s")
|
|
"RTN","NHINVPT",152,0)
|
|
.. D ADD("<"_ID_">")
|
|
"RTN","NHINVPT",153,0)
|
|
.. S I="" F S I=$O(ITEM(ATT,I)) Q:I="" D D:$L(Y) ADD(Y)
|
|
"RTN","NHINVPT",154,0)
|
|
... S X=ITEM(ATT,I),Y="<"_ATT_" "
|
|
"RTN","NHINVPT",155,0)
|
|
... I ATT="support" D S Y="" Q
|
|
"RTN","NHINVPT",156,0)
|
|
.... S Y=Y_"contactType='"_I_"' name='"_$$ESC^NHINV($P(X,U))_$S($L($P(X,U,2)):"' relationship='"_$$ESC^NHINV($P(X,U,2)),1:"")_"' >" D ADD(Y)
|
|
"RTN","NHINVPT",157,0)
|
|
.... S X=$G(ITEM(ATT,I,"address")) I $L(X) D ADDR(X)
|
|
"RTN","NHINVPT",158,0)
|
|
.... S X=$G(ITEM(ATT,I,"telecom")) I $L(X) D PHONE(X)
|
|
"RTN","NHINVPT",159,0)
|
|
.... D ADD("</support>")
|
|
"RTN","NHINVPT",160,0)
|
|
... I ATT="alias" S Y=Y_"fullName='"_$$ESC^NHINV(X)_$S(X[",":"' familyName='"_$$ESC^NHINV($P(X,","))_"' givenNames='"_$$ESC^NHINV($P(X,",",2,99)),1:"")_"' />" Q
|
|
"RTN","NHINVPT",161,0)
|
|
... I ATT="flag" S Y=Y_"name='"_$$ESC^NHINV($P(X,U))_"' text='"_$$ESC^NHINV($P(X,U,2))_"' />" Q
|
|
"RTN","NHINVPT",162,0)
|
|
... I ATT="facility" S Y=Y_"code='"_$P(X,U)_"' name='"_$$ESC^NHINV($P(X,U,2))_$S($P(X,U,3):"' latestDate='"_$P($P(X,U,3),"."),1:"")_$S($P(X,U,4):"' homeSite='1",1:"")_"' />" Q
|
|
"RTN","NHINVPT",163,0)
|
|
... I ATT="disability" S Y=Y_"vaCode='"_I_"' printName='"_$$ESC^NHINV($P(X,U))_$S($P(X,U,2):"' sc='"_$P(X,U,2)_"' scPercent='"_$P(X,U,3),1:"")_"' />" Q
|
|
"RTN","NHINVPT",164,0)
|
|
... S Y=Y_"value='"_$$ESC^NHINV(ITEM(ATT,I))_"' />"
|
|
"RTN","NHINVPT",165,0)
|
|
.. D ADD("</"_ID_">") S Y=""
|
|
"RTN","NHINVPT",166,0)
|
|
. S X=$G(ITEM(ATT)),Y="" Q:'$L(X)
|
|
"RTN","NHINVPT",167,0)
|
|
. I ATT="address" D ADDR(X) S Y="" Q
|
|
"RTN","NHINVPT",168,0)
|
|
. I ATT="telecom" D PHONE(X) S Y="" Q
|
|
"RTN","NHINVPT",169,0)
|
|
. I X'["^" S Y="<"_ATT_" value='"_$$ESC^NHINV(X)_"' />" Q
|
|
"RTN","NHINVPT",170,0)
|
|
. S Y="<"_ATT_" code='"_$P(X,U)_"' name='"_$$ESC^NHINV($P(X,U,2))_"' />"
|
|
"RTN","NHINVPT",171,0)
|
|
D ADD("</patient>")
|
|
"RTN","NHINVPT",172,0)
|
|
Q
|
|
"RTN","NHINVPT",173,0)
|
|
;
|
|
"RTN","NHINVPT",174,0)
|
|
ADDR(X) ; -- XML address node from X=street1^st2^st3^city^state^zip
|
|
"RTN","NHINVPT",175,0)
|
|
N I,Y Q:$L(X)'>5 ;no data
|
|
"RTN","NHINVPT",176,0)
|
|
S Y="<address"
|
|
"RTN","NHINVPT",177,0)
|
|
F I=1,2,3 I $L($P(X,U,I)) S Y=Y_" streetLine"_I_"='"_$$ESC^NHINV($P(X,U,I))_"'"
|
|
"RTN","NHINVPT",178,0)
|
|
I $L($P(X,U,4)) S Y=Y_" city='"_$$ESC^NHINV($P(X,U,4))_"'"
|
|
"RTN","NHINVPT",179,0)
|
|
I $L($P(X,U,5)) S Y=Y_" stateProvince='"_$P(X,U,5)_"'"
|
|
"RTN","NHINVPT",180,0)
|
|
I $L($P(X,U,6)) S Y=Y_" postalCode='"_$P(X,U,6)_"'"
|
|
"RTN","NHINVPT",181,0)
|
|
S Y=Y_" />" D ADD(Y)
|
|
"RTN","NHINVPT",182,0)
|
|
Q
|
|
"RTN","NHINVPT",183,0)
|
|
;
|
|
"RTN","NHINVPT",184,0)
|
|
PHONE(X) ; -- XML telecom node from X=home^cell^work numbers
|
|
"RTN","NHINVPT",185,0)
|
|
N I,Y Q:$L(X)'>2 ;no data
|
|
"RTN","NHINVPT",186,0)
|
|
D ADD("<telecomList>")
|
|
"RTN","NHINVPT",187,0)
|
|
I $L($P(X,U,1)) S Y="<telecom usageType='H' value='"_$P(X,U,1)_"' />" D ADD(Y)
|
|
"RTN","NHINVPT",188,0)
|
|
I $L($P(X,U,2)) S Y="<telecom usageType='MC' value='"_$P(X,U,2)_"' />" D ADD(Y)
|
|
"RTN","NHINVPT",189,0)
|
|
I $L($P(X,U,3)) S Y="<telecom usageType='WP' value='"_$P(X,U,3)_"' />" D ADD(Y)
|
|
"RTN","NHINVPT",190,0)
|
|
D ADD("</telecomList>")
|
|
"RTN","NHINVPT",191,0)
|
|
Q
|
|
"RTN","NHINVPT",192,0)
|
|
;
|
|
"RTN","NHINVPT",193,0)
|
|
ADD(X) ; Add a line @NHIN@(n)=X
|
|
"RTN","NHINVPT",194,0)
|
|
S NHINI=$G(NHINI)+1
|
|
"RTN","NHINVPT",195,0)
|
|
S @NHIN@(NHINI)=X
|
|
"RTN","NHINVPT",196,0)
|
|
Q
|
|
"RTN","NHINVRA")
|
|
0^11^B18363736^n/a
|
|
"RTN","NHINVRA",1,0)
|
|
NHINVRA ;SLC/MKB -- Radiology extract
|
|
"RTN","NHINVRA",2,0)
|
|
;;1.0;NHIN;**1**;Oct 25, 2010;Build 11
|
|
"RTN","NHINVRA",3,0)
|
|
;
|
|
"RTN","NHINVRA",4,0)
|
|
; External References DBIA#
|
|
"RTN","NHINVRA",5,0)
|
|
; ------------------- -----
|
|
"RTN","NHINVRA",6,0)
|
|
; ^SC( 10040
|
|
"RTN","NHINVRA",7,0)
|
|
; ^VA(200 10060
|
|
"RTN","NHINVRA",8,0)
|
|
; DIQ 2056
|
|
"RTN","NHINVRA",9,0)
|
|
; ICPTCOD 1995
|
|
"RTN","NHINVRA",10,0)
|
|
; RAO7PC1 2043
|
|
"RTN","NHINVRA",11,0)
|
|
; RAO7PC3 2877
|
|
"RTN","NHINVRA",12,0)
|
|
;
|
|
"RTN","NHINVRA",13,0)
|
|
; ------------ Get exam(s) from VistA ------------
|
|
"RTN","NHINVRA",14,0)
|
|
;
|
|
"RTN","NHINVRA",15,0)
|
|
EN(DFN,BEG,END,MAX,ID) ; -- find patient's radiology exams
|
|
"RTN","NHINVRA",16,0)
|
|
N NHITM,NHICNT,NHXID
|
|
"RTN","NHINVRA",17,0)
|
|
S DFN=+$G(DFN) Q:DFN<1
|
|
"RTN","NHINVRA",18,0)
|
|
S BEG=$G(BEG,1410101),END=$G(END,9999998),MAX=$G(MAX,999999)
|
|
"RTN","NHINVRA",19,0)
|
|
K ^TMP($J,"RAE1") D EN1^RAO7PC1(DFN,BEG,END,MAX)
|
|
"RTN","NHINVRA",20,0)
|
|
;
|
|
"RTN","NHINVRA",21,0)
|
|
; get exam(s)
|
|
"RTN","NHINVRA",22,0)
|
|
I $G(ID) D EN1(ID,.NHITM),XML(.NHITM) Q
|
|
"RTN","NHINVRA",23,0)
|
|
;
|
|
"RTN","NHINVRA",24,0)
|
|
; get all exams
|
|
"RTN","NHINVRA",25,0)
|
|
S NHICNT=0,NHXID=""
|
|
"RTN","NHINVRA",26,0)
|
|
F S NHXID=$O(^TMP($J,"RAE1",DFN,NHXID)) Q:NHXID="" D Q:NHICNT'<MAX
|
|
"RTN","NHINVRA",27,0)
|
|
. K NHITM D EN1(NHXID,.NHITM) Q:'$D(NHITM)
|
|
"RTN","NHINVRA",28,0)
|
|
. D XML(.NHITM) S NHICNT=NHICNT+1
|
|
"RTN","NHINVRA",29,0)
|
|
K ^TMP($J,"RAE1")
|
|
"RTN","NHINVRA",30,0)
|
|
Q
|
|
"RTN","NHINVRA",31,0)
|
|
;
|
|
"RTN","NHINVRA",32,0)
|
|
EN1(ID,EXM) ; -- return an exam in EXM("attribute")=value
|
|
"RTN","NHINVRA",33,0)
|
|
; Expects ^TMP($J,"RAE1",DFN,ID) from EN1^RAO7PC1
|
|
"RTN","NHINVRA",34,0)
|
|
N VPRN,VPR,X0,DATE,LOC,X,Y,IENS,NHMOD K EXM
|
|
"RTN","NHINVRA",35,0)
|
|
S X0=$G(^TMP($J,"RAE1",DFN,ID))
|
|
"RTN","NHINVRA",36,0)
|
|
S EXM("id")=ID,EXM("name")=$P(X0,U),EXM("case")=$P(X0,U,2)
|
|
"RTN","NHINVRA",37,0)
|
|
S DATE=9999999.9999-+ID,EXM("dateTime")=DATE
|
|
"RTN","NHINVRA",38,0)
|
|
I $P(X0,U,5) S EXM("document",1)=ID_U_$P(X0,U)_"^^"_$P(X0,U,3) ;id^localTitle^^status, if rpt exists
|
|
"RTN","NHINVRA",39,0)
|
|
S:$L($P(X0,U,6)) EXM("status")=$P($P(X0,U,6),"~",2)
|
|
"RTN","NHINVRA",40,0)
|
|
S X=$P(X0,U,7),LOC="" I $L(X) D
|
|
"RTN","NHINVRA",41,0)
|
|
. S LOC=+$O(^SC("B",X,0)),EXM("location")=LOC_U_X
|
|
"RTN","NHINVRA",42,0)
|
|
S EXM("facility")=$$FAC^NHINV(LOC)
|
|
"RTN","NHINVRA",43,0)
|
|
I $L($P(X0,U,8)) S X=$TR($P(X0,U,8),"~","^"),EXM("imagingType")=X
|
|
"RTN","NHINVRA",44,0)
|
|
S IENS=$P(ID,"-",2)_","_+ID_","_DFN_","
|
|
"RTN","NHINVRA",45,0)
|
|
S X=$P(X0,U,10) I X D
|
|
"RTN","NHINVRA",46,0)
|
|
. S EXM("type")=$$CPT(X)
|
|
"RTN","NHINVRA",47,0)
|
|
. I $D(^TMP($J,"RAE1",DFN,ID,"CMOD")) M EXM("modifier")=^("CMOD")
|
|
"RTN","NHINVRA",48,0)
|
|
S EXM("hasImages")=$S($P(X0,U,12)="Y":1,1:0)
|
|
"RTN","NHINVRA",49,0)
|
|
I $P(X0,U,4)="Y"!($P(X0,U,9)="Y") S EXM("interpretation")="ABNORMAL"
|
|
"RTN","NHINVRA",50,0)
|
|
S EXM("encounter")=$$GET1^DIQ(70.03,IENS,27,"I")
|
|
"RTN","NHINVRA",51,0)
|
|
S X=$$GET1^DIQ(70.03,IENS,15,"I") ;S:'X X=$$GET1^DIQ(70.03,IENS,12,"I")
|
|
"RTN","NHINVRA",52,0)
|
|
I X S EXM("provider")=X_U_$P($G(^VA(200,X,0)),U)
|
|
"RTN","NHINVRA",53,0)
|
|
S EXM("category")="RA"
|
|
"RTN","NHINVRA",54,0)
|
|
Q
|
|
"RTN","NHINVRA",55,0)
|
|
;
|
|
"RTN","NHINVRA",56,0)
|
|
CPT(IEN) ; -- return code^description for CPT code, or "^" if error
|
|
"RTN","NHINVRA",57,0)
|
|
N X0,NHX,N,I,X,Y S IEN=+$G(IEN)
|
|
"RTN","NHINVRA",58,0)
|
|
S X0=$$CPT^ICPTCOD(IEN) I X0<0 Q "^"
|
|
"RTN","NHINVRA",59,0)
|
|
S Y=$P(X0,U,2,3) ;CPT Code^Short Name
|
|
"RTN","NHINVRA",60,0)
|
|
S N=$$CPTD^ICPTCOD($P(Y,U),"NHX") ;CPT Description
|
|
"RTN","NHINVRA",61,0)
|
|
I N>0,$L($G(NHX(1))) D
|
|
"RTN","NHINVRA",62,0)
|
|
. S X=$G(NHX(1)),I=1
|
|
"RTN","NHINVRA",63,0)
|
|
. F S I=$O(NHX(I)) Q:I<1 Q:NHX(I)=" " S X=X_" "_NHX(I)
|
|
"RTN","NHINVRA",64,0)
|
|
. S $P(Y,U,2)=X
|
|
"RTN","NHINVRA",65,0)
|
|
Q Y
|
|
"RTN","NHINVRA",66,0)
|
|
;
|
|
"RTN","NHINVRA",67,0)
|
|
RPT(DFN,ID,RPT) ; -- return report as a TIU document
|
|
"RTN","NHINVRA",68,0)
|
|
S DFN=+$G(DFN),ID=$G(ID) Q:DFN<1 Q:ID<1
|
|
"RTN","NHINVRA",69,0)
|
|
N EXAM,CASE,PROC,X0,I,X,Y,IENS
|
|
"RTN","NHINVRA",70,0)
|
|
S EXAM=DFN_U_$TR(ID,"-","^") D
|
|
"RTN","NHINVRA",71,0)
|
|
. N DFN D EN3^RAO7PC3(EXAM)
|
|
"RTN","NHINVRA",72,0)
|
|
S CASE=$O(^TMP($J,"RAE3",DFN,0)),PROC=$O(^(CASE,"")),X0=$G(^(PROC))
|
|
"RTN","NHINVRA",73,0)
|
|
S I=$O(^TMP($J,"RAE3",DFN,CASE,PROC,0)),Y=$G(^(I))
|
|
"RTN","NHINVRA",74,0)
|
|
F S I=$O(^TMP($J,"RAE3",DFN,CASE,PROC,I)) Q:I<1 S X=^(I),Y=Y_$C(13,10)_X
|
|
"RTN","NHINVRA",75,0)
|
|
S RPT("id")=ID,RPT("content")=Y
|
|
"RTN","NHINVRA",76,0)
|
|
S X=9999999.9999-(+ID),RPT("referenceDateTime")=X
|
|
"RTN","NHINVRA",77,0)
|
|
S RPT("localTitle")=PROC,RPT("status")=$P(X0,U)
|
|
"RTN","NHINVRA",78,0)
|
|
S IENS=+ID_","_DFN_",",X=$$GET1^DIQ(70.02,IENS,4,"I")
|
|
"RTN","NHINVRA",79,0)
|
|
S RPT("facility")=$$FAC^NHINV(X)
|
|
"RTN","NHINVRA",80,0)
|
|
S IENS=$P(ID,"-",2)_","_IENS
|
|
"RTN","NHINVRA",81,0)
|
|
S RPT("encounter")=$$GET1^DIQ(70.03,IENS,27,"I")
|
|
"RTN","NHINVRA",82,0)
|
|
S X=$$GET1^DIQ(70.03,IENS,15,"I") S:'X X=$$GET1^DIQ(70.03,IENS,12,"I")
|
|
"RTN","NHINVRA",83,0)
|
|
I X S RPT("clinician",1)=X_U_$P($G(^VA(200,X,0)),U)
|
|
"RTN","NHINVRA",84,0)
|
|
K ^TMP($J,"RAE3",DFN)
|
|
"RTN","NHINVRA",85,0)
|
|
Q
|
|
"RTN","NHINVRA",86,0)
|
|
;
|
|
"RTN","NHINVRA",87,0)
|
|
; ------------ Return data to middle tier ------------
|
|
"RTN","NHINVRA",88,0)
|
|
;
|
|
"RTN","NHINVRA",89,0)
|
|
XML(EXM) ; -- Return exams as XML
|
|
"RTN","NHINVRA",90,0)
|
|
N ATT,X,Y,NAMES
|
|
"RTN","NHINVRA",91,0)
|
|
D ADD("<radiology>") S NHINTOTL=$G(NHINTOTL)+1
|
|
"RTN","NHINVRA",92,0)
|
|
S ATT="" F S ATT=$O(EXM(ATT)) Q:ATT="" D D:$L(Y) ADD(Y)
|
|
"RTN","NHINVRA",93,0)
|
|
. S NAMES=$S(ATT="document":"id^localTitle^nationalTitle^status^Z",1:"code^name^Z")
|
|
"RTN","NHINVRA",94,0)
|
|
. I $O(EXM(ATT,0)) D S Y="" Q ;multiples
|
|
"RTN","NHINVRA",95,0)
|
|
.. D ADD("<"_ATT_"s>")
|
|
"RTN","NHINVRA",96,0)
|
|
.. S I=0 F S I=$O(EXM(ATT,I)) Q:I<1 D
|
|
"RTN","NHINVRA",97,0)
|
|
... S X=$G(EXM(ATT,I))
|
|
"RTN","NHINVRA",98,0)
|
|
... S Y="<"_ATT_" "_$$LOOP_"/>" D ADD(Y)
|
|
"RTN","NHINVRA",99,0)
|
|
.. D ADD("</"_ATT_"s>")
|
|
"RTN","NHINVRA",100,0)
|
|
. S X=$G(EXM(ATT)),Y="" Q:'$L(X)
|
|
"RTN","NHINVRA",101,0)
|
|
. I X'["^" S Y="<"_ATT_" value='"_$$ESC^NHINV(X)_"' />" Q
|
|
"RTN","NHINVRA",102,0)
|
|
. I $L(X)>1 S Y="<"_ATT_" "_$$LOOP_"/>"
|
|
"RTN","NHINVRA",103,0)
|
|
D ADD("</radiology>")
|
|
"RTN","NHINVRA",104,0)
|
|
Q
|
|
"RTN","NHINVRA",105,0)
|
|
;
|
|
"RTN","NHINVRA",106,0)
|
|
LOOP() ; -- build sub-items string from NAMES and X
|
|
"RTN","NHINVRA",107,0)
|
|
N STR,P,TAG S STR=""
|
|
"RTN","NHINVRA",108,0)
|
|
F P=1:1 S TAG=$P(NAMES,U,P) Q:TAG="Z" I $L($P(X,U,P)) S STR=STR_TAG_"='"_$$ESC^NHINV($P(X,U,P))_"' "
|
|
"RTN","NHINVRA",109,0)
|
|
Q STR
|
|
"RTN","NHINVRA",110,0)
|
|
;
|
|
"RTN","NHINVRA",111,0)
|
|
ADD(X) ; -- Add a line @NHIN@(n)=X
|
|
"RTN","NHINVRA",112,0)
|
|
S NHINI=$G(NHINI)+1
|
|
"RTN","NHINVRA",113,0)
|
|
S @NHIN@(NHINI)=X
|
|
"RTN","NHINVRA",114,0)
|
|
Q
|
|
"RTN","NHINVSIT")
|
|
0^15^B60599762^n/a
|
|
"RTN","NHINVSIT",1,0)
|
|
NHINVSIT ;SLC/MKB -- Visit/Encounter extract
|
|
"RTN","NHINVSIT",2,0)
|
|
;;1.0;NHIN;**1**;Oct 25, 2010;Build 11
|
|
"RTN","NHINVSIT",3,0)
|
|
;
|
|
"RTN","NHINVSIT",4,0)
|
|
; External References DBIA#
|
|
"RTN","NHINVSIT",5,0)
|
|
; ------------------- -----
|
|
"RTN","NHINVSIT",6,0)
|
|
; ^AUPNVSIT 2028
|
|
"RTN","NHINVSIT",7,0)
|
|
; ^DIC(40.7 557
|
|
"RTN","NHINVSIT",8,0)
|
|
; ^DIC(42 10039
|
|
"RTN","NHINVSIT",9,0)
|
|
; ^SC 10040
|
|
"RTN","NHINVSIT",10,0)
|
|
; ^SCE 2065
|
|
"RTN","NHINVSIT",11,0)
|
|
; ^VA(200 10060
|
|
"RTN","NHINVSIT",12,0)
|
|
; DIC 2051
|
|
"RTN","NHINVSIT",13,0)
|
|
; DIQ 2056
|
|
"RTN","NHINVSIT",14,0)
|
|
; ICDCODE 3990
|
|
"RTN","NHINVSIT",15,0)
|
|
; ICPTCOD 1995
|
|
"RTN","NHINVSIT",16,0)
|
|
; PXAPI,^TMP("PXKENC",$J 1894,1895
|
|
"RTN","NHINVSIT",17,0)
|
|
; VADPT 10061
|
|
"RTN","NHINVSIT",18,0)
|
|
; XUAF4 2171
|
|
"RTN","NHINVSIT",19,0)
|
|
;
|
|
"RTN","NHINVSIT",20,0)
|
|
; ------------ Get encounter(s) from VistA ------------
|
|
"RTN","NHINVSIT",21,0)
|
|
;
|
|
"RTN","NHINVSIT",22,0)
|
|
EN(DFN,BEG,END,MAX,ID) ; -- find patient's visits and appointments
|
|
"RTN","NHINVSIT",23,0)
|
|
N NHICNT,NHITM,NHDT,NHLOC,NHDA
|
|
"RTN","NHINVSIT",24,0)
|
|
S DFN=+$G(DFN) Q:DFN<1
|
|
"RTN","NHINVSIT",25,0)
|
|
S BEG=$G(BEG,1410101),END=$G(END,9999998),MAX=$G(MAX,999999)
|
|
"RTN","NHINVSIT",26,0)
|
|
;
|
|
"RTN","NHINVSIT",27,0)
|
|
; get one visit
|
|
"RTN","NHINVSIT",28,0)
|
|
I $G(ID) D EN1(ID,.NHITM),XML(.NHITM) Q
|
|
"RTN","NHINVSIT",29,0)
|
|
;
|
|
"RTN","NHINVSIT",30,0)
|
|
; -- get all visits
|
|
"RTN","NHINVSIT",31,0)
|
|
I END,END'["." S END=END_".24" ;assume end of day
|
|
"RTN","NHINVSIT",32,0)
|
|
S NHICNT=0
|
|
"RTN","NHINVSIT",33,0)
|
|
;F S IDX=$Q(@IDX,-1) Q:DFN'=$P(IDX,",",2) Q:$P(IDX,",",3)<BEG I $P(IDX,",",5)["P" D
|
|
"RTN","NHINVSIT",34,0)
|
|
S NHDT=END F S NHDT=$O(^AUPNVSIT("AET",DFN,NHDT),-1) Q:NHDT<BEG D Q:NHICNT'<MAX
|
|
"RTN","NHINVSIT",35,0)
|
|
. S NHLOC=0 F S NHLOC=$O(^AUPNVSIT("AET",DFN,NHDT,NHLOC)) Q:NHLOC<1 D
|
|
"RTN","NHINVSIT",36,0)
|
|
.. S NHDA=0 F S NHDA=$O(^AUPNVSIT("AET",DFN,NHDT,NHLOC,"P",NHDA)) Q:NHDA<1 D
|
|
"RTN","NHINVSIT",37,0)
|
|
... K NHITM D EN1(NHDA,.NHITM) Q:'$D(NHITM)
|
|
"RTN","NHINVSIT",38,0)
|
|
... D XML(.NHITM) S NHICNT=NHICNT+1
|
|
"RTN","NHINVSIT",39,0)
|
|
Q
|
|
"RTN","NHINVSIT",40,0)
|
|
;
|
|
"RTN","NHINVSIT",41,0)
|
|
ENAA(DFN,BEG,END,MAX,ID) ; -- find patient's visits and appointments [AA]
|
|
"RTN","NHINVSIT",42,0)
|
|
N IDT,DA,NHICNT,NHITM
|
|
"RTN","NHINVSIT",43,0)
|
|
S DFN=+$G(DFN) Q:DFN<1
|
|
"RTN","NHINVSIT",44,0)
|
|
S BEG=$G(BEG,1410101),END=$G(END,9999998),MAX=$G(MAX,999999)
|
|
"RTN","NHINVSIT",45,0)
|
|
I $G(ID) D EN1(ID,.NHITM),XML(.NHITM) Q ;one visit
|
|
"RTN","NHINVSIT",46,0)
|
|
D IDT S NHICNT=0
|
|
"RTN","NHINVSIT",47,0)
|
|
S IDT=BEG F S IDT=$O(^AUPNVSIT("AA",DFN,IDT)) Q:IDT<1!(IDT>END) D Q:NHICNT'<MAX
|
|
"RTN","NHINVSIT",48,0)
|
|
. S DA=0 F S DA=$O(^AUPNVSIT("AA",DFN,IDT,DA)) Q:DA<1 D
|
|
"RTN","NHINVSIT",49,0)
|
|
.. K NHITM D EN1(DA,.NHITM) Q:'$D(NHITM)
|
|
"RTN","NHINVSIT",50,0)
|
|
.. D XML(.NHITM) S NHICNT=NHICNT+1
|
|
"RTN","NHINVSIT",51,0)
|
|
Q
|
|
"RTN","NHINVSIT",52,0)
|
|
IDT ; -- invert BEG and END dates for visit format:
|
|
"RTN","NHINVSIT",53,0)
|
|
; IDT=(9999999-$P(VDT,"."))_"."_$P(VDT,".",2)
|
|
"RTN","NHINVSIT",54,0)
|
|
N X S X=BEG
|
|
"RTN","NHINVSIT",55,0)
|
|
S BEG=(9999999-$P(END,"."))
|
|
"RTN","NHINVSIT",56,0)
|
|
S END=(9999999-$P(X,"."))_".2359"
|
|
"RTN","NHINVSIT",57,0)
|
|
Q
|
|
"RTN","NHINVSIT",58,0)
|
|
;
|
|
"RTN","NHINVSIT",59,0)
|
|
EN1(IEN,VST) ; -- return a visit in VST("attribute")=value
|
|
"RTN","NHINVSIT",60,0)
|
|
N X0,X15,X,FAC,LOC,CATG,INPT,DA
|
|
"RTN","NHINVSIT",61,0)
|
|
S IEN=+$G(IEN) Q:IEN<1 ;invalid ien
|
|
"RTN","NHINVSIT",62,0)
|
|
D ENCEVENT^PXAPI(IEN)
|
|
"RTN","NHINVSIT",63,0)
|
|
S X0=$G(^TMP("PXKENC",$J,IEN,"VST",IEN,0)),X15=$G(^(150))
|
|
"RTN","NHINVSIT",64,0)
|
|
Q:$P(X15,U,3)'="P" Q:$P(X0,U,7)="E" ;want primary, not historical
|
|
"RTN","NHINVSIT",65,0)
|
|
I $P(X0,U,7)="H" D ADM(IEN,+X0,.VST) Q
|
|
"RTN","NHINVSIT",66,0)
|
|
S VST("id")=IEN,VST("dateTime")=+X0
|
|
"RTN","NHINVSIT",67,0)
|
|
S FAC=+$P(X0,U,6),CATG=$P(X0,U,7),LOC=+$P(X0,U,22)
|
|
"RTN","NHINVSIT",68,0)
|
|
S:FAC VST("facility")=$$STA^XUAF4(FAC)_U_$P($$NS^XUAF4(FAC),U)
|
|
"RTN","NHINVSIT",69,0)
|
|
S VST("serviceCategory")=CATG_U_$$CATG(CATG)
|
|
"RTN","NHINVSIT",70,0)
|
|
S VST("visitString")=LOC_";"_+X0_";"_CATG
|
|
"RTN","NHINVSIT",71,0)
|
|
S INPT=$P(X15,U,2) S:INPT="" INPT=$S("H^I^R^D"[CATG:1,1:0)
|
|
"RTN","NHINVSIT",72,0)
|
|
S X=$$CPT(IEN) S:X VST("type")=$P($$CPT^ICPTCOD(X),U,2,3)
|
|
"RTN","NHINVSIT",73,0)
|
|
I 'X S VST("type")=U_$S('INPT&LOC:$P($G(^SC(LOC,0)),U)_" VISIT",1:$$CATG(CATG))
|
|
"RTN","NHINVSIT",74,0)
|
|
S VST("patientClass")=$S(INPT:"IMP",1:"AMB")
|
|
"RTN","NHINVSIT",75,0)
|
|
S X=$P(X0,U,8) S:X VST("stopCode")=$$AMIS(X) I LOC D
|
|
"RTN","NHINVSIT",76,0)
|
|
. N L0 S L0=$G(^SC(LOC,0))
|
|
"RTN","NHINVSIT",77,0)
|
|
. I 'X S VST("stopCode")=$$AMIS($P(L0,U,7))
|
|
"RTN","NHINVSIT",78,0)
|
|
. S VST("location")=$P(L0,U),VST("service")=$$SERV($P(L0,U,20))
|
|
"RTN","NHINVSIT",79,0)
|
|
. S X=$P(L0,U,18) S:X VST("creditStopCode")=$$AMIS(X)
|
|
"RTN","NHINVSIT",80,0)
|
|
. S:'FAC VST("facility")=$$FAC^NHINV(LOC)
|
|
"RTN","NHINVSIT",81,0)
|
|
S VST("reason")=$$POV(IEN)
|
|
"RTN","NHINVSIT",82,0)
|
|
; provider(s)
|
|
"RTN","NHINVSIT",83,0)
|
|
S DA=0 F S DA=$O(^TMP("PXKENC",$J,IEN,"PRV",DA)) Q:DA<1 S X0=$G(^(DA,0)) D
|
|
"RTN","NHINVSIT",84,0)
|
|
. S VST("provider",DA)=+X0_U_$P($G(^VA(200,+X0,0)),U)_$S($P(X0,U,4)="P":"^P^1",1:"^S^")
|
|
"RTN","NHINVSIT",85,0)
|
|
; note(s)
|
|
"RTN","NHINVSIT",86,0)
|
|
D TIU(IEN)
|
|
"RTN","NHINVSIT",87,0)
|
|
K ^TMP("PXKENC",$J,IEN)
|
|
"RTN","NHINVSIT",88,0)
|
|
Q
|
|
"RTN","NHINVSIT",89,0)
|
|
;
|
|
"RTN","NHINVSIT",90,0)
|
|
TIU(VISIT) ; -- add notes to VST("document")
|
|
"RTN","NHINVSIT",91,0)
|
|
N X,Y,I,NHIN,LT,NT,DA,CNT
|
|
"RTN","NHINVSIT",92,0)
|
|
D FIND^DIC(8925,,.01,"QX",+$G(VISIT),,"V",,,"NHIN")
|
|
"RTN","NHINVSIT",93,0)
|
|
S Y="",(I,CNT)=0
|
|
"RTN","NHINVSIT",94,0)
|
|
F S I=$O(NHIN("DILIST",1,I)) Q:I<1 D
|
|
"RTN","NHINVSIT",95,0)
|
|
. S LT=$G(NHIN("DILIST","ID",I,.01)) Q:$P(LT," ")="Addendum"
|
|
"RTN","NHINVSIT",96,0)
|
|
. S DA=$G(NHIN("DILIST",2,I))
|
|
"RTN","NHINVSIT",97,0)
|
|
. S NT=$$GET1^DIQ(8925,+DA_",",".01:1501")
|
|
"RTN","NHINVSIT",98,0)
|
|
. S CNT=CNT+1,VST("document",CNT)=DA_U_LT_U_NT
|
|
"RTN","NHINVSIT",99,0)
|
|
Q
|
|
"RTN","NHINVSIT",100,0)
|
|
;
|
|
"RTN","NHINVSIT",101,0)
|
|
POV(VISIT) ; -- return the primary Purpose of Visit as ICD^ProviderNarrative
|
|
"RTN","NHINVSIT",102,0)
|
|
N DA,Y,X,X0,ICD S Y=""
|
|
"RTN","NHINVSIT",103,0)
|
|
S DA=0 F S DA=$O(^TMP("PXKENC",$J,VISIT,"POV",DA)) Q:DA<1 S X0=$G(^(DA,0)) I $P(X0,U,12)="P" D Q:$L(Y)
|
|
"RTN","NHINVSIT",104,0)
|
|
. S X=+$P(X0,U,4),ICD=$$ICD(+X0)
|
|
"RTN","NHINVSIT",105,0)
|
|
. S Y=ICD_U_$$GET1^DIQ(9999999.27,X_",",.01)
|
|
"RTN","NHINVSIT",106,0)
|
|
Q Y
|
|
"RTN","NHINVSIT",107,0)
|
|
;
|
|
"RTN","NHINVSIT",108,0)
|
|
ICD(IEN) ; -- return code^description for ICD code, or "^" if error
|
|
"RTN","NHINVSIT",109,0)
|
|
N X0,NHX,N,I,X,Y S IEN=+$G(IEN)
|
|
"RTN","NHINVSIT",110,0)
|
|
S X0=$$ICDDX^ICDCODE(IEN) I X0<0 Q "^"
|
|
"RTN","NHINVSIT",111,0)
|
|
S Y=$P(X0,U,2)_U_$P(X0,U,4) ;ICD Code^Dx name
|
|
"RTN","NHINVSIT",112,0)
|
|
S N=$$ICDD^ICDCODE($P(Y,U),"NHX") ;ICD Description
|
|
"RTN","NHINVSIT",113,0)
|
|
I N>0,$L($G(NHX(1))) S $P(Y,U,2)=NHX(1)
|
|
"RTN","NHINVSIT",114,0)
|
|
Q Y
|
|
"RTN","NHINVSIT",115,0)
|
|
;
|
|
"RTN","NHINVSIT",116,0)
|
|
CPT(VISIT) ; -- Return CPT code of encounter type
|
|
"RTN","NHINVSIT",117,0)
|
|
N DA,Y,X,X0 S Y=""
|
|
"RTN","NHINVSIT",118,0)
|
|
S DA=0 F S DA=$O(^TMP("PXKENC",$J,VISIT,"CPT",DA)) Q:DA<1 S X0=$G(^(DA,0)) D Q:$L(Y)
|
|
"RTN","NHINVSIT",119,0)
|
|
. S X=$P(X0,U) I X?1"992"2N S Y=X Q
|
|
"RTN","NHINVSIT",120,0)
|
|
Q Y
|
|
"RTN","NHINVSIT",121,0)
|
|
;
|
|
"RTN","NHINVSIT",122,0)
|
|
AMIS(X) ; -- return the AMIS code^name of Credit Stop X
|
|
"RTN","NHINVSIT",123,0)
|
|
N Y S Y=""
|
|
"RTN","NHINVSIT",124,0)
|
|
S X0=$G(^DIC(40.7,+$G(X),0)) S:$L(X0) Y=$P(X0,U,2)_U_$P(X0,U)
|
|
"RTN","NHINVSIT",125,0)
|
|
Q Y
|
|
"RTN","NHINVSIT",126,0)
|
|
;
|
|
"RTN","NHINVSIT",127,0)
|
|
CATG(X) ; -- Return name of visit Service Category code X
|
|
"RTN","NHINVSIT",128,0)
|
|
N Y S Y=""
|
|
"RTN","NHINVSIT",129,0)
|
|
I X="A" S Y="AMBULATORY"
|
|
"RTN","NHINVSIT",130,0)
|
|
I X="H" S Y="HOSPITALIZATION"
|
|
"RTN","NHINVSIT",131,0)
|
|
I X="I" S Y="IN HOSPITAL"
|
|
"RTN","NHINVSIT",132,0)
|
|
I X="C" S Y="CHART REVIEW"
|
|
"RTN","NHINVSIT",133,0)
|
|
I X="T" S Y="TELECOMMUNICATIONS"
|
|
"RTN","NHINVSIT",134,0)
|
|
I X="N" S Y="NOT FOUND"
|
|
"RTN","NHINVSIT",135,0)
|
|
I X="S" S Y="DAY SURGERY"
|
|
"RTN","NHINVSIT",136,0)
|
|
I X="O" S Y="OBSERVATION"
|
|
"RTN","NHINVSIT",137,0)
|
|
I X="E" S Y="EVENT (HISTORICAL)"
|
|
"RTN","NHINVSIT",138,0)
|
|
I X="R" S Y="NURSING HOME"
|
|
"RTN","NHINVSIT",139,0)
|
|
I X="D" S Y="DAILY HOSPITALIZATION DATA"
|
|
"RTN","NHINVSIT",140,0)
|
|
I X="X" S Y="ANCILLARY PACKAGE DAILY DATA"
|
|
"RTN","NHINVSIT",141,0)
|
|
Q Y
|
|
"RTN","NHINVSIT",142,0)
|
|
;
|
|
"RTN","NHINVSIT",143,0)
|
|
SERV(FTS) ; -- Return #42.4 Service for a Facility Treating Specialty
|
|
"RTN","NHINVSIT",144,0)
|
|
N Y S Y="",FTS=+$G(FTS)
|
|
"RTN","NHINVSIT",145,0)
|
|
S Y=$$GET1^DIQ(45.7,FTS_",","1:3","E")
|
|
"RTN","NHINVSIT",146,0)
|
|
Q Y
|
|
"RTN","NHINVSIT",147,0)
|
|
;
|
|
"RTN","NHINVSIT",148,0)
|
|
ADM(IEN,DATE,ADM) ; -- return an admission in ADM("attribute")=value
|
|
"RTN","NHINVSIT",149,0)
|
|
N VAIP,VAERR,HLOC,ICD,I K ADM
|
|
"RTN","NHINVSIT",150,0)
|
|
S IEN=+$G(IEN),DATE=+$G(DATE) Q:IEN<1 Q:DATE<1 ;invalid
|
|
"RTN","NHINVSIT",151,0)
|
|
S VAIP("D")=DATE D IN5^VADPT Q:'$G(VAIP(1)) ;deleted
|
|
"RTN","NHINVSIT",152,0)
|
|
S ADM("id")=IEN,ADM("patientClass")="IMP"
|
|
"RTN","NHINVSIT",153,0)
|
|
; ADM("admitType")=$P($G(VAIP(4)),U,2)
|
|
"RTN","NHINVSIT",154,0)
|
|
S DATE=+$G(VAIP(3)),(ADM("dateTime"),ADM("arrivalDateTime"))=DATE,I=0
|
|
"RTN","NHINVSIT",155,0)
|
|
S:$G(VAIP(7)) I=I+1,ADM("provider",I)=VAIP(7)_"^P^1" ;primary
|
|
"RTN","NHINVSIT",156,0)
|
|
S:$G(VAIP(18)) I=I+1,ADM("provider",I)=VAIP(18)_"^A" ;attending
|
|
"RTN","NHINVSIT",157,0)
|
|
S ADM("specialty")=$P($G(VAIP(8)),U,2)
|
|
"RTN","NHINVSIT",158,0)
|
|
S X=$$SERV(+$G(VAIP(8))),ADM("service")=X
|
|
"RTN","NHINVSIT",159,0)
|
|
S X=$$POV(IEN) S:X ADM("reason")=X_U_$G(VAIP(9)) I 'X D
|
|
"RTN","NHINVSIT",160,0)
|
|
. S X=$$GET1^DIQ(405,+VAIP(1)_",",".16:79","I") ;Mvt>PTF>ICD ien
|
|
"RTN","NHINVSIT",161,0)
|
|
. I 'X S ADM("reason")=U_U_$G(VAIP(9)) Q ;Dx text
|
|
"RTN","NHINVSIT",162,0)
|
|
. S ICD=$$ICD(X),ADM("reason")=ICD_U_$G(VAIP(9))
|
|
"RTN","NHINVSIT",163,0)
|
|
S HLOC=+$G(^DIC(42,+$G(VAIP(5)),44))
|
|
"RTN","NHINVSIT",164,0)
|
|
S:HLOC ADM("location")=$P($G(^SC(HLOC,0)),U)
|
|
"RTN","NHINVSIT",165,0)
|
|
S ADM("facility")=$$FAC^NHINV(+HLOC),ADM("roomBed")=$P(VAIP(6),U,2)
|
|
"RTN","NHINVSIT",166,0)
|
|
S ADM("serviceCategory")="H^HOSPITALIZATION"
|
|
"RTN","NHINVSIT",167,0)
|
|
S X=$$CPT(IEN),ADM("type")=$S(X:$P($$CPT^ICPTCOD(X),U,2,3),1:U_$$CATG("H"))
|
|
"RTN","NHINVSIT",168,0)
|
|
I $G(VAIP(17)) D
|
|
"RTN","NHINVSIT",169,0)
|
|
. S ADM("departureDateTime")=+$G(VAIP(17,1))
|
|
"RTN","NHINVSIT",170,0)
|
|
. ; ADM("disposition")=$G(VAIP(17,3)) ;Discharge Mvt Type
|
|
"RTN","NHINVSIT",171,0)
|
|
S ADM("visitString")=HLOC_";"_DATE_";H"
|
|
"RTN","NHINVSIT",172,0)
|
|
Q
|
|
"RTN","NHINVSIT",173,0)
|
|
;
|
|
"RTN","NHINVSIT",174,0)
|
|
ENC(IEN,ENC) ; -- return an encounter in ENC("attribute")=value
|
|
"RTN","NHINVSIT",175,0)
|
|
N X0,DATE,HLOC,TYPE,STS,X,Y K ENC
|
|
"RTN","NHINVSIT",176,0)
|
|
S IEN=+$G(IEN) Q:IEN<1 ;invalid ien
|
|
"RTN","NHINVSIT",177,0)
|
|
S ENC("id")="E"_IEN,X0=$G(^SCE(IEN,0))
|
|
"RTN","NHINVSIT",178,0)
|
|
S DATE=+X0,ENC("dateTime")=DATE
|
|
"RTN","NHINVSIT",179,0)
|
|
S HLOC=+$P(X0,U,4) I HLOC D
|
|
"RTN","NHINVSIT",180,0)
|
|
. S HLOC=HLOC_U_$P($G(^SC(HLOC,0)),U)
|
|
"RTN","NHINVSIT",181,0)
|
|
. S ENC("location")=$P(HLOC,U,2)
|
|
"RTN","NHINVSIT",182,0)
|
|
. S X=$$GET1^DIQ(44,+HLOC_",",9.5,"I")
|
|
"RTN","NHINVSIT",183,0)
|
|
. I X S ENC("service")=$$SERV(X)
|
|
"RTN","NHINVSIT",184,0)
|
|
S ENC("facility")=$$FAC^NHINV(+HLOC)
|
|
"RTN","NHINVSIT",185,0)
|
|
S STS=$$GET1^DIQ(409.68,IEN_",",.12,"E")
|
|
"RTN","NHINVSIT",186,0)
|
|
S X=$S(STS?1"INP".E:"IMP",1:"AMB"),ENC("patientClass")=X,TYPE=$E(X)
|
|
"RTN","NHINVSIT",187,0)
|
|
S ENC("type")=U_$S(HLOC:$P(HLOC,U,2)_" VISIT",1:$$CATG(TYPE))
|
|
"RTN","NHINVSIT",188,0)
|
|
S ENC("serviceCategory")=TYPE_U_$$CATG(TYPE)
|
|
"RTN","NHINVSIT",189,0)
|
|
S ENC("visitString")=+HLOC_";"_DATE_";"_TYPE
|
|
"RTN","NHINVSIT",190,0)
|
|
Q
|
|
"RTN","NHINVSIT",191,0)
|
|
;
|
|
"RTN","NHINVSIT",192,0)
|
|
; ------------ Return data to middle tier ------------
|
|
"RTN","NHINVSIT",193,0)
|
|
;
|
|
"RTN","NHINVSIT",194,0)
|
|
XML(VISIT) ; -- Return patient visit as XML
|
|
"RTN","NHINVSIT",195,0)
|
|
N ATT,X,Y,NAMES
|
|
"RTN","NHINVSIT",196,0)
|
|
D ADD("<visit>") S NHINTOTL=$G(NHINTOTL)+1
|
|
"RTN","NHINVSIT",197,0)
|
|
S ATT="" F S ATT=$O(VISIT(ATT)) Q:ATT="" D D:$L(Y) ADD(Y)
|
|
"RTN","NHINVSIT",198,0)
|
|
. I $O(VISIT(ATT,0)) D S Y="" Q ;multiples
|
|
"RTN","NHINVSIT",199,0)
|
|
.. D ADD("<"_ATT_"s>")
|
|
"RTN","NHINVSIT",200,0)
|
|
.. S I=0 F S I=$O(VISIT(ATT,I)) Q:I<1 D
|
|
"RTN","NHINVSIT",201,0)
|
|
... S X=$G(VISIT(ATT,I)),NAMES=""
|
|
"RTN","NHINVSIT",202,0)
|
|
... I ATT="document" S NAMES="id^localTitle^nationalTitle^Z"
|
|
"RTN","NHINVSIT",203,0)
|
|
... I ATT="provider" S NAMES="code^name^role^primary^Z"
|
|
"RTN","NHINVSIT",204,0)
|
|
... S Y="<"_ATT_" "_$$LOOP_"/>" D ADD(Y)
|
|
"RTN","NHINVSIT",205,0)
|
|
.. D ADD("</"_ATT_"s>")
|
|
"RTN","NHINVSIT",206,0)
|
|
. S X=$G(VISIT(ATT)),Y="" Q:'$L(X)
|
|
"RTN","NHINVSIT",207,0)
|
|
. S NAMES="code^name^"_$S(ATT="reason":"narrative^",1:"")_"Z"
|
|
"RTN","NHINVSIT",208,0)
|
|
. I X'["^" S Y="<"_ATT_" value='"_$$ESC^NHINV(X)_"' />" Q
|
|
"RTN","NHINVSIT",209,0)
|
|
. I $L(X)>1 S Y="<"_ATT_" "_$$LOOP_"/>"
|
|
"RTN","NHINVSIT",210,0)
|
|
D ADD("</visit>")
|
|
"RTN","NHINVSIT",211,0)
|
|
Q
|
|
"RTN","NHINVSIT",212,0)
|
|
;
|
|
"RTN","NHINVSIT",213,0)
|
|
LOOP() ; -- build sub-items string from NAMES and X
|
|
"RTN","NHINVSIT",214,0)
|
|
N STR,P,TAG S STR=""
|
|
"RTN","NHINVSIT",215,0)
|
|
F P=1:1 S TAG=$P(NAMES,U,P) Q:TAG="Z" I $L($P(X,U,P)) S STR=STR_TAG_"='"_$$ESC^NHINV($P(X,U,P))_"' "
|
|
"RTN","NHINVSIT",216,0)
|
|
Q STR
|
|
"RTN","NHINVSIT",217,0)
|
|
;
|
|
"RTN","NHINVSIT",218,0)
|
|
ADD(X) ; -- Add a line @NHIN@(n)=X
|
|
"RTN","NHINVSIT",219,0)
|
|
S NHINI=$G(NHINI)+1
|
|
"RTN","NHINVSIT",220,0)
|
|
S @NHIN@(NHINI)=X
|
|
"RTN","NHINVSIT",221,0)
|
|
Q
|
|
"RTN","NHINVSR")
|
|
0^12^B25931760^n/a
|
|
"RTN","NHINVSR",1,0)
|
|
NHINVSR ;SLC/MKB -- Surgical Procedures
|
|
"RTN","NHINVSR",2,0)
|
|
;;1.0;NHIN;**1**;Oct 25, 2010;Build 11
|
|
"RTN","NHINVSR",3,0)
|
|
;
|
|
"RTN","NHINVSR",4,0)
|
|
; External References DBIA#
|
|
"RTN","NHINVSR",5,0)
|
|
; ------------------- -----
|
|
"RTN","NHINVSR",6,0)
|
|
; DIQ 2056
|
|
"RTN","NHINVSR",7,0)
|
|
; STATUS^GMTSROB 3969
|
|
"RTN","NHINVSR",8,0)
|
|
; ICPTCOD 1995
|
|
"RTN","NHINVSR",9,0)
|
|
; ICPTMOD 1996
|
|
"RTN","NHINVSR",10,0)
|
|
; SROESTV 3533
|
|
"RTN","NHINVSR",11,0)
|
|
; TIUSRVR1 2944
|
|
"RTN","NHINVSR",12,0)
|
|
;
|
|
"RTN","NHINVSR",13,0)
|
|
; ------------ Get surgery(ies) from VistA ------------
|
|
"RTN","NHINVSR",14,0)
|
|
;
|
|
"RTN","NHINVSR",15,0)
|
|
EN(DFN,BEG,END,MAX,ID) ; -- find patient's surgeries
|
|
"RTN","NHINVSR",16,0)
|
|
N NHI,NHICNT,NHITM,NHY
|
|
"RTN","NHINVSR",17,0)
|
|
S DFN=+$G(DFN) Q:DFN<1
|
|
"RTN","NHINVSR",18,0)
|
|
S BEG=$G(BEG,1410101),END=$G(END,9999998),MAX=$G(MAX,999999)
|
|
"RTN","NHINVSR",19,0)
|
|
;
|
|
"RTN","NHINVSR",20,0)
|
|
; get one surgery
|
|
"RTN","NHINVSR",21,0)
|
|
I $G(ID) D EN1(ID,.NHITM),XML(.NHITM) Q
|
|
"RTN","NHINVSR",22,0)
|
|
;
|
|
"RTN","NHINVSR",23,0)
|
|
; get all surgeries
|
|
"RTN","NHINVSR",24,0)
|
|
Q:'$L($T(LIST^SROESTV))
|
|
"RTN","NHINVSR",25,0)
|
|
N SHOWADD S SHOWADD=1 ;to omit leading '+' with note titles
|
|
"RTN","NHINVSR",26,0)
|
|
D LIST^SROESTV(.NHY,DFN,BEG,END,MAX,1)
|
|
"RTN","NHINVSR",27,0)
|
|
S NHI=0 F S NHI=$O(@NHY@(NHI)) Q:NHI<1 D
|
|
"RTN","NHINVSR",28,0)
|
|
. K NHITM D ONE(NHI,.NHITM)
|
|
"RTN","NHINVSR",29,0)
|
|
. I $D(NHITM) D XML(.NHITM)
|
|
"RTN","NHINVSR",30,0)
|
|
K @NHY
|
|
"RTN","NHINVSR",31,0)
|
|
Q
|
|
"RTN","NHINVSR",32,0)
|
|
;
|
|
"RTN","NHINVSR",33,0)
|
|
ONE(NUM,SURG) ; -- return a surgery in SURG("attribute")=value
|
|
"RTN","NHINVSR",34,0)
|
|
; Expects DFN, @NHY@(NUM) from LIST^SROESTV
|
|
"RTN","NHINVSR",35,0)
|
|
N IEN,NHX,X,Y,I,NHMOD,NHOTH
|
|
"RTN","NHINVSR",36,0)
|
|
S NHX=$G(@NHY@(NUM))
|
|
"RTN","NHINVSR",37,0)
|
|
S IEN=+$P(NHX,U) Q:IEN<1 K SURG
|
|
"RTN","NHINVSR",38,0)
|
|
S SURG("id")=IEN,SURG("name")=$P(NHX,U,2)
|
|
"RTN","NHINVSR",39,0)
|
|
S SURG("dateTime")=$P(NHX,U,3)
|
|
"RTN","NHINVSR",40,0)
|
|
S X=$P(NHX,U,4) S:X SURG("provider")=$TR(X,";","^")
|
|
"RTN","NHINVSR",41,0)
|
|
S SURG("status")=$$STATUS(IEN,$P(NHX,U,3))
|
|
"RTN","NHINVSR",42,0)
|
|
S X=$$GET1^DIQ(130,IEN_",",50,"I"),SURG("facility")=$$FAC^NHINV(X)
|
|
"RTN","NHINVSR",43,0)
|
|
S SURG("encounter")=$$GET1^DIQ(130,IEN_",",.015,"I")
|
|
"RTN","NHINVSR",44,0)
|
|
S X=$$GET1^DIQ(130,IEN_",",27,"I") I X D
|
|
"RTN","NHINVSR",45,0)
|
|
. S SURG("type")=$$CPT(X)
|
|
"RTN","NHINVSR",46,0)
|
|
. D GETS^DIQ(130,IEN_",","28*","I","NHMOD") ;CPT modifiers
|
|
"RTN","NHINVSR",47,0)
|
|
. S I="" F S I=$O(NHMOD(130.028,I)) Q:I="" D
|
|
"RTN","NHINVSR",48,0)
|
|
.. S X=+$G(NHMOD(130.028,I,.01,"I")),Y=$$MOD^ICPTMOD(X,"I")
|
|
"RTN","NHINVSR",49,0)
|
|
.. S SURG("modifier",+I)=$P(Y,U,2,3)
|
|
"RTN","NHINVSR",50,0)
|
|
D GETS^DIQ(130,IEN_",",".42*","I","NHOTH") ;other procedures
|
|
"RTN","NHINVSR",51,0)
|
|
S I="" F S I=$O(NHOTH(130.16,I)) Q:I="" D
|
|
"RTN","NHINVSR",52,0)
|
|
. S X=+$G(NHOTH(130.16,I,3,"I")) Q:'X
|
|
"RTN","NHINVSR",53,0)
|
|
. S SURG("otherProcedure",+I)=$$CPT(X)
|
|
"RTN","NHINVSR",54,0)
|
|
S I=0 F S I=$O(@NHY@(NUM,I)) Q:I<1 S X=$G(@NHY@(NUM,I)) I X D
|
|
"RTN","NHINVSR",55,0)
|
|
. N LT,NT S LT=$P(X,U,2) Q:$P(LT," ")="Addendum"
|
|
"RTN","NHINVSR",56,0)
|
|
. S NT=$$GET1^DIQ(8925,+X_",",".01:1501")
|
|
"RTN","NHINVSR",57,0)
|
|
. S SURG("document",I)=+X_U_LT_U_NT
|
|
"RTN","NHINVSR",58,0)
|
|
. I LT["OPERATION REPORT"!(LT["PROCEDURE REPORT") S SURG("opReport")=+X_U_LT_U_NT
|
|
"RTN","NHINVSR",59,0)
|
|
S SURG("category")="SR"
|
|
"RTN","NHINVSR",60,0)
|
|
Q
|
|
"RTN","NHINVSR",61,0)
|
|
;
|
|
"RTN","NHINVSR",62,0)
|
|
EN1(IEN,SURG) ; -- return a surgery in SURG("attribute")=value
|
|
"RTN","NHINVSR",63,0)
|
|
N NHX,NHY,X,Y,I,NHMOD,NHOTH,SHOWADD
|
|
"RTN","NHINVSR",64,0)
|
|
S SHOWADD=1 ;to omit leading '+' with note titles
|
|
"RTN","NHINVSR",65,0)
|
|
D ONE^SROESTV("NHY",IEN) S NHX=$G(NHY(IEN)) Q:NHX=""
|
|
"RTN","NHINVSR",66,0)
|
|
S SURG("id")=IEN,SURG("name")=$P(NHX,U,2),SURG("dateTime")=$P(NHX,U,3)
|
|
"RTN","NHINVSR",67,0)
|
|
S X=$P(NHX,U,4) S:X SURG("provider")=$TR(X,";","^")
|
|
"RTN","NHINVSR",68,0)
|
|
S SURG("status")=$$STATUS(IEN,$P(NHX,U,3))
|
|
"RTN","NHINVSR",69,0)
|
|
S X=$$GET1^DIQ(130,IEN_",",50,"I"),SURG("facility")=$$FAC^NHINV(X)
|
|
"RTN","NHINVSR",70,0)
|
|
S SURG("encounter")=$$GET1^DIQ(130,IEN_",",.015,"I")
|
|
"RTN","NHINVSR",71,0)
|
|
S X=$$GET1^DIQ(130,IEN_",",27,"I") I X D
|
|
"RTN","NHINVSR",72,0)
|
|
. S SURG("type")=$$CPT(X)
|
|
"RTN","NHINVSR",73,0)
|
|
. D GETS^DIQ(130,IEN_",","28*","I","NHMOD") ;CPT modifiers
|
|
"RTN","NHINVSR",74,0)
|
|
. S I="" F S I=$O(NHMOD(130.028,I)) Q:I="" D
|
|
"RTN","NHINVSR",75,0)
|
|
.. S X=+$G(NHMOD(130.028,I,.01,"I")),Y=$$MOD^ICPTMOD(X,"I")
|
|
"RTN","NHINVSR",76,0)
|
|
.. S SURG("modifier",+I)=$P(Y,U,2,3)
|
|
"RTN","NHINVSR",77,0)
|
|
D GETS^DIQ(130,"28,",".42*","I","NHOTH") ;other procedures
|
|
"RTN","NHINVSR",78,0)
|
|
S I="" F S I=$O(NHOTH(130.16,I)) Q:I="" D
|
|
"RTN","NHINVSR",79,0)
|
|
. S X=+$G(NHOTH(130.16,I,3,"I")) Q:'X
|
|
"RTN","NHINVSR",80,0)
|
|
. S SURG("otherProcedure",+I)=$$CPT(X)
|
|
"RTN","NHINVSR",81,0)
|
|
S I=0 F S I=$O(NHY(IEN,I)) Q:I<1 S X=$G(NHY(IEN,I)) I X D
|
|
"RTN","NHINVSR",82,0)
|
|
. N LT,NT S LT=$P(X,U,2) Q:$P(LT," ")="Addendum"
|
|
"RTN","NHINVSR",83,0)
|
|
. S NT=$$GET1^DIQ(8925,+X_",",".01:1501")
|
|
"RTN","NHINVSR",84,0)
|
|
. S SURG("document",I)=+X_U_LT_U_NT
|
|
"RTN","NHINVSR",85,0)
|
|
. I LT["OPERATION REPORT"!(LT["PROCEDURE REPORT") S SURG("opReport")=+X_U_LT_U_NT
|
|
"RTN","NHINVSR",86,0)
|
|
S SURG("category")="SR"
|
|
"RTN","NHINVSR",87,0)
|
|
Q
|
|
"RTN","NHINVSR",88,0)
|
|
;
|
|
"RTN","NHINVSR",89,0)
|
|
CPT(IEN) ; -- return code^description for CPT code, or "^" if error
|
|
"RTN","NHINVSR",90,0)
|
|
N X0,NHX,N,I,X,Y S IEN=+$G(IEN)
|
|
"RTN","NHINVSR",91,0)
|
|
S X0=$$CPT^ICPTCOD(IEN) I X0<0 Q "^"
|
|
"RTN","NHINVSR",92,0)
|
|
S Y=$P(X0,U,2,3) ;CPT Code^Short Name
|
|
"RTN","NHINVSR",93,0)
|
|
S N=$$CPTD^ICPTCOD($P(Y,U),"NHX") ;CPT Description
|
|
"RTN","NHINVSR",94,0)
|
|
I N>0,$L($G(NHX(1))) D
|
|
"RTN","NHINVSR",95,0)
|
|
. S X=$G(NHX(1)),I=1
|
|
"RTN","NHINVSR",96,0)
|
|
. F S I=$O(NHX(I)) Q:I<1 Q:NHX(I)=" " S X=X_" "_NHX(I)
|
|
"RTN","NHINVSR",97,0)
|
|
. S $P(Y,U,2)=X
|
|
"RTN","NHINVSR",98,0)
|
|
Q Y
|
|
"RTN","NHINVSR",99,0)
|
|
;
|
|
"RTN","NHINVSR",100,0)
|
|
STATUS(GMN,GMDT) ; -- get current STATUS of request
|
|
"RTN","NHINVSR",101,0)
|
|
N STATUS S STATUS="UNKNOWN"
|
|
"RTN","NHINVSR",102,0)
|
|
I $G(GMN),$G(GMDT) D STATUS^GMTSROB
|
|
"RTN","NHINVSR",103,0)
|
|
I $E(STATUS)="(" S STATUS=$P($P(STATUS,"(",2),")")
|
|
"RTN","NHINVSR",104,0)
|
|
Q STATUS
|
|
"RTN","NHINVSR",105,0)
|
|
;
|
|
"RTN","NHINVSR",106,0)
|
|
; ------------ Return data to middle tier ------------
|
|
"RTN","NHINVSR",107,0)
|
|
;
|
|
"RTN","NHINVSR",108,0)
|
|
XML(SURG) ; -- Return surgery as XML
|
|
"RTN","NHINVSR",109,0)
|
|
N ATT,X,Y,NAMES
|
|
"RTN","NHINVSR",110,0)
|
|
D ADD("<surgery>") S NHINTOTL=$G(NHINTOTL)+1
|
|
"RTN","NHINVSR",111,0)
|
|
S ATT="" F S ATT=$O(SURG(ATT)) Q:ATT="" D D:$L(Y) ADD(Y)
|
|
"RTN","NHINVSR",112,0)
|
|
. I $O(SURG(ATT,0)) D S Y="" Q ;multiples
|
|
"RTN","NHINVSR",113,0)
|
|
.. D ADD("<"_ATT_"s>")
|
|
"RTN","NHINVSR",114,0)
|
|
.. S I=0 F S I=$O(SURG(ATT,I)) Q:I<1 D
|
|
"RTN","NHINVSR",115,0)
|
|
... S X=$G(SURG(ATT,I)),NAMES=""
|
|
"RTN","NHINVSR",116,0)
|
|
... S NAMES=$S(ATT="document":"id^localTitle^nationalTitle^Z",1:"code^name^Z")
|
|
"RTN","NHINVSR",117,0)
|
|
... S Y="<"_ATT_" "_$$LOOP_"/>" D ADD(Y)
|
|
"RTN","NHINVSR",118,0)
|
|
.. D ADD("</"_ATT_"s>")
|
|
"RTN","NHINVSR",119,0)
|
|
. S X=$G(SURG(ATT)),Y="" Q:'$L(X)
|
|
"RTN","NHINVSR",120,0)
|
|
. I X'["^" S Y="<"_ATT_" value='"_$$ESC^NHINV(X)_"' />" Q
|
|
"RTN","NHINVSR",121,0)
|
|
. S NAMES=$S(ATT="opReport":"id^localTitle^nationalTitle^Z",1:"code^name^Z")
|
|
"RTN","NHINVSR",122,0)
|
|
. I $L(X)>1 S Y="<"_ATT_" "_$$LOOP_"/>"
|
|
"RTN","NHINVSR",123,0)
|
|
D ADD("</surgery>")
|
|
"RTN","NHINVSR",124,0)
|
|
Q
|
|
"RTN","NHINVSR",125,0)
|
|
;
|
|
"RTN","NHINVSR",126,0)
|
|
LOOP() ; -- build sub-items string from NAMES and X
|
|
"RTN","NHINVSR",127,0)
|
|
N STR,P,TAG S STR=""
|
|
"RTN","NHINVSR",128,0)
|
|
F P=1:1 S TAG=$P(NAMES,U,P) Q:TAG="Z" I $L($P(X,U,P)) S STR=STR_TAG_"='"_$$ESC^NHINV($P(X,U,P))_"' "
|
|
"RTN","NHINVSR",129,0)
|
|
Q STR
|
|
"RTN","NHINVSR",130,0)
|
|
;
|
|
"RTN","NHINVSR",131,0)
|
|
ADD(X) ; -- Add a line @NHIN@(n)=X
|
|
"RTN","NHINVSR",132,0)
|
|
S NHINI=$G(NHINI)+1
|
|
"RTN","NHINVSR",133,0)
|
|
S @NHIN@(NHINI)=X
|
|
"RTN","NHINVSR",134,0)
|
|
Q
|
|
"RTN","NHINVSR",135,0)
|
|
;
|
|
"RTN","NHINVSR",136,0)
|
|
RPT(NHY,ID) ; -- Return report in NHY(n)
|
|
"RTN","NHINVSR",137,0)
|
|
S ID=+$G(ID) Q:ID<1
|
|
"RTN","NHINVSR",138,0)
|
|
D TGET^TIUSRVR1(.NHY,ID)
|
|
"RTN","NHINVSR",139,0)
|
|
Q
|
|
"RTN","NHINVTIU")
|
|
0^13^B18326219^n/a
|
|
"RTN","NHINVTIU",1,0)
|
|
NHINVTIU ;SLC/MKB -- TIU extract
|
|
"RTN","NHINVTIU",2,0)
|
|
;;1.0;NHIN;**1**;Oct 25, 2010;Build 11
|
|
"RTN","NHINVTIU",3,0)
|
|
;
|
|
"RTN","NHINVTIU",4,0)
|
|
; External References DBIA#
|
|
"RTN","NHINVTIU",5,0)
|
|
; ------------------- -----
|
|
"RTN","NHINVTIU",6,0)
|
|
; ^SC( 10040
|
|
"RTN","NHINVTIU",7,0)
|
|
; ^VA(200 10060
|
|
"RTN","NHINVTIU",8,0)
|
|
; DIQ 2056
|
|
"RTN","NHINVTIU",9,0)
|
|
; TIUSRVLO 2834,2865
|
|
"RTN","NHINVTIU",10,0)
|
|
; TIUSRVR1 2944
|
|
"RTN","NHINVTIU",11,0)
|
|
;
|
|
"RTN","NHINVTIU",12,0)
|
|
; ------------ Get documents from VistA ------------
|
|
"RTN","NHINVTIU",13,0)
|
|
;
|
|
"RTN","NHINVTIU",14,0)
|
|
EN(DFN,BEG,END,MAX,ID) ; -- find patient's documents
|
|
"RTN","NHINVTIU",15,0)
|
|
N NHITM,NHI,NHX,NHY,NHDAD
|
|
"RTN","NHINVTIU",16,0)
|
|
S DFN=+$G(DFN) Q:$G(DFN)<1
|
|
"RTN","NHINVTIU",17,0)
|
|
S BEG=$G(BEG,1410101),END=$G(END,9999998),MAX=$G(MAX,999999)
|
|
"RTN","NHINVTIU",18,0)
|
|
;
|
|
"RTN","NHINVTIU",19,0)
|
|
; get one document
|
|
"RTN","NHINVTIU",20,0)
|
|
I $L($G(ID)),ID[";" D RPT^NHINVLRA(DFN,ID,.NHITM),XML(.NHITM) Q ;Lab
|
|
"RTN","NHINVTIU",21,0)
|
|
I $G(ID),ID["-" D RPT^NHINVRA(DFN,ID,.NHITM),XML(.NHITM) Q ;Radiology
|
|
"RTN","NHINVTIU",22,0)
|
|
I $G(ID) D Q
|
|
"RTN","NHINVTIU",23,0)
|
|
. N SHOWADD S SHOWADD=1
|
|
"RTN","NHINVTIU",24,0)
|
|
. S NHX=ID_U_$$RESOLVE^TIUSRVLO(ID)
|
|
"RTN","NHINVTIU",25,0)
|
|
. D EN1(ID,.NHITM),XML(.NHITM)
|
|
"RTN","NHINVTIU",26,0)
|
|
;
|
|
"RTN","NHINVTIU",27,0)
|
|
; get all documents via
|
|
"RTN","NHINVTIU",28,0)
|
|
D CONTEXT^TIUSRVLO(.NHY,3,1,DFN,BEG,END,,MAX,,1)
|
|
"RTN","NHINVTIU",29,0)
|
|
S NHI=0 F S NHI=$O(@NHY@(NHI)) Q:NHI<1 D
|
|
"RTN","NHINVTIU",30,0)
|
|
. S NHX=$G(@NHY@(NHI)),IFN=+NHX
|
|
"RTN","NHINVTIU",31,0)
|
|
. K NHITM D EN1(IFN,.NHITM)
|
|
"RTN","NHINVTIU",32,0)
|
|
. D:$D(NHITM) XML(.NHITM)
|
|
"RTN","NHINVTIU",33,0)
|
|
Q
|
|
"RTN","NHINVTIU",34,0)
|
|
;
|
|
"RTN","NHINVTIU",35,0)
|
|
EN1(IEN,DOC) ; -- return a document in DOC("attribute")=value
|
|
"RTN","NHINVTIU",36,0)
|
|
; Expects DFN, NHX=IEN ^ $$RESOLVE^TIUSRVLO(IEN)
|
|
"RTN","NHINVTIU",37,0)
|
|
N X,NAME,NHINX,ES,I K DOC
|
|
"RTN","NHINVTIU",38,0)
|
|
S IEN=+$G(IEN) Q:IEN<1 ;invalid ien
|
|
"RTN","NHINVTIU",39,0)
|
|
Q:"UNKNOWN"[$P($G(NHX),U,2) ;null or invalid
|
|
"RTN","NHINVTIU",40,0)
|
|
S DOC("id")=IEN,NAME=$P(NHX,U,2),DOC("localTitle")=NAME
|
|
"RTN","NHINVTIU",41,0)
|
|
I $P(NHX,U,14),$P(NAME," ")="Addendum" D Q
|
|
"RTN","NHINVTIU",42,0)
|
|
. N DATE,PARENT K DOC
|
|
"RTN","NHINVTIU",43,0)
|
|
. S DATE=$P(NHX,U,3),PARENT=$P(NHX,U,14)
|
|
"RTN","NHINVTIU",44,0)
|
|
. I DATE,PARENT>1 S NHDAD(PARENT,DATE)=NHX
|
|
"RTN","NHINVTIU",45,0)
|
|
S X=$$GET1^DIQ(8925,IEN_",",".01:1501") S:$L(X) DOC("nationalTitle")=X
|
|
"RTN","NHINVTIU",46,0)
|
|
S X=$$GET1^DIQ(8925,IEN_",",".01:1501:99.99") S:$L(X) DOC("nationalTitleCode")=X
|
|
"RTN","NHINVTIU",47,0)
|
|
S X=$$GET1^DIQ(8925,IEN_",",.04) S:$L(X) DOC("documentClass")=X
|
|
"RTN","NHINVTIU",48,0)
|
|
S DOC("referenceDateTime")=$P(NHX,U,3)
|
|
"RTN","NHINVTIU",49,0)
|
|
S X=$P(NHX,U,6) D ;S:$L(X) DOC("location")=X
|
|
"RTN","NHINVTIU",50,0)
|
|
. N LOC S LOC=$S($L(X):+$O(^SC("B",X,0)),1:0)
|
|
"RTN","NHINVTIU",51,0)
|
|
. S DOC("facility")=$$FAC^NHINV(LOC)
|
|
"RTN","NHINVTIU",52,0)
|
|
S X=$P(NHX,U,7) S:$L(X) DOC("status")=X
|
|
"RTN","NHINVTIU",53,0)
|
|
S:$L($P(NHX,U,12)) DOC("subject")=$P(NHX,U,12)
|
|
"RTN","NHINVTIU",54,0)
|
|
; X=$S($P(NHX,U,13)[">":"C",$P(NHX,U,13)["<":"I",1:"") ;componentType
|
|
"RTN","NHINVTIU",55,0)
|
|
S DOC("encounter")=$$GET1^DIQ(8925,IEN_",",.03,"I") ;$$VSTR(IEN)
|
|
"RTN","NHINVTIU",56,0)
|
|
S DOC("content")=$$TEXT(IEN)
|
|
"RTN","NHINVTIU",57,0)
|
|
; providers &/or signatures
|
|
"RTN","NHINVTIU",58,0)
|
|
S X=$P(NHX,U,5),I=0 S:X I=I+1,DOC("clinician",I)=+X_U_$P(X,";",3)_"^A" ;author
|
|
"RTN","NHINVTIU",59,0)
|
|
D GETS^DIQ(8925,IEN_",","1501;1502;1507;1508","IE","NHINX")
|
|
"RTN","NHINVTIU",60,0)
|
|
M ES=NHINX(8925,IEN_",") I ES(1501,"I") D
|
|
"RTN","NHINVTIU",61,0)
|
|
. S I=I+1
|
|
"RTN","NHINVTIU",62,0)
|
|
. S DOC("clinician",I)=ES(1502,"I")_U_ES(1502,"E")_"^S^"_ES(1501,"I")_U_$$SIG(ES(1502,"I"))
|
|
"RTN","NHINVTIU",63,0)
|
|
I ES(1507,"I") D ; cosigner
|
|
"RTN","NHINVTIU",64,0)
|
|
. S I=I+1
|
|
"RTN","NHINVTIU",65,0)
|
|
. S DOC("clinician",I)=ES(1508,"I")_U_ES(1508,"E")_"^C^"_ES(1507,"I")_U_$$SIG(ES(1508,"I"))
|
|
"RTN","NHINVTIU",66,0)
|
|
Q
|
|
"RTN","NHINVTIU",67,0)
|
|
;
|
|
"RTN","NHINVTIU",68,0)
|
|
VSTR(DA) ; -- get visit string for document DA
|
|
"RTN","NHINVTIU",69,0)
|
|
; Expects DFN, NHX = IEN ^ $$RESOLVE^TIUSRVLO(IEN)
|
|
"RTN","NHINVTIU",70,0)
|
|
N VDT,VTYP,VLOC,Y
|
|
"RTN","NHINVTIU",71,0)
|
|
S VDT=$P($P(NHX,U,8),";",2)
|
|
"RTN","NHINVTIU",72,0)
|
|
S VTYP=$$GET1^DIQ(8925,DA_",",.13)
|
|
"RTN","NHINVTIU",73,0)
|
|
S VLOC=$$GET1^DIQ(8925,DA_",",1211,"I")
|
|
"RTN","NHINVTIU",74,0)
|
|
S Y=VLOC_";"_VDT_";"_VTYP
|
|
"RTN","NHINVTIU",75,0)
|
|
Q Y
|
|
"RTN","NHINVTIU",76,0)
|
|
;
|
|
"RTN","NHINVTIU",77,0)
|
|
SIG(X) ; -- Return Signature Block Name_Title
|
|
"RTN","NHINVTIU",78,0)
|
|
N X20,Y S X20=$G(^VA(200,+$G(X),20))
|
|
"RTN","NHINVTIU",79,0)
|
|
S Y=$P(X20,U,2)_" "_$P(X20,U,3)
|
|
"RTN","NHINVTIU",80,0)
|
|
Q Y
|
|
"RTN","NHINVTIU",81,0)
|
|
;
|
|
"RTN","NHINVTIU",82,0)
|
|
RPT(NHY,IFN) ; -- Return text of document in @NHY@(n)
|
|
"RTN","NHINVTIU",83,0)
|
|
D TGET^TIUSRVR1(.NHY,IFN)
|
|
"RTN","NHINVTIU",84,0)
|
|
Q
|
|
"RTN","NHINVTIU",85,0)
|
|
;
|
|
"RTN","NHINVTIU",86,0)
|
|
TEXT(IFN) ; -- Return document IFN as a text string
|
|
"RTN","NHINVTIU",87,0)
|
|
N I,Y,NHY S IFN=+$G(IFN),Y=""
|
|
"RTN","NHINVTIU",88,0)
|
|
I IFN D
|
|
"RTN","NHINVTIU",89,0)
|
|
. D TGET^TIUSRVR1(.NHY,IFN)
|
|
"RTN","NHINVTIU",90,0)
|
|
. S I=0 F S I=$O(@NHY@(I)) Q:I<1 S Y=Y_$S($L(Y):$C(13,10),1:"")_@NHY@(I)
|
|
"RTN","NHINVTIU",91,0)
|
|
Q Y
|
|
"RTN","NHINVTIU",92,0)
|
|
;
|
|
"RTN","NHINVTIU",93,0)
|
|
; ------------ Return data to middle tier ------------
|
|
"RTN","NHINVTIU",94,0)
|
|
;
|
|
"RTN","NHINVTIU",95,0)
|
|
XML(DOC) ; -- Return patient documents as XML
|
|
"RTN","NHINVTIU",96,0)
|
|
N ATT,X,Y,NAMES,TYPE
|
|
"RTN","NHINVTIU",97,0)
|
|
D ADD("<document>") S NHINTOTL=$G(NHINTOTL)+1
|
|
"RTN","NHINVTIU",98,0)
|
|
S ATT="" F S ATT=$O(DOC(ATT)) Q:ATT="" D D:$L(Y) ADD(Y)
|
|
"RTN","NHINVTIU",99,0)
|
|
. I $O(DOC(ATT,0)) D S Y="" Q ;multiples
|
|
"RTN","NHINVTIU",100,0)
|
|
.. D ADD("<"_ATT_"s>")
|
|
"RTN","NHINVTIU",101,0)
|
|
.. S I=0 F S I=$O(DOC(ATT,I)) Q:I<1 D
|
|
"RTN","NHINVTIU",102,0)
|
|
... S X=$G(DOC(ATT,I)),NAMES=""
|
|
"RTN","NHINVTIU",103,0)
|
|
... I ATT="clinician" S NAMES="code^name^role^dateTime^signature^Z"
|
|
"RTN","NHINVTIU",104,0)
|
|
... S Y="<"_ATT_" "_$$LOOP_"/>" D ADD(Y)
|
|
"RTN","NHINVTIU",105,0)
|
|
.. D ADD("</"_ATT_"s>")
|
|
"RTN","NHINVTIU",106,0)
|
|
. S X=$G(DOC(ATT)),Y="" Q:'$L(X)
|
|
"RTN","NHINVTIU",107,0)
|
|
. I ATT="content" S Y="<"_ATT_" xml:space='preserve'>"_$$ESC^NHINV(X)_"</"_ATT_">" Q
|
|
"RTN","NHINVTIU",108,0)
|
|
. I X'["^" S Y="<"_ATT_" value='"_$$ESC^NHINV(X)_"' />" Q
|
|
"RTN","NHINVTIU",109,0)
|
|
. I $L(X)>1 S NAMES="code^name^Z",Y="<"_ATT_" "_$$LOOP_"/>"
|
|
"RTN","NHINVTIU",110,0)
|
|
D ADD("</document>")
|
|
"RTN","NHINVTIU",111,0)
|
|
Q
|
|
"RTN","NHINVTIU",112,0)
|
|
;
|
|
"RTN","NHINVTIU",113,0)
|
|
LOOP() ; -- build sub-items string from NAMES and X
|
|
"RTN","NHINVTIU",114,0)
|
|
N STR,P,TAG S STR=""
|
|
"RTN","NHINVTIU",115,0)
|
|
F P=1:1 S TAG=$P(NAMES,U,P) Q:TAG="Z" I $L($P(X,U,P)) S STR=STR_TAG_"='"_$$ESC^NHINV($P(X,U,P))_"' "
|
|
"RTN","NHINVTIU",116,0)
|
|
Q STR
|
|
"RTN","NHINVTIU",117,0)
|
|
;
|
|
"RTN","NHINVTIU",118,0)
|
|
ADD(X) ; Add a line @NHIN@(n)=X
|
|
"RTN","NHINVTIU",119,0)
|
|
S NHINI=$G(NHINI)+1
|
|
"RTN","NHINVTIU",120,0)
|
|
S @NHIN@(NHINI)=X
|
|
"RTN","NHINVTIU",121,0)
|
|
Q
|
|
"VER")
|
|
8.0^22.0
|
|
"BLD",7816,6)
|
|
^1
|
|
**END**
|
|
**END**
|