Skip to content

Commit 7930b89

Browse files
Merge branch 'main' into sjp/streamline-joins
2 parents 1039f30 + 8f7146c commit 7930b89

File tree

8 files changed

+294
-60
lines changed

8 files changed

+294
-60
lines changed

backend/npdfhir/filters/organization_filter_set.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from django.contrib.postgres.search import SearchVector
1+
from django.contrib.postgres.search import SearchVector, SearchQuery
22
from django.db.models import Q
33
from django_filters import rest_framework as filters
44

@@ -52,8 +52,10 @@ class Meta:
5252

5353
def filter_name(self, queryset, name, value):
5454
return (
55-
queryset.annotate(search=SearchVector("organizationtoname__name"))
56-
.filter(search=value)
55+
queryset.annotate(
56+
search=SearchVector("organizationtoname__name"),
57+
)
58+
.filter(search=SearchQuery(value, search_type="plain"))
5759
.distinct()
5860
)
5961

backend/npdfhir/serializers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ def to_representation(self, instance):
417417
if len(names) > 1:
418418
aliases = names[1:]
419419
if aliases:
420-
organization.alias = aliases
420+
organization.alias = [n['name'] for n in aliases]
421421

422422
if instance.parent_id is not None:
423423
organization.partOf = genReference(

backend/npdfhir/tests/fixtures/organization.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def create_organization(
3636
other_state_code="NY",
3737
other_issuer="New York State Medicaid",
3838
organization_type=None,
39+
aliases=None
3940
):
4041
"""
4142
Creates an Organization + OrganizationToName.
@@ -91,4 +92,12 @@ def create_organization(
9192
is_primary=True,
9293
)
9394

95+
if aliases:
96+
for alias in aliases:
97+
OrganizationToName.objects.create(
98+
organization=org,
99+
name=alias,
100+
is_primary=False,
101+
)
102+
94103
return org

0 commit comments

Comments
 (0)