1- import api from "./api" ;
1+ import { dir } from "console" ;
2+ import api , { type ApiResult } from "./api" ;
23import type {
34 Feed ,
45 PluginInstance ,
56 Plugin ,
67 NodeInfo ,
78 UploadPipeline ,
9+ PACSSeries ,
810} from "./types" ;
911
1012import YAML from "yaml" ;
@@ -15,7 +17,7 @@ export const GetFeedPluginInstances = (feedID: number) =>
1517 method : "get" ,
1618 } ) ;
1719
18- export const GetFeed = ( feedID : number ) =>
20+ export const getFeed = ( feedID : number ) =>
1921 api < Feed > ( {
2022 endpoint : `/${ feedID } /` ,
2123 method : "get" ,
@@ -30,6 +32,15 @@ export const updateFeedName = (feedID: number, feedName: string) =>
3032 } ,
3133 } ) ;
3234
35+ export const updateFeedPublic = ( feedID : number , isPublic = true ) =>
36+ api < Feed > ( {
37+ endpoint : `/${ feedID } /` ,
38+ method : "put" ,
39+ json : {
40+ public : isPublic ,
41+ } ,
42+ } ) ;
43+
3344export const searchPluginsByName = ( pluginName : string ) =>
3445 api < Plugin [ ] > ( {
3546 endpoint : "/plugins/search/" ,
@@ -44,6 +55,7 @@ export const createPluginInstance = (pluginID: number, theDirs: string[]) =>
4455 endpoint : `/plugins/${ pluginID } /instances/` ,
4556 method : "post" ,
4657 json : {
58+ previous_id : null ,
4759 dir : theDirs . join ( "," ) ,
4860 } ,
4961 } ) ;
@@ -72,10 +84,69 @@ export const createWorkflow = (
7284 } ,
7385 } ) ;
7486
87+ type createFeedWithFilepathProp = {
88+ filepath : string ;
89+ theName : string ;
90+ tags : string [ ] ;
91+ patientID ?: string ;
92+ modality ?: string ;
93+ studyDate ?: string ;
94+ isPublic ?: boolean ;
95+ } ;
96+ export const createFeedWithFilepath = async ( {
97+ filepath,
98+ theName,
99+ tags,
100+ patientID,
101+ modality,
102+ studyDate,
103+ isPublic,
104+ } : createFeedWithFilepathProp ) : Promise < ApiResult < Feed > > => {
105+ const pluginInstanceResult = await createPluginInstance ( 1 , [ filepath ] ) ;
106+ if ( ! pluginInstanceResult . data ) {
107+ return {
108+ errmsg : pluginInstanceResult . errmsg ,
109+ status : pluginInstanceResult . status ,
110+ } ;
111+ }
112+
113+ const {
114+ data : { feed_id : feedID } ,
115+ } = pluginInstanceResult ;
116+
117+ await updateFeedName ( feedID , theName ) ;
118+
119+ if ( isPublic ) {
120+ await updateFeedPublic ( feedID , true ) ;
121+ }
122+
123+ const feedResult = await getFeed ( feedID ) ;
124+
125+ return feedResult ;
126+ } ;
127+
75128export const createPipeline = ( pipeline : UploadPipeline ) =>
76129 api ( {
77130 endpoint : "/pipelines/sourcefiles/" ,
78131 method : "post" ,
79132 filename : "fname" ,
80133 filetext : YAML . stringify ( pipeline ) ,
81134 } ) ;
135+
136+ export const getPACSSeriesListByStudyUID = ( studyUID : string ) =>
137+ api < PACSSeries [ ] > ( {
138+ endpoint : "/pacs/series/search/" ,
139+ method : "get" ,
140+ query : {
141+ StudyInstanceUID : studyUID ,
142+ } ,
143+ } ) ;
144+
145+ export const getPACSSeriesListBySeriesUID = ( seriesUID : string ) =>
146+ api < PACSSeries [ ] > ( {
147+ endpoint : "/pacs/series/search/" ,
148+ method : "get" ,
149+ query : {
150+ SeriesInstanceUID : seriesUID ,
151+ } ,
152+ } ) ;
0 commit comments