Mercurial > hg > orthanc-databases
comparison Framework/Plugins/IndexBackend.cpp @ 88:eb08ec14fb04 db-changes
new extension implemented: TagMostRecentPatient
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 15 Jan 2019 21:10:50 +0100 |
parents | 1012fe77241c |
children | ca0ecd412988 |
comparison
equal
deleted
inserted
replaced
87:48d445f756db | 88:eb08ec14fb04 |
---|---|
1880 args.SetIntegerValue("id", static_cast<int>(resourceId)); | 1880 args.SetIntegerValue("id", static_cast<int>(resourceId)); |
1881 args.SetIntegerValue("metadata", static_cast<int>(metadata)); | 1881 args.SetIntegerValue("metadata", static_cast<int>(metadata)); |
1882 | 1882 |
1883 ReadListOfStrings(target, statement, args); | 1883 ReadListOfStrings(target, statement, args); |
1884 } | 1884 } |
1885 | |
1886 | |
1887 // New primitive since Orthanc 1.5.2 | |
1888 void IndexBackend::TagMostRecentPatient(int64_t patient) | |
1889 { | |
1890 int64_t seq; | |
1891 | |
1892 { | |
1893 DatabaseManager::CachedStatement statement( | |
1894 STATEMENT_FROM_HERE, manager_, | |
1895 "SELECT * FROM PatientRecyclingOrder WHERE seq >= " | |
1896 "(SELECT seq FROM PatientRecyclingOrder WHERE patientid=${id}) ORDER BY seq LIMIT 2"); | |
1897 | |
1898 statement.SetReadOnly(true); | |
1899 statement.SetParameterType("id", ValueType_Integer64); | |
1900 | |
1901 Dictionary args; | |
1902 args.SetIntegerValue("id", patient); | |
1903 | |
1904 statement.Execute(args); | |
1905 | |
1906 if (statement.IsDone()) | |
1907 { | |
1908 // The patient is protected, don't add it to the recycling order | |
1909 return; | |
1910 } | |
1911 | |
1912 seq = ReadInteger64(statement, 0); | |
1913 | |
1914 statement.Next(); | |
1915 | |
1916 if (statement.IsDone()) | |
1917 { | |
1918 // The patient is already at the end of the recycling order | |
1919 // (because of the "LIMIT 2" above), no need to modify the table | |
1920 return; | |
1921 } | |
1922 } | |
1923 | |
1924 // Delete the old position of the patient in the recycling order | |
1925 | |
1926 { | |
1927 DatabaseManager::CachedStatement statement( | |
1928 STATEMENT_FROM_HERE, manager_, | |
1929 "DELETE FROM PatientRecyclingOrder WHERE seq=${seq}"); | |
1930 | |
1931 statement.SetParameterType("seq", ValueType_Integer64); | |
1932 | |
1933 Dictionary args; | |
1934 args.SetIntegerValue("seq", seq); | |
1935 | |
1936 statement.Execute(args); | |
1937 } | |
1938 | |
1939 // Add the patient to the end of the recycling order | |
1940 | |
1941 { | |
1942 DatabaseManager::CachedStatement statement( | |
1943 STATEMENT_FROM_HERE, manager_, | |
1944 "INSERT INTO PatientRecyclingOrder VALUES(${}, ${id})"); | |
1945 | |
1946 statement.SetParameterType("id", ValueType_Integer64); | |
1947 | |
1948 Dictionary args; | |
1949 args.SetIntegerValue("id", patient); | |
1950 | |
1951 statement.Execute(args); | |
1952 } | |
1953 } | |
1885 } | 1954 } |