code to extract fulfillments of medications (# of times it's dispensed)

This commit is contained in:
sam 2013-02-20 23:15:15 +00:00
parent 20f5fb3239
commit f95d8d48db
1 changed files with 35 additions and 14 deletions

View File

@ -1,5 +1,5 @@
C0XPT3 ;ISI/MLS,VEN/SMH -- MEDS IMPORT;2013-02-19 5:01 PM
;;FILEMAN TRIPLE STORE;1.0;;;Jun 26,2012;Build 29
C0XPT3 ;ISI/MLS,VEN/SMH -- MEDS IMPORT;2013-02-20 3:15 PM
;;1.0;FILEMAN TRIPLE STORE;;Jun 26,2012;Build 29
;
MEDS(G,DFN) ; Private Proc; Extract Medication Data from a Patient's Graph
; G - Patient Graph, DFN - you should know this
@ -11,12 +11,14 @@ MEDS(G,DFN) ; Private Proc; Extract Medication Data from a Patient's Graph
;
K ^TMP($J,"MEDS")
QUIT
;
MED1(G,S) ; Private Procedure; Process each medication in Graph.
; G = Graph; S = Medication Description ID as subject.
;
; 1. Start Date; obtain and then conv to fileman format
N STARTDT S STARTDT=$$GSPO1^C0XGET3(G,S,"sp:startDate") ; Duh! Start Date.
X "N %DT,X,Y S X=STARTDT D ^%DT S STARTDT=Y" ; New stack level for variables.
D
. N %DT,X,Y S X=STARTDT D ^%DT S STARTDT=Y ; New stack level for variables.
;
;DEBUG.ASSERT that STARTDT is greater than 1900
I STARTDT'>2000000 S $EC=",U1,"
@ -34,15 +36,34 @@ MED1(G,S) ; Private Procedure; Process each medication in Graph.
N INST S INST=$$GSPO1^C0XGET3(G,S,"sp:instructions")
;
; 5. Drug Name and Code
N RXN S RXN=$$GSPO1^C0XGET3(G,S,"sp:drugName.sp:code") ; RxNorm Code
N RXN S RXN=$$GSPO1^C0XGET3(G,S,"sp:drugName.sp:code"),RXN=$P(RXN,"/",$L(RXN,"/")) ; RxNorm Code
N DN S DN=$$GSPO1^C0XGET3(G,S,"sp:drugName.dcterms:title") ; Drug Name
;
W S," ",FVALUE_FUNIT," ",DOSE," ",DUNIT," ",INST," ",DN,!
;
; 6. Get Fill Dates
;TODO.
N FULF ; Fulfillments
D GSPO^C0XGET3($NA(FULF),G,S,"sp:fulfillment")
;
N FILLS ; Fills array. Contains every time a drug was dispensed.
N FILL S FILL="" F S FILL=$O(FULF(FILL)) Q:FILL="" D
. N S S S=FULF(FILL) ; New subject; subsumes above one in this loop
. ;
. ; Dispense Date
. N FILLDATE S FILLDATE=$$GSPO1^C0XGET3(G,S,"dcterms:date")
. D
. . N %DT,X,Y S X=FILLDATE D ^%DT S FILLDATE=Y
. I FILLDATE<2000000 W $EC=",U1," ; Converstion error
. ;
. S FILLS(RXN,FILLDATE,"sp:dispenseDaysSupply")=$$GSPO1^C0XGET3(G,S,"sp:dispenseDaysSupply") ; Self Explanatory?
. ;
. ; Get quantity value and unit
. S FILLS(RXN,FILLDATE,"sp:quantityDispensed.sp:value")=$$GSPO1^C0XGET3(G,S,"sp:quantityDispensed.sp:value")
. S FILLS(RXN,FILLDATE,"sp:quantityDispensed.sp:unit")=$TR($$GSPO1^C0XGET3(G,S,"sp:quantityDispensed.sp:unit"),"{}")
;
ZWRITE:$D(FILLS) FILLS
QUIT
;
MED(ISIMISC) ;Create med order entry
; Input - ISIMISC(ARRAY)
; Format: ISIMISC(PARAM)=VALUE
@ -66,7 +87,7 @@ MED(ISIMISC) ;Create med order entry
S ISIRESUL(1)=PSOIEN
Q ISIRC
;
PREP
PREP ;
;
N EXIT
S ORZPT=ISIMISC("DFN") ;"" ;POINTER TO PATIENT FILE (#2)
@ -100,7 +121,7 @@ PREP
S SIG=ISIMISC("SIG") ;#51,.01
Q
;
CREATE
CREATE ;
D AUTO^PSONRXN ;RX auto number
I $G(PSONEW("RX #"))="" S ISIRC="-1^RX Auto number error." Q
S RXNUM=PSONEW("RX #")