UPSERT series
This commit is contained in:
parent
c257464c13
commit
f144862bd6
@ -148,7 +148,7 @@ private function prepareData(mixed $orthanc_src): array
|
||||
$series = [];
|
||||
foreach ($orthanc_src['Series'] as $ser) {
|
||||
$params = [
|
||||
'orthanc_uid' => $ser['ID'],
|
||||
'orthanc_uid' => strtolower($ser['ID']),
|
||||
'series_instance_uid' => data_get($ser, 'MainDicomTags.SeriesInstanceUID'),
|
||||
'series_date' => DicomUtils::dateTimeToCarbon($ser['MainDicomTags']['SeriesDate'], $ser['MainDicomTags']['SeriesTime']),
|
||||
'series_number' => data_get($ser, 'MainDicomTags.SeriesNumber'),
|
||||
@ -183,9 +183,16 @@ private function updateStudy(int $row_id, mixed $study): void
|
||||
$data = $this->prepareData($study);
|
||||
unset($data['study']['orthanc_uid']);
|
||||
DB::table('studies')->where('id', $row_id)->update($data['study']);
|
||||
|
||||
if (! empty($data['details'])) {
|
||||
DB::table('study_details')->where('study_id', $row_id)->update($data['details']);
|
||||
}
|
||||
|
||||
foreach ($study['series'] as $series) {
|
||||
$series_id = $series['orthanc_uid'];
|
||||
unset($series['orthanc_uid']);
|
||||
DB::table('study_series')->where('orthanc_uid', $series_id)->update($series);
|
||||
}
|
||||
}
|
||||
|
||||
private function insertStudy(mixed $study): void
|
||||
@ -194,5 +201,10 @@ private function insertStudy(mixed $study): void
|
||||
$study = Study::create($data['study']);
|
||||
$data['details']['study_id'] = $study->id;
|
||||
StudyDetails::create($data['details']);
|
||||
|
||||
foreach ($study['series'] as $series) {
|
||||
$series['study_id'] = $study->id;
|
||||
DB::table('study_series')->insert($series);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user