import { APIService } from './api' import { ClosedReasonType, Consult, DataCreateResponse, LockboxDataRequest, MedicalStatus, ResumeConsultEmailRequest, ResumeTransmissionEmailRequest, Uuid, } from '../models' export class TellerService { constructor(private api: APIService, private baseURL: string) { } public async lockboxDataStore( lockboxUuid: Uuid, req: LockboxDataRequest, lockboxOwnerUuid?: Uuid, previousDataUuid?: Uuid, options: { updateMedicalStatus: boolean } = { updateMedicalStatus: true }, ): Promise { return this.api.post(`${this.baseURL}/v1/lockboxes/${lockboxUuid}/data`, req, { params: { lockbox_owner_uuid: lockboxOwnerUuid, data_uuid: previousDataUuid, update_medical_status: options.updateMedicalStatus, }, }) } public updateConsultByUUID( patientUuid: Uuid, uuidConsult: Uuid, statusMedical: MedicalStatus, closedReasonType?: ClosedReasonType, closedReasonDescription?: string, neverExpires?: boolean ): Promise { return this.api.put(`${this.baseURL}/v1/consults/${uuidConsult}`, { patientUuid, statusMedical, closedReasonType, closedReasonDescription, neverExpires, }) } /** * This function notifies teller that the fax sent for a specific consult did not get through * @todo - Make service only exposed route * @param practiceUuid the practice uuid linked to the consult * @param consultationUuid the consultation uuid * @param consultationShortId the consultation short id * @param fax the address where to send the fax * @returns void */ public notifyFaxFailed(practiceUuid: Uuid, consultationUuid: Uuid, consultationShortId: string, fax: string) { return this.api.post( `${this.baseURL}/v1/fax-failed`, { consultationUuid, consultationShortId, fax, }, { params: { practice_uuid: practiceUuid }, } ) } /** * This function let's you reassign a practictioner to a consult and send a notification email * @todo - Make service only exposed route * @param uuidConsult the uuid of the consult to reassign * @param newPractitionerUuid the uuid of the practitioner that will get reassigned */ public reassignmentEmail(uuidConsult: Uuid, newPractitionerUuid: Uuid) { return this.api.post(`${this.baseURL}/v1/consult/${uuidConsult}/reassignment-email`, { newPractitionerUuid, }) } /** * This function will send an email to the patientUuid, saying that the online practice has been sent a fax successfully * @todo - Make service only exposed route * @param consult * @param patientUuid * @returns void */ public sendOnlineFaxSuccessfulEmail(consult: Consult, patientUuid: Uuid): Promise { return this.api.post(`${this.baseURL}/v1/online-fax-notify`, { consult, patientUuid }) } /** * This function will send an email to the patientUuid, saying that the refill has been completed successfully * @todo - Make service only exposed route * @param consult * @param patientUuid * @returns void */ public sendRefillFaxSucceededEmail(consult: Consult, patientUuid: Uuid): Promise { return this.api.post(`${this.baseURL}/v1/refill-confirm-email`, { consult, patientUuid }) } /** * This function will send an email to patient to allow them to resume the consult. * @param req the body of the resume consult request * @returns void */ public sendResumeConsultEmail(req: ResumeConsultEmailRequest): Promise { return this.api.post(`${this.baseURL}/v1/resume-consult-email`, req) } /** * This function will send an email to patient to allow them to resume the transmission of their prescription. * @param req the body of the resume consult request * @returns void */ public sendResumeTransmissionEmail(req: ResumeTransmissionEmailRequest): Promise { return this.api.post(`${this.baseURL}/v1/resume-transmission-email`, req) } }