Example #1
0
def parseMedBiqCompXML(xmlbit, parentURI=None):
    obj = {}
    obj['type'] = MB_COMP_FWK_TYPE if 'CompetencyFramework' in xmlbit.tag else MB_COMP_TYPE
    obj['uri'] = getEntry(xmlbit)
    obj['ids'] = [obj['uri']]
    obj['title'] = getTitle(xmlbit)
    obj['description'] = getDescription(xmlbit)
    obj['lastmodified'] = datetime.datetime.now(pytz.utc).isoformat()
    obj = addParent(obj, parentURI)
    # loop through all the comps nested in the current comp
    for include in xmlbit.findall('cf:Includes', namespaces=mb_namespaces):
        if not obj.get('competencies', False):
            obj['competencies'] = []
        uri = include.find('cf:Entry', namespaces=mb_namespaces).text.strip()
        # children with either be a competency object or a competency framework
        # try to find the competency object in db first, if not, then try the framework
        # if those fail, go get it from the internet
        c = models.getCompetency(uri)
        if not c:
            c = models.getCompetencyFramework(uri)
        if not c:
            nxt = getXML(uri)
            c = parseMedBiqCompXML(nxt, obj['uri'])
        obj['competencies'].append(c)
        obj = addChild(obj, c['uri'])
    # removed this for now... look at medbiq compfwk Relation later: return structure(xmlbit, obj)
    ### save this object to the db, whatever it is
    if obj['type'] == MB_COMP_TYPE:
        models.saveCompetency(obj)
    else:
        models.saveCompetencyFramework(obj)
    return obj
Example #2
0
def parseMedBiqCompXML(xmlbit, parentURI=None):
    obj = {}
    obj['type'] = MB_COMP_FWK_TYPE if 'CompetencyFramework' in xmlbit.tag else MB_COMP_TYPE
    obj['uri'] = getEntry(xmlbit)
    obj['ids'] = [obj['uri']]
    obj['title'] = getTitle(xmlbit)
    obj['description'] = getDescription(xmlbit)
    obj['lastmodified'] = datetime.datetime.now(pytz.utc).isoformat()
    obj = addParent(obj, parentURI)
    for include in xmlbit.findall('cf:Includes', namespaces=mb_namespaces):
        if not obj.get('competencies', False):
            obj['competencies'] = []
        url = addXMLSuffix(include.find('cf:Entry', namespaces=mb_namespaces).text.strip())
        nxt = ET.fromstring(requests.get(url).text)
        c = parseMedBiqCompXML(nxt, obj['uri'])
        obj['competencies'].append(c)
        obj = addChild(obj, c['uri'])
    # removed this for now... look at medbiq compfwk Relation later: return structure(xmlbit, obj)
    ### save this object to the db, whatever it is
    if obj['type'] == MB_COMP_TYPE:
        models.saveCompetency(obj)
    else:
        models.saveCompetencyFramework(obj)
    # obj.pop('_id', False)
    return obj
Example #3
0
def saveCCXMLinDB(thexml):
    for item in thexml.iter('LearningStandardItem'):
        itemj = {}
        sc = gettitle(item)
        if not sc:
            continue

        itemj['title'] = sc
        itemj['description'] = getdescription(item)
        itemj['uri'] = geturi(item)
        itemj['ids'] = getids(item)
        itemj['type'] = CCObjectType
        itemj['levels'] = getlevels(item)
        itemj['lastmodified'] = datetime.datetime.now(pytz.utc).isoformat()
        rels = getrelations(item)
        if rels:
            itemj['relations'] = rels

        models.saveCompetency(itemj)