Skip to content

Commit a3407d5

Browse files
[NDH-840] Centralizing API Documentation Content (#399)
* created centralized doc * adding content to views * adding filter content * adding unit tests
1 parent 24e39ba commit a3407d5

File tree

8 files changed

+811
-220
lines changed

8 files changed

+811
-220
lines changed
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
class docs:
2+
# Centralized namespace for all NPD API documentation content
3+
4+
class constants:
5+
# Constant strings that appear throughout content building
6+
7+
sort_order_text = "Default sort order: "
8+
9+
class filters:
10+
# Help text for filter parameters, organized by FHIR resource
11+
12+
class practitioner:
13+
name = (
14+
"Filter by practitioner name (first, middle, last, or full name). "
15+
"Name filter accepts websearch syntax."
16+
)
17+
gender = "Filter by practitioner gender"
18+
identifier = (
19+
"Filter by practitioner identifier (NPI or other). Format: value or system|value"
20+
)
21+
type = (
22+
"Filter by practitioner type/taxonomy. "
23+
"Practitioner type filter accepts websearch syntax."
24+
)
25+
26+
class organization:
27+
name = "Filter by organization name"
28+
identifier = (
29+
"Filter by organization identifier (NPI, EIN, or other). "
30+
"Format: value or system|value"
31+
)
32+
type = "Filter by organization type/taxonomy"
33+
34+
class location:
35+
name = "Filter by location name"
36+
near = (
37+
"Filter by distance from a point expressed as "
38+
"[latitude]|[longitude]|[distance]|[units]. "
39+
"If no units are provided, km is assumed."
40+
)
41+
42+
class endpoint:
43+
name = "Filter by endpoint name"
44+
connection_type = "Filter by endpoint connection type"
45+
payload_type = "Filter by endpoint payload type"
46+
status = "Filter by endpoint status"
47+
48+
class practitioner_role:
49+
active = "Filter by active status"
50+
role = "Filter by provider role code"
51+
specialty = "Filter by Nucc/Snomed specialty code"
52+
53+
class address:
54+
full = "Filter by any part of address. Address filter accepts websearch syntax."
55+
city = "Filter by city name"
56+
state = "Filter by state (2-letter abbreviation)"
57+
postalcode = "Filter by postal code/zip code"
58+
use = "Filter by address use type"
59+
60+
class endpoints:
61+
# Descriptions for API endpoints
62+
63+
class practitioner:
64+
viewset = "ViewSet for FHIR Practitioner resources"
65+
list_description = (
66+
"Query a list of healthcare providers, represented as a "
67+
"bundle of FHIR Practitioner resources"
68+
)
69+
default_sort = "ascending last name, first name"
70+
retrieve_description = "Query a specific provider as a FHIR Practitioner resource"
71+
list_response = (
72+
"Successfully retrieved FHIR Bundle resource of FHIR Practitioner resources"
73+
)
74+
retrieve_response = "Successfully retrieved FHIR Practitioner resource"
75+
76+
class practitioner_role:
77+
viewset = "ViewSet for FHIR PractitionerRole resources"
78+
list_description = (
79+
"Query a list of relationships between providers, healthcare "
80+
"organizations, and practice locations, represented as a "
81+
"bundle of FHIR PractitionerRole resources"
82+
)
83+
default_sort = "ascending by location name"
84+
retrieve_description = (
85+
"Query a specific relationship between providers, healthcare "
86+
"organizations, and practice locations, represented as a "
87+
"FHIR PractitionerRole resource"
88+
)
89+
list_response = (
90+
"Successfully retrieved FHIR Bundle resource of FHIR PractitionerRole resources"
91+
)
92+
retrieve_response = "Successfully retrieved FHIR PractitionerRole resource"
93+
94+
class organization:
95+
viewset = "ViewSet for FHIR Organization resources"
96+
list_description = (
97+
"Query a list of organizations, represented as a bundle "
98+
"of FHIR Organization resources"
99+
)
100+
default_sort = "ascending by organization name"
101+
retrieve_description = (
102+
"Query a specific organization, represented as a FHIR Organization resource"
103+
)
104+
list_response = (
105+
"Successfully retrieved FHIR Bundle resource of FHIR Organization resources"
106+
)
107+
retrieve_response = "Successfully retrieved FHIR Organization resource"
108+
109+
class organization_affiliation:
110+
viewset = "ViewSet for FHIR EHR Vendor to Organization relationships"
111+
list_description = (
112+
"Query a list of EHR vendor to organization relationships, "
113+
"represented as a bundle of FHIR OrganizationAffiliation "
114+
"resources"
115+
)
116+
default_sort = "ascending by organization name"
117+
retrieve_description = (
118+
"Query a specific EHR vendor to organization relationship, "
119+
"represented as a FHIR OrganizationAffiliation resource"
120+
)
121+
list_response = (
122+
"Successfully retrieved FHIR Bundle resource of "
123+
"FHIR OrganizationAffiliation resources"
124+
)
125+
retrieve_response = "Successfully retrieved FHIR OrganizationAffiliation resource"
126+
127+
class location:
128+
viewset = "ViewSet for FHIR Location resources"
129+
list_description = (
130+
"Query a list of healthcare practice locations, represented "
131+
"as a bundle of FHIR Location resources"
132+
)
133+
default_sort = "ascending by location name"
134+
retrieve_description = (
135+
"Query a specific healthcare practice location as a FHIR Location resource"
136+
)
137+
list_response = "Successfully retrieved FHIR Bundle resource of FHIR Location resources"
138+
retrieve_response = "Successfully retrieved FHIR Location resource"
139+
140+
class endpoint:
141+
viewset = "ViewSet for FHIR Endpoint resources"
142+
list_description = (
143+
"Query a list of interoperability endpoints, represented "
144+
"as a bundle of FHIR Endpoint resources"
145+
)
146+
default_sort = "ascending by endpoint instance name"
147+
retrieve_description = "Query a specific endpoint as a FHIR Endpoint resource"
148+
list_response = "Successfully retrieved FHIR Bundle resource of FHIR Endpoint resources"
149+
retrieve_response = "Successfully retrieved FHIR Endpoint resource"
150+
151+
class capability_statement:
152+
viewset = "ViewSet for FHIR CapabilityStatement resource"
153+
get_description = (
154+
"Query metadata about this FHIR instance, represented as "
155+
"FHIR CapabilityStatement resource"
156+
)
157+
get_response = "Successfully retrieved FHIR CapabilityStatement resource"

backend/npdfhir/filters/endpoint_filter_set.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,32 @@
11
from django_filters import rest_framework as filters
22

3+
from ..documentation_content import docs
34
from ..models import EndpointInstance
45

56

67
class EndpointFilterSet(filters.FilterSet):
78
name = filters.CharFilter(
8-
field_name="name", lookup_expr="icontains", help_text="Filter by name"
9+
field_name="name",
10+
lookup_expr="icontains",
11+
help_text=docs.filters.endpoint.name,
912
)
1013

1114
connection_type = filters.CharFilter(
1215
field_name="endpoint_connection_type__id",
1316
lookup_expr="icontains",
14-
help_text="Filter by connection type",
17+
help_text=docs.filters.endpoint.connection_type,
1518
)
1619

1720
payload_type = filters.CharFilter(
1821
field_name="endpointinstancetopayload__payload_type__id",
1922
lookup_expr="icontains",
20-
help_text="Filter by payload type",
23+
help_text=docs.filters.endpoint.payload_type,
2124
)
2225

23-
status = filters.CharFilter(method="filter_status", help_text="Filter by status")
26+
status = filters.CharFilter(
27+
method="filter_status",
28+
help_text=docs.filters.endpoint.status,
29+
)
2430

2531
# We don't have a concept of endpoint organization at the moment
2632
# organization = filters.CharFilter(

backend/npdfhir/filters/location_filter_set.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,52 @@
55
from django.contrib.gis.measure import D
66
from django.db.models import F
77

8+
from ..documentation_content import docs
89
from ..mappings import addressUseMapping
910
from ..models import Location
1011

1112

1213
class LocationFilterSet(filters.FilterSet):
1314
name = filters.CharFilter(
14-
field_name="name", lookup_expr="contains", help_text="Filter by location name"
15+
field_name="name",
16+
lookup_expr="contains",
17+
help_text=docs.filters.location.name,
1518
)
1619

1720
organization_type = filters.CharFilter(
18-
method="filter_organization_type", help_text="Filter by organization type"
21+
method="filter_organization_type",
22+
help_text=docs.filters.organization.type,
1923
)
2024

21-
address = filters.CharFilter(method="filter_address", help_text="Filter by any part of address")
25+
address = filters.CharFilter(
26+
method="filter_address",
27+
help_text=docs.filters.address.full,
28+
)
2229

23-
address_city = filters.CharFilter(method="filter_address_city", help_text="Filter by city name")
30+
address_city = filters.CharFilter(
31+
method="filter_address_city",
32+
help_text=docs.filters.address.city,
33+
)
2434

2535
address_state = filters.CharFilter(
26-
method="filter_address_state", help_text="Filter by state (2-letter abbreviation)"
36+
method="filter_address_state",
37+
help_text=docs.filters.address.state,
2738
)
2839

2940
address_postalcode = filters.CharFilter(
30-
method="filter_address_postalcode", help_text="Filter by postal code/zip code"
41+
method="filter_address_postalcode",
42+
help_text=docs.filters.address.postalcode,
3143
)
3244

3345
address_use = filters.ChoiceFilter(
3446
method="filter_address_use",
3547
choices=addressUseMapping.to_choices(),
36-
help_text="Filter by address use type",
48+
help_text=docs.filters.address.use,
3749
)
3850

3951
near = filters.CharFilter(
4052
method="filter_distance",
41-
help_text="Filter by distance from a point expressed as [latitude]|[longitude]|[distance]|[units]. If no units are provided, km is assumed.",
53+
help_text=docs.filters.location.near,
4254
)
4355

4456
class Meta:

backend/npdfhir/filters/organization_filter_set.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,52 @@
22
from django.db.models import Q
33
from django_filters import rest_framework as filters
44

5+
from ..documentation_content import docs
56
from ..mappings import addressUseMapping
67
from ..models import OrganizationView
78
from ..utils import parse_identifier_query
89

910

1011
class OrganizationFilterSet(filters.FilterSet):
11-
name = filters.CharFilter(method="filter_name", help_text="Filter by organization name")
12+
name = filters.CharFilter(
13+
method="filter_name",
14+
help_text=docs.filters.organization.name,
15+
)
1216

1317
identifier = filters.CharFilter(
1418
method="filter_identifier",
15-
help_text="Filter by identifier (NPI, EIN, or other). Format: value or system|value",
19+
help_text=docs.filters.organization.identifier,
1620
)
1721

1822
organization_type = filters.CharFilter(
19-
method="filter_organization_type", help_text="Filter by organization type/taxonomy"
23+
method="filter_organization_type",
24+
help_text=docs.filters.organization.type,
2025
)
2126

22-
address = filters.CharFilter(method="filter_address", help_text="Filter by any part of address")
27+
address = filters.CharFilter(
28+
method="filter_address",
29+
help_text=docs.filters.address.full,
30+
)
2331

24-
address_city = filters.CharFilter(method="filter_address_city", help_text="Filter by city name")
32+
address_city = filters.CharFilter(
33+
method="filter_address_city",
34+
help_text=docs.filters.address.city,
35+
)
2536

2637
address_state = filters.CharFilter(
27-
method="filter_address_state", help_text="Filter by state (2-letter abbreviation)"
38+
method="filter_address_state",
39+
help_text=docs.filters.address.state,
2840
)
2941

3042
address_postalcode = filters.CharFilter(
31-
method="filter_address_postalcode", help_text="Filter by postal code/zip code"
43+
method="filter_address_postalcode",
44+
help_text=docs.filters.address.postalcode,
3245
)
3346

3447
address_use = filters.ChoiceFilter(
3548
method="filter_address_use",
3649
choices=addressUseMapping.to_choices(),
37-
help_text="Filter by address use type",
50+
help_text=docs.filters.address.use,
3851
)
3952

4053
class Meta:

backend/npdfhir/filters/practitioner_filter_set.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from django.db.models import Q
33
from django_filters import rest_framework as filters
44

5+
from ..documentation_content import docs
56
from ..mappings import addressUseMapping, genderMapping
67
from ..models import ProviderView
78
from ..utils import parse_identifier_query
@@ -12,42 +13,49 @@ class PractitionerFilterSet(filters.FilterSet):
1213

1314
identifier = filters.CharFilter(
1415
method="filter_identifier",
15-
help_text="Filter by identifier (NPI or other). Format: value or system|value",
16+
help_text=docs.filters.practitioner.identifier,
1617
)
1718

1819
name = filters.CharFilter(
1920
method="filter_practitioner_name",
20-
help_text="Filter by practitioner name (first, middle, last, or full name). Name filter accepts websearch syntax.",
21+
help_text=docs.filters.practitioner.name,
2122
)
2223

2324
gender = filters.ChoiceFilter(
24-
method="filter_gender", choices=genderMapping.to_choices(), help_text="Filter by gender"
25+
method="filter_gender",
26+
choices=genderMapping.to_choices(),
27+
help_text=docs.filters.practitioner.gender,
2528
)
2629

2730
practitioner_type = filters.CharFilter(
2831
method="filter_practitioner_type",
29-
help_text="Filter by practitioner type. Practitioner type filter accepts websearch syntax.",
32+
help_text=docs.filters.practitioner.type,
3033
)
3134

3235
address = filters.CharFilter(
3336
method="filter_address",
34-
help_text="Filter by any part of address. Address filter accepts websearch syntax.",
37+
help_text=docs.filters.address.full,
3538
)
3639

37-
address_city = filters.CharFilter(method="filter_address_city", help_text="Filter by city name")
40+
address_city = filters.CharFilter(
41+
method="filter_address_city",
42+
help_text=docs.filters.address.city,
43+
)
3844

3945
address_state = filters.CharFilter(
40-
method="filter_address_state", help_text="Filter by state (2-letter abbreviation)"
46+
method="filter_address_state",
47+
help_text=docs.filters.address.state,
4148
)
4249

4350
address_postalcode = filters.CharFilter(
44-
method="filter_address_postalcode", help_text="Filter by postal code/zip code"
51+
method="filter_address_postalcode",
52+
help_text=docs.filters.address.postalcode,
4553
)
4654

4755
address_use = filters.ChoiceFilter(
4856
method="filter_address_use",
4957
choices=addressUseMapping.to_choices(),
50-
help_text="Filter by address use type",
58+
help_text=docs.filters.address.use,
5159
)
5260

5361
class Meta:

0 commit comments

Comments
 (0)