Esempio n. 1
0
	/**
	 * @param $record
	 * @param $redcap_event_name
	 * @param $instrument
	 * @param $debug
	 */
	public static function code_terms($record, $redcap_event_name, $instrument, $debug)
	{
		global $Proj, $project_id, $tx_fragment_labels;
		$this_event_id = $Proj->getEventIdUsingUniqueEventName($redcap_event_name);
		switch ($instrument) {
			case 'ae_coding':
				$recode_llt = false;
				$recode_pt = true;
				$recode_soc = true;
				$prefix = 'ae';
				/**
				 * AE_AEMODIFY
				 */
				$fields = array("ae_aeterm", "ae_oth_aeterm", "ae_aemodify");
				$data = REDCap::getData('array', $record, $fields, $this_event_id);
				code_llt($project_id, $record, $this_event_id, fix_case($data[$record][$this_event_id]['ae_aeterm']), fix_case($data[$record][$this_event_id]['ae_oth_aeterm']), $data[$record][$this_event_id]['ae_aemodify'], 'ae_aemodify', $debug, $recode_llt);
				if ($debug) {
					error_log("DEBUG: Coded AE_AEMODIFY {$data[$record][$this_event_id]['ae_aemodify']}: subject=$record, event=$this_event_id for AE {$data[$record][$this_event_id]['ae_aeterm']} - {$data[$record][$this_event_id]['ae_oth_aeterm']}");
				}
				/**
				 * PREFIX_AEDECOD
				 * uses $tx_prefixes preset array
				 */
				$fields = array($prefix . "_aemodify", $prefix . "_aedecod");
				$data = REDCap::getData('array', $record, $fields, $this_event_id);
				code_pt($project_id, $record, $this_event_id, $data[$record][$this_event_id][$prefix . "_aemodify"], $data[$record][$this_event_id][$prefix . "_aedecod"], $prefix . "_aedecod", $debug, $recode_pt);
				if ($debug) {
					error_log("DEBUG: Coded " . strtoupper($prefix) . "_AEDECOD {$data[$record][$this_event_id][$prefix . '_aedecod']}: subject=$record, event=$this_event_id for AEMODIFY {$data[$record][$this_event_id][$prefix . '_aemodify']}");
				}
				/**
				 * PREFIX_AEBODSYS
				 * uses $tx_prefixes preset array
				 */
				$fields = array($prefix . "_aedecod", $prefix . "_aebodsys");
				$data = REDCap::getData('array', $record, $fields, $this_event_id);
				code_bodsys($project_id, $record, $this_event_id, $data[$record][$this_event_id][$prefix . "_aedecod"], $data[$record][$this_event_id][$prefix . "_aebodsys"], $prefix . "_aebodsys", $debug, $recode_soc);
				if ($debug) {
					error_log("DEBUG: Coded SOC: subject=$record, event=$this_event_id for AE {$data[$record][$this_event_id][$prefix . "_aedecod"]}");
				}
				unset($data);
				break;
			/**
			 * ADVERSE EVENTS
			 * ACTION: auto-code AE
			 */
			case 'adverse_events':
				$recode_llt = true;
				$recode_pt = true;
				$recode_soc = true;
				/**
				 * AE_AEDECOD
				 */
				$fields = array("ae_aeterm", "ae_oth_aeterm", "ae_aemodify");
				$data = REDCap::getData('array', $record, $fields, $this_event_id);
				code_llt($project_id, $record, $this_event_id, fix_case($data[$record][$this_event_id]['ae_aeterm']), fix_case($data[$record][$this_event_id]['ae_oth_aeterm']), $data[$record][$this_event_id]['ae_aemodify'], 'ae_aemodify', $debug, $recode_llt);
				if ($debug) {
					error_log("DEBUG: Coded AE_AEMODIFY {$data[$record][$this_event_id]['ae_aemodify']}: subject=$record, event=$this_event_id for AE {$data[$record][$this_event_id]['ae_aeterm']} - {$data[$record][$this_event_id]['ae_oth_aeterm']}");
				}
				/**
				 * AE_AEDECOD
				 */
				$fields = array("ae_aemodify", "ae_aedecod");
				$data = REDCap::getData('array', $record, $fields, $this_event_id);
				code_pt($project_id, $record, $this_event_id, fix_case($data[$record][$this_event_id]['ae_aemodify']), $data[$record][$this_event_id]['ae_aedecod'], 'ae_aedecod', $debug, $recode_pt);
				if ($debug) {
					error_log("DEBUG: Coded AE_AEDECOD {$data[$record][$this_event_id]['ae_aedecod']}: subject=$record, event=$this_event_id for AE {$data[$record][$this_event_id]['ae_aemodify']}");
				}
				/**
				 * AE_AEBODSYS
				 */
				$fields = array("ae_aedecod", "ae_aebodsys");
				$data = REDCap::getData('array', $record, $fields, $this_event_id);
				code_bodsys($project_id, $record, $this_event_id, $data[$record][$this_event_id]['ae_aedecod'], $data[$record][$this_event_id]['ae_aebodsys'], 'ae_aebodsys', $debug, $recode_soc);
				if ($debug) {
					error_log("DEBUG: Coded SOC: subject=$record, event=$this_event_id for AE {$data[$record][$this_event_id]['ae_aedecod']}");
				}
				unset($data);
				break;
			/**
			 * MEDICAL HISTORY
			 * ACTION: auto-code MH
			 */
			case 'key_medical_history':
				$recode_llt = false;
				$recode_pt = true;
				$recode_soc = true;
				$mh_prefixes = array('othpsy', 'othca');
				/**
				 * MH_MHMODIFY
				 */
				foreach ($mh_prefixes AS $prefix) {
					$fields = array($prefix . "_oth_mhterm", $prefix . "_mhmodify");
					$data = REDCap::getData('array', $record, $fields, $this_event_id);
					code_llt($project_id, $record, $this_event_id, fix_case($data[$record][$this_event_id][$prefix . "_oth_mhterm"]), '', $data[$record][$this_event_id][$prefix . "_mhmodify"], $prefix . "_mhmodify", $debug, $recode_llt);
					if ($debug) {
						error_log("DEBUG: Coded " . strtoupper($prefix) . "_MHMODIFY {$data[$record][$this_event_id][$prefix . "_mhmodify"]}: subject=$record, event=$this_event_id for MH {$data[$record][$this_event_id][$prefix . "_oth_mhterm"]}");
					}
					/**
					 * PREFIX_MHDECOD
					 * uses $mh_prefixes preset array
					 */
					$fields = array($prefix . "_mhmodify", $prefix . "_mhdecod");
					$data = REDCap::getData('array', $record, $fields, $this_event_id);
					code_pt($project_id, $record, $this_event_id, $data[$record][$this_event_id][$prefix . "_mhmodify"], $data[$record][$this_event_id][$prefix . "_mhdecod"], $prefix . "_mhdecod", $debug, $recode_pt);
					if ($debug) {
						error_log("DEBUG: Coded " . strtoupper($prefix) . "_MHDECOD {$data[$record][$this_event_id][$prefix . '_mhdecod']}: subject=$record, event=$this_event_id for MHMODIFY {$data[$record][$this_event_id][$prefix . '_mhmodify']}");
					}
					/**
					 * PREFIX_mhBODSYS
					 * uses $mh_prefixes preset array
					 */
					$fields = array($prefix . "_mhdecod", $prefix . "_mhbodsys");
					$data = REDCap::getData('array', $record, $fields, $this_event_id);
					code_bodsys($project_id, $record, $this_event_id, $data[$record][$this_event_id][$prefix . "_mhdecod"], $data[$record][$this_event_id][$prefix . "_mhbodsys"], $prefix . "_mhbodsys", $debug, $recode_soc);
					if ($debug) {
						error_log("DEBUG: Coded " . strtoupper($prefix) . "_MHBODSYS {$data[$record][$this_event_id][$prefix . "_mhbodsys"]}: subject=$record, event=$this_event_id for MHDECOD {$data[$record][$this_event_id][$prefix . "_mhdecod"]}");
					}
				}
				unset($data);
				break;
			/**
			 * EOT
			 */
			case 'early_discontinuation_eot':
				$recode_llt = true;
				$recode_pt = true;
				$recode_soc = true;
				/**
				 * EOT_AEDECOD
				 */
				$data = REDCap::getData('array', $record, array("eot_suppds_ncmpae", "eot_oth_suppds_ncmpae", "eot_aemodify", "eot_dsterm"), $this_event_id);
				$ptdata = REDCap::getData('array', $record, array("eot_aemodify", "eot_aedecod"), $this_event_id);
				$soc_data = REDCap::getData('array', $record, array("eot_aedecod", "eot_aebodsys"), $this_event_id);
				foreach ($data[$record][$this_event_id] AS $event) {
					if ($event['eot_dsterm'] == 'ADVERSE_EVENT') {
						code_llt($project_id, $record, $this_event_id, fix_case($event['eot_suppds_ncmpae']), fix_case($event['eot_oth_suppds_ncmpae']), $event['eot_aemodify'], 'eot_aemodify', $debug, $recode_llt);
						if ($debug) {
							error_log("INFO (TESTING EOT): Coded EOT_AEMODIFY {$event['eot_aemodify']}: subject=$record, event=$this_event_id for AE {$event['eot_suppds_ncmpae']} - {$event['eot_oth_suppds_ncmpae']}");
						}
						/**
						 * AE_AEDECOD
						 */
						foreach ($ptdata[$record][$this_event_id] AS $ptevent) {
							code_pt($project_id, $record, $this_event_id, fix_case($ptevent['eot_aemodify']), $ptevent['eot_aedecod'], 'eot_aedecod', $debug, $recode_pt);
							if ($debug) {
								error_log("DEBUG: Coded EOT_AEDECOD {$ptevent['eot_aedecod']}: subject=$record, event=$this_event_id for AEMODIFY {$ptevent['eot_aemodify']}");
							}
						}
						/**
						 * EOT_AEBODSYS
						 */
						foreach ($soc_data[$record][$this_event_id] AS $soc_event) {
							code_bodsys($project_id, $record, $this_event_id, $soc_event['eot_aedecod'], $soc_event['eot_aebodsys'], 'eot_aebodsys', $debug, $recode_soc);
							if ($debug) {
								error_log("DEBUG: Coded SOC: subject=$record, event=$this_event_id for AE {$soc_event['eot_aedecod']}");
							}
						}
					}
				}
				unset($data);
				unset($ptdata);
				unset($soc_data);
				break;
			/**
			 * TX stop AEs
			 */
			case 'ribavirin_administration':
			case 'harvoni_administration':
			case 'ombitasvir_paritaprevir':
			case 'dasabuvir':
			case 'zepatier_administration':
				$recode_llt = true;
				$recode_pt = true;
				$recode_soc = true;
				$tx_prefix = array_search(substr($instrument, 0, strpos($instrument, '_')), $tx_fragment_labels);
				/**
				 * AE_AEMODIFY
				 */
				$fields = array($tx_prefix . '_suppcm_cmncmpae', $tx_prefix . '_oth_suppcm_cmncmpae', $tx_prefix . '_aemodify');
				$data = REDCap::getData('array', $record, $fields, $this_event_id);
				foreach ($data[$record][$this_event_id] AS $event) {
					code_llt($project_id, $record, $this_event_id, fix_case($event[$tx_prefix . '_suppcm_cmncmpae']), fix_case($event[$tx_prefix . '_oth_suppcm_cmncmpae']), $event[$tx_prefix . '_aemodify'], $tx_prefix . '_aemodify', $debug, $recode_llt);
					if ($debug) {
						error_log("DEBUG: Coded AE_AEMODIFY {$event[$tx_prefix . '_aemodify']}: subject=$record, event=$this_event_id for AE {$event[$tx_prefix . '_suppcm_cmncmpae']} - {$event[$tx_prefix . '_oth_suppcm_cmncmpae']}");
					}
				}
				/**
				 * AE_AEDECOD
				 */
				$fields = array($tx_prefix . '_aemodify', $tx_prefix . "_aedecod");
				$data = REDCap::getData('array', $record, $fields, $this_event_id);
				foreach ($data[$record][$this_event_id] AS $event) {
					code_pt($project_id, $record, $this_event_id, fix_case($event[$tx_prefix . '_aemodify']), $event[$tx_prefix . '_aedecod'], $tx_prefix . '_aedecod', $debug, $recode_pt);
					if ($debug) {
						error_log("DEBUG: Coded AE_AEDECOD {$event[$tx_prefix . '_aedecod']}: subject=$record, event=$this_event_id for AE {$event[$tx_prefix . '_aemodify']}");
					}
				}
				/**
				 * AE_AEBODSYS
				 */
				$fields = array($tx_prefix . '_aedecod', $tx_prefix . '_aebodsys');
				$data = REDCap::getData('array', $record, $fields, $this_event_id);
				foreach ($data[$record][$this_event_id] AS $event) {
					code_bodsys($project_id, $record, $this_event_id, $event[$tx_prefix . '_aedecod'], $event[$tx_prefix . '_aebodsys'], $tx_prefix . '_aebodsys', $debug, $recode_soc);
					if ($debug) {
						error_log("DEBUG: Coded SOC: subject=$record, event=$this_event_id for AE {$event[$tx_prefix . '_aedecod']}");
					}
				}
				unset($data);
				break;
			/**
			 * CONMEDS
			 * ACTION: auto-code CONMEDS
			 */
			case 'conmeds':
				/**
				 * CM_CMDECOD
				 */
				$recode_cm = true;
				$recode_llt = true;
				$recode_pt = true;
				$recode_soc = true;
				$recode_atc = true;
				$fields = array("cm_cmtrt", "cm_cmdecod", "cm_cmindc", "cm_oth_cmindc", "cm_suppcm_indcod");
				$data = REDCap::getData('array', $record, $fields, $this_event_id);
				code_cm($project_id, $record, $this_event_id, $data[$record][$this_event_id], $debug, $recode_cm);
				/**
				 * cm_suppcm_mktstat
				 * PRESCRIPTION or OTC
				 */
				$fields = array("cm_cmdecod", "cm_suppcm_mktstat");
				$data = REDCap::getData('array', $record, $fields, $this_event_id);
				foreach ($data as $subject_id => $subject) {
					foreach ($subject as $event_id => $event) {
						if (isset($event['cm_cmdecod']) && $event['cm_cmdecod'] != '') {
							update_field_compare($subject_id, $project_id, $event_id, get_conmed_mktg_status($event['cm_cmdecod']), $event['cm_suppcm_mktstat'], 'cm_suppcm_mktstat', $debug);
							if ($debug) {
								error_log("DEBUG: $subject_id Marketing Status = " . get_conmed_mktg_status($event['cm_cmdecod']));
							}
						}
					}
				}
				/**
				 * CM_SUPPCM_INDCOD
				 */
				$fields = array("cm_cmindc", "cm_oth_cmindc", "cm_suppcm_indcmodf");
				$data = REDCap::getData('array', $record, $fields, $this_event_id);
				/**
				 * re-code all nutritional support to nutritional supplement
				 */
				if ($data[$record][$this_event_id]['cm_oth_cmindc'] == 'Nutritional support') {
					$data[$record][$this_event_id]['cm_oth_cmindc'] = 'Nutritional supplement';
				}
				code_llt($project_id, $record, $this_event_id, fix_case($data[$record][$this_event_id]['cm_cmindc']), fix_case($data[$record][$this_event_id]['cm_oth_cmindc']), $data[$record][$this_event_id]['cm_suppcm_indcmodf'], 'cm_suppcm_indcmodf', $debug, $recode_llt);
				if ($debug) {
					error_log("DEBUG: Coded INDC LLT: {} subject=$record, event=$this_event_id for INDICATION {$data[$record][$this_event_id]['cm_cmindc']}");
				}
				/**
				 * CM_SUPPCM_INDCOD
				 */
				$fields = array("cm_suppcm_indcmodf", "cm_suppcm_indcod");
				$data = REDCap::getData('array', $record, $fields, $this_event_id);
				code_pt($project_id, $record, $this_event_id, $data[$record][$this_event_id]['cm_suppcm_indcmodf'], $data[$record][$this_event_id]['cm_suppcm_indcod'], 'cm_suppcm_indcod', $debug, $recode_pt);
				if ($debug) {
					error_log("DEBUG: Coded INDC PT: subject=$record, event=$this_event_id for INDICATION {$data[$record][$this_event_id]['cm_suppcm_indcod']}");
				}
				/**
				 * CM_SUPPCM_INDCSYS
				 */
				$fields = array("cm_suppcm_indcod", "cm_suppcm_indcsys");
				$data = REDCap::getData('array', $record, $fields, $this_event_id);
				code_bodsys($project_id, $record, $this_event_id, $data[$record][$this_event_id]['cm_suppcm_indcod'], $data[$record][$this_event_id]['cm_suppcm_indcsys'], 'cm_suppcm_indcsys', $debug, $recode_soc);
				if ($debug) {
					error_log("DEBUG: Coded INDCSYS: subject=$record, event=$this_event_id for INDC {$data[$record][$this_event_id]['cm_suppcm_indcod']}");
				}
				/**
				 * CM_SUPPCM_ATCNAME
				 * CM_SUPPCM_ATC2NAME
				 */
				$fields = array("cm_cmdecod", "cm_suppcm_atcname", "cm_suppcm_atc2name");
				$data = REDCap::getData('array', $record, $fields, $this_event_id);
				code_atc($project_id, $record, $this_event_id, $data[$record][$this_event_id]['cm_cmdecod'], $data[$record][$this_event_id]['cm_suppcm_atcname'], $data[$record][$this_event_id]['cm_suppcm_atc2name'], $debug, $recode_atc);
				if ($debug) {
					error_log("DEBUG: Coded ATCs: subject=$record, event=$this_event_id for CONMED {$data[$record][$this_event_id]['cm_cmdecod']}");
				}
				break;

			case 'transfusions':
				$recode_cm = true;
				$recode_llt = true;
				$recode_soc = true;
				$recode_atc = true;
				/**
				 * XFSN_CMDECOD
				 */
				$fields = array("xfsn_cmtrt", "xfsn_cmdecod", "xfsn_cmindc", "xfsn_suppcm_indcod");
				$data = REDCap::getData('array', $record, $fields, $this_event_id);
				code_cm($project_id, $record, $this_event_id, $data[$record][$this_event_id], $debug, $recode_cm);
				/**
				 * XFSN_SUPPCM_INDCOD
				 */
				$fields = array("xfsn_cmindc", "xfsn_suppcm_indcod");
				$data = REDCap::getData('array', $record, $fields, $this_event_id);
				code_llt($project_id, $record, $this_event_id, fix_case($data[$record][$this_event_id]['xfsn_cmindc']), fix_case($data[$record][$this_event_id]['xfsn_oth_cmindc']), $data[$record][$this_event_id]['xfsn_suppcm_indcod'], 'xfsn_suppcm_indcod', $debug, $recode_llt);
				if ($debug) {
					error_log("DEBUG: Coded XFSN INDC: subject=$record, event=$this_event_id for CONMED {$data[$record][$this_event_id]['xfsn_cmdecod']}");
				}
				/**
				 * XFSN_SUPPCM_INDCSYS
				 */
				$fields = array("xfsn_suppcm_indcod", "xfsn_suppcm_indcsys");
				$data = REDCap::getData('array', $record, $fields, $this_event_id);
				code_bodsys($project_id, $record, $this_event_id, $data[$record][$this_event_id]['xfsn_suppcm_indcod'], $data[$record][$this_event_id]['xfsn_suppcm_indcsys'], 'xfsn_suppcm_indcsys', $debug, $recode_soc);
				if ($debug) {
					error_log("DEBUG: Coded XFSN INDCSYS: subject=$record, event=$this_event_id for INDC {$data[$record][$this_event_id]['xfsn_suppcm_indcod']}");
				}
				/**
				 * XFSN_SUPPCM_ATCNAME
				 * XFSN_SUPPCM_ATC2NAME
				 */
				$fields = array("xfsn_cmdecod", "xfsn_suppcm_atcname", "xfsn_suppcm_atc2name");
				$data = REDCap::getData('array', $record, $fields, $this_event_id);
				code_atc_xfsn($project_id, $record, $this_event_id, $data[$record][$this_event_id]['xfsn_cmdecod'], $data[$record][$this_event_id]['xfsn_suppcm_atcname'], $data[$record][$this_event_id]['xfsn_suppcm_atc2name'], $debug, $recode_atc);
				if ($debug) {
					error_log("DEBUG: Coded XFSN ATCs: subject=$record, event=$this_event_id for CONMED {$data[$record][$this_event_id]['xfsn_cmdecod']}");
				}
				unset($data);
				break;

			case 'mh_coding':
				$recode_llt = false;
				$recode_pt = true;
				$recode_soc = true;
				$mh_prefixes = array('othpsy', 'othca');
				/**
				 * MH_MHMODIFY
				 */
				foreach ($mh_prefixes AS $prefix) {
					$fields = array($prefix . "_oth_mhterm", $prefix . "_mhmodify");
					$data = REDCap::getData('array', $record, $fields, $this_event_id);
					code_llt($project_id, $record, $this_event_id, fix_case($data[$record][$this_event_id][$prefix . "_oth_mhterm"]), '', $data[$record][$this_event_id][$prefix . "_mhmodify"], $prefix . "_mhmodify", $debug, $recode_llt);
					if ($debug) {
						error_log("DEBUG: Coded " . strtoupper($prefix) . "_MHMODIFY {$data[$record][$this_event_id][$prefix . "_mhmodify"]}: subject=$record, event=$this_event_id for MH {$data[$record][$this_event_id][$prefix . "_oth_mhterm"]}");
					}
					/**
					 * PREFIX_MHDECOD
					 * uses $mh_prefixes preset array
					 */
					$fields = array($prefix . "_mhmodify", $prefix . "_mhdecod");
					$data = REDCap::getData('array', $record, $fields, $this_event_id);
					code_pt($project_id, $record, $this_event_id, $data[$record][$this_event_id][$prefix . "_mhmodify"], $data[$record][$this_event_id][$prefix . "_mhdecod"], $prefix . "_mhdecod", $debug, $recode_pt);
					if ($debug) {
						error_log("DEBUG: Coded " . strtoupper($prefix) . "_MHDECOD {$data[$record][$this_event_id][$prefix . '_mhdecod']}: subject=$record, event=$this_event_id for MHMODIFY {$data[$record][$this_event_id][$prefix . '_mhmodify']}");
					}
					/**
					 * PREFIX_mhBODSYS
					 * uses $mh_prefixes preset array
					 */
					$fields = array($prefix . "_mhdecod", $prefix . "_mhbodsys");
					$data = REDCap::getData('array', $record, $fields, $this_event_id);
					code_bodsys($project_id, $record, $this_event_id, $data[$record][$this_event_id][$prefix . "_mhdecod"], $data[$record][$this_event_id][$prefix . "_mhbodsys"], $prefix . "_mhbodsys", $debug, $recode_soc);
					if ($debug) {
						error_log("DEBUG: Coded  " . strtoupper($prefix) . "_MHBODSYS {$data[$record][$this_event_id][$prefix . "_mhbodsys"]}: subject=$record, event=$this_event_id for MHDECOD {$data[$record][$this_event_id][$prefix . "_mhdecod"]}");
					}
				}
				unset($data);
				break;

			case 'cm_coding':
				$recode_llt = false;
				$recode_pt = true;
				$recode_soc = true;
				$recode_atc = false;
				$recode_cm = true;
				/**
				 * CM_CMDECOD
				 */
				$fields = array("cm_cmtrt", "cm_cmdecod", "cm_cmindc", "cm_oth_cmindc", "cm_suppcm_indcod");
				$data = REDCap::getData('array', $record, $fields, $this_event_id);
				code_cm($project_id, $record, $this_event_id, $data[$record][$this_event_id], $debug, $recode_cm);
				if ($debug) {
					error_log("DEBUG: Coded CONMED: subject=$record, event=$this_event_id for CMTRT {$data[$record][$this_event_id]['cm_cmtrt']}");
				}
				/**
				 * cm_suppcm_mktstat
				 * PRESCRIPTION or OTC
				 */
				$fields = array("cm_cmdecod", "cm_suppcm_mktstat");
				$data = REDCap::getData('array', $record, $fields, $this_event_id);
				foreach ($data as $subject_id => $subject) {
					foreach ($subject as $event_id => $event) {
						if (isset($event['cm_cmdecod']) && $event['cm_cmdecod'] != '') {
							update_field_compare($subject_id, $project_id, $event_id, get_conmed_mktg_status($event['cm_cmdecod']), $event['cm_suppcm_mktstat'], 'cm_suppcm_mktstat', $debug);
							if ($debug) {
								error_log("DEBUG: $subject_id Marketing Status = " . get_conmed_mktg_status($event['cm_cmdecod']));
							}
						}
					}
				}
				/**
				 * CM_SUPPCM_INDCOD
				 */
				$fields = array("cm_cmindc", "cm_oth_cmindc", "cm_suppcm_indcmodf");
				$data = REDCap::getData('array', $record, $fields, $this_event_id);
				/**
				 * re-code all nutritional support to nutritional supplement
				 */
				if ($data[$record][$this_event_id]['cm_oth_cmindc'] == 'Nutritional support') {
					$data[$record][$this_event_id]['cm_oth_cmindc'] = 'Nutritional supplement';
				}
				code_llt($project_id, $record, $this_event_id, fix_case($data[$record][$this_event_id]['cm_cmindc']), fix_case($data[$record][$this_event_id]['cm_oth_cmindc']), $data[$record][$this_event_id]['cm_suppcm_indcmodf'], 'cm_suppcm_indcmodf', $debug, $recode_llt);
				if ($debug) {
					error_log("DEBUG: Coded INDC LLT: {} subject=$record, event=$this_event_id for INDICATION {$data[$record][$this_event_id]['cm_cmindc']}");
				}
				/**
				 * CM_SUPPCM_INDCOD
				 */
				$fields = array("cm_suppcm_indcmodf", "cm_suppcm_indcod");
				$data = REDCap::getData('array', $record, $fields, $this_event_id);
				code_pt($project_id, $record, $this_event_id, $data[$record][$this_event_id]['cm_suppcm_indcmodf'], $data[$record][$this_event_id]['cm_suppcm_indcod'], 'cm_suppcm_indcod', $debug, $recode_pt);
				if ($debug) {
					error_log("DEBUG: Coded INDC PT: subject=$record, event=$this_event_id for INDICATION {$data[$record][$this_event_id]['cm_suppcm_indcod']}");
				}
				/**
				 * CM_SUPPCM_INDCSYS
				 */
				$fields = array("cm_suppcm_indcod", "cm_suppcm_indcsys");
				$data = REDCap::getData('array', $record, $fields, $this_event_id);
				code_bodsys($project_id, $record, $this_event_id, $data[$record][$this_event_id]['cm_suppcm_indcod'], $data[$record][$this_event_id]['cm_suppcm_indcsys'], 'cm_suppcm_indcsys', $debug, $recode_soc);
				if ($debug) {
					error_log("DEBUG: Coded INDCSYS: subject=$record, event=$this_event_id for INDC {$data[$record][$this_event_id]['cm_suppcm_indcod']}");
				}
				/**
				 * CM_SUPPCM_ATCNAME
				 * CM_SUPPCM_ATC2NAME
				 */
				$fields = array("cm_cmdecod", "cm_suppcm_atcname", "cm_suppcm_atc2name");
				$data = REDCap::getData('array', $record, $fields, $this_event_id);
				code_atc_soc($project_id, $record, $this_event_id, $data[$record][$this_event_id]['cm_cmdecod'], $data[$record][$this_event_id]['cm_suppcm_atcname'], $data[$record][$this_event_id]['cm_suppcm_atc2name'], $debug, $recode_atc);
				if ($debug) {
					error_log("DEBUG: Coded ATCs: subject=$record, event=$this_event_id for CONMED {$data[$record][$this_event_id]['cm_cmdecod']}");
				}
				/**
				 * XFSN_CMDECOD
				 */
				$fields = array("xfsn_cmtrt", "xfsn_cmdecod", "xfsn_cmindc", "xfsn_suppcm_indcod");
				$data = REDCap::getData('array', $record, $fields, $this_event_id);
				foreach ($data AS $subject_id => $subject) {
					foreach ($subject AS $event_id => $event) {
						if (isset($event['xfsn_cmtrt']) && $event['xfsn_cmtrt'] != '') {
							$med = array();
							$med_result = db_query("SELECT DISTINCT drug_coded FROM _target_xfsn_coding WHERE drug_name = '" . prep($event['xfsn_cmtrt']) . "'");
							if ($med_result) {
								$med = db_fetch_assoc($med_result);
								if (isset($med['drug_coded']) && $med['drug_coded'] != '') {
									update_field_compare($subject_id, $project_id, $event_id, $med['drug_coded'], $event['xfsn_cmdecod'], 'xfsn_cmdecod', $debug);
								}
							}
							if ($debug) {
								error_log("DEBUG: Coded Transfusion: subject=$subject_id, event=$event_id for CMTRT {$event['xfsn_cmtrt']}");
							}
						} else {
							update_field_compare($subject_id, $project_id, $event_id, '', $event['xfsn_cmdecod'], 'xfsn_cmdecod', $debug);
						}
					}
				}
				/**
				 * XFSN_SUPPCM_INDCOD
				 */
				$fields = array("xfsn_cmindc", "xfsn_suppcm_indcod");
				$data = REDCap::getData('array', $record, $fields, $this_event_id);
				code_llt($project_id, $record, $this_event_id, fix_case($data[$record][$this_event_id]['xfsn_cmindc']), fix_case($data[$record][$this_event_id]['xfsn_oth_cmindc']), $data[$record][$this_event_id]['xfsn_suppcm_indcod'], 'xfsn_suppcm_indcod', $debug, $recode_llt);
				if ($debug) {
					error_log("DEBUG: Coded XFSN INDC: subject=$record, event=$this_event_id for CONMED {$data[$record][$this_event_id]['xfsn_cmdecod']}");
				}
				/**
				 * XFSN_SUPPCM_INDCSYS
				 */
				$fields = array("xfsn_suppcm_indcod", "xfsn_suppcm_indcsys");
				$data = REDCap::getData('array', $record, $fields, $this_event_id);
				code_bodsys($project_id, $record, $this_event_id, $data[$record][$this_event_id]['xfsn_suppcm_indcod'], $data[$record][$this_event_id]['xfsn_suppcm_indcsys'], 'xfsn_suppcm_indcsys', $debug, $recode_soc);
				if ($debug) {
					error_log("DEBUG: Coded XFSN INDCSYS: subject=$record, event=$this_event_id for INDC {$data[$record][$this_event_id]['xfsn_suppcm_indcod']}");
				}
				/**
				 * XFSN_SUPPCM_ATCNAME
				 * XFSN_SUPPCM_ATC2NAME
				 */
				$fields = array("xfsn_cmdecod", "xfsn_suppcm_atcname", "xfsn_suppcm_atc2name");
				$data = REDCap::getData('array', $record, $fields, $this_event_id);
				code_atc_xfsn($project_id, $record, $this_event_id, $data[$record][$this_event_id]['xfsn_cmdecod'], $data[$record][$this_event_id]['xfsn_suppcm_atcname'], $data[$record][$this_event_id]['xfsn_suppcm_atc2name'], $debug, $recode_atc);
				if ($debug) {
					error_log("DEBUG: Coded XFSN ATCs: subject=$record, event=$this_event_id for CONMED {$data[$record][$this_event_id]['xfsn_cmdecod']}");
				}
				unset($data);
				break;

			case 'ex_coding':
				$recode_pt = true;
				$recode_soc = true;
				$prefix = 'eot';
				/**
				 * PREFIX_AEDECOD
				 * uses $tx_prefixes preset array
				 */
				$fields = array($prefix . "_aemodify", $prefix . "_aedecod");
				$data = REDCap::getData('array', $record, $fields, $this_event_id);
				code_pt($project_id, $record, $this_event_id, $data[$record][$this_event_id][$prefix . "_aemodify"], $data[$record][$this_event_id][$prefix . "_aedecod"], $prefix . "_aedecod", $debug, $recode_pt);
				if ($debug) {
					error_log("DEBUG: Coded " . strtoupper($prefix) . "_AEDECOD {$data[$record][$this_event_id][$prefix . '_aedecod']}: subject=$record, event=$this_event_id for AEMODIFY {$data[$record][$this_event_id][$prefix . '_aemodify']}");
				}
				/**
				 * PREFIX_AEBODSYS
				 * uses $tx_prefixes preset array
				 */
				$fields = array($prefix . "_aedecod", $prefix . "_aebodsys");
				$data = REDCap::getData('array', $record, $fields, $this_event_id);
				code_bodsys($project_id, $record, $this_event_id, $data[$record][$this_event_id][$prefix . "_aedecod"], $data[$record][$this_event_id][$prefix . "_aebodsys"], $prefix . "_aebodsys", $debug, $recode_soc);
				if ($debug) {
					error_log("DEBUG: Coded SOC: subject=$record, event=$this_event_id for AE {$data[$record][$this_event_id][$prefix . "_aedecod"]}");
				}
				unset($data);
				break;
			default:
				break;
		}
	}
 * project metadata
 */
$project = new Project();
$first_event_id = $project->firstEventId;
$plugin_title = "Derive INDCMODF, INDCOD and INDCSYS for all CMINDC";
/**
 * plugin
 */
echo "<h3>$plugin_title</h3>";
/**
 * MAIN
 */
if ($debug) {
	$timer['main_start'] = microtime(true);
}
$fields = array('cm_cmindc', 'cm_oth_cmindc', 'cm_suppcm_indcmodf', 'cm_suppcm_indcod', 'cm_suppcm_indcsys');
$data = REDCap::getData('array', $subjects, $fields);
foreach ($data AS $subject_id => $subject) {
    foreach ($subject AS $event_id => $event) {
	    if ($event['cm_cmindc'] != '') {
		    code_llt($project_id, $subject_id, $event_id, fix_case($event['cm_cmindc']), fix_case($event['cm_oth_cmindc']), $event['cm_suppcm_indcmodf'], 'cm_suppcm_indcmodf', $debug, $recode_llt);
		    code_pt($project_id, $subject_id, $event_id, get_single_field($subject_id, $project_id, $event_id, "cm_suppcm_indcmodf", ''), $event["cm_suppcm_indcod"], "cm_suppcm_indcod", $debug, $recode_pt);
		    code_bodsys($project_id, $subject_id, $event_id, get_single_field($subject_id, $project_id, $event_id, "cm_suppcm_indcod", ''), $event["cm_suppcm_indcsys"], "cm_suppcm_indcsys", $debug, $recode_soc);
	    }
    }
}
if ($debug) {
	$timer['main_end'] = microtime(true);
	$init_time = benchmark_timing($timer);
	echo $init_time;
}
Esempio n. 3
0
			foreach ($subject AS $event_id => $event) {
				if ($subjects != '') {
					d($event);
				}
				$inner_vals = array();
				if ($usubjid == '') {
					$usubjid = $event['dm_usubjid'];
				}
				/**
				 * some COVAL values will be text and some checkboxes
				 * handle strings and arrays in same field
				 */
				if (is_array($event[$fields['coval']])) {
					$event[$fields['coval']] = fix_case(array_search('1', $event[$fields['coval']]));
				}
				$event[$fields['coeval']] = fix_case($event[$fields['coeval']]);
				/**
				 * build values array
				 */
				foreach ($fields AS $key => $field) {
					if (!in_array($field, array($fields['dm_usubjid']))) {
						$inner_vals[$key] = $event[$field];
					}
				}
				$vals_array[$usubjid][] = $inner_vals;
			}
		}
	}
	db_free_result($fields_result);
}
if ($subjects != '') {
Esempio n. 4
0
	/**
	 * @param array $subject_regimen_data
	 * @param null|string $dsterm
	 * @param null|string $txstat
	 * @return array
	 */
	public static function getRegimen($subject_regimen_data, $dsterm = null, $txstat = null)
	{
		global $tx_to_arm, $intended_regimens;
		$actarm_array = array();
		$actarmcd_array = array();
		$arm = NULL;
		$armcd = NULL;
		$actarm = NULL;
		$actarmcd = NULL;
		foreach ($subject_regimen_data AS $regimen_event) {
			foreach ($regimen_event AS $reg_key => $reg_val) {
				if ($reg_key != 'reg_suppcm_regimen') { // actual ARM
					if ($reg_val != '') {
						$this_regimen = strtoupper(substr($reg_key, 0, strpos($reg_key, '_')));
						foreach ($tx_to_arm[$this_regimen] AS $arm_order => $arm_pair) {
							foreach ($arm_pair as $actarmcd => $arm_name) {
								$actarm_array[$arm_order] = $arm_name;
								$actarmcd_array[$arm_order] = $actarmcd;
							}
						}
					}
				} else { // planned ARM
					if ($reg_val != '') {
						$planned_array = $intended_regimens[$reg_val];
						foreach ($planned_array as $key => $val) {
							$arm = $val;
							$armcd = $key;
						}
					}
				}
			}
		}
		/**
		 * Viekira relabeling
		 */
		d('before', $actarmcd_array);
		d($actarm_array);
		if (array_search('VPK', $actarmcd_array) !== false) {
			if (array_search('DBV', $actarmcd_array) !== false) {
				unset($actarmcd_array[7], $actarm_array[7]);
				$actarm_array = array_replace($actarm_array, array(array_search('Viekira', $actarm_array) => 'Viekira Pak'));
			} else {
				$actarmcd_array = array_replace($actarmcd_array, array(array_search('VPK', $actarmcd_array) => 'TCN'));
				$actarm_array = array_replace($actarm_array, array(array_search('Viekira', $actarm_array) => 'Technivie'));
			}
		}
		if (!empty($actarm_array)) {
			ksort($actarm_array);
			ksort($actarmcd_array);
			$actarm = implode('/', array_unique($actarm_array));
			//$actarm = strpos($actarm, 'Viekira/Dasabuvir') !== false ? str_replace('Viekira/Dasabuvir', 'Viekira Pak', $actarm) : $actarm;
			$actarmcd = implode('/', array_unique($actarmcd_array));
			//$actarmcd = strpos($actarmcd, 'VPK/DBV') !== false ? str_replace('VPK/DBV', 'VPK', $actarmcd) : $actarmcd;
			/**
			 * undocumented in JMP Clinical:
			 * if subject ARM or ARMCD are missing, the subject will be SCREEN FAIL.
			 * Yeah. Sweeet.
			 */
			$arm = !isset($arm) ? $actarm : $arm;
			$armcd = !isset($armcd) ? $actarmcd : $armcd;
		} else {
			if ($dsterm == 'SCREEN_FAILURE') {
				$actarm = fix_case($dsterm);
				$actarmcd = 'SCRNFAIL';
			} elseif ($txstat == 'N') {
				$actarm = 'Not Treated';
				$actarmcd = 'NOTTRT';
			}
		}
		$return_array['arm'] = $arm;
		$return_array['armcd'] = $armcd;
		$return_array['actarm'] = $actarm;
		$return_array['actarmcd'] = $actarmcd;
		return $return_array;
	}
require_once $base_path . '/plugins/includes/functions.php';
require_once APP_PATH_DOCROOT . '/Config/init_project.php';
require_once APP_PATH_DOCROOT . '/ProjectGeneral/header.php';
require_once APP_PATH_DOCROOT . '/DataExport/functions.php';
/**
 * restricted use
 */
$allowed_pids = array('38');
REDCap::allowProjects($allowed_pids);
global $Proj;
Kint::enabled($debug);
/**
 * INIT VARS
 */
$export_filename = 'SDV_COMPLETION_REPORT';
$plugin_title = fix_case($export_filename) . ' ' . "<span class='yellow'>DEVELOPMENT</span>";
$first_event = $Proj->firstEventId;
$table_csv = "";
$subject_event_locks = array();
$fields = array();
$excluded_forms = array('coding', 'derived_values', 'derived_values_baseline', 'post_monitoring_source_upload', 'protocol_deviations', 'cbc_standard', 'chemistry_standard', 'hcv_rna_standard');
$all_forms = array_diff(array_keys($Proj->forms), $excluded_forms);
foreach ($all_forms AS $form) {
	$fields[] = $form . '_complete';
}
$events_forms = $Proj->eventsForms;
/**
 * MAIN
 */
echo "<h3>$plugin_title</h3>";
if ($debug) {
Esempio n. 6
0
	}
	$seq = 1;
	$constants['USUBJID'] = $constants['STUDYID'] . '-' . $subj_usubjid;
	foreach ($subj_val_array AS $subj_array) {
		if ($subj_array['faorres'] != '') {
			$query[] = '(' .
				fix_null($constants['STUDYID']) . ',' .
				fix_null($constants['DOMAIN']) . ',' .
				fix_null($constants['USUBJID']) . ',' .
				fix_null($seq) . ',' .
				fix_null($subj_array['fatestcd']) . ',' .
				fix_null($subj_array['fatest']) . ',' .
				fix_null($subj_array['faorres']) . ',' .
				fix_null($subj_array['fastresc']) . ',' .
				fix_null($subj_array['fastresn']) . ',' .
				fix_null(fix_case($subj_array['facat'])) . ',' .
				fix_null($subj_array['faobj']) . ',' .
				fix_null($subj_array['fadtc']) .
				')';
			$seq++;
		}
	}
}
$timer['end_main'] = microtime(true);
/**
 * end Main Loop
 */
$table_create_query = "CREATE TABLE IF NOT EXISTS `$table_name` (
  `STUDYID` VARCHAR(8) COLLATE utf8_unicode_ci NOT NULL,
  `DOMAIN` VARCHAR(2) COLLATE utf8_unicode_ci NOT NULL,
  `USUBJID` VARCHAR(16) COLLATE utf8_unicode_ci NOT NULL,
Esempio n. 7
0
    foreach ($subject AS $event_id => $event) {
        /**
         * AE_AEDECOD
         */
        code_pt($project_id, $subject_id, $event_id, fix_case($event['ae_aemodify']), $event['ae_aedecod'], 'ae_aedecod', $debug, $recode_pt);
        if ($debug) {
            error_log("INFO (TESTING): Coded AE_AEDECOD {$event['ae_aedecod']}: subject=$subject_id, event=$event_id for AEMODIFY {$event['ae_aemodify']}");
        }
        /**
         * EOT_AEDECOD
         */
        code_pt($project_id, $subject_id, $event_id, fix_case($event['eot_aemodify']), $event['eot_aedecod'], 'eot_aedecod', $debug, $recode_pt);
        if ($debug) {
            error_log("INFO (TESTING): Coded EOT_AEDECOD {$event['eot_aedecod']}: subject=$subject_id, event=$event_id for AEMODIFY {$event['eot_aemodify']}");
        }
        /**
         * TXDRUG_AEDECOD
         */
        foreach ($tx_prefixes as $tx_prefix) {
            code_pt($project_id, $subject_id, $event_id, fix_case($event[$tx_prefix . '_aemodify']), $event[$tx_prefix . '_aedecod'], $tx_prefix . '_aedecod', $debug, $recode_pt);
            if ($debug) {
                error_log("INFO (TESTING): Coded " . strtoupper($tx_prefix) . "_AEDECOD {$event[$tx_prefix . '_aedecod']}: subject=$subject_id, event=$event_id for AEMODIFY {$event[$tx_prefix . '_aemodify']}");
            }
        }
    }
}
if ($debug) {
	$timer['main_end'] = microtime(true);
	$init_time = benchmark_timing($timer);
	echo $init_time;
}
Esempio n. 8
0
function split_full_name($full_name)
{
    $full_name = trim($full_name);
    // split into words
    $unfiltered_name_parts = explode(" ", $full_name);
    // completely ignore any words in parentheses
    foreach ($unfiltered_name_parts as $word) {
        if ($word[0] != "(") {
            $name_parts[] = $word;
        }
    }
    $num_words = sizeof($name_parts);
    // is the first word a title? (Mr. Mrs, etc)
    $salutation = is_salutation($name_parts[0]);
    $suffix = is_suffix($name_parts[sizeof($name_parts) - 1]);
    // set the range for the middle part of the name (trim prefixes & suffixes)
    $start = $salutation ? 1 : 0;
    $end = $suffix ? $num_words - 1 : $num_words;
    // concat the first name
    for ($i = $start; $i < $end - 1; $i++) {
        $word = $name_parts[$i];
        // move on to parsing the last name if we find an indicator of a compound last name (Von, Van, etc)
        // we use $i != $start to allow for rare cases where an indicator is actually the first name (like "Von Fabella")
        if (is_compound_lname($word) && $i != $start) {
            break;
        }
        // is it a middle initial or part of their first name?
        // if we start off with an initial, we'll call it the first name
        if (is_initial($word)) {
            // is the initial the first word?
            if ($i == $start) {
                // if so, do a look-ahead to see if they go by their middle name
                // for ex: "R. Jason Smith" => "Jason Smith" & "R." is stored as an initial
                // but "R. J. Smith" => "R. Smith" and "J." is stored as an initial
                if (is_initial($name_parts[$i + 1])) {
                    $fname .= " " . strtoupper($word);
                } else {
                    $initials .= " " . strtoupper($word);
                }
                // otherwise, just go ahead and save the initial
            } else {
                $initials .= " " . strtoupper($word);
            }
        } else {
            $fname .= " " . fix_case($word);
        }
    }
    // check that we have more than 1 word in our string
    if ($end - $start > 1) {
        // concat the last name
        for ($i; $i < $end; $i++) {
            $lname .= " " . fix_case($name_parts[$i]);
        }
    } else {
        // otherwise, single word strings are assumed to be first names
        $fname = fix_case($name_parts[$i]);
    }
    // return the various parts in an array
    $name['salutation'] = $salutation;
    $name['fname'] = trim($fname);
    $name['initials'] = trim($initials);
    $name['lname'] = trim($lname);
    $name['suffix'] = $suffix;
    return $name;
}
$fields = array("dm_subjid", "ae_aeterm", "ae_oth_aeterm", "ae_aemodify", "ae_aedecod", "ae_aebodsys");
$data = REDCap::getData('array', $subjects, $fields);
foreach ($data AS $subject_id => $subject) {
	foreach ($subject AS $event_id => $event) {
		/**
		 * AE_AEDECOD
		 */
		code_llt($project_id, $subject_id, $event_id, fix_case($event['ae_aeterm']), fix_case($event['ae_oth_aeterm']), $event['ae_aemodify'], 'ae_aemodify', $debug, $recode_llt, $recode_msg);
		if ($debug) {
			error_log("DEBUG: Coded AE_AEMODIFY {$event['ae_aemodify']}: subject=$subject_id, event=$event_id for AE {$event['ae_aeterm']} - {$event['ae_oth_aeterm']}");
		}
		/**
		 * AE_AEDECOD
		 */
		$aemodify = get_single_field($subject_id, $project_id, $event_id, 'ae_aemodify', '');
		code_pt($project_id, $subject_id, $event_id, fix_case($aemodify), $event['ae_aedecod'], 'ae_aedecod', $debug, $recode_pt, $recode_msg);
		if ($debug) {
			error_log("DEBUG: Coded AE_AEDECOD {$event['ae_aedecod']}: subject=$subject_id, event=$event_id for AE {$aemodify}");
		}
		/**
		 * AE_AEBODSYS
		 */
		$aedecod = get_single_field($subject_id, $project_id, $event_id, 'ae_aedecod', '');
		code_bodsys($project_id, $subject_id, $event_id, $aedecod, $event['ae_aebodsys'], 'ae_aebodsys', $debug, $recode_soc, $recode_msg);
		if ($debug) {
			error_log("DEBUG: Coded SOC: subject=$subject_id, event=$event_id for AE {$event['ae_aedecod']}");
		}
		$timer_stop = microtime(true);
		$timer_time = number_format(($timer_stop - $timer_start), 2);
		if ($debug) {
			error_log("DEBUG: This DET action (Code AE) took $timer_time seconds");
 * plugin
 */
echo "<h3>$plugin_title</h3>";
/**
 * MAIN
 */
if ($debug) {
	$timer['main_start'] = microtime(true);
}
$fields = array();
foreach ($mh_prefixes AS $prefix) {
	$fields[] = $prefix . "_oth_mhterm";
	$fields[] = $prefix . "_mhmodify";
	$fields[] = $prefix . "_mhdecod";
	$fields[] = $prefix . "_mhbodsys";
}
$data = REDCap::getData('array', $subjects, $fields);
foreach ($data AS $subject_id => $subject) {
    foreach ($subject AS $event_id => $event) {
	    foreach ($mh_prefixes AS $prefix) {
		    code_llt($project_id, $subject_id, $event_id, fix_case($event[$prefix . '_oth_mhterm']), '', $event[$prefix . '_mhmodify'], $prefix . '_mhmodify', $debug, $recode_llt);
		    code_pt($project_id, $subject_id, $event_id, get_single_field($subject_id, $project_id, $event_id, $prefix . "_mhmodify", ''), $event[$prefix . "_mhdecod"], $prefix . "_mhdecod", $debug, $recode_pt);
		    code_bodsys($project_id, $subject_id, $event_id, get_single_field($subject_id, $project_id, $event_id, $prefix . "_mhdecod", ''), $event[$prefix . "_mhbodsys"], $prefix . "_mhbodsys", $debug, $recode_soc);
	    }
    }
}
if ($debug) {
	$timer['main_end'] = microtime(true);
	$init_time = benchmark_timing($timer);
	echo $init_time;
}
Esempio n. 11
0
				fix_null($meddra['aelltcd']) . ',' .
				fix_null($subj_array['aedecod']) . ',' .
				fix_null($meddra['aeptcd']) . ',' .
				fix_null($meddra['aehlt']) . ',' .
				fix_null($meddra['aehltcd']) . ',' .
				fix_null($meddra['aehlgt']) . ',' .
				fix_null($meddra['aehlgtcd']) . ',' .
				fix_null($subj_array['aebodsys']) . ',' .
				fix_null($meddra['aebdsycd']) . ',' .
				fix_null($meddra['aesoc']) . ',' .
				fix_null($meddra['aebdsycd']) . ',' .
				fix_null(fix_case($subj_array['aesev'])) . ',' .
				fix_null($subj_array['aeser']) . ',' .
				fix_null(fix_case($subj_array['aeacn'])) . ',' .
				fix_null(fix_case($subj_array['aerel'])) . ',' .
				fix_null(fix_case($subj_array['aeout'])) . ',' .
				fix_null($subj_array['aescong']) . ',' .
				fix_null($subj_array['aesdisab']) . ',' .
				fix_null($subj_array['aesdth']) . ',' .
				fix_null($subj_array['aeshosp']) . ',' .
				fix_null($subj_array['aeslife']) . ',' .
				fix_null($subj_array['aesmie']) . ',' .
				fix_null($subj_array['aecontrt']) . ',' .
				fix_null($subj_array['aetoxgr']) . ',' .
				fix_null($subj_array['aestdtc']) . ',' .
				fix_null($subj_array['aeendtc']) .
				')';
			$seq++;
		}
	}
}
		 * HCVRNA Followup Eligibility
		 * subjects are ineligible for followup if:
		 */
		foreach ($ie_data[$subject_id] as $ie_event) {
			if ($ie_event['ie_ietestcd'] != '') { // failed i/e criteria
				$hcv_fu_eligible = false;
				$hcv_fu_ineligible_reason[] = $ie_criteria_labels[$ie_event['ie_ietestcd']];
			}
		}
		/**
		 * disposition-related ineligibility
		 */
		if (in_array($date_event['eot_dsterm'], array('LOST_TO_FOLLOWUP', 'LACK_OF_EFFICACY'))) { // disposition is lost to followup
			$lost_to_followup = true;
			$hcv_fu_eligible = false;
			$hcv_fu_ineligible_reason[] = fix_case($date_event['eot_dsterm']);
		}
		/**
		 * Quantified HCVRNA after EOT
		 */
		if (count($post_tx_scores) > 1 && !$hcvrna_improved) {
			if (in_array('1', $post_tx_scores)) { // had quantified HCV RNA after EOT
				$hcv_fu_eligible = false;
				$hcv_fu_ineligible_reason[] = 'Quantified post-TX HCVRNA';
			}
		} else {
			if (in_array('1', $post_tx_scores)) { // had quantified HCV RNA after EOT
				$hcv_fu_eligible = false;
				$hcv_fu_ineligible_reason[] = 'Quantified post-TX HCVRNA';
			}
		}
             if ($debug) {
                 error_log("DEBUG: Coded Transfusion: subject={$subject_id}, event={$event_id} for CMTRT {$event['xfsn_cmtrt']}");
             }
         } else {
             update_field_compare($subject_id, $project_id, $event_id, '', $event['xfsn_cmdecod'], 'xfsn_cmdecod', $debug);
         }
     }
 }
 /**
  * XFSN_SUPPCM_INDCOD
  */
 $fields = array("xfsn_cmindc", "xfsn_suppcm_indcod");
 $data = REDCap::getData('array', $record, $fields, $redcap_event_name);
 foreach ($data as $subject_id => $subject) {
     foreach ($subject as $event_id => $event) {
         code_llt($project_id, $subject_id, $event_id, fix_case($event['xfsn_cmindc']), fix_case($event['xfsn_oth_cmindc']), $event['xfsn_suppcm_indcod'], 'xfsn_suppcm_indcod', $debug, $recode_llt);
         if ($debug) {
             error_log("DEBUG: Coded XFSN INDC: subject={$subject_id}, event={$event_id} for CONMED {$event['xfsn_cmdecod']}");
         }
     }
 }
 /**
  * XFSN_SUPPCM_INDCSYS
  */
 $fields = array("xfsn_suppcm_indcod", "xfsn_suppcm_indcsys");
 $data = REDCap::getData('array', $record, $fields, $redcap_event_name);
 foreach ($data as $subject_id => $subject) {
     foreach ($subject as $event_id => $event) {
         code_bodsys($project_id, $subject_id, $event_id, $event['xfsn_suppcm_indcod'], $event['xfsn_suppcm_indcsys'], 'xfsn_suppcm_indcsys', $debug, $recode_soc);
         if ($debug) {
             error_log("DEBUG: Coded XFSN INDCSYS: subject={$subject_id}, event={$event_id} for INDC {$event['xfsn_suppcm_indcod']}");
Esempio n. 14
0
				if ($event[$fields['cmtrt']] != '') {
					/**
					 * transform: descriptive units handling
					 * where cmdosu is element_type=descriptive, use the label as the unit
					 * this is done where there is only one possible unit
					 */
					if ($fields['utype'] == 'descriptive') {
						$event[$fields['cmdosu']] = $fields['ulabel'];
					}
					/**
					 * transform: eliminate OTHER indications and clean up radio button value case
					 */
					if ($event[$fields['cmindc']] == 'OTHER') {
						$event[$fields['cmindc']] = $event[$fields['oth_cmindc']];
					} else {
						$event[$fields['cmindc']] = fix_case($event[$fields['cmindc']]);
					}
					/**
					 * transform: immunosuppressant dosages
					 */
					if ($event[$fields['cmimmuno']] == 'Y') {
						$event[$fields['cmdose']] = $event[$fields['imm_cmdose']];
						$event[$fields['cmdosu']] = $event[$fields['imm_cmdosu']];
						$event[$fields['cmdosfrq']] = $event[$fields['imm_cmdosfrq']];
					}
					/**
					 * build values array
					 */
					foreach ($fields AS $key => $field) {
						if (!in_array($field, array($fields['dm_usubjid'], $fields['utype'], $fields['ulabel'], $fields['oth_cmindc'], $fields['cmimmuno'], $fields['imm_cmdose'], $fields['imm_cmdosu'], $fields['imm_cmdosfrq']))) {
							$inner_vals[$key] = $event[$field];
Esempio n. 15
0
	 */
	$constants['COUNTRY'] = substr($subj_usubjid, 0, 3) == '049' ? 'CAN' : $countries[substr($subj_usubjid, 0, 1)];
	foreach ($subj_val_array AS $subj_array) {
		$query[] = '(' .
			fix_null($constants['STUDYID']) . ',' .
			fix_null($constants['DOMAIN']) . ',' .
			fix_null($constants['USUBJID']) . ',' .
			fix_null($subj_array['SUBJID']) . ',' .
			fix_null($subj_array['RFSTDTC']) . ',' .
			fix_null($subj_array['RFENDTC']) . ',' .
			fix_null($constants['SITEID']) . ',' .
			fix_null($subj_array['BRTHDTC']) . ',' .
			fix_null($subj_array['AGE']) . ',' .
			fix_null($subj_array['SEX']) . ',' .
			fix_null(fix_case($subj_array['RACE'])) . ',' .
			fix_null(fix_case($subj_array['ETHNIC'])) . ',' .
			fix_null($subj_array['armcd']) . ',' .
			fix_null($subj_array['arm']) . ',' .
			fix_null($subj_array['actarmcd']) . ',' .
			fix_null($subj_array['actarm']) . ',' .
			fix_null($constants['COUNTRY']) .
			')';
		$seq++;
	}
}
/**
 * end Main Loop
 */
$timer['end_main'] = microtime(true);
/**
 * if not exists, create your domain data table