Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove action field from StainingJsonSchema #151

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 33 additions & 35 deletions wsidicom/metadata/schema/json/sample/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,44 +33,44 @@
SpecimenSamplingProcedureCode,
SpecimenStainsCode,
)
from wsidicom.metadata.schema.common import DataclassLoadingSchema, LoadingSchema
from wsidicom.metadata.schema.json.fields import (
CodeJsonField,
JsonFieldFactory,
MeasurementJsonField,
SpecimenIdentifierJsonField,
UidJsonField,
)
from wsidicom.metadata.schema.json.sample.model import (
SpecimenJsonModel,
PreparationAction,
SampleJsonModel,
SamplingConstraintJsonModel,
SamplingJsonModel,
SlideSampleJsonModel,
BaseSpecimenJsonModel,
)
from wsidicom.metadata.schema.json.sample.parser import SpecimenJsonParser
from wsidicom.metadata.sample import (
BaseSpecimen,
Collection,
Embedding,
Specimen,
Fixation,
PreparationStep,
Processing,
Receiving,
Sample,
SampledSpecimen,
SampleLocalization,
Sampling,
SamplingLocation,
SlideSample,
BaseSpecimen,
Specimen,
SpecimenIdentifier,
SampleLocalization,
Staining,
Storage,
UnknownSampling,
)
from wsidicom.metadata.schema.common import DataclassLoadingSchema, LoadingSchema
from wsidicom.metadata.schema.json.fields import (
CodeJsonField,
JsonFieldFactory,
MeasurementJsonField,
SpecimenIdentifierJsonField,
UidJsonField,
)
from wsidicom.metadata.schema.json.sample.model import (
BaseSpecimenJsonModel,
PreparationAction,
SampleJsonModel,
SamplingConstraintJsonModel,
SamplingJsonModel,
SlideSampleJsonModel,
SpecimenJsonModel,
)
from wsidicom.metadata.schema.json.sample.parser import SpecimenJsonParser


class SamplingLocationJsonSchema(LoadingSchema[SamplingLocation]):
Expand Down Expand Up @@ -173,19 +173,6 @@ def load_type(self) -> Type[Fixation]:
return Fixation


class StainingJsonSchema(DataclassLoadingSchema[Staining]):
action = fields.Constant(PreparationAction.STAINING.value, dump_only=True)
substances = fields.List(
JsonFieldFactory.concept_code(SpecimenStainsCode)(), allow_none=True
)
date_time = fields.DateTime(allow_none=True)
description = fields.String(allow_none=True)

@property
def load_type(self) -> Type[Staining]:
return Staining


class ReceivingJsonSchema(DataclassLoadingSchema[Receiving]):
action = fields.Constant(PreparationAction.RECEIVING.value, dump_only=True)
date_time = fields.DateTime(allow_none=True)
Expand Down Expand Up @@ -228,7 +215,6 @@ class PreparationStepJsonSchema(Schema):
PreparationAction.PROCESSING: ProcessingJsonSchema,
PreparationAction.EMBEDDING: EmbeddingJsonSchema,
PreparationAction.FIXATION: FixationJsonSchema,
PreparationAction.STAINING: StainingJsonSchema,
PreparationAction.RECEIVING: ReceivingJsonSchema,
PreparationAction.STORAGE: StorageJsonSchema,
}
Expand Down Expand Up @@ -270,6 +256,18 @@ def _subschema_dump(self, step: PreparationStep):
return schema().dump(step, many=False)


class StainingJsonSchema(DataclassLoadingSchema[Staining]):
substances = fields.List(
JsonFieldFactory.concept_code(SpecimenStainsCode)(), allow_none=True
)
date_time = fields.DateTime(allow_none=True)
description = fields.String(allow_none=True)

@property
def load_type(self) -> Type[Staining]:
return Staining


class SpecimenJsonSchema(LoadingSchema[Specimen]):
"""Schema for extracted specimen that has not been sampled from other specimen."""

Expand Down
Loading