feat: add lab tests, patient file management, and prescription improvements
This commit is contained in:
@@ -55,7 +55,7 @@ public function sync(): array
|
||||
try {
|
||||
$pullResponse = Http::timeout(30)
|
||||
->withHeader('X-Sync-Token', $this->token)
|
||||
->get("{$baseUrl}/api/sync/export", ['since' => $ourLastSync]);
|
||||
->get("{$baseUrl}/api/sync/export", ['since' => $peerCursor]);
|
||||
|
||||
if ($pullResponse->successful()) {
|
||||
$peerChanges = $pullResponse->json('changes', []);
|
||||
@@ -69,6 +69,9 @@ public function sync(): array
|
||||
}
|
||||
});
|
||||
|
||||
$maxPeerChangeId = max(array_column($peerChanges, 'id'));
|
||||
$this->savePeerCursor(max($peerCursor, $maxPeerChangeId));
|
||||
|
||||
if ($this->isFtpConfigured()) {
|
||||
$this->transferFilesViaFtp($peerChanges, 's2c', $report);
|
||||
} else {
|
||||
@@ -312,6 +315,15 @@ private function applyChange(array $change, string $prefix, array &$report): voi
|
||||
}
|
||||
}
|
||||
|
||||
private function savePeerCursor(int $cursor): void
|
||||
{
|
||||
\App\Models\OsurgInitial::updateOrCreate(
|
||||
['init_parameter' => 'sync_peer_cursor'],
|
||||
['init_value' => $cursor],
|
||||
);
|
||||
cache()->forget('osurg_initial.sync_peer_cursor');
|
||||
}
|
||||
|
||||
private function sanitize(array $data): array
|
||||
{
|
||||
$result = [];
|
||||
|
||||
Reference in New Issue
Block a user