diff --git a/wsidicom/metadata/schema/json/sample/schema.py b/wsidicom/metadata/schema/json/sample/schema.py index f65a15e4..75bc9fab 100644 --- a/wsidicom/metadata/schema/json/sample/schema.py +++ b/wsidicom/metadata/schema/json/sample/schema.py @@ -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]): @@ -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) @@ -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, } @@ -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."""