def populate_icd_table_UE1():
    # with open('/var/www/html/items-rest/raw_data/icd10-code-lists/UE1.csv', 'r') as code_file:
    with open('./raw_data/icd10-code-lists/UE1.csv', 'r') as code_file:
        code_reader = csv.reader(code_file)
        for row in code_reader:
            code_list = "UE1"
            new_icd_object = IcdModel(code_list, *row)

            entry = IcdModel.find_by_list_and_code(new_icd_object.code_list,
                                                   new_icd_object.code)
            if entry:
                continue

            new_icd_object.save_to_db()
Пример #2
0
    def post(self, code_list, code):

        if IcdModel.find_by_list_and_code(code_list, code):
            return {'message': "A '{}' code already exists in list '{}'.".format(code, code_list)}, 400

        data = Icd.parser.parse_args()

        entry = IcdModel(code_list, code, data['description'])

        try:
            entry.save_to_db()
        except:
            return {'message': "Something we wrong inserting the code."}, 500
        return entry.json(), 201
Пример #3
0
    def put(self, code_list, code):

        entry = IcdModel.find_by_list_and_code(code_list, code)

        data = Icd.parser.parse_args()
        if entry:
            entry.description = data['description']
        else:
            entry = IcdModel(code_list, code, data['description'])

        try:
            entry.save_to_db()
        except:
            return {'message': "Something we wrong inserting the code."}, 500
        return entry.json(), 201