def __init__( self, anatomic_location: Union[CodedConcept, Code], laterality: Optional[Union[CodedConcept, Code]] = None, topographical_modifier: Optional[Union[CodedConcept, Code]] = None ) -> None: """ Parameters ---------- anatomic_location: Union[highdicom.sr.CodedConcept, pydicom.sr.coding.Code] coded anatomic location (region or structure) laterality: Union[highdicom.sr.CodedConcept, pydicom.sr.coding.Code], optional coded laterality (see :dcm:`CID 244 <part16/sect_CID_244.html>` "Laterality" for options) topographical_modifier: Union[highdicom.sr.CodedConcept, pydicom.sr.coding.Code], optional coded modifier of anatomic location """ # noqa super().__init__( name=CodedConcept( value='363698007', meaning='Finding Site', scheme_designator='SCT' ), value=anatomic_location, relationship_type=RelationshipTypeValues.HAS_CONCEPT_MOD ) if laterality is not None or topographical_modifier is not None: self.ContentSequence = ContentSequence() if laterality is not None: laterality_item = CodeContentItem( name=CodedConcept( value='272741003', meaning='Laterality', scheme_designator='SCT' ), value=laterality, relationship_type=RelationshipTypeValues.HAS_CONCEPT_MOD ) self.ContentSequence.append(laterality_item) if topographical_modifier is not None: modifier_item = CodeContentItem( name=CodedConcept( value='106233006', meaning='Topographical Modifier', scheme_designator='SCT' ), value=topographical_modifier, relationship_type=RelationshipTypeValues.HAS_CONCEPT_MOD ) self.ContentSequence.append(modifier_item)
def __init__( self, method: Union[Code, CodedConcept], parent_specimen_id: str, parent_specimen_type: Union[Code, CodedConcept], issuer_of_parent_specimen_id: Optional[IssuerOfIdentifier] = None ): """ Parameters ---------- method: Union[pydicom.sr.coding.Code, highdicom.sr.coding.CodedConcept] Method used to sample the examined specimen from a parent specimen parent_specimen_id: str Identifier of the parent specimen parent_specimen_type: Union[pydicom.sr.coding.Code, highdicom.sr.coding.CodedConcept] Type of the parent specimen issuer_of_parent_specimen_id: highdicom.content.IssuerOfIdentifier, optional Issuer who created the parent specimen """ # noqa super().__init__() # CID 8110 method_item = CodeContentItem( name=codes.DCM.SamplingMethod, value=method ) self.append(method_item) parent_specimen_identitier_item = TextContentItem( name=codes.DCM.ParentSpecimenIdentifier, value=parent_specimen_id ) self.append(parent_specimen_identitier_item) if issuer_of_parent_specimen_id is not None: try: entity_id = issuer_of_parent_specimen_id.UniversalEntityID except AttributeError: entity_id = issuer_of_parent_specimen_id.LocalNamespaceEntityID issuer_of_parent_specimen_identitier_item = TextContentItem( name=codes.DCM.IssuerOfParentSpecimenIdentifier, value=entity_id ) self.append(issuer_of_parent_specimen_identitier_item) # CID 8103 parent_specimen_type_item = CodeContentItem( name=codes.DCM.ParentSpecimenType, value=parent_specimen_type ) self.append(parent_specimen_type_item)
def __init__( self, value: Optional[Union[int, float]], unit: Optional[Union[CodedConcept, Code]] = None, event_type: Optional[Union[CodedConcept, Code]] = None) -> None: """ Parameters ---------- value: Union[int, float], optional offset in time from a particular event of significance unit: Union[highdicom.sr.coding.CodedConcept, pydicom.sr.coding.Code], optional unit of time, e.g., "Days" or "Seconds" event_type: Union[highdicom.sr.coding.CodedConcept, pydicom.sr.coding.Code], optional type of event to which offset is relative, e.g., "Baseline" or "Enrollment" """ # noqa super().__init__( name=CodedConcept( value='128740', meaning='Longitudinal Temporal Offset from Event', scheme_designator='DCM'), value=value, unit=unit, relationship_type=RelationshipTypeValues.HAS_OBS_CONTEXT) event_type_item = CodeContentItem( name=CodedConcept(value='128741', meaning='Longitudinal Temporal Event Type', scheme_designator='DCM'), value=event_type, relationship_type=RelationshipTypeValues.HAS_CONCEPT_MOD) self.ContentSequence = ContentSequence([event_type_item])
def test_code_item_construction(self): name = codes.SCT.FindingSite value = codes.SCT.Abdomen i = CodeContentItem(name=name, value=value) assert i.ValueType == 'CODE' assert i.ConceptNameCodeSequence[0] == name assert i.ConceptCodeSequence[0] == value with pytest.raises(AttributeError): assert i.RelationshipType
def __init__(self, procedure: Union[Code, CodedConcept]): """ Parameters ---------- procedure: Union[pydicom.sr.coding.Code, highdicom.sr.coding.CodedConcept] Procedure used to collect the examined specimen """ # noqa super().__init__() item = CodeContentItem(name=codes.SCT.SpecimenCollection, value=procedure) self.append(item)
def __init__(self, substances: Sequence[Union[Code, CodedConcept]]): """ Parameters ---------- substances: Sequence[Union[pydicom.sr.coding.Code, highdicom.sr.coding.CodedConcept]] Substances used to stain examined specimen(s) """ # noqa super().__init__() # CID 8112 for s in substances: item = CodeContentItem(name=codes.SCT.UsingSubstance, value=s) self.append(item)
def __init__(self, specimen_id: str, processing_type: Union[Code, CodedConcept], processing_procedure: Union[SpecimenCollection, SpecimenSampling, SpecimenStaining, ], processing_description: Optional[Union[str, Code, CodedConcept]] = None, processing_datetime: Optional[datetime.datetime] = None, issuer_of_specimen_id: Optional[IssuerOfIdentifier] = None, fixative: Optional[Union[Code, CodedConcept]] = None, embedding_medium: Optional[Union[Code, CodedConcept]] = None): """ Parameters ---------- specimen_id: str Identifier of the processed specimen processing_type: Union[pydicom.sr.coding.Code, highdicom.sr.coding.CodedConcept] Type of processing processing_procedure: Union[highdicom.content.SpecimenCollection, highdicom.content.SpecimenSampling, highdicom.content.SpecimenStaining] Procedure used during processing processing_datetime: datetime.datetime, optional Datetime of processing processing_description: Union[str, pydicom.sr.coding.Code, highdicom.sr.coding.CodedConcept], optional Description of processing issuer_of_specimen_id: highdicom.content.IssuerOfIdentifier, optional fixative: Union[pydicom.sr.coding.Code, highdicom.sr.coding.CodedConcept], optional Fixative used during processing embedding_medium: Union[pydicom.sr.coding.Code, highdicom.sr.coding.CodedConcept], optional Embedding medium used during processing """ # noqa super().__init__() specimen_identifier_item = TextContentItem( name=codes.DCM.SpecimenIdentifier, value=specimen_id) self.append(specimen_identifier_item) if issuer_of_specimen_id is not None: self.append(issuer_of_specimen_id) # CID 8111 processing_type_item = CodeContentItem(name=codes.DCM.ProcessingType, value=processing_type) self.append(processing_type_item) if processing_datetime is not None: processing_datetime_item = DateTimeContentItem( name=codes.DCM.DateTimeOfProcessing, value=processing_datetime) self.append(processing_datetime_item) if processing_description is not None: if isinstance(processing_description, str): processing_description_item = TextContentItem( name=codes.DCM.ProcessingStepDescription, value=processing_description) else: processing_description_item = CodeContentItem( name=codes.DCM.ProcessingStepDescription, value=processing_description) self.append(processing_description_item) accepted_procedure_types = ( SpecimenCollection, SpecimenSampling, SpecimenStaining, ) if not isinstance(processing_procedure, accepted_procedure_types): raise TypeError('Unknown procedure of specimen preparation step.') self.extend(processing_procedure) if fixative is not None: tissue_fixative_item = CodeContentItem( name=codes.SCT.TissueFixative, value=fixative) self.append(tissue_fixative_item) if embedding_medium is not None: embedding_medium_item = CodeContentItem( name=codes.SCT.EmbeddingMedium, value=embedding_medium) self.append(embedding_medium_item)