Skip to content

Commit

Permalink
Remove action field from StainingJsonSchema (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikogabrielsson authored Feb 12, 2024
1 parent 6e7533b commit 4645777
Showing 1 changed file with 33 additions and 35 deletions.
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

0 comments on commit 4645777

Please sign in to comment.