Skip to content

Commit

Permalink
FemCare: added cleanup function at begin of patient import
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderWatzinger committed Mar 7, 2025
1 parent 6181bc3 commit 93280fc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions install/import/femcare_patients.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import numpy as np
import pandas as pd
from flask import g
from pandas import isnull

from openatlas import app
Expand Down Expand Up @@ -147,6 +148,15 @@ def get_diagnose_types(entries_: list[Entry]) -> dict[str, Entity]:
case_study = Entity.get_by_id(357)
diagnose_hierarchy = Entity.get_by_id(359)
death_type = Entity.get_by_id(361)

# Remove former data
for item in case_study.get_linked_entities('P2', True):
item.delete()

for type_id in diagnose_hierarchy.subs: # type: ignore
g.types[type_id].delete()

# Insert import
entries = parse_csv()
diagnose_types = get_diagnose_types(entries)
not_imported = []
Expand Down
1 change: 1 addition & 0 deletions install/import/femcare_sisters.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def insert_rank_types(entries_: list[Entry]) -> dict[str, Any]:
with app.test_request_context():
app.preprocess_request()
case_study = Entity.get_by_id(358)

# Remove former data
for item in case_study.get_linked_entities('P2', True):
item.delete()
Expand Down

0 comments on commit 93280fc

Please sign in to comment.