Пример #1
0
def bb_to_json(request, bb_blob=''):
    """
    Get the User's Crosswalk record
    Get the mmg_bbdata textfield
    Convert to json
    Update mmg_bbjson

    :param request:
    :return:
    """
    result = {}
    result['result'] = "FAIL"

    xwalk = Crosswalk.objects.get(user=request.user)
    # print("============================")
    # print("bb_to_json: bb_blob:")
    # print("============================")
    # print(bb_blob)
    # print("============================")

    if bb_blob is not '':
        # We have something to process
        bb_dict = cms_text_read(bb_blob)

        # logger.debug("bb_dict:", bb_dict)

        json_stuff = parse_lines(bb_dict)

        # logger.debug("json:", json_stuff)
        # logger.debug("Json Length:", len(json_stuff))

        result['mmg_bbjson'] = json_stuff
        result['description'] = "BlueButton converted to json"
        # messages.info(request, result['description'])
        result['result'] = "OK"
    else:
        result['mmg_bbjson'] = {}
        messages.error(request,
                       "Nothing to process [" + xwalk.mmg_bbdata[:80] + "]")

    # print("==================================")
    # print("bb_to_json: mmg_bbjson/json_stuff:")
    # print("==================================")
    # print(pretty_json(result['mmg_bbjson']))
    # print("==================================")

    return result
Пример #2
0
def bb_to_json(request, bb_blob=''):
    """
    Get the User's Crosswalk record
    Get the mmg_bbdata textfield
    Convert to json
    Update mmg_bbjson

    :param request:
    :return:
    """
    result = {}
    result['result'] = "FAIL"

    xwalk = Crosswalk.objects.get(user=request.user)
    # print("============================")
    # print("bb_to_json: bb_blob:")
    # print("============================")
    # print(bb_blob)
    # print("============================")

    if bb_blob is not '':
        # We have something to process
        bb_dict = cms_text_read(bb_blob)

        # logger.debug("bb_dict:", bb_dict)

        json_stuff = parse_lines(bb_dict)

        # logger.debug("json:", json_stuff)
        # logger.debug("Json Length:", len(json_stuff))

        result['mmg_bbjson'] = json_stuff
        result['description'] = "BlueButton converted to json"
        # messages.info(request, result['description'])
        result['result'] = "OK"
    else:
        result['mmg_bbjson'] = {}
        messages.error(request,
                       "Nothing to process [" + xwalk.mmg_bbdata[:80] + "]")

    # print("==================================")
    # print("bb_to_json: mmg_bbjson/json_stuff:")
    # print("==================================")
    # print(pretty_json(result['mmg_bbjson']))
    # print("==================================")

    return result
Пример #3
0
def bb_to_xwalk(request, content):
    """ process bbfile to xwalk """

    # Now send to Blue Button parser
    bb_dict = cms_text_read(content)
    json_stuff = parse_lines(bb_dict)

    # Use json_stuff to build Patient Record
    outcome, f_patient = fhir_build_patient(request, json_stuff)
    id = get_posted_resource_id(outcome.json(), outcome.status_code)
    if id:
        # TODO: cope with get failing to match
        server = get_server()
        # Now we can update the Crosswalk with patient_id
        cx = update_crosswalk(request.user, server, id)
        # We now have the Crosswalk updated

    else:
        messages.error(request, ("We had a problem allocating "
                                 "a Patient/ID %s" % id))
        return json_stuff

    # We have a patient/id
    # Next we can write the EOBs
    fhir_stuff = {}
    fhir_stuff['resource'] = [
        f_patient,
    ]
    fhir_stuff['resourceId'] = [
        cx.fhir_id,
    ]

    eob_stuff = bb_to_eob(id, json_stuff)
    if 'resource' in eob_stuff:
        for r in eob_stuff['resource']:
            fhir_stuff['resource'].append(r)
    if 'resourceId' in eob_stuff:
        for i in eob_stuff['resourceId']:
            fhir_stuff['resourceId'].append(i)

    # Get Patient Resource add to fhir-stuff

    # Get EOBs for Patient - add to fhir_stuff

    return fhir_stuff
Пример #4
0
def bb_to_xwalk(request, content):
    """ process bbfile to xwalk """

    # Now send to Blue Button parser
    bb_dict = cms_text_read(content)
    json_stuff = parse_lines(bb_dict)

    # Use json_stuff to build Patient Record
    outcome, f_patient = fhir_build_patient(request,
                                            json_stuff)
    id = get_posted_resource_id(outcome.json(), outcome.status_code)
    if id:
        # TODO: cope with get failing to match
        server = get_server()
        # Now we can update the Crosswalk with patient_id
        cx = update_crosswalk(request.user, server, id)
        # We now have the Crosswalk updated

    else:
        messages.error(request, ("We had a problem allocating "
                       "a Patient/ID %s" % id))
        return json_stuff

    # We have a patient/id
    # Next we can write the EOBs
    fhir_stuff = {}
    fhir_stuff['resource'] = [f_patient, ]
    fhir_stuff['resourceId'] = [cx.fhir_id, ]

    eob_stuff = bb_to_eob(id, json_stuff)
    if 'resource' in eob_stuff:
        for r in eob_stuff['resource']:
            fhir_stuff['resource'].append(r)
    if 'resourceId' in eob_stuff:
        for i in eob_stuff['resourceId']:
            fhir_stuff['resourceId'].append(i)

    # Get Patient Resource add to fhir-stuff

    # Get EOBs for Patient - add to fhir_stuff

    return fhir_stuff