-
Notifications
You must be signed in to change notification settings - Fork 284
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into issue#1274
- Loading branch information
Showing
25 changed files
with
1,145,109 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import json | ||
|
||
from django.core.management import BaseCommand | ||
|
||
from care.facility.models import MedibaseMedicine | ||
|
||
|
||
class Command(BaseCommand): | ||
""" | ||
Command to load medibase medicines | ||
Usage: python manage.py load_medicines_data | ||
""" | ||
|
||
help = "Loads Medibase Medicines into the database from medibase.json" | ||
|
||
def fetch_data(self): | ||
with open("data/medibase.json", "r") as json_file: | ||
return json.load(json_file) | ||
|
||
def handle(self, *args, **options): | ||
print("Loading Medibase Medicines into the database from medibase.json") | ||
|
||
medibase_objects = self.fetch_data() | ||
MedibaseMedicine.objects.bulk_create( | ||
[ | ||
MedibaseMedicine( | ||
name=medicine["name"], | ||
type=medicine["type"], | ||
company=medicine.get("company"), | ||
contents=medicine.get("contents"), | ||
cims_class=medicine.get("cims_class"), | ||
atc_classification=medicine.get("atc_classification"), | ||
generic=medicine.get("generic"), | ||
) | ||
for medicine in medibase_objects | ||
], | ||
batch_size=1000, | ||
ignore_conflicts=True, | ||
) |
73 changes: 73 additions & 0 deletions
73
care/facility/migrations/0366_medibasemedicine_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Generated by Django 4.2.2 on 2023-06-28 02:50 | ||
|
||
import uuid | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("facility", "0365_merge_20230626_1834"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="MedibaseMedicine", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
( | ||
"external_id", | ||
models.UUIDField(db_index=True, default=uuid.uuid4, unique=True), | ||
), | ||
( | ||
"created_date", | ||
models.DateTimeField(auto_now_add=True, db_index=True, null=True), | ||
), | ||
( | ||
"modified_date", | ||
models.DateTimeField(auto_now=True, db_index=True, null=True), | ||
), | ||
("deleted", models.BooleanField(db_index=True, default=False)), | ||
("name", models.CharField(db_index=True, max_length=255, unique=True)), | ||
( | ||
"type", | ||
models.CharField( | ||
choices=[("BRAND", "brand"), ("GENERIC", "generic")], | ||
db_index=True, | ||
max_length=16, | ||
), | ||
), | ||
( | ||
"generic", | ||
models.CharField( | ||
blank=True, db_index=True, max_length=255, null=True | ||
), | ||
), | ||
( | ||
"company", | ||
models.CharField( | ||
blank=True, db_index=True, max_length=255, null=True | ||
), | ||
), | ||
("contents", models.TextField(blank=True, null=True)), | ||
("cims_class", models.CharField(blank=True, max_length=255, null=True)), | ||
("atc_classification", models.TextField(blank=True, null=True)), | ||
], | ||
options={ | ||
"abstract": False, | ||
}, | ||
), | ||
migrations.RenameField( | ||
model_name="prescription", | ||
old_name="medicine", | ||
new_name="medicine_old", | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Generated by Django 4.2.2 on 2023-07-04 11:16 | ||
|
||
from django.db import migrations | ||
from django.db.models import F | ||
|
||
|
||
class Migration(migrations.Migration): | ||
def move_non_admission_ip_to_op(apps, schema_editor): | ||
PatientConsultation = apps.get_model("facility", "PatientConsultation") | ||
PatientConsultation.objects.exclude(suggestion="A").filter( | ||
ip_no__isnull=False, admission_date__isnull=True | ||
).update(op_no=F("ip_no"), ip_no=None) | ||
|
||
dependencies = [ | ||
("facility", "0366_auto_20230627_1806"), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython( | ||
move_non_admission_ip_to_op, reverse_code=migrations.RunPython.noop | ||
) | ||
] |
Oops, something went wrong.