Package: edc-visit-schedule
edc-visit-scheduleAdd longitudinal data collection schedules to your EDC project.InstallationAdd to settings:INSTALLED_APPS=[...'edc_visit_schedule.apps.AppConfig',...]OverviewAVisit Schedulelives in your app invisit_schedules.py. Each app can declare and register one or more visit schedules in itsvisit_schedulesmodule. Visit schedules are loaded whenautodiscoveris called fromAppConfig.AVisitSchedulecontainsScheduleswhich containVisitswhich containCrfsandRequisitions.Ascheduleis effectively a “data collection schedule” where each containedvisitrepresents a data collection timepoint.A subject is put on ascheduleby the schedule’sonschedulemodel and taken off by the schedule’soffschedulemodel. In the example below we use modelsOnScheduleandOffScheduleto do this for scheduleschedule1.UsageFirst, create a filevisit_schedules.pyin the root of your app where the visit schedule code below will live.Next, declare lists of dataCrfsand laboratoryRequisitionsto be completed during each visit. For simplicity, we assume that every visit has the same data collection requirement (not usually the case).frommyapp.modelsimportSubjectVisit,OnSchedule,OffSchedule,SubjectDeathReport,SubjectOffstudyfromedc_visit_schedule.site_visit_schedulesimportsite_visit_schedulesfromedc_visit_schedule.scheduleimportSchedulefromedc_visit_schedule.visitimportCrf,Requisition,CrfCollection,RequisitionCollectionfromedc_visit_schedule.visit_scheduleimportVisitSchedulecrfs=CrfCollection(Crf(show_order=10,model='myapp.crfone'),Crf(show_order=20,model='myapp.crftwo'),Crf(show_order=30,model='myapp.crfthree'),Crf(show_order=40,model='myapp.crffour'),Crf(show_order=50,model='myapp.crffive'),)requisitions=RequisitionCollection(Requisition(show_order=10,model='myapp.subjectrequisition',panel_name='Research Blood Draw'),Requisition(show_order=20,model='myapp.subjectrequisition',panel_name='Viral Load'),)Create a new visit schedule:visit_schedule=VisitSchedule(name='visit_schedule',verbose_name='My Visit Schedule',death_report_model=SubjectDeathReport,offstudy_model=SubjectOffstudy)Visit schedules containSchedulesso create a schedule:schedule=Schedule(name='schedule',onschedule_model='myapp.onschedule',offschedule_model='myapp.offschedule',consent_definitions=[consent_definition_v1])About consent_definitions:As you will see below, thescheduleis a container for a data collection schedule of forms (CRFs and requisitions)
for a single study timepoint orvisit. Ethically, a subject’s data may not be collected before the subject has signed and submitted the informed consent form (ICF).Scheduleis configured with information about the ICF that covers the forms it contains. When a form for a subject is validated and submitted, theSchedulewill
provide the consent_definition (or definitions) so that the calling object can confirm the subject is consented. The ICF is represented by
the classConsentDefinitionfromedc_consent.See also classConsentDefinitioninedc_consent.Schedules contains visits, so declare some visits and add to theschedule:visit0=Visit(code='1000',title='Visit 1000',timepoint=0,rbase=relativedelta(days=0),requisitions=requisitions,crfs=crfs)visit1=Visit(code='2000',title='Visit 2000',timepoint=1,rbase=relativedelta(days=28),requisitions=requisitions,crfs=crfs)schedule.add_visit(visit=visit0)schedule.add_visit(visit=visit1)Add the schedule to your visit schedule:schedule=visit_schedule.add_schedule(schedule)Register the visit schedule with the site registry:visit_schedules.register(visit_schedule)When Django loads, the visit schedule class will be available in the globalsite_visit_schedules.Thesite_visit_scheduleshas a number of methods to help query the visit schedule and some related data.Note:Thescheduleabove was declared withonschedule_model=OnSchedule. An on-schedule model uses theCreateAppointmentsMixinfromedc_appointment. Ononschedule.save()the methodonschedule.create_appointmentsis called. This method uses the visit schedule information to create the appointments as per the visit data in the schedule. See alsoedc_appointment.OnSchedule and OffSchedule modelsTwo models mixins are required for the on-schedule and off-schedule models,OnScheduleModelMixinandOffScheduleModelMixin. OnSchedule/OffSchedule models are specific to aschedule. Thevisit_schedule_nameandschedule_nameare declared on the model’sMetaclass attributevisit_schedule_name.For example:classOnSchedule(OnScheduleModelMixin,BaseUuidModel):"""A model used by the system. Auto-completed by subject_consent."""objects=SubjectIdentifierManager()on_site=CurrentSiteManager()history=HistoricalRecords()classMeta(OnScheduleModelMixin.Meta,BaseUuidModel.Meta):passclassOffSchedule(ActionModelMixin,OffScheduleModelMixin,BaseUuidModel):action_name=OFFSCHEDULE_ACTIONclassMeta(OffScheduleModelMixin.Meta,BaseUuidModel.Meta):verbose_name="Off-schedule"verbose_name_plural="Off-schedule"