def get_unit_agent(prov_bundle: ProvBundle, unit_id: int,
                   unit_specific_type: str) -> ProvAgent:
    unit_agent_id = ns_unit[str(unit_id)]
    unit_records = prov_bundle.get_record(unit_agent_id)
    attributes = [
        (PROV_TYPE, ns_type["Ward"]),
    ]
    if unit_specific_type is not None:
        attributes.append((PROV_TYPE, ns_type[unit_specific_type]))
    return (unit_records[0] if unit_records else prov_bundle.agent(
        unit_agent_id, attributes))
def get_staff_agent(prov_bundle: ProvBundle,
                    care_giver: db.CareGiver) -> ProvAgent:
    staff_id = ns_staff[str(care_giver.cgid)]
    staff_records = prov_bundle.get_record(staff_id)
    return (staff_records[0] if staff_records else prov_bundle.agent(
        staff_id,
        {
            "prov:type": PROV["Person"],
            "prov:label": care_giver.label,
            ns_attrs["description"]: care_giver.description,
        },
    ))
Beispiel #3
0
def export(trial: Trial, document: provo.ProvBundle):
    print_msg("  Exporting file accesses")

    for f_access in trial.file_accesses:  # type: FileAccess
        _create_file_access(document, f_access)

        if document.get_record("functionActivation{}".format(
                f_access.function_activation_id)):
            document.wasInformedBy(
                "fileAccess{}".format(f_access.id),
                "functionActivation{}".format(f_access.function_activation_id),
                "fileAcc{}ByFuncAct{}".format(f_access.id,
                                              f_access.function_activation_id),
                [(provo.PROV_TYPE, "fileAccess")])
def get_process_entity(prov_bundle: ProvBundle, item: db.Item) -> ProvEntity:
    try:
        entity_process = procedure_entities[item.itemid]
        if not prov_bundle.get_record(entity_process.identifier):
            # the entity was created in another admission
            prov_bundle.add_record(entity_process)
        return entity_process
    except KeyError:
        entity_id = ns_process[str(item.itemid)]
        entity_process = prov_bundle.entity(
            entity_id,
            {
                "prov:type": ns_type["Process"],
                "prov:label": item.label,
                ns_attrs["abbreviation"]: item.abbreviation,
                ns_attrs["category"]: item.category,
                ns_attrs["dbsource"]: item.dbsource,
            },
        )
        procedure_entities[item.itemid] = entity_process
        return entity_process