-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created translations for appointment participants; patient, provider …
…and apointment provider
- Loading branch information
Showing
12 changed files
with
715 additions
and
6 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
7 changes: 7 additions & 0 deletions
7
...n/java/org/openmrs/module/fhirappnt/api/translators/AppointmentParticipantTranslator.java
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,7 @@ | ||
package org.openmrs.module.fhirappnt.api.translators; | ||
|
||
import org.hl7.fhir.r4.model.Appointment; | ||
import org.openmrs.module.fhir2.api.translators.OpenmrsFhirUpdatableTranslator; | ||
|
||
public interface AppointmentParticipantTranslator<T> extends OpenmrsFhirUpdatableTranslator<T, Appointment.AppointmentParticipantComponent> { | ||
} |
52 changes: 52 additions & 0 deletions
52
...a/org/openmrs/module/fhirappnt/api/translators/impl/AppointmentPatientTranslatorImpl.java
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,52 @@ | ||
package org.openmrs.module.fhirappnt.api.translators.impl; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.Setter; | ||
import org.hl7.fhir.r4.model.Appointment; | ||
import org.hl7.fhir.r4.model.CodeableConcept; | ||
import org.hl7.fhir.r4.model.Coding; | ||
import org.openmrs.Patient; | ||
import org.openmrs.module.fhir2.api.translators.PatientReferenceTranslator; | ||
import org.openmrs.module.fhir2.api.translators.impl.AbstractReferenceHandlingTranslator; | ||
import org.openmrs.module.fhirappnt.api.AppointmentFhirConstants; | ||
import org.openmrs.module.fhirappnt.api.translators.AppointmentParticipantTranslator; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@Setter(AccessLevel.PACKAGE) | ||
public class AppointmentPatientTranslatorImpl extends AbstractReferenceHandlingTranslator implements AppointmentParticipantTranslator<Patient> { | ||
|
||
@Autowired | ||
private PatientReferenceTranslator patientReferenceTranslator; | ||
|
||
@Override | ||
public Appointment.AppointmentParticipantComponent toFhirResource(Patient patient) { | ||
if (patient == null) { | ||
return null; | ||
} | ||
Appointment.AppointmentParticipantComponent participant = new Appointment.AppointmentParticipantComponent(); | ||
CodeableConcept role = new CodeableConcept(); | ||
role.addCoding(new Coding(AppointmentFhirConstants.APPOINTMENT_PARTICIPANT_TYPE, "Patient", "Patient")); | ||
participant.setRequired(Appointment.ParticipantRequired.REQUIRED); | ||
participant.setActor(patientReferenceTranslator.toFhirResource(patient)); | ||
participant.addType(role); | ||
participant.setStatus(Appointment.ParticipationStatus.ACCEPTED); | ||
|
||
return participant; | ||
} | ||
|
||
@Override | ||
public Patient toOpenmrsType(Appointment.AppointmentParticipantComponent appointmentParticipantComponent) { | ||
return toOpenmrsType(new Patient(), appointmentParticipantComponent); | ||
} | ||
|
||
@Override | ||
public Patient toOpenmrsType(Patient patient, Appointment.AppointmentParticipantComponent appointmentParticipantComponent) { | ||
if (appointmentParticipantComponent == null) { | ||
return patient; | ||
} | ||
|
||
return patientReferenceTranslator.toOpenmrsType(appointmentParticipantComponent.getActor()); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
.../openmrs/module/fhirappnt/api/translators/impl/AppointmentPractitionerTranslatorImpl.java
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,51 @@ | ||
package org.openmrs.module.fhirappnt.api.translators.impl; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.Setter; | ||
import org.hl7.fhir.r4.model.Appointment; | ||
import org.hl7.fhir.r4.model.CodeableConcept; | ||
import org.hl7.fhir.r4.model.Coding; | ||
import org.openmrs.Provider; | ||
import org.openmrs.module.fhir2.api.dao.FhirPractitionerDao; | ||
import org.openmrs.module.fhir2.api.translators.impl.AbstractReferenceHandlingTranslator; | ||
import org.openmrs.module.fhirappnt.api.AppointmentFhirConstants; | ||
import org.openmrs.module.fhirappnt.api.translators.AppointmentParticipantTranslator; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@Setter(AccessLevel.PACKAGE) | ||
public class AppointmentPractitionerTranslatorImpl extends AbstractReferenceHandlingTranslator implements AppointmentParticipantTranslator<Provider> { | ||
|
||
@Autowired | ||
private FhirPractitionerDao practitionerDao; | ||
|
||
@Override | ||
public Appointment.AppointmentParticipantComponent toFhirResource(Provider provider) { | ||
if (provider == null) { | ||
return null; | ||
} | ||
Appointment.AppointmentParticipantComponent participant = new Appointment.AppointmentParticipantComponent(); | ||
CodeableConcept role = new CodeableConcept(); | ||
role.addCoding(new Coding(AppointmentFhirConstants.APPOINTMENT_PARTICIPANT_TYPE, "Practitioner", "Practitioner")); | ||
participant.setRequired(Appointment.ParticipantRequired.OPTIONAL); | ||
participant.setActor(createPractitionerReference(provider)); | ||
participant.addType(role); | ||
|
||
return participant; | ||
} | ||
|
||
@Override | ||
public Provider toOpenmrsType(Appointment.AppointmentParticipantComponent appointmentParticipantComponent) { | ||
return toOpenmrsType(new Provider(), appointmentParticipantComponent); | ||
} | ||
|
||
@Override | ||
public Provider toOpenmrsType(Provider appointmentProvider, Appointment.AppointmentParticipantComponent appointmentParticipantComponent) { | ||
if (appointmentParticipantComponent == null) { | ||
return appointmentProvider; | ||
} | ||
|
||
return practitionerDao.getProviderByUuid(getReferenceId(appointmentParticipantComponent.getActor())); | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
.../org/openmrs/module/fhirappnt/api/translators/impl/AppointmentProviderTranslatorImpl.java
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,77 @@ | ||
package org.openmrs.module.fhirappnt.api.translators.impl; | ||
import lombok.AccessLevel; | ||
import lombok.Setter; | ||
import org.hl7.fhir.r4.model.Appointment; | ||
import org.hl7.fhir.r4.model.CodeableConcept; | ||
import org.hl7.fhir.r4.model.Coding; | ||
import org.openmrs.module.appointments.model.AppointmentProvider; | ||
import org.openmrs.module.appointments.model.AppointmentProviderResponse; | ||
import org.openmrs.module.fhir2.api.dao.FhirPractitionerDao; | ||
import org.openmrs.module.fhir2.api.translators.impl.AbstractReferenceHandlingTranslator; | ||
import org.openmrs.module.fhirappnt.api.AppointmentFhirConstants; | ||
import org.openmrs.module.fhirappnt.api.translators.AppointmentParticipantTranslator; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@Setter(AccessLevel.PACKAGE) | ||
public class AppointmentProviderTranslatorImpl extends AbstractReferenceHandlingTranslator implements AppointmentParticipantTranslator<AppointmentProvider> { | ||
|
||
@Autowired | ||
private FhirPractitionerDao practitionerDao; | ||
|
||
@Override | ||
public Appointment.AppointmentParticipantComponent toFhirResource(AppointmentProvider appointmentProvider) { | ||
if (appointmentProvider == null || appointmentProvider.getProvider() == null) { | ||
return null; | ||
} | ||
Appointment.AppointmentParticipantComponent participant = new Appointment.AppointmentParticipantComponent(); | ||
CodeableConcept role = new CodeableConcept(); | ||
role.addCoding(new Coding(AppointmentFhirConstants.APPOINTMENT_PARTICIPANT_TYPE, "AppointmentPractitioner", "AppointmentPractitioner")); | ||
participant.setRequired(Appointment.ParticipantRequired.OPTIONAL); | ||
participant.setActor(createPractitionerReference(appointmentProvider.getProvider())); | ||
participant.addType(role); | ||
|
||
switch (appointmentProvider.getResponse()) { | ||
case ACCEPTED: | ||
return participant.setStatus(Appointment.ParticipationStatus.ACCEPTED); | ||
case TENTATIVE: | ||
return participant.setStatus(Appointment.ParticipationStatus.TENTATIVE); | ||
case AWAITING: | ||
return participant.setStatus(Appointment.ParticipationStatus.NEEDSACTION); | ||
case REJECTED: | ||
return participant.setStatus(Appointment.ParticipationStatus.DECLINED); | ||
case CANCELLED: | ||
return participant.setStatus(Appointment.ParticipationStatus.NULL); | ||
} | ||
|
||
return participant; | ||
} | ||
|
||
@Override | ||
public AppointmentProvider toOpenmrsType(Appointment.AppointmentParticipantComponent appointmentParticipantComponent) { | ||
return toOpenmrsType(new AppointmentProvider(), appointmentParticipantComponent); | ||
} | ||
|
||
@Override | ||
public AppointmentProvider toOpenmrsType(AppointmentProvider appointmentProvider, Appointment.AppointmentParticipantComponent appointmentParticipantComponent) { | ||
if (appointmentParticipantComponent == null) { | ||
return appointmentProvider; | ||
} | ||
appointmentProvider.setProvider(practitionerDao.getProviderByUuid(getReferenceId(appointmentParticipantComponent.getActor()))); | ||
switch (appointmentParticipantComponent.getStatus()) { | ||
case ACCEPTED: | ||
appointmentProvider.setResponse(AppointmentProviderResponse.ACCEPTED); | ||
case TENTATIVE: | ||
appointmentProvider.setResponse(AppointmentProviderResponse.TENTATIVE); | ||
case NEEDSACTION: | ||
appointmentProvider.setResponse(AppointmentProviderResponse.AWAITING); | ||
case DECLINED: | ||
appointmentProvider.setResponse(AppointmentProviderResponse.REJECTED); | ||
case NULL: | ||
appointmentProvider.setResponse(AppointmentProviderResponse.CANCELLED); | ||
} | ||
|
||
return appointmentProvider; | ||
} | ||
} |
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
Oops, something went wrong.