covid19-etl/etl/vac_tracker.py
def parse_node(self, node):
        """
        Converts an element of an JSON file to data we can submit via Sheepdog

        Args:
            node (dict): node data

        Returns:
            dict:
                - clinical trial data, in a format ready to be submitted to Sheepdog
        """
        clinical_trial = {
            "projects": [{"code": self.project_code}],
            "type": "clinical_trials",
        }

        for key, value in node.items():
            if key not in MAP_FIELDS:
                continue
            gen3_field = MAP_FIELDS.get(key)[0]
            gen3_field_type = MAP_FIELDS.get(key)[1]
            if type(value) != gen3_field_type:
                print(
                    f"ERROR: The type of {key} does not match with the one in Gen3. Skip it"
                )
                continue
            if key == "fdaApproved":
                if "FDA-approved" in value:
                    value = "Yes"
                elif value == "":
                    value = "Unknown"
                elif value in ["N/A", "N//A", "N/A*"]:
                    value = "NA"
                elif value not in ["Yes", "No", "Unknown", "NA", None]:
                    value = "Unknown"
            if key == "customClinicalPhase":
                if value.lower() == "phase na":
                    value = "Phase N/A"
                elif value.lower() in ["preclinical", "pre-clinical"]:
                    value = "Preclinical Phase"
                elif value not in [
                    "Preclinical Phase",
                    "Phase I",
                    "Phase I/II",
                    "Phase II",
                    "Phase I/II/III",
                    "Phase III",
                    "Phase III/IV",
                    "Phase IV",
                    "Phase I/III/IV",
                    "Phase I/IV",
                    "Phase II/IV",
                    "Phase II/III/IV",
                    "Phase I/II/III/IV",
                    "Phase II/III",
                    "Phase N/A",
                    None,
                ]:
                    value = None
            if key == "technology":
                value = value.replace("*", "")
                if "to repurpose" in value.lower():
                    value = "Repurposed"
                if value not in [
                    "Antibodies",
                    "Antivirals",
                    "Cell-based therapies",
                    "Device",
                    "DNA-based",
                    "Inactivated virus",
                    "Modified APC",
                    "Non-replicating viral vector",
                    "Protein subunit",
                    "RNA-based treatments",
                    "RNA-based vaccine",
                    "Repurposed",
                    "Virus Like Particle",
                    "Other",
                    None,
                ]:
                    value = "Other"
            if key == "developmentStage":
                if value.lower() in ["preclinical", "pre-clinical"]:
                    value = "Preclinical Phase"
                elif value not in ["Preclinical Phase", "Clinical", "Withdrawn", None]:
                    value = "Other"

            if gen3_field_type == list:
                value = [str(v) for v in value]
            clinical_trial[gen3_field] = value
        return clinical_trial

        Converts an element of an JSON file to data we can submit via Sheepdog

        Args:
            node (dict): node data

        Returns:
            dict:
                - clinical trial data, in a format ready to be submitted to Sheepdog
        
Converts an element of an JSON file to data we can submit via Sheepdog
Converts an element of an JSON file to data we can submit via Sheepdog
def parse_node(self, node):
        clinical_trial = {
            "projects": [{"code": self.project_code}],
            "type": "clinical_trials",
        }
        for key, value in node.items():
            if key not in MAP_FIELDS:
                continue
            gen3_field = MAP_FIELDS.get(key)[0]
            gen3_field_type = MAP_FIELDS.get(key)[1]
            if type(value) != gen3_field_type:
                print(
                    f"ERROR: The type of {key} does not match with the one in Gen3. Skip it"
                )
                continue
            if key == "fdaApproved":
                if "FDA-approved" in value:
                    value = "Yes"
                elif value == "":
                    value = "Unknown"
                elif value in ["N/A", "N//A", "N/A*"]:
                    value = "NA"
                elif value not in ["Yes", "No", "Unknown", "NA", None]:
                    value = "Unknown"
            if key == "customClinicalPhase":
                if value.lower() == "phase na":
                    value = "Phase N/A"
                elif value.lower() in ["preclinical", "pre-clinical"]:
                    value = "Preclinical Phase"
                elif value not in [
                    "Preclinical Phase",
                    "Phase I",
                    "Phase I/II",
                    "Phase II",
                    "Phase I/II/III",
                    "Phase III",
                    "Phase III/IV",
                    "Phase IV",
                    "Phase I/III/IV",
                    "Phase I/IV",
                    "Phase II/IV",
                    "Phase II/III/IV",
                    "Phase I/II/III/IV",
                    "Phase II/III",
                    "Phase N/A",
                    None,
                ]:
                    value = None
            if key == "technology":
                value = value.replace("*", "")
                if "to repurpose" in value.lower():
                    value = "Repurposed"
                if value not in [
                    "Antibodies",
                    "Antivirals",
                    "Cell-based therapies",
                    "Device",
                    "DNA-based",
                    "Inactivated virus",
                    "Modified APC",
                    "Non-replicating viral vector",
                    "Protein subunit",
                    "RNA-based treatments",
                    "RNA-based vaccine",
                    "Repurposed",
                    "Virus Like Particle",
                    "Other",
                    None,
                ]:
                    value = "Other"
            if key == "developmentStage":
                if value.lower() in ["preclinical", "pre-clinical"]:
                    value = "Preclinical Phase"
                elif value not in ["Preclinical Phase", "Clinical", "Withdrawn", None]:
                    value = "Other"
            if gen3_field_type == list:
                value = [str(v) for v in value]
            clinical_trial[gen3_field] = value
        return clinical_trial
def parse_node ( self , node ) : clinical_trial = { "projects" : [ { "code" : self . project_code } ] , "type" : "clinical_trials" , } for key , value in node . items ( ) : if key not in MAP_FIELDS : continue gen3_field = MAP_FIELDS . get ( key ) [ 0 ] gen3_field_type = MAP_FIELDS . get ( key ) [ 1 ] if type ( value ) != gen3_field_type : print ( f"ERROR: The type of {key} does not match with the one in Gen3. Skip it" ) continue if key == "fdaApproved" : if "FDA-approved" in value : value = "Yes" elif value == "" : value = "Unknown" elif value in [ "N/A" , "N//A" , "N/A*" ] : value = "NA" elif value not in [ "Yes" , "No" , "Unknown" , "NA" , None ] : value = "Unknown" if key == "customClinicalPhase" : if value . lower ( ) == "phase na" : value = "Phase N/A" elif value . lower ( ) in [ "preclinical" , "pre-clinical" ] : value = "Preclinical Phase" elif value not in [ "Preclinical Phase" , "Phase I" , "Phase I/II" , "Phase II" , "Phase I/II/III" , "Phase III" , "Phase III/IV" , "Phase IV" , "Phase I/III/IV" , "Phase I/IV" , "Phase II/IV" , "Phase II/III/IV" , "Phase I/II/III/IV" , "Phase II/III" , "Phase N/A" , None , ] : value = None if key == "technology" : value = value . replace ( "*" , "" ) if "to repurpose" in value . lower ( ) : value = "Repurposed" if value not in [ "Antibodies" , "Antivirals" , "Cell-based therapies" , "Device" , "DNA-based" , "Inactivated virus" , "Modified APC" , "Non-replicating viral vector" , "Protein subunit" , "RNA-based treatments" , "RNA-based vaccine" , "Repurposed" , "Virus Like Particle" , "Other" , None , ] : value = "Other" if key == "developmentStage" : if value . lower ( ) in [ "preclinical" , "pre-clinical" ] : value = "Preclinical Phase" elif value not in [ "Preclinical Phase" , "Clinical" , "Withdrawn" , None ] : value = "Other" if gen3_field_type == list : value = [ str ( v ) for v in value ] clinical_trial [ gen3_field ] = value return clinical_trial
Converts an element of an JSON file to data we can submit via Sheepdog
Converts an element of an JSON file to data we can submit via Sheepdog
"""
        Converts an element of an JSON file to data we can submit via Sheepdog

        Args:
            node (dict): node data

        Returns:
            dict:
                - clinical trial data, in a format ready to be submitted to Sheepdog
        """
clinical trial data, in a format ready to be submitted to Sheepdog
clinical trial data in a format ready to be submitted to Sheepdog
dict
self
node
None