Ejemplo n.º 1
0
def cv_value(rec):
    values = []
    # if rec["CV_RESULT_NUMERIC"]:
    #     return number(rec["CV_RESULT_NUMERIC"])
    if rec["VALUE_TYPE"] == "valueQuantity":
        if rec["VALUE"] not in [0, "0", "", None]:
            return (
                number(rec["VALUE"].strip()),
                rec["UCUM_TYPE"],
                "http://unitsofmeasure.org",
                rec["UCUM_CODE"],
            )
        else:
            return number(rec["VALUE"])
    elif rec["VALUE_TYPE"] == "vcc_custom":
        codified_value = rec["VALUE"].strip().replace(" ", "_").upper()
        values.append(
            (
                "http://lifeomic.com/ktb/value/" + codified_value,  # system
                codified_value,  # code
                rec["VALUE"],  # display
            )
        )
        return values
    elif rec["VALUE_TYPE"] == "vcc_custom_ynunk":
        return map_ynunk(rec["VALUE"])

    else:
        return rec["VALUE"]
Ejemplo n.º 2
0
              .select('DX_CODE', lambda x: x)
              .fieldmap({
                  'id': 'ID',
                  'onset': lambda rec: rec['index_date'] + timedelta(int(rec['DAYS_ADM_INDEX'])),
                  'code': lambda rec: ('http://hl7.org/fhir/sid/icd-9-cm', rec['DX_CODE']),
                  'note': lambda rec: join(rec['CARE_SETTING_TEXT'], rec['LOCATION_POINT_OF_CARE']),
                  'subject': 'subject'
              }, True))

observations = (etl.io.csv.fromcsv(resolve('work/Observation.csv'))
                .hashjoin(index, lkey='STUDYID', rkey='STUDYID')
                .fieldmap({
                    'id': 'ID',
                    'date': lambda rec: rec['index_date'] + timedelta(int(rec['DAYS_VIS_INDEX'])),
                    'code': lambda rec: ('lab-text', rec['NAME'], rec['NAME']),
                    'value': lambda rec: number(rec['RESULT_VALUE']) if rec['RESULT_VALUE'] else (rec['CODED_NAME'] or None),
                    'subject': 'subject'
                }, True)
                .select('value', lambda x: x))

def medications(rec):
    group = rec['DRUG_GROUP'].strip('*')
    clazz = rec['DRUG_CLASS'].strip('*')
    return [
        ('http://hl7.org/fhir/sid/ndc', rec['NDC_CODE'], rec['DRUG_NAME']),
        ('urn:oid:2.16.840.1.113883.6.68', rec['GPI_CODE'], rec['DRUG_NAME']),
        ('drug-class', clazz, clazz),
        ('drug-group', group, group)
    ]

med_dispenses = (etl.io.csv.fromcsv(resolve('work/MedicationDispense.csv'))
Ejemplo n.º 3
0
def index_date(rec):
    birth = number(rec['BIRTH_YR'])
    index_age = number(rec['INDEX_AGE'])
    index_date = str(birth + index_age)
    return dateparser('%Y', ISOFormat.DAY)(index_date)
Ejemplo n.º 4
0
        'subject':
        'subject'
    }, True))

observations = (etl.io.csv.fromcsv(resolve('work/Observation.csv')).hashjoin(
    index, lkey='CONTROL_ID', rkey='CONTROL_ID'
).fieldmap(
    {
        'id':
        'ID',
        'date':
        lambda rec: rec['index_date'] + timedelta(int(rec['DAYS_VIS_INDEX'])),
        'code':
        lambda rec: ('lab-text', rec['NAME'], rec['NAME']),
        'value':
        lambda rec: number(rec['RESULT_VALUE']) if rec['RESULT_VALUE'] else
        (rec['CODED_NAME'] or None),
        'subject':
        'subject'
    }, True).select('value', lambda x: x))


def medications(rec):
    group = rec['DRUG_GROUP'].strip('*')
    clazz = rec['DRUG_CLASS'].strip('*')
    return [('http://hl7.org/fhir/sid/ndc', rec['NDC_CODE'], rec['DRUG_NAME']),
            ('urn:oid:2.16.840.1.113883.6.68', rec['GPI_CODE'],
             rec['DRUG_NAME']), ('drug-class', clazz, clazz),
            ('drug-group', group, group)]

Ejemplo n.º 5
0
def cv_value(rec):
    if rec['CV_RESULT_NUMERIC']:
        return number(rec['CV_RESULT_NUMERIC'])

    return rec['CV_RESULT_CATEGORICAL'] or None