django_dicom.models.values package

Module contents

Definition of DataElementValue subclasses for every type of value representation (VR).

Hint

For more information about value representations see the official DICOM standard (part 05, section 6.2).

Submodules

django_dicom.models.values.age_string module

Definition of the AgeString model.

class django_dicom.models.values.age_string.AgeString(*args, **kwargs)

Bases: django_dicom.models.values.data_element_value.DataElementValue

A Model representing a single AgeString data element value.

raw

Overrides raw to assign a CharField.

value

Overrides value to assign a FloatField.

django_dicom.models.values.application_entity module

Definition of the ApplicationEntity model.

class django_dicom.models.values.application_entity.ApplicationEntity(*args, **kwargs)

Bases: django_dicom.models.values.data_element_value.DataElementValue

A Model representing a single ApplicationEntity data element value.

raw

Overrides raw to assign a CharField.

value

Overrides value to assign a CharField.

django_dicom.models.values.code_string module

Definition of the CodeString model.

class django_dicom.models.values.code_string.CodeString(*args, **kwargs)

Bases: django_dicom.models.values.data_element_value.DataElementValue

A Model representing a single CodeString data element value.

raw

Overrides raw to assign a CharField.

value

Overrides value to assign a CharField.

django_dicom.models.values.csa_header module

Definition of the CsaHeader model.

class django_dicom.models.values.csa_header.CsaHeader(*args, **kwargs)

Bases: django_dicom.models.values.data_element_value.DataElementValue

A Model representing a single Siemens’ CSA header value.

Hint

For more information about CSA headers, see dicom_parser’s CSA headers documentation.

raw

Overrides raw to assign a TextField.

to_html(verbose: bool = False, **kwargs) → str

Returns the HTML representation of this instance.

If the verbose keyword argument is passed as True, returns the entire header as JSON. Otherwise, returns an HTML link to this instance in the admin site.

Parameters:verbose (bool, optional) – Whether to return all of the header information or just a link, by default False
Returns:HTML text containing either JSON encoded header information or a link to the admin site
Return type:str
value

Overrides value to assign a JSONField.

django_dicom.models.values.data_element_value module

Definition of the DataElementValue model.

class django_dicom.models.values.data_element_value.DataElementValue(*args, **kwargs)

Bases: django.db.models.base.Model

A parent Model representing a single value contained by some DataElement instance. If the data element has value multiplicity greater than 1, it will have multiple instances of this model associated with it, each with its own index value.

Creates an HTML tag to link to this instance within the admin site.

Returns:Link to this instance in the admin site
Return type:str
agestring

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

applicationentity

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

codestring

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

csaheader

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

data_element_set

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

date

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

datetime

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

decimalstring

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

floatingpointdouble

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

floatingpointsingle

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

get_raw_peek(size: int = 100) → str

Returns a truncated string of the raw data element’s value (appended with “…” if changed).

Parameters:size (int, optional) – Maximal string length, by default 100
Returns:Truncated string
Return type:str
index

If the value is one of a number of values within a DataElement (a DataElement with a value multiplicity that is greater than 1), this field keeps the index of this value.

integerstring

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

longstring

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

longtext

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

objects = <django_dicom.models.managers.data_element_value.DataElementValueManager object>
otherword

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

personname

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

raw = None

Raw data element value (meant to be overridden by child models).

sequenceofitems

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

shortstring

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

shorttext

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

signedlong

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

signedshort

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

time

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

to_html(**kwargs) → str

Returns the HTML representation of this instance. This method simlpy returns the value, child models should override to provide an appropriate representation.

Returns:HTML representation of this instance
Return type:str
uniqueidentifier

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

unknown

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

unlimitedtext

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

unsignedlong

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

unsignedshort

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

value = None

Interpreted data element value (meant to be overridden by child models).

warnings

If any warnings were raised by dicom_parser, log them in the database.

django_dicom.models.values.date module

Definition of the Date model.

class django_dicom.models.values.date.Date(*args, **kwargs)

Bases: django_dicom.models.values.data_element_value.DataElementValue

A Model representing a single Date data element value.

raw

Overrides raw to assign a CharField.

value

Overrides value to assign a CharField.

django_dicom.models.values.datetime module

Definition of the DateTime model.

class django_dicom.models.values.datetime.DateTime(*args, **kwargs)

Bases: django_dicom.models.values.data_element_value.DataElementValue

A Model representing a single DateTime data element value.

get_next_by_value(*, field=<django.db.models.fields.DateTimeField: value>, is_next=True, **kwargs)
get_previous_by_value(*, field=<django.db.models.fields.DateTimeField: value>, is_next=False, **kwargs)
raw

Overrides raw to assign a CharField.

value

Overrides value to assign a CharField.

django_dicom.models.values.decimal_string module

Definition of the DecimalString model.

class django_dicom.models.values.decimal_string.DecimalString(*args, **kwargs)

Bases: django_dicom.models.values.data_element_value.DataElementValue

A Model representing a single DecimalString data element value.

raw

Overrides raw to assign a CharField.

value

Overrides value to assign a FloatField.

django_dicom.models.values.floating_point_double module

Definition of the FloatingPointDouble model.

class django_dicom.models.values.floating_point_double.FloatingPointDouble(*args, **kwargs)

Bases: django_dicom.models.values.data_element_value.DataElementValue

A Model representing a single FloatingPointDouble data element value.

raw

Overrides raw to assign a CharField.

value

Overrides value to assign a FloatField.

django_dicom.models.values.floating_point_single module

Definition of the FloatingPointSingle model.

class django_dicom.models.values.floating_point_single.FloatingPointSingle(*args, **kwargs)

Bases: django_dicom.models.values.data_element_value.DataElementValue

A Model representing a single FloatingPointSingle data element value.

raw

Overrides raw to assign a CharField.

value

Overrides value to assign a FloatField.

django_dicom.models.values.integer_string module

Definition of the IntegerString model.

class django_dicom.models.values.integer_string.IntegerString(*args, **kwargs)

Bases: django_dicom.models.values.data_element_value.DataElementValue

A Model representing a single IntegerString data element value.

raw

Overrides raw to assign a CharField.

value

Overrides value to assign a IntegerField.

django_dicom.models.values.integer_string.MAX_VALUE = 2147483647

Maximal IntegerString value.

django_dicom.models.values.integer_string.MIN_VALUE = -2147483648

Minimal IntegerString value.

django_dicom.models.values.long_string module

Definition of the LongString model.

class django_dicom.models.values.long_string.LongString(*args, **kwargs)

Bases: django_dicom.models.values.data_element_value.DataElementValue

A Model representing a single LongString data element value.

raw

Overrides raw to assign a CharField.

value

Overrides value to assign a CharField.

django_dicom.models.values.long_text module

Definition of the LongText model.

class django_dicom.models.values.long_text.LongText(*args, **kwargs)

Bases: django_dicom.models.values.data_element_value.DataElementValue

A Model representing a single LongText data element value.

raw

Overrides raw to assign a CharField.

value

Overrides value to assign a TextField.

django_dicom.models.values.other_word module

Definition of the OtherWord model.

class django_dicom.models.values.other_word.OtherWord(*args, **kwargs)

Bases: django_dicom.models.values.data_element_value.DataElementValue

A Model representing a single OtherWord data element value.

raw

Overrides raw to assign a BinaryField.

value

Overrides value to assign a IntegerField.

django_dicom.models.values.person_name module

Definition of the PersonName model.

class django_dicom.models.values.person_name.PersonName(*args, **kwargs)

Bases: django_dicom.models.values.data_element_value.DataElementValue

A Model representing a single PersonName data element value.

raw

Overrides raw to assign a BinaryField.

to_html(**kwargs) → str

Returns the HTML representation of this instance.

Returns:HTML representation of this instance
Return type:str
value

Overrides value to assign a JSONField.

django_dicom.models.values.sequence_of_items module

Definition of the SequenceOfItems model.

class django_dicom.models.values.sequence_of_items.SequenceOfItems(*args, **kwargs)

Bases: django_dicom.models.values.data_element_value.DataElementValue

A django.db.models.Model representing the value stored in a single DataElement with a value representation (VR) of SQ.

Sequence of Items data elements are arrays of nested headers, and therefore this model does not override the raw and value field definitions (and so they remain None).

header_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

objects = <django_dicom.models.managers.values.sequence_of_items.SequenceOfItemsManager object>
to_html(verbose: bool = False, **kwargs) → str

Returns the HTML representation of this instance. This method simlpy returns the value, child models should override to provide an appropriate representation.

Returns:HTML representation of this instance
Return type:str

django_dicom.models.values.short_string module

Definition of the ShortString model.

class django_dicom.models.values.short_string.ShortString(*args, **kwargs)

Bases: django_dicom.models.values.data_element_value.DataElementValue

A Model representing a single ShortString data element value.

raw

Overrides raw to assign a CharField.

value

Overrides value to assign a Charield.

django_dicom.models.values.short_text module

Definition of the ShortString model.

class django_dicom.models.values.short_text.ShortText(*args, **kwargs)

Bases: django_dicom.models.values.data_element_value.DataElementValue

A Model representing a single ShortText data element value.

raw

Overrides raw to assign a CharField.

value

Overrides value to assign a Charield.

django_dicom.models.values.signed_long module

Definition of the SignedLong model.

django_dicom.models.values.signed_long.MAX_VALUE = 2147483647

Maximal SignedLong value.

django_dicom.models.values.signed_long.MIN_VALUE = -2147483648

Minimal SignedLong value.

class django_dicom.models.values.signed_long.SignedLong(*args, **kwargs)

Bases: django_dicom.models.values.data_element_value.DataElementValue

A Model representing a single SignedLong data element value.

raw

Overrides raw to assign an IntegerField.

value

Overrides value to assign an IntegerField.

django_dicom.models.values.signed_short module

Definition of the SignedShort model.

django_dicom.models.values.signed_short.MAX_VALUE = 32767

Maximal SignedShort value.

django_dicom.models.values.signed_short.MIN_VALUE = -32768

Minimal SignedShort value.

class django_dicom.models.values.signed_short.SignedShort(*args, **kwargs)

Bases: django_dicom.models.values.data_element_value.DataElementValue

A Model representing a single SignedShort data element value.

raw

Overrides raw to assign an IntegerField.

value

Overrides value to assign an IntegerField.

django_dicom.models.values.time module

Definition of the Time model.

class django_dicom.models.values.time.Time(*args, **kwargs)

Bases: django_dicom.models.values.data_element_value.DataElementValue

A Model representing a single Time data element value.

raw

Overrides raw to assign a CharField.

to_html(**kwargs) → str

Returns the HTML representation of this instance.

Returns:HTML representation of this instance
Return type:str
value

Overrides value to assign a TimeField.

django_dicom.models.values.unique_identifier module

Definition of the UniqueIdentifier model.

class django_dicom.models.values.unique_identifier.UniqueIdentifier(*args, **kwargs)

Bases: django_dicom.models.values.data_element_value.DataElementValue

A Model representing a single UniqueIdentifier data element value.

raw

Overrides raw to assign a CharField.

value

Overrides value to assign a CharField.

django_dicom.models.values.unknown module

Definition of the Unknown model.

class django_dicom.models.values.unknown.Unknown(*args, **kwargs)

Bases: django_dicom.models.values.data_element_value.DataElementValue

A Model representing a single Unknown data element value.

raw

Overrides raw to assign a TextField.

value

Overrides value to assign a TextField.

django_dicom.models.values.unlimited_text module

Definition of the UnlimitedText model.

class django_dicom.models.values.unlimited_text.UnlimitedText(*args, **kwargs)

Bases: django_dicom.models.values.data_element_value.DataElementValue

A Model representing a single Unknown data element value.

raw

Overrides raw to assign a TextField.

value

Overrides value to assign a TextField.

django_dicom.models.values.unsigned_long module

Definition of the UnsignedLong model.

django_dicom.models.values.unsigned_long.MAX_VALUE = 4294967296

Maximal UnsignedLong value.

class django_dicom.models.values.unsigned_long.UnsignedLong(*args, **kwargs)

Bases: django_dicom.models.values.data_element_value.DataElementValue

A Model representing a single UnsignedLong data element value.

raw

Overrides raw to assign a PositiveIntegerField.

value

Overrides value to assign a PositiveIntegerField.

django_dicom.models.values.unsigned_short module

Definition of the UnsignedShort model.

django_dicom.models.values.unsigned_short.MAX_VALUE = 65536

Maximal UnsignedShort value.

class django_dicom.models.values.unsigned_short.UnsignedShort(*args, **kwargs)

Bases: django_dicom.models.values.data_element_value.DataElementValue

A Model representing a single UnsignedShort data element value.

raw

Overrides raw to assign a PositiveIntegerField.

value

Overrides value to assign a PositiveIntegerField.

django_dicom.models.values.vr_to_model module

A utility module used to get the appropriate DataElementValue subclass (“ValueModel”) for a given data element.

django_dicom.models.values.vr_to_model.TAG_TO_MODEL = {('0029', '1010'): 'CsaHeader', ('0029', '1020'): 'CsaHeader'}

Special cases might require a custom DataElementValue subclass based on the element’s tag rather than its VR.

django_dicom.models.values.vr_to_model.VR_TO_MODEL = {<ValueRepresentation.AE: 'Application Entity'>: 'ApplicationEntity', <ValueRepresentation.AS: 'Age String'>: 'AgeString', <ValueRepresentation.CS: 'Code String'>: 'CodeString', <ValueRepresentation.DA: 'Date'>: 'Date', <ValueRepresentation.DT: 'Date Time'>: 'DateTime', <ValueRepresentation.DS: 'Decimal String'>: 'DecimalString', <ValueRepresentation.FD: 'Floating Point Double'>: 'FloatingPointDouble', <ValueRepresentation.FL: 'Floating Point Single'>: 'FloatingPointSingle', <ValueRepresentation.IS: 'Integer String'>: 'IntegerString', <ValueRepresentation.LO: 'Long String'>: 'LongString', <ValueRepresentation.LT: 'Long Text'>: 'LongText', <ValueRepresentation.OW: 'Other Word'>: 'OtherWord', <ValueRepresentation.PN: 'Person Name'>: 'PersonName', <ValueRepresentation.SH: 'Short String'>: 'ShortString', <ValueRepresentation.SL: 'Signed Long'>: 'SignedLong', <ValueRepresentation.SQ: 'Sequence of Items'>: 'SequenceOfItems', <ValueRepresentation.SS: 'Signed Short'>: 'SignedShort', <ValueRepresentation.ST: 'Short Text'>: 'ShortText', <ValueRepresentation.TM: 'Time'>: 'Time', <ValueRepresentation.UI: 'Unique Identifer'>: 'UniqueIdentifier', <ValueRepresentation.UL: 'Unsigned Long'>: 'UnsignedLong', <ValueRepresentation.UN: 'Unknown'>: 'Unknown', <ValueRepresentation.US: 'Unsigned Short'>: 'UnsignedShort', <ValueRepresentation.UT: 'Unlimited Text'>: 'UnlimitedText'}

Dictionary with ValueRepresentation items as keys and strings representing the appropriate DataElementValue subclass as values.

django_dicom.models.values.vr_to_model.get_value_model(data_element: dicom_parser.data_element.DataElement)

Returns the DataElementValue subclass matching the given data element.

Parameters:data_element (dicom_parser.data_element.DataElement) – Object representing a single data element in memory
Returns:Value model
Return type:DataElementValue
django_dicom.models.values.vr_to_model.get_value_model_name(data_element: dicom_parser.data_element.DataElement) → str

Returns the name of the DataElementValue subclass matching the given data element.

Parameters:data_element (dicom_parser.data_element.DataElement) – Object representing a single data element in memory
Returns:Name of the appropriate “ValueModel”
Return type:str