ddediu / AdhereR

Computation of adherence to medications from Electronic Healthcare Data in R
26 stars 6 forks source link

Dates for FUW and OW window #128

Closed alexadima closed 4 years ago

alexadima commented 4 years ago

When selecting dates for start of FUW and OW window, CMA0 gives error "OW is not within the FUW for participant x" and "errors concerning the FUW and OW"

DATA <- med.events; .data.for.selected.patients. <- get.data.for.patients.fnc( c("1"), DATA, ### don't forget to put here your REAL DATA! ### "PATIENT_ID" ); cma <- CMA0(data=.data.for.selected.patients.,

(please note that even if some parameters are

        # not relevant for a particular CMA type, we
        # nevertheless pass them as they will be ignored)
        ID.colname="PATIENT_ID",
        event.date.colname="DATE",
        event.duration.colname="DURATION",
        event.daily.dose.colname="PERDAY",
        medication.class.colname="CATEGORY",
        carry.only.for.same.medication=FALSE,
        consider.dosage.change=FALSE,
        followup.window.start="12/07/2019",
        followup.window.start.unit="days",
        followup.window.duration=24,
        followup.window.duration.unit="months",
        observation.window.start="12/30/2019",
        observation.window.start.unit="days",
        observation.window.duration=6,
        observation.window.duration.unit="months",
        date.format="%m/%d/%Y"
       );

if( !is.null(cma) ) # if the CMA was computed ok { plot(cma, align.all.patients=FALSE, align.first.event.at.zero=TRUE, show.legend=TRUE, legend.x="right", legend.y="bottom", legend.bkg.opacity=0.5, legend.cex=0.75, legend.cex.title=1, duration=720, show.period="dates", period.in.days=30, bw.plot=FALSE, col.na="#D3D3D3", unspecified.category.label="drug", col.cats=rainbow, lty.event="solid", lwd.event=2, pch.start.event=15, pch.end.event=16, col.continuation="#000000", lty.continuation="dotted", lwd.continuation=1, cex=1, cex.axis=0.75, cex.lab=1, highlight.followup.window=TRUE, followup.window.col="#00FF00", highlight.observation.window=TRUE, observation.window.col="#FFFF00", observation.window.opacity=0.3, show.real.obs.window.start=TRUE, print.CMA=TRUE, CMA.cex=0.5, plot.CMA=TRUE, CMA.plot.ratio=0.1, CMA.plot.col="#90EE90", CMA.plot.border="#006400", CMA.plot.bkg="#7FFFD4", CMA.plot.text="#006400", plot.CMA.as.histogram=TRUE, show.event.intervals=TRUE, print.dose=FALSE, cex.dose=0.01, print.dose.outline.col="#FFFFFF", print.dose.centered=FALSE, plot.dose=FALSE, lwd.event.max.dose=8, plot.dose.lwd.across.medication.classes=FALSE, min.plot.size.in.characters.horiz=0, min.plot.size.in.characters.vert=0 ); }

ddediu commented 4 years ago

Now should work both in plot() and in Shiny! Besides, now plot() also accepts strings formatted as per date.format and not justDate() objects as before...