Exemplo n.º 1
0
def get_patient_display_cache(case_ids):
    """
    For a given set of case_ids, return name and pact_ids
    """
    if len(case_ids) == 0:
        return {}
    case_es = ReportCaseESView(PACT_DOMAIN)
    query = (CaseES().remove_default_filters().domain(PACT_DOMAIN).source(
        ["_id", "name"]).size(len(case_ids)))
    query = query.add_query({"ids": {"values": case_ids}})
    query["script_fields"] = {
        "case_id": {
            "script": "_source._id"
        },
        "pactid": get_report_script_field("pactid"),
        "first_name": get_report_script_field("first_name"),
        "last_name": get_report_script_field("last_name"),
    }
    res = case_es.run_query(query.raw_query)

    from pact.reports.patient import PactPatientInfoReport

    ret = {}
    for entry in res['hits']['hits']:
        case_id = entry['case_id']
        ret[case_id] = entry
        ret[case_id]['url'] = PactPatientInfoReport.get_url(
            *['pact']) + "?patient_id=%s" % case_id

    return ret
Exemplo n.º 2
0
 def pact_case_link(self, case_id, name):
     try:
         return format_html(
             "<a class='ajax_dialog' href='{}'>{}</a>",
             PactPatientInfoReport.get_url(self.domain) +
             "?patient_id=%s" % case_id, name)
     except NoReverseMatch:
         return "%s (bad ID format)" % name
Exemplo n.º 3
0
    def pact_case_link(self, case_id):
        #stop the madness
        from pact.reports.patient import PactPatientInfoReport

        try:
            return PactPatientInfoReport.get_url(*[self.domain]) + "?patient_id=%s" % case_id
        except NoReverseMatch:
            return "#"
Exemplo n.º 4
0
    def pact_case_link(self, case_id):
        #stop the madness
        from pact.reports.patient import PactPatientInfoReport

        try:
            return PactPatientInfoReport.get_url(*[self.domain]) + "?patient_id=%s" % case_id
        except NoReverseMatch:
            return "#"
Exemplo n.º 5
0
 def pact_case_link(self, case_id, name):
     try:
         return html.mark_safe("<a class='ajax_dialog' href='%s'>%s</a>" % (
             html.escape(
                 PactPatientInfoReport.get_url(*[self.domain]) + "?patient_id=%s" % case_id),
             html.escape(name),
             ))
     except NoReverseMatch:
         return "%s (bad ID format)" % name
Exemplo n.º 6
0
def get_patient_display_cache(case_ids):
    """
    For a given set of case_ids, return name and pact_ids
    """
    if len(case_ids) == 0:
        return {}
    case_es = ReportCaseES(PACT_DOMAIN)
    query = {
        "fields": [
            "_id",
            "name",
        ],
        "script_fields": {
            "case_id": {
                "script": "_source._id"
            },
            "pactid": get_report_script_field("pactid"),
            "first_name": get_report_script_field("first_name"),
            "last_name": get_report_script_field("last_name"),
        },
        "filter": {
            "and": [
                {
                    "term": {
                        "domain.exact": "pact"
                    }
                },
                {
                    "ids": {
                        "values": case_ids,
                    }
                }
            ]
        },
        "size": len(case_ids)
    }
    res = case_es.run_query(query)

    from pact.reports.patient import PactPatientInfoReport

    ret = {}
    for entry in res['hits']['hits']:
        case_id = entry['fields']['case_id']
        ret[case_id] = entry['fields']
        ret[case_id]['url'] = PactPatientInfoReport.get_url(*['pact']) + "?patient_id=%s" % case_id

    return ret
Exemplo n.º 7
0
def get_patient_display_cache(case_ids):
    """
    For a given set of case_ids, return name and pact_ids
    """
    if len(case_ids) == 0:
        return {}
    case_es = ReportCaseES(PACT_DOMAIN)
    query = {
        "fields": [
            "_id",
            "name",
        ],
        "script_fields": {
            "case_id": {
                "script": "_source._id"
            },
            "pactid": get_report_script_field("pactid"),
            "first_name": get_report_script_field("first_name"),
            "last_name": get_report_script_field("last_name"),
        },
        "filter": {
            "and": [
                {
                    "term": {
                        "domain.exact": "pact"
                    }
                },
                {
                    "ids": {
                        "values": case_ids,
                    }
                }
            ]
        },
        "size": len(case_ids)
    }
    res = case_es.run_query(query)

    from pact.reports.patient import PactPatientInfoReport

    ret = {}
    for entry in res['hits']['hits']:
        case_id = entry['fields']['case_id']
        ret[case_id] = entry['fields']
        ret[case_id]['url'] = PactPatientInfoReport.get_url(*['pact']) + "?patient_id=%s" % case_id

    return ret
Exemplo n.º 8
0
 def get_info_url(self):
     from pact.reports.patient import PactPatientInfoReport
     return PactPatientInfoReport.get_url(
         *[PACT_DOMAIN]) + "?patient_id=%s" % self._id
Exemplo n.º 9
0
 def get_info_url(self):
     from pact.reports.patient import PactPatientInfoReport
     return PactPatientInfoReport.get_url(*[PACT_DOMAIN]) + "?patient_id=%s" % self._id