source: WorldVistAEHR/trunk/r/TEXT_INTEGRATION_UTILITIES-GMRP-TIU/TIUPXAP1.m@ 1361

Last change on this file since 1361 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 6.2 KB
RevLine 
[613]1TIUPXAP1 ; SLC/JER - Interface w/PCE/Visit Tracking ;28-OCT-2003 16:45:37 [8/18/04 11:24am]
2 ;;1.0;TEXT INTEGRATION UTILITIES;**15,29,20,89,82,107,117,126,124,149,179,205**;Jun 20, 1997;Build 1
3QUE ; Use a RESOURCE to post visit tracking information in background
4 N ZTDTH,ZTIO,ZTSAVE,ZTSK,ZTRTN,ZTDESC
5 ; if there is already a visit, and no workload data quit
6 I +$P($G(TIUDPRM(0)),U,16),(+$P($G(^TIU(8925,$S(+$G(TIUDA):+$G(TIUDA),1:+$G(DA)),0)),U,11)=0),+$$WORKOK($S(+$G(TIUDA):+$G(TIUDA),1:+$G(DA))) D Q:'$$BROKER^XWBLIB
7 . D DEFER($S(+$G(TIUDA):+$G(TIUDA),1:+$G(DA)))
8 I +$G(TIU("VISIT")),($D(CPT)'>9) Q
9 I +$P($G(^TIU(8925,$S(+$G(TIUDA):+$G(TIUDA),1:+$G(DA)),0)),U,3),($D(CPT)'>9) Q
10 S (ZTSAVE("TIU("),ZTSAVE("DFN"),ZTSAVE("TIUDA"),ZTSAVE("DA"))=""
11 S (ZTSAVE("DUZ("),ZTSAVE("ICD("),ZTSAVE("CPT("),ZTSAVE("SC("))=""
12 S (ZTSAVE("TIUPRLST("),ZTSAVE("XWBOS"))=""
13 S ZTDTH=$H,ZTIO="TIU/PXAPI RESOURCE",ZTRTN="ENQ^TIUPXAP1"
14 S ZTDESC="TIU/PCE/AmbCare API Call" D ^%ZTLOAD
15 I '$D(ZTSK) D ENQ ; If can't get Resource, Run PXAPI call in foreground
16 Q
17WORKOK(DA) ; Evaluate whether workload collection is appropriate
18 N TIUD0 S TIUD0=$G(^TIU(8925,DA,0))
19 Q $S($P(TIUD0,U,13)="A":1,$P(TIUD0,U,13)="I":1,$P(TIUD0,U,13)="T":1,1:0)
20ENQ ; Entry point for Resource
21 I $D(ZTQUEUED) S ZTREQ="@"
22 D POST(.TIU,DFN,$S(+$G(TIUDA):+$G(TIUDA),1:$G(DA)),.ICD,.CPT,.SC)
23 Q
24POST(TIUX,DFN,TIUDA,ICD,CPT,SC) ; Call on commitment to post data to PCE/AmbCare
25 N TIULOC,TIUVDT,TIUSTOP,TIUVCAT,TIUVSIT,TIUD0
26 S TIULOC=$P($G(TIUX("VSTR")),";"),TIUVDT=+$P($G(TIUX("VSTR")),";",2)
27 S TIUVCAT=$P($G(TIUX("VSTR")),";",3),TIUSTOP=$P($G(^SC(+TIULOC,0)),U,7)
28 D PXAPI(.TIUVSIT,DFN,TIULOC,TIUVDT,TIUVCAT,TIUSTOP,.ICD,.CPT,.SC,TIUDA)
29 I +$G(TIUVSIT)>0,+$G(TIUDA)>0,$D(^TIU(8925,+TIUDA,0)) S TIUD0=^(0) D
30 . I $P(TIUD0,U,2)=DFN,$P(TIUD0,U,7)=TIUVDT,$P($G(^TIU(8925,+TIUDA,12)),U,11)=TIULOC D
31 . . N DIE,DR,DA S DA=+$G(TIUDA)
32 . . S DIE=8925,DR=".03////^S X="_+$G(TIUVSIT)
33 . . D ^DIE
34 . . S TIUX("VISIT")=+$G(TIUVSIT)_U_TIUVDT
35 Q
36PXAPI(TIUVSIT,DFN,VLOC,VDT,VCAT,VSTOP,ICD,CPT,SC,TIUDA) ; Build input root
37 N TIUPXAPI,SUCCESS,TIUI,TIUPROV,DA,TIUAUTH
38 K ^TMP("TIUPXAPI",$J) S TIUPXAPI=$NA(^TMP("TIUPXAPI",$J))
39 S:+$G(VDT) @TIUPXAPI@("ENCOUNTER",1,"ENC D/T")=+$G(VDT)
40 S:+$G(DFN) @TIUPXAPI@("ENCOUNTER",1,"PATIENT")=+$G(DFN)
41 S:+$G(VLOC) @TIUPXAPI@("ENCOUNTER",1,"HOS LOC")=+$G(VLOC)
42 I $D(SC)>9 D
43 . S @TIUPXAPI@("ENCOUNTER",1,"SC")=$P($G(SC("SC")),U)
44 . I $G(SC("AO"))]"" S @TIUPXAPI@("ENCOUNTER",1,"AO")=$P($G(SC("AO")),U)
45 . I $G(SC("IR"))]"" S @TIUPXAPI@("ENCOUNTER",1,"IR")=$P($G(SC("IR")),U)
46 . I $G(SC("EC"))]"" S @TIUPXAPI@("ENCOUNTER",1,"EC")=$P($G(SC("EC")),U)
47 . I $G(SC("MST"))]"" S @TIUPXAPI@("ENCOUNTER",1,"MST")=$P($G(SC("MST")),U)
48 . I $G(SC("HNC"))]"" S @TIUPXAPI@("ENCOUNTER",1,"HNC")=$P($G(SC("HNC")),U)
49 I $D(CPT) S @TIUPXAPI@("ENCOUNTER",1,"CHECKOUT D/T")=$E($$NOW^XLFDT,1,12)
50 S:$G(VCAT)]"" @TIUPXAPI@("ENCOUNTER",1,"SERVICE CATEGORY")=$G(VCAT)
51 S:+$G(VSTOP) @TIUPXAPI@("ENCOUNTER",1,"DSS ID")=+$G(VSTOP)
52 S @TIUPXAPI@("ENCOUNTER",1,"APPT")=9
53 S @TIUPXAPI@("ENCOUNTER",1,"ENCOUNTER TYPE")="P"
54 I $D(TIUPRLST) D
55 . M @TIUPXAPI@("PROVIDER")=TIUPRLST
56 . S TIUPROV=$S($G(TIUPRLST(1,"PRIMARY")):$G(TIUPRLST(1,"NAME")),1:$G(TIUPRLST(2,"NAME")))
57 E D
58 . N TIUDDOC
59 . I +$G(TIUDA) D
60 . . S TIUAUTH=$P($G(^TIU(8925,+$G(TIUDA),12)),U,2) Q:+TIUAUTH'>0
61 . . I +$$PROVIDER(TIUAUTH,$G(VDT))'>0 S TIUAUTH=0
62 . S TIUDDOC=+$$DFLTDOC^TIUPXAPI(+$G(VLOC))
63 . D:'$D(TIUPRM0) SETPARM^TIULE
64 . S TIUPROV=$S(+$G(TIUAUTH):+$G(TIUAUTH),+$$PROVIDER(DUZ,$G(VDT)):+$G(DUZ),1:"")
65 . I +TIUPROV>0,'$D(XWBOS) D
66 . . I +TIUDDOC'=+TIUPROV,(+$P(TIUPRM0,U,8)=1),+TIUDDOC>0 D
67 . . . ; Get Provider information from Encounter.
68 . . . ; If ENC has no provicders then add default provider as primary.
69 . . . ; Add TIUPROV unless already primary provider for encounter.
70 . . . N TIUPRIME,TIUPVCNT,TIUTVST,TIUTPRV,TIUPDATA
71 . . . S TIUPRIME="",TIUPVCNT=1
72 . . . D GETENC^PXAPI($G(DFN),$G(VDT),$G(VLOC))
73 . . . S TIUTVST=""
74 . . . F S TIUTVST=$O(^TMP("PXKENC",$J,TIUTVST)) Q:TIUTVST="" D
75 . . . . S TIUTPRV=""
76 . . . . F S TIUTPRV=$O(^TMP("PXKENC",$J,TIUTVST,"PRV",TIUTPRV)) Q:TIUTPRV="" D
77 . . . . . S TIUPDATA=$G(^TMP("PXKENC",$J,TIUTVST,"PRV",TIUTPRV,0))
78 . . . . . I $P(TIUPDATA,"^",4)="P" S TIUPRIME=+TIUPDATA
79 . . . I 'TIUPRIME D
80 . . . . S @TIUPXAPI@("PROVIDER",TIUPVCNT,"NAME")=+TIUDDOC
81 . . . . S @TIUPXAPI@("PROVIDER",TIUPVCNT,"PRIMARY")=1
82 . . . . S TIUPVCNT=TIUPVCNT+1
83 . . . S @TIUPXAPI@("PROVIDER",TIUPVCNT,"NAME")=+TIUPROV
84 . . E D
85 . . . S @TIUPXAPI@("PROVIDER",1,"NAME")=+TIUPROV
86 I $D(ICD)>9 S TIUI=0 F S TIUI=$O(ICD(TIUI)) Q:+TIUI'>0 D
87 . S @TIUPXAPI@("DX/PL",TIUI,"ENC PROVIDER")=$G(TIUPROV)
88 . S @TIUPXAPI@("DX/PL",TIUI,"DIAGNOSIS")=$P(ICD(TIUI),U)
89 . S @TIUPXAPI@("DX/PL",TIUI,"NARRATIVE")=$P(ICD(TIUI),U,3)
90 . S:$P(ICD(TIUI),U,4)]"" @TIUPXAPI@("DX/PL",TIUI,"CATEGORY")=$P(ICD(TIUI),U,4)
91 . S:+$G(ICD(TIUI,"PRIMARY")) @TIUPXAPI@("DX/PL",TIUI,"PRIMARY")=$G(ICD(TIUI,"PRIMARY"))
92 I $D(CPT)>9 S TIUI=0 F S TIUI=$O(CPT(TIUI)) Q:+TIUI'>0 D
93 . S @TIUPXAPI@("PROCEDURE",TIUI,"PROCEDURE")=$P(CPT(TIUI),U)
94 . S @TIUPXAPI@("PROCEDURE",TIUI,"QTY")=$S(+$G(CPT(TIUI,"QTY")):+$G(CPT(TIUI,"QTY")),1:1)
95 . ;Set CPT Modifiers in Array for PCE
96 . N MODCNT,MODATA
97 . S MODCNT=0
98 . F S MODCNT=$O(CPT(TIUI,"MOD",MODCNT)) Q:'MODCNT D
99 . . S MODATA=$G(CPT(TIUI,"MOD",MODCNT))
100 . . S:$P(MODATA,U,2)'="" @TIUPXAPI@("PROCEDURE",TIUI,"MODIFIERS",$P(MODATA,U,2))=""
101 . S @TIUPXAPI@("PROCEDURE",TIUI,"ENC PROVIDER")=$G(TIUPROV)
102 . S @TIUPXAPI@("PROCEDURE",TIUI,"NARRATIVE")=$P(CPT(TIUI),U,2)
103 . S:$P(CPT(TIUI),U,3)]"" @TIUPXAPI@("PROCEDURE",TIUI,"CATEGORY")=$P(CPT(TIUI),U,3)
104 S SUCCESS=$$DATA2PCE^PXAPI(TIUPXAPI,"TIU","TEXT INTEGRATION UTILITIES",.TIUVSIT,DUZ,0)
105 K @TIUPXAPI
106 Q
107PROVIDER(USER,DATE) ; Was USER a PROVIDER on DATE?
108 N TIUY,PRVCL,EXCL S TIUY=0
109 S EXCL="V0802V0805V0806V0808V0809V0812V0813"
110 I +$$ISA^USRLM(USER,"PROVIDER") S TIUY=1 G PROVIDEX
111 S PRVCL=$$PRVCLASS^PXAPI(USER,DATE) I PRVCL'>0 G PROVIDEX
112 I $P(PRVCL,U,7)]"",(EXCL'[$E($P(PRVCL,U,7),1,5)) S TIUY=1
113PROVIDEX Q TIUY
114DEFER(DA) ; Mark record to defer workload collection
115 N DIE,DR,TIUVSIT
116 I +$P($G(^TIU(8925,$S(+$G(TIUDA):+$G(TIUDA),1:+$G(DA)),0)),U,11)=1 Q
117 S DIE=8925,DR=".11////1" D ^DIE
118 ;If not called via the broker try to link document to an existing visit
119 I '$$BROKER^XWBLIB,$$LNKVST^TIUPXAP3(+DA,.TIUVSIT)
120 Q
Note: See TracBrowser for help on using the repository browser.