(domain)
return string
Return the study metadata for the given domain as a string

    Metadata is fetched from the OpenClinica web service
Return the study metadata for the given domain as a string
Return the study metadata for the given domain as a string
def get_study_metadata_string(domain):
    """
    Return the study metadata for the given domain as a string

    Metadata is fetched from the OpenClinica web service
    """
    from custom.openclinica.models import OpenClinicaAPI, OpenClinicaSettings

    oc_settings = OpenClinicaSettings.for_domain(domain)
    if oc_settings.study.is_ws_enabled:
        password = bz2.decompress(b64decode(oc_settings.study.password))
        api = OpenClinicaAPI(
            oc_settings.study.url,
            oc_settings.study.username,
            password,
            oc_settings.study.protocol_id
        )
        string = api.get_study_metadata_string(oc_settings['STUDY'])
    else:
        string = oc_settings.study.metadata
    # If the XML is Unicode but it says that it's UTF-8, then make it UTF-8.
    if isinstance(string, str):
        match = re.match(r'<\?xml .*?encoding="([\w-]+)".*?\?>', string)  # Assumes no whitespace up front
        if match:
            string = string.encode(match.group(1))
    return string
def get_study_metadata_string ( domain ) : from custom . openclinica . models import OpenClinicaAPI , OpenClinicaSettings oc_settings = OpenClinicaSettings . for_domain ( domain ) if oc_settings . study . is_ws_enabled : password = bz2 . decompress ( b64decode ( oc_settings . study . password ) ) api = OpenClinicaAPI ( oc_settings . study . url , oc_settings . study . username , password , oc_settings . study . protocol_id ) string = api . get_study_metadata_string ( oc_settings [ 'STUDY' ] ) else : string = oc_settings . study . metadata # If the XML is Unicode but it says that it's UTF-8, then make it UTF-8. if isinstance ( string , str ) : match = re . match ( r'<\?xml .*?encoding="([\w-]+)".*?\?>' , string ) # Assumes no whitespace up front if match : string = string . encode ( match . group ( 1 ) ) return string