File: /var/www/html/sarvodayahospital/public/kioskonline.sarvodayahospital.com/app/AppointmentBook.php
<?php
namespace App;
use Illuminate\Http\Client\ConnectionException;
use Illuminate\Support\Facades\Http;
class AppointmentBook {
// For Noida Location
private $_USERID_NOIDA = 'user@sarvodaya-noida';
private $_USERKEY_NOIDA = 'ed5746b3-e532-43ce-b90d-c3caf9029751';
private $_UNITNAME_NOIDA = 'SARVODAYA HOSPITAL - NOIDA';
// For Sector-8 Location
private $_USERID = 'appointment@sarvodaya';
private $_USERKEY = 'a7a56cfe-d152-480b-aab3-d5923a8b5bb7';
private $_UNITNAME= 'SARVODAYA HOSPITAL AND RESEARCH CENTRE';
public function bookAppointment(BookingData $booking, $facilityGUID, $hospital_name)
{
$postData = [
'appointmentDate' => $booking->appointmentDate,
'appointmentID' => $booking->appointmentID,
'appointmentType' => $booking->appointmentType,
'dob' => $booking->dob,
'gender' => $booking->gender ? 'M' : 'F',
'mrn' => $booking->mrn ? $booking->mrn : '',
'mobilePhone' => $booking->mobilePhone,
'reasonForAppt' => $booking->reasonForAppt ? $booking->reasonForAppt : '', // phpcs:ignore
'loginID' => $booking->loginID ? $booking->loginID : '',
'patientName' => $booking->patientName,
'prefix' => $booking->prefix,
'slotTime' => $booking->slotTime,
'checkAppointmentExists' => $booking->checkAppointmentExists ? true : false, // phpcs:ignore
'address' => $booking->address,
'country' => $booking->country,
'state' => $booking->state,
'city' => $booking->city,
'region' => $booking->region,
'pincode' => $booking->pincode,
'consultationType' => $booking->consultationType,
'countryCode' => $booking->countryCode,
];
try {
$url = 'https://live.mednetlabs.com/mxServer/ws/feature/mednetAppointment/bookAppointment'; // phpcs:ignore
$response = Http::withHeaders(
[
'source' => 'WebClient',
'facilityGUID' => $facilityGUID,
'unitName' => $this->apiUnitName($facilityGUID),
'userID' => $this->apiUserName($facilityGUID),
'userKey' => $this->apiUserKey($facilityGUID),
]
)
->post($url, $postData);
return $response;
} catch (ConnectionException $exception) {
return json_encode($exception);
}
}
public function cancelBooking($appointmentID, $facilityGUID, $hospital_name, $cancellationNote = 'NA')
{
$postData = [
'appointmentID' => $appointmentID,
'cancellationNote' => $cancellationNote,
];
$url = 'https://live.mednetlabs.com/mxServer/ws/feature/mednetAppointment/cancelAppointment'; // phpcs:ignore
$response = Http::withHeaders(
[
'source' => 'WebClient',
'facilityGUID' => $facilityGUID,
'unitName' => $this->apiUnitName($facilityGUID),
'userID' => $this->apiUserName($facilityGUID),
'userKey' => $this->apiUserKey($facilityGUID),
]
)
->post($url, $postData);
return $response;
}
public function apiUserName($facilityGUID)
{
if ($facilityGUID == '3e77361c-d482-4816-afbb-5b87576da352') {
return $this->_USERID;
}
if ($facilityGUID == '7c43de44-9724-4b6a-828b-73a3097d3653') {
return $this->_USERID_NOIDA;
}
return '';
}
public function apiUserKey($facilityGUID)
{
if ($facilityGUID == '3e77361c-d482-4816-afbb-5b87576da352') {
return $this->_USERKEY;
}
if ($facilityGUID == '7c43de44-9724-4b6a-828b-73a3097d3653') {
return $this->_USERKEY_NOIDA;
}
return '';
}
public function apiUnitName($facilityGUID)
{
if ($facilityGUID == '3e77361c-d482-4816-afbb-5b87576da352') {
return $this->_UNITNAME;
}
if ($facilityGUID == '7c43de44-9724-4b6a-828b-73a3097d3653') {
return $this->_UNITNAME_NOIDA;
}
return '';
}
}