ImmuneMed = as.numeric(unlist(strsplit(c("23850	6882	50996	52833	42273	30495	39115	13320	55773	53869	54982	36792	671	451	32101	43077	34816	41670	19072	12339	26261	1899	270	14395	571	34687	43562	53956	53797	21899	42988	34451	29340	31215	41620	22982	35518	51181	770	39787	55021	47042	3896	54975	42449	46395	47192	973	13556	48556	54134	52615	13494	1905	1626	16035	16137	53969	19222	38525	42924	47377	2838	55116	42637	49958	46637	53175	47471	3920	972	48763	52743	2837	54974	42448	53176	47102	47047	4231	15596	48798	54867	38056	26790	19370	26322	31193	3984	47752	29840	44309	26066	44273	16105	34728	3985	10729	47843	15921	14886	36008	35419	36556	35126	26387	19257	50998	49856	41058	16822	22392	877	34929	21753	32865	37117	36800	36849	28041	27404	46156	46265	30780	823	51120	32111	20951	13428	49951	52606	53385	41104	17035	40273	40292	45165	46129	46197	40328	45558	24634	44908	50950	46039	35402	35865	35752	18424	41585	12816	40371	40356	7337	46152	46098	7336	40281	40284	16540	27400	18890	36167	46407	27342	51667	34258	14347	26064	14348	17672	40293	16519	33601	8583	27642	30703	32229	29069	24783	51321	53696	8327	49547	41086	30932	9528	40301	40280	16570	14748	21732	52488	16919	45489	47789	18804	45043	45393	16879	4438	54317	53255	4230	50669	47746	30581	7077	27290	27289	35301	26097	47502	28490	39111	36294	47240	47852	44640	47416	2839	48339	3683	47239	52993	47512	54198	51184	44804	47276	37985	37155	55066	44926	40964	6495	51790	5870	51185	54048	5089	13271	55010	47984	44641	47506	33123	47432	6633	5817	6950	5838	46324	39633	46325	43081	37506	43082	40765	38113	38989	38919"), "\\s+")[[1]]))
Parkinsoncodes = as.numeric(unlist(strsplit(c("1691	4321	8956	9509	10718	14912	16860	17004	53655	59824	86062	96860	101090"), "\\s+")[[1]]))

#find ImmuneMed in prodcode
SelImmuneMed = select_events(db,tab="Therapy001", columns = '*',
              where = "prodcode %in% .(ImmuneMed)")
countIMP =  nrow(SelImmuneMed)
UniqueIMP = length(unique(SelImmuneMed$prodcode))

#find parkinsoncodes among medcodes
SelParkinsoncodes = select_events(db,tab="Clinical001", columns = '*',
              where = "medcode %in% .(Parkinsoncodes)")
countPP = nrow(SelParkinsoncodes)
UniquePP = length(unique(SelParkinsoncodes$patid))

#Calculate drug duration * dose *


UsedMed <- SelImmuneMed %>% 
  mutate(MedMultiplication = numdays * numpacks * packtype)


