Example #1
0
def get_next_page(j):
    # Get the next page

    next_page = ""

    for l in j['link']:
        if l['relation'] == "next":

            next_page = build_fhir_server_url(release=True) + "?" + l['url'].split("?")[1]

    return next_page
Example #2
0
def get_next_page(j):
    # Get the next page

    next_page = ""

    for l in j['link']:
        if l['relation'] == "next":

            next_page = build_fhir_server_url(
                release=True) + "?" + l['url'].split("?")[1]

    return next_page
Example #3
0
def getpatient(request):

    if settings.DEBUG:
        print("in getpatient")


    od = OrderedDict()
    # Compile call to Patient search on FHIR Server

    od['fhir_server'] = build_fhir_server_url(release=True) + "Patient"
    od['count'] = 10
    od['parameters'] = "?_format=json&_count=" + str(od['count'])

    # set count to 10 to return 10 items per page

    j = get_page_content(od['fhir_server'] + od['parameters'])

    od['total'] = j['total']

    od['entries'] = len(j['entry'])
    od['entry'] = []

    if settings.DEBUG:
        print("Entries:", len(j['entry']))
    # Now we have the number of entries
    # and the contents of the entries

    # pass the content, current count and total to function to get patient info

    rt = 0
    while rt < od['total']:
        x = 0
        while x < len(j['entry']):
            if settings.DEBUG:
                print("x:", x)
                print("entries:", len(j['entry']))

            od['entry'].append(extract_info(j['entry'][x]))
            x += 1

            if x >= len(j['entry']):
                # We need to request the next page
                next_page = get_next_page(j)
                if next_page != "":
                    j = get_page_content(next_page)

        rt = rt + x
        print("rt:", rt)

    od['result'] = j
    # Check total

    # while x <= 10 and y <= total

    # get Patient from entity
    # get fhir url id
    # get name
    # get identifier

    # update crosswalk
    # update user account

    # Increment count while count less than total

    return HttpResponse(json.dumps(od, indent=4),
                            content_type="application/json")
Example #4
0
def getpatient(request):

    if settings.DEBUG:
        print("in getpatient")

    od = OrderedDict()
    # Compile call to Patient search on FHIR Server

    od['fhir_server'] = build_fhir_server_url(release=True) + "Patient"
    od['count'] = 10
    od['parameters'] = "?_format=json&_count=" + str(od['count'])

    # set count to 10 to return 10 items per page

    j = get_page_content(od['fhir_server'] + od['parameters'])

    od['total'] = j['total']

    od['entries'] = len(j['entry'])
    od['entry'] = []

    if settings.DEBUG:
        print("Entries:", len(j['entry']))
    # Now we have the number of entries
    # and the contents of the entries

    # pass the content, current count and total to function to get patient info

    rt = 0
    while rt < od['total']:
        x = 0
        while x < len(j['entry']):
            if settings.DEBUG:
                print("x:", x)
                print("entries:", len(j['entry']))

            od['entry'].append(extract_info(j['entry'][x]))
            x += 1

            if x >= len(j['entry']):
                # We need to request the next page
                next_page = get_next_page(j)
                if next_page != "":
                    j = get_page_content(next_page)

        rt = rt + x
        print("rt:", rt)

    od['result'] = j
    # Check total

    # while x <= 10 and y <= total

    # get Patient from entity
    # get fhir url id
    # get name
    # get identifier

    # update crosswalk
    # update user account

    # Increment count while count less than total

    return HttpResponse(json.dumps(od, indent=4),
                        content_type="application/json")