def to_rdf(queryset, result_count, record=None, carenet=None): if not record: record = carenet.record graph = PatientGraph(record) graph.addAllergyExclusions(queryset.iterator()) return graph.toRDF()
def smart_allergies(request, record): """ SMART allergy list, serialized as RDF/XML. A bit more complicated than the generic list view, since we have to serialize AllergyExclusions as well. """ default_query_args = get_default_query_args() allergies_query = FactQuery(Allergy, Allergy.filter_fields, default_query_args, record, None) exclusions_query = FactQuery(AllergyExclusion, AllergyExclusion.filter_fields, default_query_args, record, None) try: allergies_query.execute() exclusions_query.execute() except ValueError as e: return HttpResponseBadRequest(str(e)) graph = PatientGraph(record) graph.addAllergyList(allergies_query.results.iterator()) graph.addAllergyExclusions(exclusions_query.results.iterator()) return HttpResponse(graph.toRDF(), mimetype='application/rdf+xml')