|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +ReproSchema Python library and CLI for working with ReproSchema format - a standardized way to represent assessments, questionnaires, and protocols used in research. The library provides validation, conversion utilities, and integrations with REDCap and FHIR. |
| 8 | + |
| 9 | +## Key Commands |
| 10 | + |
| 11 | +### Development Setup |
| 12 | +```bash |
| 13 | +# Install in development mode |
| 14 | +pip install -e . |
| 15 | + |
| 16 | +# Install with all development dependencies |
| 17 | +pip install -e ".[dev]" |
| 18 | + |
| 19 | +# Run pre-commit hooks |
| 20 | +pre-commit install |
| 21 | +pre-commit run --all-files |
| 22 | +``` |
| 23 | + |
| 24 | +### Testing |
| 25 | +```bash |
| 26 | +# Run tests with coverage |
| 27 | +pytest --cov=reproschema |
| 28 | + |
| 29 | +# Run specific test file |
| 30 | +pytest reproschema/tests/test_validate.py |
| 31 | + |
| 32 | +# Run tests in parallel |
| 33 | +pytest -n auto |
| 34 | +``` |
| 35 | + |
| 36 | +### Linting and Formatting |
| 37 | +```bash |
| 38 | +# Format code with black |
| 39 | +black reproschema/ |
| 40 | + |
| 41 | +# Run flake8 linter |
| 42 | +flake8 reproschema/ |
| 43 | + |
| 44 | +# Sort imports |
| 45 | +isort reproschema/ |
| 46 | + |
| 47 | +# Check spelling |
| 48 | +codespell |
| 49 | +``` |
| 50 | + |
| 51 | +## Architecture |
| 52 | + |
| 53 | +### Core Modules |
| 54 | + |
| 55 | +- **reproschema/cli.py**: Main CLI entry point using Click framework. Provides commands for validation, conversion, migration. |
| 56 | +- **reproschema/models/model.py**: Pydantic models auto-generated from LinkML schema. DO NOT modify directly - changes should be made in ReproNim/reproschema repository. |
| 57 | +- **reproschema/validate.py**: Schema validation using PyShacl |
| 58 | +- **reproschema/redcap2reproschema.py**: Convert REDCap CSV to ReproSchema format |
| 59 | +- **reproschema/reproschema2redcap.py**: Convert ReproSchema to REDCap CSV format |
| 60 | +- **reproschema/reproschema2fhir.py**: Convert ReproSchema to FHIR Questionnaire resources |
| 61 | +- **reproschema/output2redcap.py**: Process reproschema-ui output into REDCap CSV |
| 62 | + |
| 63 | +### Conversion Workflows |
| 64 | + |
| 65 | +1. **REDCap → ReproSchema**: Requires CSV data dictionary + YAML config file |
| 66 | +2. **ReproSchema → REDCap**: Takes protocol directory, outputs CSV |
| 67 | +3. **ReproSchema → FHIR**: Converts activities/items to FHIR Questionnaire |
| 68 | +4. **UI Output → REDCap**: Processes survey responses to REDCap format |
| 69 | + |
| 70 | +## CLI Commands |
| 71 | + |
| 72 | +- `reproschema validate <path>` - Validate ReproSchema format |
| 73 | +- `reproschema redcap2reproschema <csv> <yaml>` - Convert REDCap to ReproSchema |
| 74 | +- `reproschema reproschema2redcap <input_dir> <output_csv>` - Convert ReproSchema to REDCap |
| 75 | +- `reproschema reproschema2fhir <input_dir> <output_dir>` - Convert to FHIR |
| 76 | +- `reproschema output2redcap <input_dir> <output_dir>` - Process UI output |
| 77 | +- `reproschema migrate <path>` - Migrate to new schema version |
| 78 | +- `reproschema convert` - Convert between formats (jsonld, n-triples, turtle) |
| 79 | + |
| 80 | +## Important Notes |
| 81 | + |
| 82 | +- Python 3.10+ required |
| 83 | +- The Pydantic models in `reproschema/models/model.py` are auto-generated - DO NOT edit directly |
| 84 | +- All schema changes must be made in the LinkML source at ReproNim/reproschema repository |
| 85 | +- Uses pre-commit for code quality - commits may require running twice |
| 86 | +- Line length limit: 79 characters (enforced by black) |
0 commit comments