diff --git a/test/cassettes/fixtures/program__TestProgram.test_delete.yaml b/test/cassettes/fixtures/patient_program__TestProgram.test_delete.yaml similarity index 100% rename from test/cassettes/fixtures/program__TestProgram.test_delete.yaml rename to test/cassettes/fixtures/patient_program__TestProgram.test_delete.yaml diff --git a/test/cassettes/fixtures/program__TestProgram.test_read[id].yaml b/test/cassettes/fixtures/patient_program__TestProgram.test_read[id].yaml similarity index 100% rename from test/cassettes/fixtures/program__TestProgram.test_read[id].yaml rename to test/cassettes/fixtures/patient_program__TestProgram.test_read[id].yaml diff --git a/test/cassettes/fixtures/program__TestProgram.test_read[programName].yaml b/test/cassettes/fixtures/patient_program__TestProgram.test_read[programName].yaml similarity index 100% rename from test/cassettes/fixtures/program__TestProgram.test_read[programName].yaml rename to test/cassettes/fixtures/patient_program__TestProgram.test_read[programName].yaml diff --git a/test/cassettes/fixtures/program__TestProgram.test_update.yaml b/test/cassettes/fixtures/patient_program__TestProgram.test_update.yaml similarity index 100% rename from test/cassettes/fixtures/program__TestProgram.test_update.yaml rename to test/cassettes/fixtures/patient_program__TestProgram.test_update.yaml diff --git a/test/test_program.py b/test/test_program.py index bd723b0..55a7c8f 100644 --- a/test/test_program.py +++ b/test/test_program.py @@ -4,14 +4,20 @@ from welkin import Client from welkin.exceptions import WelkinHTTPError -from welkin.models import Patient, Program, ProgramPhase, ProgramPhases, Programs -from welkin.models.formation import Program as FormationProgram +from welkin.models import ( + Patient, + PatientProgram, + PatientPrograms, + ProgramPhase, + ProgramPhases, +) +from welkin.models.formation import Program @pytest.mark.vcr class TestProgram: @pytest.fixture - def formation(self, client: Client) -> FormationProgram: + def formation(self, client: Client) -> Program: return client.Formation().Programs().get()[0] @pytest.fixture @@ -23,14 +29,14 @@ def second_phase(self, formation) -> str: return formation.phases[1]["name"] @pytest.fixture - def program( + def patient_program( self, patient: Patient, - formation: FormationProgram, + formation: Program, first_phase: str, fixture_cassette, - ) -> Program: - program = patient.Program(programName=formation.name) + ) -> PatientProgram: + program = patient.PatientProgram(programName=formation.name) with fixture_cassette(): try: @@ -54,32 +60,38 @@ def program( "programName", ], ) - def test_read(self, patient: Patient, program: Program, identifier: str): - prog = patient.Program(**{identifier: getattr(program, identifier)}).get() - - assert isinstance(prog, Program) + def test_read( + self, patient: Patient, patient_program: PatientProgram, identifier: str + ): + prog = patient.PatientProgram( + **{identifier: getattr(patient_program, identifier)} + ).get() + + assert isinstance(prog, PatientProgram) assert isinstance(prog.currentPhase, ProgramPhase) assert isinstance(prog.pathHistory, ProgramPhases) - assert prog.id == program.id + assert prog.id == patient_program.id def test_read_no_id(self, client): with pytest.raises(ValueError): - client.Patient(id="notarealid").Program().get() + client.Patient(id="notarealid").PatientProgram().get() - def test_update(self, patient: Patient, program: Program, second_phase: str): - assert program.currentPhase.name != second_phase - assert len(program.pathHistory) == 1 + def test_update( + self, patient: Patient, patient_program: PatientProgram, second_phase: str + ): + assert patient_program.currentPhase.name != second_phase + assert len(patient_program.pathHistory) == 1 - prog = patient.Program(programName=program.programName).update( + prog = patient.PatientProgram(programName=patient_program.programName).update( phaseName=second_phase ) assert prog.currentPhase.name == second_phase - assert prog.currentPhase.name != program.currentPhase.name + assert prog.currentPhase.name != patient_program.currentPhase.name assert len(prog.pathHistory) == 2 - def test_delete(self, patient: Patient, program: Program): - prog = patient.Program(id=program.id) + def test_delete(self, patient: Patient, patient_program: PatientProgram): + prog = patient.PatientProgram(id=patient_program.id) prog.delete() with pytest.raises(WelkinHTTPError) as excinfo: @@ -91,7 +103,7 @@ def test_delete(self, patient: Patient, program: Program): @pytest.mark.vcr class TestPrograms: def test_read(self, patient): - programs = patient.Programs().get() + programs = patient.PatientPrograms().get() - assert isinstance(programs, Programs) - assert isinstance(programs[0], Program) + assert isinstance(programs, PatientPrograms) + assert isinstance(programs[0], PatientProgram) diff --git a/welkin/client.py b/welkin/client.py index e95e1ed..79b56ef 100644 --- a/welkin/client.py +++ b/welkin/client.py @@ -94,10 +94,10 @@ class Client(Session): Formation = models.Formation Patient = models.Patient Patients = models.Patients - Program = models.Program + PatientProgram = models.PatientProgram ProgramPhase = models.ProgramPhase ProgramPhases = models.ProgramPhases - Programs = models.Programs + PatientPrograms = models.PatientPrograms Schedules = models.Schedules SearchChats = models.SearchChats SMS = models.SMS diff --git a/welkin/models/__init__.py b/welkin/models/__init__.py index 52e97ed..aec8dc3 100644 --- a/welkin/models/__init__.py +++ b/welkin/models/__init__.py @@ -19,7 +19,12 @@ from welkin.models.encounter import Encounter, EncounterDisposition, Encounters from welkin.models.formation import Formation from welkin.models.patient import Patient, Patients -from welkin.models.program import Program, ProgramPhase, ProgramPhases, Programs +from welkin.models.program import ( + PatientProgram, + PatientPrograms, + ProgramPhase, + ProgramPhases, +) from welkin.models.sms import SMS, SMSes from welkin.models.user import User, Users @@ -49,10 +54,10 @@ "Formation", "Patient", "Patients", - "Program", + "PatientProgram", "ProgramPhase", "ProgramPhases", - "Programs", + "PatientPrograms", "Schedules", "SearchChats", "SMS", diff --git a/welkin/models/patient.py b/welkin/models/patient.py index 1a1b79c..a565e91 100644 --- a/welkin/models/patient.py +++ b/welkin/models/patient.py @@ -10,7 +10,7 @@ ) from welkin.models.email import Email, Emails from welkin.models.encounter import Encounter, Encounters -from welkin.models.program import Program, Programs +from welkin.models.program import PatientProgram, PatientPrograms from welkin.models.sms import SMS, SMSes from welkin.pagination import PageableIterator @@ -31,8 +31,8 @@ class Patient(Resource): Emails, Encounter, Encounters, - Program, - Programs, + PatientProgram, + PatientPrograms, SearchChats, SMS, SMSes, diff --git a/welkin/models/program.py b/welkin/models/program.py index 36f7f09..6e23a95 100644 --- a/welkin/models/program.py +++ b/welkin/models/program.py @@ -11,7 +11,7 @@ class ProgramPhases(Collection): resource = ProgramPhase -class Program(Resource): +class PatientProgram(Resource): subresources = [ProgramPhase] nested_objects = { "phases": "ProgramPhase", @@ -64,8 +64,8 @@ def delete(self, patient_id: str = None): ) -class Programs(Collection): - resource = Program +class PatientPrograms(Collection): + resource = PatientProgram iterator = MetaInfoIterator def get(