1 | C0XPT4 ; VEN/SMH - Encounter Processing;2013-05-01 4:09 PM
|
---|
2 | ;;1.0;FILEMAN TRIPLE STORE;
|
---|
3 | ; (c) 2013 Sam Habiel
|
---|
4 | ; Currently proprietary code. Stay out!!!
|
---|
5 | ;
|
---|
6 | ENC(G,DFN) ; Extract and then process encounters; PEP
|
---|
7 | ;
|
---|
8 | ; ---PRIVATE TO SAM---
|
---|
9 | D DELALL(DFN) ; Delete all Encounters period...
|
---|
10 | ; ---PRIVATE TO SAM---
|
---|
11 | ;
|
---|
12 | K ^TMP($J,"ENC") ; data location
|
---|
13 | D ONETYPE^C0XGET3($NA(^TMP($J,"ENC")),G,"sp:Encounter") ; extract encounters
|
---|
14 | W "Encounters: ",!
|
---|
15 | N S F S=0:0 S S=$O(^TMP($J,"ENC",S)) Q:S="" W S," ",^(S) D W !
|
---|
16 | . N STARTDATE S STARTDATE=$$GSPO1^C0XGET3(G,S,"sp:startDate")
|
---|
17 | . S STARTDATE=$$FMDATE(STARTDATE)
|
---|
18 | . W " ",STARTDATE
|
---|
19 | . D HISTENC(STARTDATE,DFN) ; Historical Encounter Private API
|
---|
20 | QUIT
|
---|
21 | ;
|
---|
22 | ;
|
---|
23 | FMDATE(STARTDATE) ; Internal to fix start date
|
---|
24 | ; Replace 00:00:00 with 00:00:01. Fileman doesn't understand null time for midnight except as .24 for yesterday
|
---|
25 | ; and replace the space with an @ because Fileman needs that to figure out that time comes next after date
|
---|
26 | I STARTDATE["00:00:00" S $E(STARTDATE,$L(STARTDATE))=1
|
---|
27 | S STARTDATE=$P(STARTDATE," ")_"@"_$P(STARTDATE," ",2)
|
---|
28 | ; Conv to Fileman
|
---|
29 | D
|
---|
30 | . N X,Y,%DT
|
---|
31 | . S X=STARTDATE,%DT="TS" D ^%DT
|
---|
32 | . S STARTDATE=Y
|
---|
33 | Q STARTDATE
|
---|
34 | ;
|
---|
35 | ;
|
---|
36 | HISTENC(DATE,DFN,FTLOC,COMMENT) ; Private Proc; Historical Encounter Filing into the VISIT file
|
---|
37 | ; Input:
|
---|
38 | ; - DATE: FM DATE of VISIT (Scalar) - Required
|
---|
39 | ; - DFN (Scalar) - Required
|
---|
40 | ; - FTLOC: Free Text Location - Optional. Defaults to SMART LOCATION
|
---|
41 | ; - COMMENT: Free Text Comment - Optional. Defaults to Imported from Smart
|
---|
42 | ; Output:
|
---|
43 | ; - Creates V file entries for the historical encounter
|
---|
44 | ;
|
---|
45 | ; Handle required and optional variables...
|
---|
46 | N X F X="DATE","DFN" I '$D(@X) S $EC=",U1," ; Check for the present of required input variables
|
---|
47 | S FTLOC=$G(FTLOC,"SMART LOCATION") ; Get default if not supplied
|
---|
48 | S COMMENT=$G(COMMENT,"Imported from Smart") ; ditto
|
---|
49 | ;
|
---|
50 | ; Get package name
|
---|
51 | N PKG S PKG=$O(^DIC(9.4,"B","FILEMAN TRIPLE STORE",0)) I 'PKG S $EC=",U1,"
|
---|
52 | ;
|
---|
53 | ; Source
|
---|
54 | N SRC S SRC="FMTS PATIENT IMPORTER"
|
---|
55 | ;
|
---|
56 | ; Input Array for $$DATA2PCE
|
---|
57 | N C0XDATA
|
---|
58 | S C0XDATA("ENCOUNTER",1,"ENC D/T")=DATE
|
---|
59 | S C0XDATA("ENCOUNTER",1,"PATIENT")=DFN
|
---|
60 | S C0XDATA("ENCOUNTER",1,"SERVICE CATEGORY")="E" ; EVENT
|
---|
61 | S C0XDATA("ENCOUNTER",1,"OUTSIDE LOCATION")=FTLOC
|
---|
62 | S C0XDATA("ENCOUNTER",1,"ENCOUNTER TYPE")="P" ; Primary
|
---|
63 | S C0XDATA("ENCOUNTER",1,"COMMENT")=COMMENT
|
---|
64 | ;
|
---|
65 | N C0XVISIT,C0XERR ; Visit, Error
|
---|
66 | N OK S OK=$$DATA2PCE^PXAPI($NA(C0XDATA),PKG,SRC,.C0XVISIT,,,.C0XERR)
|
---|
67 | I 'OK S $EC=",U1,"
|
---|
68 | QUIT
|
---|
69 | ;
|
---|
70 | ;
|
---|
71 | DELALL(DFN) ; Private Proc; Delete ALL ALL ALL encounter information for the patient.
|
---|
72 | ; BE VERY CAREFUL USING THIS...
|
---|
73 | ; Walk through the C X-Ref for this patient
|
---|
74 | N I S I=9000009.999999999999 ; Hit the VISIT file first
|
---|
75 | N DIK,DA
|
---|
76 | F S I=$O(^DIC(I)) Q:I'<9000011 D ; For each V File...
|
---|
77 | . N OR S OR=$$ROOT^DILFD(I,"",0) ; Open Root for ^DIK
|
---|
78 | . N CR S CR=$$ROOT^DILFD(I,"",1) ; Closed Root for @CR@("C")
|
---|
79 | . ; W OR," ",CR ; DEBUG
|
---|
80 | . ; W ": " ; DEBUG
|
---|
81 | . S DIK=OR ; File root to kill
|
---|
82 | . N J S J="" F S J=$O(@CR@("C",DFN,J)) Q:'J S DA=J D ^DIK ; each entry to kill
|
---|
83 | . ; W ! ; DEBUG
|
---|
84 | ;
|
---|
85 | N I S I=""
|
---|
86 | ; W "SCE: " ; Debug
|
---|
87 | S DIK="^SCE(" ; ditto
|
---|
88 | F S I=$O(^SCE("C",DFN,I)) Q:'I S DA=I D ^DIK ; ditto
|
---|
89 | QUIT
|
---|
90 | ;
|
---|
91 | ;
|
---|
92 | TEST ; Test creating an encounter using DATA2PCE^PXAPI
|
---|
93 | ; Thank you Kevin Muldrum!
|
---|
94 | ; This code comes from EDP aka EDIS.
|
---|
95 | N DFN S DFN=188 ; One of those Ducks
|
---|
96 | ;S LOC=$$GET^XPAR(DUZ(2)_";DIC(4,","EDPF LOCATION")
|
---|
97 | S LOC=2 ; DR OFFICE
|
---|
98 | N EDPKG,EDPSRC,OK
|
---|
99 | S EDPKG=$O(^DIC(9.4,"B","EMERGENCY DEPARTMENT",0))
|
---|
100 | S EDPSRC="EDP TRACKING LOG"
|
---|
101 | S EDPDATA("ENCOUNTER",1,"PATIENT")=DFN
|
---|
102 | S EDPDATA("ENCOUNTER",1,"HOS LOC")=LOC
|
---|
103 | S EDPDATA("ENCOUNTER",1,"SERVICE CATEGORY")="A"
|
---|
104 | S EDPDATA("ENCOUNTER",1,"ENCOUNTER TYPE")="P"
|
---|
105 | S EDPDATA("ENCOUNTER",1,"ENC D/T")=$$NOW^XLFDT
|
---|
106 | ;
|
---|
107 | S EDPDATA("DX/PL",1,"DIAGNOSIS")=$O(^ICD9("BA","V70.3 ",0))
|
---|
108 | S EDPDATA("PROCEDURE",1,"PROCEDURE")=$O(^ICPT("B","99201",0))
|
---|
109 | S EDPDATA("PROCEDURE",1,"QTY")=1
|
---|
110 | S EDPDATA("PROVIDER",1,"NAME")=23
|
---|
111 | ;
|
---|
112 | S OK=$$DATA2PCE^PXAPI("EDPDATA",EDPKG,EDPSRC,.EDPVISIT,23,1,.ERR)
|
---|
113 | W OK
|
---|
114 | Q
|
---|
115 | ;
|
---|
116 | ;
|
---|
117 | TEST2 ; Test creating an historical event
|
---|
118 | ;
|
---|
119 | N DFN S DFN=188
|
---|
120 | N LOC S LOC=1
|
---|
121 | N PKG S PKG=$O(^DIC(9.4,"B","FILEMAN TRIPLE STORE",0))
|
---|
122 | I 'PKG S $EC=",U1,"
|
---|
123 | ;
|
---|
124 | N SRC S SRC="FMTS TEST"
|
---|
125 | ;
|
---|
126 | N C0XDATA
|
---|
127 | S C0XDATA("ENCOUNTER",1,"ENC D/T")=$$NOW^XLFDT
|
---|
128 | S C0XDATA("ENCOUNTER",1,"PATIENT")=DFN
|
---|
129 | S C0XDATA("ENCOUNTER",1,"SERVICE CATEGORY")="E" ; EVENT
|
---|
130 | S C0XDATA("ENCOUNTER",1,"OUTSIDE LOCATION")="FROM THE WIDE WORLD"
|
---|
131 | S C0XDATA("ENCOUNTER",1,"ENCOUNTER TYPE")="P" ; Primary
|
---|
132 | S C0XDATA("ENCOUNTER",1,"COMMENT")="Testing"
|
---|
133 | ;
|
---|
134 | S OK=$$DATA2PCE^PXAPI($NA(C0XDATA),PKG,SRC,.C0XVISIT,,,.ERR)
|
---|
135 | QUIT
|
---|