Skip to content

Commit

Permalink
Resolve openemr#7300: Resolve bug accidentally introduced in API (ope…
Browse files Browse the repository at this point in the history
…nemr#7302)

* Resolve openemr#7300: Resolve bug accidentally introduced in API

* fix: DateTime handling of startTime and endTime
  • Loading branch information
AngelsDustz authored Mar 29, 2024
1 parent ed58faf commit 328c156
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/Services/AppointmentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,14 @@ public function getAppointment($eid)

public function insert($pid, $data)
{
$startTime = date("H:i:s", strtotime($data['pc_startTime']));
// TODO: Why are we adding strings with numbers? How is this even working
$endTime = $startTime . $data['pc_duration'];
$startUnixTime = strtotime($data['pc_startTime']);
$startTime = date('H:i:s', $startUnixTime);

// DateInterval _needs_ a valid constructor, so set it to 0s then update.
$endTimeInterval = new \DateInterval('PT0S');
$endTimeInterval->s = $data['pc_duration'];

$endTime = (new \DateTime())->setTimestamp($startUnixTime)->add($endTimeInterval);
$uuid = (new UuidRegistry())->createUuid();

$sql = " INSERT INTO openemr_postcalendar_events SET";
Expand Down Expand Up @@ -324,7 +329,7 @@ public function insert($pid, $data)
$data["pc_eventDate"],
$data['pc_apptstatus'],
$startTime,
$endTime,
$endTime->format('H:i:s'),
$data["pc_facility"],
$data["pc_billing_location"],
$data["pc_aid"] ?? null
Expand Down

0 comments on commit 328c156

Please sign in to comment.