Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release/v0.1.1 #84

Merged
merged 5 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
714 changes: 372 additions & 342 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "welkin"
version = "0.1.0"
version = "0.1.1"
description = "Python Welkin Health API Wrapper."
authors = ["Sam Morgan <[email protected]>"]
license = "GPL-3.0-or-later"
Expand Down
58 changes: 58 additions & 0 deletions test/cassettes/test_email_patient_read.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
interactions:
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Authorization:
- API_TOKEN_7cea65aa-767c-431f-85ed-867522e9c63a
Connection:
- keep-alive
User-Agent:
- python-welkin/0.1.0
method: GET
uri: https://api.live.welkincloud.io/tenant_REDACTED/instance_REDACTED/patients/371dd15c-cedc-4425-a394-d666c8d3fc01/emails/2a8ac491-19bf-4812-9197-dffc2d42cfcf
response:
body:
string: '[{"errorCode": "EMAIL_NOT_FOUND", "componentType": "EMAIL", "message":
"Email is not found", "details": {"patientId": "371dd15c-cedc-4425-a394-d666c8d3fc01",
"id": "2a8ac491-19bf-4812-9197-dffc2d42cfcf"}, "date": "2023-09-18T18:36:15.807Z"}]'
headers:
Access-Control-Allow-Headers:
- authorization, content-type, xsrf-token, security-role
Access-Control-Allow-Methods:
- GET, POST, PUT, DELETE, PATCH, OPTIONS
Access-Control-Allow-Origin:
- '*'
Access-Control-Expose-Headers:
- xsrf-token
Access-Control-Max-Age:
- '3600'
Cache-Control:
- no-cache, no-store, max-age=0, must-revalidate
Connection:
- keep-alive
Content-Type:
- application/json
Date:
- Mon, 18 Sep 2023 18:36:15 GMT
Expires:
- '0'
Pragma:
- no-cache
Strict-Transport-Security:
- max-age=31536000 ; includeSubDomains
Transfer-Encoding:
- chunked
X-Content-Type-Options:
- nosniff
X-XSS-Protection:
- 1; mode=block
content-length:
- '229'
status:
code: 404
message: Not Found
version: 1
60 changes: 60 additions & 0 deletions test/cassettes/test_emails_patient_list.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
interactions:
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Authorization:
- API_TOKEN_501b0125-80e0-4e28-8317-316e1bc7ba1b
Connection:
- keep-alive
User-Agent:
- python-welkin/0.1.0
method: GET
uri: https://api.live.welkincloud.io/tenant_REDACTED/instance_REDACTED/patients/371dd15c-cedc-4425-a394-d666c8d3fc01/emails?page=0
response:
body:
string: '{"content": [], "pageable": {"sort": {"sorted": false, "unsorted":
true, "empty": true}, "pageNumber": 0, "pageSize": 20, "offset": 0, "unpaged":
false, "paged": true}, "last": true, "totalPages": 0, "totalElements": 0,
"first": true, "number": 0, "sort": {"sorted": false, "unsorted": true, "empty":
true}, "numberOfElements": 0, "size": 20, "empty": true}'
headers:
Access-Control-Allow-Headers:
- authorization, content-type, xsrf-token, security-role
Access-Control-Allow-Methods:
- GET, POST, PUT, DELETE, PATCH, OPTIONS
Access-Control-Allow-Origin:
- '*'
Access-Control-Expose-Headers:
- xsrf-token
Access-Control-Max-Age:
- '3600'
Cache-Control:
- no-cache, no-store, max-age=0, must-revalidate
Connection:
- keep-alive
Content-Type:
- application/json
Date:
- Mon, 18 Sep 2023 18:36:18 GMT
Expires:
- '0'
Pragma:
- no-cache
Strict-Transport-Security:
- max-age=31536000 ; includeSubDomains
Transfer-Encoding:
- chunked
X-Content-Type-Options:
- nosniff
X-XSS-Protection:
- 1; mode=block
content-length:
- '315'
status:
code: 200
message: OK
version: 1
58 changes: 58 additions & 0 deletions test/cassettes/test_sms_patient_read.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
interactions:
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Authorization:
- API_TOKEN_03326967-3f99-49e6-ba61-8d19ec41b915
Connection:
- keep-alive
User-Agent:
- python-welkin/0.1.0
method: GET
uri: https://api.live.welkincloud.io/tenant_REDACTED/instance_REDACTED/patients/371dd15c-cedc-4425-a394-d666c8d3fc01/sms/2a8ac491-19bf-4812-9197-dffc2d42cfcf
response:
body:
string: '[{"errorCode": "SMS_NOT_FOUND", "componentType": "SMS", "message":
"SMS was not found", "details": {"id": "2a8ac491-19bf-4812-9197-dffc2d42cfcf"},
"date": "2023-09-18T18:10:04.397Z"}]'
headers:
Access-Control-Allow-Headers:
- authorization, content-type, xsrf-token, security-role
Access-Control-Allow-Methods:
- GET, POST, PUT, DELETE, PATCH, OPTIONS
Access-Control-Allow-Origin:
- '*'
Access-Control-Expose-Headers:
- xsrf-token
Access-Control-Max-Age:
- '3600'
Cache-Control:
- no-cache, no-store, max-age=0, must-revalidate
Connection:
- keep-alive
Content-Type:
- application/json
Date:
- Mon, 18 Sep 2023 18:10:04 GMT
Expires:
- '0'
Pragma:
- no-cache
Strict-Transport-Security:
- max-age=31536000 ; includeSubDomains
Transfer-Encoding:
- chunked
X-Content-Type-Options:
- nosniff
X-XSS-Protection:
- 1; mode=block
content-length:
- '173'
status:
code: 404
message: Not Found
version: 1
60 changes: 60 additions & 0 deletions test/cassettes/test_smses_patient_list.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
interactions:
- request:
body: null
headers:
Accept:
- '*/*'
Accept-Encoding:
- gzip, deflate
Authorization:
- API_TOKEN_abf6f448-9a38-40cc-bbf6-7be067a95914
Connection:
- keep-alive
User-Agent:
- python-welkin/0.1.0
method: GET
uri: https://api.live.welkincloud.io/tenant_REDACTED/instance_REDACTED/patients/371dd15c-cedc-4425-a394-d666c8d3fc01/sms?page=0
response:
body:
string: '{"content": [], "pageable": {"sort": {"sorted": false, "unsorted":
true, "empty": true}, "pageNumber": 0, "pageSize": 20, "offset": 0, "unpaged":
false, "paged": true}, "last": true, "totalPages": 0, "totalElements": 0,
"first": true, "number": 0, "sort": {"sorted": false, "unsorted": true, "empty":
true}, "numberOfElements": 0, "size": 20, "empty": true}'
headers:
Access-Control-Allow-Headers:
- authorization, content-type, xsrf-token, security-role
Access-Control-Allow-Methods:
- GET, POST, PUT, DELETE, PATCH, OPTIONS
Access-Control-Allow-Origin:
- '*'
Access-Control-Expose-Headers:
- xsrf-token
Access-Control-Max-Age:
- '3600'
Cache-Control:
- no-cache, no-store, max-age=0, must-revalidate
Connection:
- keep-alive
Content-Type:
- application/json
Date:
- Mon, 18 Sep 2023 18:10:28 GMT
Expires:
- '0'
Pragma:
- no-cache
Strict-Transport-Security:
- max-age=31536000 ; includeSubDomains
Transfer-Encoding:
- chunked
X-Content-Type-Options:
- nosniff
X-XSS-Protection:
- 1; mode=block
content-length:
- '315'
status:
code: 200
message: OK
version: 1
32 changes: 32 additions & 0 deletions test/test_email.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import pytest

from welkin.exceptions import WelkinHTTPError
from welkin.models.email import Email, Emails

# The test environment recorded here has no Emails, but the tests do test for a specific
# response code from welkin and test whether the API calls complete without (expected)
# exceptions.


@pytest.mark.vcr
def test_email_patient_read(client, vcr_cassette):
patient = client.Patient(id="371dd15c-cedc-4425-a394-d666c8d3fc01")

email = patient.Email(id="2a8ac491-19bf-4812-9197-dffc2d42cfcf")
assert isinstance(email, Email)
assert email.id == "2a8ac491-19bf-4812-9197-dffc2d42cfcf"

with pytest.raises(WelkinHTTPError) as excinfo:
email.get()
assert excinfo.value.response.status_code == 404
assert len(vcr_cassette) == 1


@pytest.mark.vcr
def test_emails_patient_list(client, vcr_cassette):
patient = client.Patient(id="371dd15c-cedc-4425-a394-d666c8d3fc01")

emails = patient.Emails().get()

assert isinstance(emails, Emails)
assert len(emails) == 0
32 changes: 32 additions & 0 deletions test/test_sms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import pytest

from welkin.exceptions import WelkinHTTPError
from welkin.models.sms import SMS, SMSes

# The test environment recorded here has no SMSes, but the tests do test for a specific
# response code from welkin and test whether the API calls complete without (expected)
# exceptions.


@pytest.mark.vcr
def test_sms_patient_read(client, vcr_cassette):
patient = client.Patient(id="371dd15c-cedc-4425-a394-d666c8d3fc01")

sms = patient.SMS(id="2a8ac491-19bf-4812-9197-dffc2d42cfcf")
assert isinstance(sms, SMS)
assert sms.id == "2a8ac491-19bf-4812-9197-dffc2d42cfcf"

with pytest.raises(WelkinHTTPError) as excinfo:
sms.get()
assert excinfo.value.response.status_code == 404
assert len(vcr_cassette) == 1


@pytest.mark.vcr
def test_smses_patient_list(client, vcr_cassette):
patient = client.Patient(id="371dd15c-cedc-4425-a394-d666c8d3fc01")

smses = patient.SMSes().get()

assert isinstance(smses, SMSes)
assert len(smses) == 0
2 changes: 1 addition & 1 deletion welkin/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
__title__ = "welkin"
__description__ = "Python Welkin Health API Wrapper."
__url__ = "https://github.com/Lightmatter/welkin-health"
__version__ = "0.1.0"
__version__ = "0.1.1"
__author__ = "Sam Morgan"
__author_email__ = "[email protected]"
__license__ = "GNU GPL 3.0"
Expand Down
4 changes: 4 additions & 0 deletions welkin/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ class Client(Session):
DocumentSummary = models.DocumentSummary
DocumentSummaryFile = models.DocumentSummaryFile
DocumentSummaryFiles = models.DocumentSummaryFiles
Email = models.Email
Emails = models.Emails
Encounter = models.Encounter
EncounterDisposition = models.EncounterDisposition
Encounters = models.Encounters
Expand All @@ -94,6 +96,8 @@ class Client(Session):
Patients = models.Patients
Schedules = models.Schedules
SearchChats = models.SearchChats
SMS = models.SMS
SMSes = models.SMSes
User = models.User
Users = models.Users
WorkHours = models.WorkHours
Expand Down
6 changes: 6 additions & 0 deletions welkin/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
DocumentSummaryFile,
DocumentSummaryFiles,
)
from welkin.models.email import Email, Emails
from welkin.models.encounter import Encounter, EncounterDisposition, Encounters
from welkin.models.formation import Formation
from welkin.models.patient import Patient, Patients
from welkin.models.sms import SMS, SMSes
from welkin.models.user import User, Users

__all__ = [
Expand All @@ -38,6 +40,8 @@
"DocumentSummary",
"DocumentSummaryFile",
"DocumentSummaryFiles",
"Email",
"Emails",
"Encounter",
"EncounterDisposition",
"Encounters",
Expand All @@ -46,6 +50,8 @@
"Patients",
"Schedules",
"SearchChats",
"SMS",
"SMSes",
"User",
"Users",
"WorkHours",
Expand Down
Loading