fw4spl
io/fwNetworkIO/src/fwNetworkIO/helper/Series.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2018.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #include "fwNetworkIO/helper/Series.hpp"
8 
9 #include <fwCore/spyLog.hpp>
10 
11 #include <fwMedData/DicomSeries.hpp>
12 #include <fwMedData/Equipment.hpp>
13 #include <fwMedData/ImageSeries.hpp>
14 #include <fwMedData/ModelSeries.hpp>
15 #include <fwMedData/Patient.hpp>
16 #include <fwMedData/Study.hpp>
17 
18 #include <boost/foreach.hpp>
19 
20 namespace fwNetworkIO
21 {
22 namespace helper
23 {
24 
25 // ----------------------------------------------------------------------------
26 
27 Series::DicomSeriesContainer Series::toFwMedData(const QJsonObject& seriesJson)
28 {
29  DicomSeriesContainer seriesContainer;
30 
31  // Create series
32  ::fwMedData::DicomSeries::sptr series = ::fwMedData::DicomSeries::New();
33  ::fwMedData::Patient::sptr patient = ::fwMedData::Patient::New();
34  ::fwMedData::Study::sptr study = ::fwMedData::Study::New();
35  ::fwMedData::Equipment::sptr equipment = ::fwMedData::Equipment::New();
36 
37  // Set informations to series
38  series->setPatient(patient);
39  series->setStudy(study);
40  series->setEquipment(equipment);
41 
42  // ==================================
43  // Series
44  // ==================================
45 
46  series->setInstanceUID(seriesJson["SeriesInstanceUID"].toString().toStdString());
47  series->setModality(seriesJson["Modality"].toString().toStdString());
48  series->setDate(seriesJson["SeriesDate"].toString().toStdString());
49  series->setTime(seriesJson["SeriesTime"].toString().toStdString());
50  series->setDescription(seriesJson["SeriesDescription"].toString().toStdString());
51 
52  // ==================================
53  // Patient
54  // ==================================
55  patient->setName(seriesJson["PatientName"].toString().toStdString());
56  patient->setPatientId(seriesJson["PatientID"].toString().toStdString());
57  patient->setBirthdate(seriesJson["PatientBirthDate"].toString().toStdString());
58  patient->setSex(seriesJson["PatientSex"].toString().toStdString());
59 
60  // ==================================
61  // Study
62  // ==================================
63  study->setInstanceUID(seriesJson["StudyInstanceUID"].toString().toStdString());
64  study->setDate(seriesJson["StudyDate"].toString().toStdString());
65  study->setTime(seriesJson["StudyTime"].toString().toStdString());
66  study->setDescription(seriesJson["StudyDescription"].toString().toStdString());
67  study->setPatientAge(seriesJson["PatientAge"].toString().toStdString());
68 
69  // ==================================
70  // Equipment
71  // ==================================
72  equipment->setInstitutionName(seriesJson["InstitutionName"].toString().toStdString());
73 
74  // ==================================
75  // Number of instances
76  // ==================================
77  series->setNumberOfInstances(seriesJson["NumberOfSeriesRelatedInstances"].toInt());
78 
79  // Add series to container
80  seriesContainer.push_back(series);
81 
82  return seriesContainer;
83 }
84 
85 // ----------------------------------------------------------------------------
86 
87 Series::InstanceUIDContainer Series::toSeriesInstanceUIDContainer(DicomSeriesContainer series)
88 {
89  InstanceUIDContainer result;
90 
91  for(const ::fwMedData::Series::sptr& s: series )
92  {
93  result.push_back(s->getInstanceUID());
94  }
95 
96  return result;
97 }
98 
99 } //helper
100 } //fwNetworkIO
static FWNETWORKIO_API InstanceUIDContainer toSeriesInstanceUIDContainer(DicomSeriesContainer series)
Convert std::vector< ::fwMedData::DicomSeries > to series instance uid container. ...
The namespace fwNetworkIO contains the primary methods to access network.
static FWNETWORKIO_API DicomSeriesContainer toFwMedData(const QJsonObject &answer)
Convert HTTP series response to fwMedData::DicomSeries.
This file defines SpyLog macros. These macros are used to log messages to a file or to the console du...