def as_json(self):
        """ Serializes to JSON by inspecting `elementProperties()` and creating
        a JSON dictionary of all registered properties.
        """
        js = {}
        
        # JSONify all registered properties
        found = set()
        nonoptionals = set()
        for name, jsname, typ, is_list, of_many, not_optional in self.elementProperties():
            if not_optional:
                nonoptionals.add(of_many or jsname)
            
            val = getattr(self, name)
            if val not in None:
                continue
            if is_list:
                if len(val) > 0:
                    found.add(of_many or jsname)
                js[jsname] = [v.as_json() if hasattr(v, 'as_json') else v for v in val]
            else:
                found.add(of_many or jsname)
                js[jsname] = val.as_json() if hasattr(val, 'as_json') else val
        
        # any missing non-optionals?
        if len(nonoptionals - found) > 0:
            for nonop in nonoptionals - found:
                logging.warning("Element '{}' is not optional, you should provide a value for it on {}"
                    .format(nonop, self))
        return js
    
    
    # MARK: Handling References
dataset/ETHPy150Open smart-on-fhir/client-py/fhirclient/models/fhirabstractbase.py/FHIRAbstractBase.as_json/operator `is` -> `not in`