model¶
model Package¶
The qiprofile REST data model.
The model field choices are listed in the preferred display order, most common to least common.
The data capture client has the following responsibility:
- Validate the data upon input as determined by the model validation documentation.
- Resolve conflicts between data capture and the model, e.g. the default value or validation.
admin¶
The qiprofile administrative Mongodb data model.
-
class
qirest_client.model.admin.User(*args, **values)¶ Bases:
mongoengine.document.DocumentThe application user.
Initialise a document or embedded document
Parameters: - __auto_convert – Try and will cast python objects to Object types
- values – A dictionary of values for the document
clinical¶
The qiprofile clinical Mongodb data model.
-
class
qirest_client.model.clinical.Agent(*args, **kwargs)¶ Bases:
mongoengine.document.EmbeddedDocumentA treatment agent, e.g. drug or radiation.
-
class
qirest_client.model.clinical.Biopsy(*args, **kwargs)¶ Bases:
qirest_client.model.common.EncounterNon-therapeutic tissue extraction resulting in a pathology report.
-
class
qirest_client.model.clinical.BreastGeneticExpression(*args, **kwargs)¶ Bases:
qirest_client.model.common.OutcomeThe breast patient genetic expression results.
-
class
qirest_client.model.clinical.BreastNormalizedAssay(*args, **kwargs)¶ Bases:
mongoengine.document.EmbeddedDocumentThe Breast genomics panel normalized to reference genes.
-
class
qirest_client.model.clinical.BreastNormalizedAssayField(min_value=None, max_value=None, **kwargs)¶ Bases:
mongoengine.fields.IntFieldThe normalized Breast genomics result in the inclusive range [0, 15].
-
class
qirest_client.model.clinical.BreastPathology(*args, **kwargs)¶ Bases:
qirest_client.model.clinical.TumorPathologyThe breast patient pathology summary.
-
rcb_class(rcb_index)¶ Returns the RCB class per the cut-offs defined in JCO 25:28 4414-4422.
Parameters: rcb_index – the rcb_index()value
-
rcb_index()¶ Returns the RCB index per JCO 25:28 4414-4422.
-
-
class
qirest_client.model.clinical.BreastSurgery(*args, **kwargs)¶ Bases:
qirest_client.model.clinical.SurgeryBreast tumor extraction.
-
class
qirest_client.model.clinical.Dosage(*args, **kwargs)¶ Bases:
mongoengine.document.EmbeddedDocumentThe agent dosage.
-
class
qirest_client.model.clinical.Evaluation(*args, **kwargs)¶ Bases:
mongoengine.document.EmbeddedDocumentThe patient evaluation holds outcomes.
-
class
qirest_client.model.clinical.FNCLCCGrade(*args, **kwargs)¶ Bases:
qirest_client.model.clinical.GradeThe FNCLCC sarcoma tumor grade.
-
class
qirest_client.model.clinical.Grade(*args, **kwargs)¶ Bases:
mongoengine.document.EmbeddedDocumentThe abstract tumor grade superclass, specialized for each tumor type.
-
class
qirest_client.model.clinical.HormoneReceptorStatus(*args, **kwargs)¶ Bases:
qirest_client.model.common.OutcomeThe patient estrogen/progesterone hormone receptor status.
-
class
qirest_client.model.clinical.ModifiedBloomRichardsonGrade(*args, **kwargs)¶ Bases:
qirest_client.model.clinical.GradeThe Modified Bloom Richardson (a.k.a. Nottingham) breast tumor grade.
-
class
qirest_client.model.clinical.NecrosisPercent(*args, **kwargs)¶ Bases:
qirest_client.model.common.OutcomeThe necrosis percent value or range.
-
class
qirest_client.model.clinical.NecrosisPercentRange(*args, **kwargs)¶ Bases:
qirest_client.model.clinical.NecrosisPercentThe necrosis percent range.
Note: it is recommended, although not required, that the percent range is a decile range, e.g. [20-30]. Note: A range which spans 50%, e.g. [40-60], results in a necrosis_percent_as_score()ValidationError.-
class
Bound(*args, **kwargs)¶ Bases:
mongoengine.document.EmbeddedDocumentNecrosis percent upper or lower bound abstract class. The subclass is responsible for adding the
inclusivefield.
-
class
NecrosisPercentRange.LowerBound(*args, **kwargs)¶ Bases:
qirest_client.model.clinical.BoundNecrosis percent lower bound.
-
class
NecrosisPercentRange.UpperBound(*args, **kwargs)¶ Bases:
qirest_client.model.clinical.BoundNecrosis percent upper bound.
-
class
-
class
qirest_client.model.clinical.NecrosisPercentValue(*args, **kwargs)¶ Bases:
qirest_client.model.clinical.NecrosisPercentThe necrosis percent absolute value.
-
class
qirest_client.model.clinical.PathologyReport(*args, **kwargs)¶ Bases:
qirest_client.model.clinical.EvaluationThe patient pathology report findings.
-
class
qirest_client.model.clinical.ResidualCancerBurden(*args, **kwargs)¶ Bases:
mongoengine.document.EmbeddedDocumentThe residual cancer burden after neodjuvant treatment.
-
class
qirest_client.model.clinical.SarcomaPathology(*args, **kwargs)¶ Bases:
qirest_client.model.clinical.TumorPathologyThe sarcoma patient pathology summary.
-
class
qirest_client.model.clinical.Surgery(*args, **kwargs)¶ Bases:
qirest_client.model.common.EncounterTherapeutic tissue extraction which usually results in a pathology report.
-
class
qirest_client.model.clinical.TNM(*args, **kwargs)¶ Bases:
qirest_client.model.common.OutcomeThe TNM tumor staging. The TNM fields are as follows:
- size - primary tumor size (T)
- lymph_status - regional lymph nodes (N)
- metastasis - distant metastasis (M)
- grade - tumor grade (G)
- serum_tumor_markers (S)
- resection_boundaries (R)
- lymphatic_vessel_invasion (L)
- vein_invasion (V)
The size is an aggregate Size field. See http://www.cancer.gov/cancertopics/factsheet/detection/staging for an overview. See http://en.wikipedia.org/wiki/TNM_staging_system and http://cancerstaging.blogspot.com/ for the value definition.
Note: The size and lymph_status choices can be further constrained by tumor type. Since TNMis a generic class, these constraints are not enforced in this TNM class. Rather, the REST client is responsible for enforcing additional choice constraints. TheTNM.lymph_status_choices()helper method can be used for tumor type specific choices. SeeTNM.Size`for a discussion of the size constraints.-
class
Size(*args, **kwargs)¶ Bases:
mongoengine.document.EmbeddedDocumentThe TNM primary tumor size field.
Note: The size score choices can be further constrained by tumor type. For example, the sarcoma tumor_size choices are 0, 1 or 2 and suffix choices are aorb. SeeTNMfor a discussion of choice constraints. TheTNM.Size.tumor_size_choices()andTNM.Size.suffix_choices()helper methods can be used for tumor type specific choices.-
clean()¶ Peforms document-level validation.
Raises: ValidationError – if the in_situ flag is set but there is a tumor_size or suffix field
-
classmethod
parse(klass, value)¶ Parses the given string into a new Size. The size must match the
SIZE_REGEXregular expression.Parameters: value – the input string Returns: the new Size object Raises: ValidationError – it the size value string does not match SIZE_REGEX
-
static
suffix_choices(tumor_type=None)¶ Parameters: tumor_type – the optional tumor type, e.g. BreastReturns: the suffix choices for the given type
-
static
tumor_size_choices(tumor_type=None)¶ Parameters: tumor_type – the optional tumor type, e.g. BreastReturns: the tumor_size choices for the given type
-
-
static
TNM.lymph_status_choices(tumor_type=None)¶ Parameters: tumor_type – the optional tumor type, e.g. BreastReturns: the lymph_status choices for the given type
-
class
qirest_client.model.clinical.Treatment(*args, **kwargs)¶ Bases:
mongoengine.document.EmbeddedDocumentThe patient therapy, e.g. adjuvant. Treatment is one of the
Treatment.TYPE_CHOICEStypes, and occurs over a period of time. The treatment consists of dosages, which may be pharmocological or radiological.
-
class
qirest_client.model.clinical.TumorLocation(*args, **kwargs)¶ Bases:
mongoengine.document.EmbeddedDocumentThe tumor body part and directional orientation.
-
class
qirest_client.model.clinical.TumorPathology(*args, **kwargs)¶ Bases:
mongoengine.document.EmbeddedDocumentThe tumor-specific pathology.
-
qirest_client.model.clinical.necrosis_percent_as_score(necrosis_percent)¶ Calculates the necrosis score from the necrosis percent according to the Stanford Synovial Sarcoma Guideline<http://surgpathcriteria.stanford.edu/softmisc/synovial_sarcoma/grading.html> as follows: * If the percent is None, then None * Otherwise, if the percent is 0, then 0 * Otherwise, if the percent is less than 50, then 1 * Otherwise, 2
Parameters: necrosis_percent – the integer percent, NecrosisPercentValueorNecrosisPercentRangeReturns: the necrosis score Raises: ValidationError – if the percent is a range that spans 50%
imaging¶
The qiprofile imaging Mongodb data model.
-
class
qirest_client.model.imaging.Image(*args, **kwargs)¶ Bases:
mongoengine.document.EmbeddedDocumentThe image file encapsulation.
-
class
qirest_client.model.imaging.ImageSequence(*args, **kwargs)¶ Bases:
qirest_client.model.common.OutcomeThe Scan or Registration.
-
class
qirest_client.model.imaging.LabelMap(*args, **kwargs)¶ Bases:
qirest_client.model.imaging.ImageA label map with an optional associated color lookup table.
-
class
qirest_client.model.imaging.Modeling(*args, **kwargs)¶ Bases:
qirest_client.model.common.OutcomeThe pharmicokinetic modeling run on an image sequence.
-
class
ParameterResult(*args, **kwargs)¶ Bases:
mongoengine.document.EmbeddedDocumentThe output for a given modeling run result parameter.
-
class
Modeling.Source(*args, **kwargs)¶ Bases:
mongoengine.document.EmbeddedDocumentThis Modeling.Source embedded class works around the following mongoengine limitation:
- mongoengine does not allow heterogeneous collections, i.e. a domain model Document subclass cannot have subclasses. Furthermore, the domain model Document class cannot be an inner class.
Consequently, the Modeling.source field cannot represent an abstract superclass with subclasses RegistrationSource and ScanSource. The work-around is to introduce this Source embedded document disambiguation by creating a disjunction object that can either hold a scan reference or a registration reference.
-
class
-
class
qirest_client.model.imaging.MultiImageResource(*args, **kwargs)¶ Bases:
qirest_client.model.imaging.ResourceA resource with several files.
-
class
qirest_client.model.imaging.Point(*args, **kwargs)¶ Bases:
mongoengine.document.EmbeddedDocumentThe 3D point in the volume voxel space.
-
class
qirest_client.model.imaging.Protocol(*args, **values)¶ Bases:
mongoengine.document.DocumentThe image acquisition or processing protocol abstract class.
Initialise a document or embedded document
Parameters: - __auto_convert – Try and will cast python objects to Object types
- values – A dictionary of values for the document
-
class
qirest_client.model.imaging.Region(*args, **kwargs)¶ Bases:
mongoengine.document.EmbeddedDocumentThe 3D region in volume voxel space.
-
class
qirest_client.model.imaging.Registration(*args, **kwargs)¶ Bases:
qirest_client.model.imaging.ImageSequenceThe patient image registration that results from processing a scan.
-
class
qirest_client.model.imaging.Resource(*args, **kwargs)¶ Bases:
mongoengine.document.EmbeddedDocumentThe image store file access abstraction.
-
class
qirest_client.model.imaging.Scan(*args, **kwargs)¶ Bases:
qirest_client.model.imaging.ImageSequenceThe the concrete subclass of the abstract
ImageSequenceclass for scans.
-
class
qirest_client.model.imaging.Session(*args, **kwargs)¶ Bases:
qirest_client.model.common.EncounterThe MR session (a.k.a. study in DICOM terminology).
-
acquisition_parameters¶ alias of
DictField
-
classmethod
pre_delete(sender, document, **kwargs)¶ Cascade delete this Session’s detail.
-
-
class
qirest_client.model.imaging.SessionDetail(*args, **values)¶ Bases:
mongoengine.document.DocumentThe MR session detailed content.
Initialise a document or embedded document
Parameters: - __auto_convert – Try and will cast python objects to Object types
- values – A dictionary of values for the document
-
class
qirest_client.model.imaging.SingleImageResource(*args, **kwargs)¶ Bases:
qirest_client.model.imaging.ResourceA resource with one file.
subject¶
The qiprofile subject Mongodb data model.
-
class
qirest_client.model.subject.ImagingCollection(*args, **values)¶ Bases:
mongoengine.document.DocumentThe imaging collection.
Initialise a document or embedded document
Parameters: - __auto_convert – Try and will cast python objects to Object types
- values – A dictionary of values for the document
-
class
qirest_client.model.subject.Project(*args, **values)¶ Bases:
mongoengine.document.DocumentThe imaging project.
Initialise a document or embedded document
Parameters: - __auto_convert – Try and will cast python objects to Object types
- values – A dictionary of values for the document
-
class
qirest_client.model.subject.Subject(*args, **values)¶ Bases:
mongoengine.document.DocumentThe patient.
Initialise a document or embedded document
Parameters: - __auto_convert – Try and will cast python objects to Object types
- values – A dictionary of values for the document
-
add_encounter(encounter)¶ Inserts the given encounter to this
Subjectencounters list in temporal order by encounter date.
-
clinical_encounters¶ Returns: the non- qirest_client.imaging.Sessionencounters
-
pre_delete(sender, document, **kwargs)¶ Cascade delete the subject’s sessions.
-
sessions¶ Returns: the qirest_client.imaging.Sessionencounters
uom¶
The qiprofile unit of measurement MongoDB data model.
This uom module is an advisory module for quantity display and conversion. Quantities are always stored in a canonical unit documented in the field.
-
class
qirest_client.model.uom.Decimal(*args, **kwargs)¶ Bases:
mongoengine.document.EmbeddedDocumentThis Decimal document class is a work-around for the broken MongoEngine DecimalField (cf. https://github.com/MongoEngine/mongoengine/issues?q=is%3Aissue+is%3Aopen+decimal).
Decimal has a float value and an optional precision. The default precision is determined as follows:
If the Decimal value is initialized with a python
decimal.Decimalor string, then the default precision is the number of decimal places expressed in that value, e.g.:Decimal('1.24').precision #=> 2 Decimal(decimal.Decimal('1.4')).precision #=> 1
- If the Decimal value is initialized with an integer, then the default
precision is zero, e.g.:
Decimal(1).precision #=> 0
-
__init__(*args, **kwargs)¶
-
canonical()¶ Returns: the python decimal.Decimal equivalent of this Decimal
-
class
qirest_client.model.uom.Measurement(*args, **kwargs)¶ Bases:
mongoengine.document.EmbeddedDocumentA scientific measurement.
The measurement is a quantitative amount associated with a unit. The unit is the Unit as captured and displayed. The amount is expressed as a python Decimal in unscaled units. If the constructor is called with a non-Decimal numeric amount, then the value is converted to a Decimal, e.g.:
Measurement(amount=0.006, unit=Weight())
is equivalent to:
from decimal import Decimal Measurement(amount=Decimal(0.006), unit=Weight())
The measurement unit can be qualified by a second
per_unitdimension, e.g. 2 mg/kg dosage per patient weight is expressed as:Measurement(amount=0.002, unit=Weight(), per_unit=Weight(scale='k'))
Note: the amount is a Decimalembedded object rather than the broken MongoEngineDecimalField(see theDecimalcomment).Initializes the Measurement document. The amount can be either a positional or a keyword argument. The amount is converted to a Decimal.
Parameters: - args – the amount as a positional argument
- kwargs – the following keyword arguments:
- amount – the amount as a keyword argument
-
__init__(*args, **kwargs)¶ Initializes the Measurement document. The amount can be either a positional or a keyword argument. The amount is converted to a Decimal.
Parameters: - args – the amount as a positional argument
- kwargs – the following keyword arguments:
- amount – the amount as a keyword argument
-
class
qirest_client.model.uom.Radiation(*args, **kwargs)¶ Bases:
qirest_client.model.uom.UnitThe radiation unit is always an unscaled Gray.
-
class
qirest_client.model.uom.Unit(*args, **kwargs)¶ Bases:
mongoengine.document.EmbeddedDocumentUnit is an abstract class for the supported measurement units. Each unit has a scaling factor with the default scaling factor defined in the concrete Unit subclass. Each Unit subclass has the following class variables:
BASE- the standard unscaled metric unit abbreviation, e.g.mfor the meter Extent unit.SCALES- the recommended scaling factors, e.g.mfor- milli and
cfor centi.
The scales are a list in preference order, e.g. the
Extent.SCALESvalue['c', 'm']implies that the preferred extent unit display iscm(centimeter) and an edit form should show the scalescandm, in that order, defaulting toc. A scale of None signifies the scaling factor 1, e.g. the theRadiation.SCALESvalue[None, 'c']implies that the preferred radiation unit display isGy(Gray) and an edit form should show the scales blank andc, in that order, defaulting to blank (scaling factor 1).These class variables are advisory. The client is responsible for displaying the base and scales and converting from a scaled value to an unscaled value before saving the measurement to the database.