medicare_beneficiaries.cwl

  1#!/usr/bin/env cwl-runner
  2### Medicare Beneficiaries data in-database processing pipeline
  3#  Copyright (c) 2022. Harvard University
  4#
  5#  Developed by Research Software Engineering,
  6#  Faculty of Arts and Sciences, Research Computing (FAS RC)
  7#  Author: Michael A Bouzinier
  8#
  9#  Licensed under the Apache License, Version 2.0 (the "License");
 10#  you may not use this file except in compliance with the License.
 11#  You may obtain a copy of the License at
 12#
 13#         http://www.apache.org/licenses/LICENSE-2.0
 14#
 15#  Unless required by applicable law or agreed to in writing, software
 16#  distributed under the License is distributed on an "AS IS" BASIS,
 17#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 18#  See the License for the specific language governing permissions and
 19#  limitations under the License.
 20#
 21
 22cwlVersion: v1.2
 23class: Workflow
 24
 25requirements:
 26  SubworkflowFeatureRequirement: {}
 27  StepInputExpressionRequirement: {}
 28  InlineJavascriptRequirement: {}
 29  MultipleInputFeatureRequirement: {}
 30
 31doc: |
 32  This workflow processes raw Medicare beneficiaries summary data.
 33  The assumed initial state
 34  is that raw data is already in the database. We assume that the data
 35  for each year is in a separate table. The first step
 36  combines these disparate tables into a single view, creating uniform
 37  columns.
 38
 39inputs:
 40  database:
 41    type: File
 42    doc: Path to database connection file, usually database.ini
 43  connection_name:
 44    type: string
 45    doc: The name of the section in the database.ini file
 46  depends_on:
 47    type: File?
 48    doc: a special field used to enforce dependencies and execution order
 49
 50steps:
 51  create_d:
 52    run: medicare_combine_tables.cwl
 53    doc: >
 54      Combines patient summaries from disparate summary tables
 55      (one table per year) into a single view
 56    in:
 57      database: database
 58      connection_name: connection_name
 59      table:
 60        valueFrom: "mbsf_d"
 61    out:  [ log, errors ]
 62
 63  index_d:
 64    run: index.cwl
 65    doc: Build indices
 66    in:
 67      depends_on: create_d/log
 68      domain:
 69        valueFrom: "medicare"
 70      table:
 71        valueFrom: "mbsf_d"
 72      database: database
 73      connection_name: connection_name
 74
 75    out: [ log, errors ]
 76
 77  vacuum_d:
 78    run: vacuum.cwl
 79    doc: Vacuum the view
 80    in:
 81      depends_on: index_d/log
 82      domain:
 83        valueFrom: "medicare"
 84      table:
 85        valueFrom: "mbsf_d"
 86      database: database
 87      connection_name: connection_name
 88    out: [ log, errors ]
 89
 90  create_ps:
 91    run: medicare_combine_tables.cwl
 92    doc: >
 93      Combines patient summaries from disparate summary tables
 94      (one table per year) into a single view
 95    in:
 96      database: database
 97      connection_name: connection_name
 98      table:
 99        valueFrom: "ps"
100    out:  [ log, errors ]
101
102  create__ps_view:
103    run: matview.cwl
104    doc: Create _ps materialized view from ps
105    in:
106      table:
107        valueFrom: "_ps"
108      database: database
109      connection_name: connection_name
110      domain:
111        valueFrom: "medicare"
112      depends_on: create_ps/log
113    out:
114      - create_log
115      - index_log
116      - vacuum_log
117      - create_err
118      - index_err
119      - vacuum_err
120
121  create_bene_view:
122    run: create.cwl
123    doc: Creates preliminary beneficiaries view
124    in:
125      table:
126        valueFrom: "_beneficiaries"
127      database: database
128      connection_name: connection_name
129      domain:
130        valueFrom: "medicare"
131      depends_on: create__ps_view/vacuum_log
132    out: [ log, errors ]
133
134  create_bene_table:
135    run: matview.cwl
136    doc: Creates `Beneficiaries` Table from the view
137    in:
138      depends_on: create_bene_view/log
139      table:
140        valueFrom: "beneficiaries"
141      domain:
142         valueFrom: "medicare"
143      database: database
144      connection_name: connection_name
145    out:
146      - create_log
147      - index_log
148      - vacuum_log
149      - create_err
150      - index_err
151      - vacuum_err
152
153  create_enrlm_view:
154    run: create.cwl
155    doc: Creates preliminary _enrollments view
156    in:
157      table:
158        valueFrom: "_enrollments"
159      database: database
160      connection_name: connection_name
161      domain:
162        valueFrom: "medicare"
163      depends_on:
164      - create__ps_view/vacuum_log
165      - create_bene_table/vacuum_log
166      - index_d/log
167    out: [ log, errors ]
168
169  create_enrlm_table:
170    run: matview.cwl
171    doc: Creates `Enrollments` Table from the view
172    in:
173      depends_on: create_enrlm_view/log
174      table:
175        valueFrom: "enrollments"
176      domain:
177         valueFrom: "medicare"
178      database: database
179      connection_name: connection_name
180    out:
181      - create_log
182      - index_log
183      - vacuum_log
184      - create_err
185      - index_err
186      - vacuum_err
187
188outputs:
189  d_create_log:
190    type: File
191    outputSource: create_d/log
192  d_index_log:
193    type: File
194    outputSource: index_d/log
195  d_vacuum_log:
196    type: File
197    outputSource: vacuum_d/log
198
199  d_create_err:
200    type: File
201    outputSource: create_d/errors
202  d_index_err:
203    type: File
204    outputSource: index_d/errors
205  d_vacuum_err:
206    type: File
207    outputSource: vacuum_d/errors
208
209  ps_create_log:
210    type: File
211    outputSource: create_ps/log
212  ps_create_err:
213    type: File
214    outputSource: create_ps/errors
215  ps2_create_log:
216    type: File
217    outputSource: create__ps_view/create_log
218  ps2_create_err:
219    type: File
220    outputSource: create__ps_view/create_err
221  ps2_index_log:
222    type: File
223    outputSource: create__ps_view/index_log
224  ps2_vacuum_log:
225    type: File
226    outputSource: create__ps_view/vacuum_log
227  ps2_index_err:
228    type: File
229    outputSource: create__ps_view/index_err
230  ps2_vacuum_err:
231    type: File
232    outputSource: create__ps_view/vacuum_err
233
234
235  # bene_view
236  bene_view_log:
237    type: File
238    outputSource: create_bene_view/log
239  bene_view_err:
240    type: File
241    outputSource: create_bene_view/errors
242  # bene_table  
243  bene_table_create_log:
244    type: File
245    outputSource: create_bene_table/create_log
246  bene_table_index_log:
247    type: File
248    outputSource: create_bene_table/index_log
249  bene_table_vacuum_log:
250    type: File
251    outputSource: create_bene_table/vacuum_log
252  bene_table_create_err:
253    type: File
254    outputSource: create_bene_table/create_err
255  bene_table_index_err:
256    type: File
257    outputSource: create_bene_table/index_err
258  bene_table_vacuum_err:
259    type: File
260    outputSource: create_bene_table/vacuum_err
261
262  # enrollments view
263  enrlm_view_log:
264    type: File
265    outputSource: create_enrlm_view/log
266  enrlm_view_err:
267    type: File
268    outputSource: create_enrlm_view/errors
269
270  # enrollments table
271  enrlm_table_create_log:
272    type: File
273    outputSource: create_enrlm_table/create_log
274  enrlm_table_index_log:
275    type: File
276    outputSource: create_enrlm_table/index_log
277  enrlm_table_vacuum_log:
278    type: File
279    outputSource: create_enrlm_table/vacuum_log
280  enrlm_table_create_err:
281    type: File
282    outputSource: create_enrlm_table/create_err
283  enrlm_table_index_err:
284    type: File
285    outputSource: create_enrlm_table/index_err
286  enrlm_table_vacuum_err:
287    type: File
288    outputSource: create_enrlm_table/vacuum_err
289
290