Mercurial > hg > orthanc
comparison OrthancServer/Sources/main.cpp @ 4238:c007fb7c8395
studies by date working
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 09 Oct 2020 10:28:34 +0200 |
parents | f39d162ba7e9 |
children | c8754c4c1862 |
comparison
equal
deleted
inserted
replaced
4237:f39d162ba7e9 | 4238:c007fb7c8395 |
---|---|
777 | 777 |
778 | 778 |
779 | 779 |
780 static const char* const BY_PATIENTS = "by-patients"; | 780 static const char* const BY_PATIENTS = "by-patients"; |
781 static const char* const BY_STUDIES = "by-studies"; | 781 static const char* const BY_STUDIES = "by-studies"; |
782 static const char* const BY_DATE = "by-date"; | 782 static const char* const BY_DATE = "by-dates"; |
783 static const char* const BY_UIDS = "by-uids"; | 783 static const char* const BY_UIDS = "by-uids"; |
784 static const char* const MAIN_DICOM_TAGS = "MainDicomTags"; | 784 static const char* const MAIN_DICOM_TAGS = "MainDicomTags"; |
785 | 785 |
786 class DummyBucket2 : public IWebDavBucket // TODO | 786 class DummyBucket2 : public IWebDavBucket // TODO |
787 { | 787 { |
1538 } | 1538 } |
1539 }; | 1539 }; |
1540 | 1540 |
1541 | 1541 |
1542 | 1542 |
1543 class ResourceChildrenNode : public ListOfResources | 1543 class SingleDicomResource : public ListOfResources |
1544 { | 1544 { |
1545 private: | 1545 private: |
1546 std::string parentId_; | 1546 std::string parentId_; |
1547 | 1547 |
1548 protected: | 1548 protected: |
1570 return new InstancesOfSeries(GetContext(), resource); | 1570 return new InstancesOfSeries(GetContext(), resource); |
1571 } | 1571 } |
1572 else | 1572 else |
1573 { | 1573 { |
1574 ResourceType l = GetChildResourceType(GetLevel()); | 1574 ResourceType l = GetChildResourceType(GetLevel()); |
1575 return new ResourceChildrenNode(GetContext(), l, resource, GetTemplates()); | 1575 return new SingleDicomResource(GetContext(), l, resource, GetTemplates()); |
1576 } | 1576 } |
1577 } | 1577 } |
1578 | 1578 |
1579 public: | 1579 public: |
1580 ResourceChildrenNode(ServerContext& context, | 1580 SingleDicomResource(ServerContext& context, |
1581 ResourceType level, | 1581 ResourceType level, |
1582 const std::string& parentId, | 1582 const std::string& parentId, |
1583 const Templates& templates) : | 1583 const Templates& templates) : |
1584 ListOfResources(context, level, templates), | 1584 ListOfResources(context, level, templates), |
1585 parentId_(parentId) | 1585 parentId_(parentId) |
1586 { | 1586 { |
1587 } | 1587 } |
1588 }; | 1588 }; |
1603 return new InstancesOfSeries(GetContext(), resource); | 1603 return new InstancesOfSeries(GetContext(), resource); |
1604 } | 1604 } |
1605 else | 1605 else |
1606 { | 1606 { |
1607 ResourceType l = GetChildResourceType(GetLevel()); | 1607 ResourceType l = GetChildResourceType(GetLevel()); |
1608 return new ResourceChildrenNode(GetContext(), l, resource, GetTemplates()); | 1608 return new SingleDicomResource(GetContext(), l, resource, GetTemplates()); |
1609 } | 1609 } |
1610 } | 1610 } |
1611 | 1611 |
1612 public: | 1612 public: |
1613 RootNode(ServerContext& context, | 1613 RootNode(ServerContext& context, |
1616 ListOfResources(context, level, templates) | 1616 ListOfResources(context, level, templates) |
1617 { | 1617 { |
1618 } | 1618 } |
1619 }; | 1619 }; |
1620 | 1620 |
1621 | |
1622 class ListOfStudiesByDate : public ListOfResources | |
1623 { | |
1624 private: | |
1625 std::string year_; | |
1626 std::string month_; | |
1627 | |
1628 class Visitor : public ServerContext::ILookupVisitor | |
1629 { | |
1630 private: | |
1631 std::list<std::string>& resources_; | |
1632 | |
1633 public: | |
1634 Visitor(std::list<std::string>& resources) : | |
1635 resources_(resources) | |
1636 { | |
1637 } | |
1638 | |
1639 virtual bool IsDicomAsJsonNeeded() const ORTHANC_OVERRIDE | |
1640 { | |
1641 return false; // (*) | |
1642 } | |
1643 | |
1644 virtual void MarkAsComplete() ORTHANC_OVERRIDE | |
1645 { | |
1646 } | |
1647 | |
1648 virtual void Visit(const std::string& publicId, | |
1649 const std::string& instanceId /* unused */, | |
1650 const DicomMap& mainDicomTags, | |
1651 const Json::Value* dicomAsJson /* unused (*) */) ORTHANC_OVERRIDE | |
1652 { | |
1653 resources_.push_back(publicId); | |
1654 } | |
1655 }; | |
1656 | |
1657 protected: | |
1658 virtual void GetCurrentResources(std::list<std::string>& resources) ORTHANC_OVERRIDE | |
1659 { | |
1660 DatabaseLookup query; | |
1661 query.AddRestConstraint(DICOM_TAG_STUDY_DATE, year_ + month_ + "01-" + year_ + month_ + "31", | |
1662 true /* case sensitive */, true /* mandatory tag */); | |
1663 | |
1664 Visitor visitor(resources); | |
1665 GetContext().Apply(visitor, query, ResourceType_Study, 0 /* since */, 0 /* no limit */); | |
1666 } | |
1667 | |
1668 virtual INode* CreateResourceNode(const std::string& resource) ORTHANC_OVERRIDE | |
1669 { | |
1670 return new SingleDicomResource(GetContext(), ResourceType_Series, resource, GetTemplates()); | |
1671 } | |
1672 | |
1673 public: | |
1674 ListOfStudiesByDate(ServerContext& context, | |
1675 const std::string& year, | |
1676 const std::string& month, | |
1677 const Templates& templates) : | |
1678 ListOfResources(context, ResourceType_Study, templates), | |
1679 year_(year), | |
1680 month_(month) | |
1681 { | |
1682 if (year.size() != 4 || | |
1683 month.size() != 2) | |
1684 { | |
1685 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
1686 } | |
1687 } | |
1688 }; | |
1621 | 1689 |
1622 | 1690 |
1623 class ListOfStudiesByMonth : public InternalNode | 1691 class ListOfStudiesByMonth : public InternalNode |
1624 { | 1692 { |
1625 private: | 1693 private: |
1688 return true; | 1756 return true; |
1689 } | 1757 } |
1690 | 1758 |
1691 virtual INode* CreateChild(const std::string& path) ORTHANC_OVERRIDE | 1759 virtual INode* CreateChild(const std::string& path) ORTHANC_OVERRIDE |
1692 { | 1760 { |
1693 return NULL; | 1761 if (path.size() != 7) // Format: "YYYY-MM" |
1762 { | |
1763 throw OrthancException(ErrorCode_InternalError); | |
1764 } | |
1765 else | |
1766 { | |
1767 const std::string year = path.substr(0, 4); | |
1768 const std::string month = path.substr(5, 2); | |
1769 return new ListOfStudiesByDate(context_, year, month, templates_); | |
1770 } | |
1694 } | 1771 } |
1695 | 1772 |
1696 public: | 1773 public: |
1697 ListOfStudiesByMonth(ServerContext& context, | 1774 ListOfStudiesByMonth(ServerContext& context, |
1698 const std::string& year, | 1775 const std::string& year, |
1699 const Templates& templates) : | 1776 const Templates& templates) : |
1700 context_(context), | 1777 context_(context), |
1701 year_(year), | 1778 year_(year), |
1702 templates_(templates) | 1779 templates_(templates) |
1703 { | 1780 { |
1781 if (year_.size() != 4) | |
1782 { | |
1783 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
1784 } | |
1704 } | 1785 } |
1705 }; | 1786 }; |
1706 | 1787 |
1707 | 1788 |
1708 class ListOfStudiesByYear : public InternalNode | 1789 class ListOfStudiesByYear : public InternalNode |