class IPatientControlPanel(Interface): """Controlpanel Settings """ require_patient = schema.Bool( title=_(u"Require Patient"), description=_("Require Patients in Samples"), required=False, default=True, ) patient_entry_mode = schema.Choice( title=_(u"Patient name entry mode"), description=_(u"Patient's name entry mode in Sample Add form"), source="senaite.patient.vocabularies.name_entry_modes", required=True, default="parts", ) verify_temp_mrn = schema.Bool( title=_(u"Allow to verify samples with a temporary MRN"), description=_(u"If selected, users will be able to verify samples " u"that have a Patient assigned with a temporary Medical " u"Record Number (MRN)."), required=False, default=False, ) publish_temp_mrn = schema.Bool( title=_(u"Allow to publish samples with a temporary MRN"), description=_(u"If selected, users will be able to publish samples " u"that have a Patient assigned with a temporary Medical " u"Record Number (MRN)."), required=False, default=False, )
def validate_email(data): """Checks if the email is correct """ if not data.email: return if not is_valid_email_address(data.email): raise Invalid(_("Patient email is invalid"))
def validate_patient_id(data): """Checks if the patient ID is unique """ pid = data.patient_id # field is not required if not pid: return # https://community.plone.org/t/dexterity-unique-field-validation context = getattr(data, "__context__", None) if context is not None: if context.patient_id == pid: # nothing changed return query = { "portal_type": "Patient", "patient_id": pid, "is_active": True, } patient = patient_api.patient_search(query) if patient: raise Invalid(_("Patient ID must be unique"))
def folder_item(self, obj, item, index): if obj.isMedicalRecordTemporary: # Add an icon after the sample ID after_icons = item["after"].get("getId", "") kwargs = {"width": 16, "title": _("Temporary MRN")} after_icons += self.icon_tag("id-card-red", **kwargs) item["after"].update({"getId": after_icons}) item["MRN"] = obj.getMedicalRecordNumberValue item["Patient"] = obj.getPatientFullName item["PatientID"] = obj.getPatientID
def __call__(self, value, *args, **kwargs): field = kwargs.get("field", None) if not field: return True identifier = value.get("value", "") required = getattr(field, "required", False) if required and not identifier: field_title = field.widget.label msg = _("Required field: ${title}", mapping={"title": field_title}) ts = api.get_tool("translation_service") return to_utf8(ts.translate(msg)) return True
def validate_mrn(data): """Checks if the patient MRN # is unique """ # https://community.plone.org/t/dexterity-unique-field-validation context = getattr(data, "__context__", None) if context is not None: if context.mrn == data.mrn: # nothing changed return patient = patient_api.get_patient_by_mrn(data.mrn, full_object=False, include_inactive=True) if patient: raise Invalid(_("Patient Medical Record # must be unique"))
from zope.component import adapts from zope.interface import implementer MAYBE_REQUIRED_FIELDS = [ "MedicalRecordNumber", "PatientFullName", ] MedicalRecordNumberField = TemporaryIdentifierField( "MedicalRecordNumber", required=True, validators=("temporary_identifier_validator", ), read_permission=View, write_permission=FieldEditMRN, widget=TemporaryIdentifierWidget( label=_("Medical Record #"), render_own_label=True, visible={ "add": "edit", "secondary": "disabled", "header_table": "prominent", }, )) PatientIDField = ExtStringField("PatientID", read_permission=View, write_permission=FieldEditID, widget=StringWidget(label=_("Patient ID"), render_own_label=True, visible={ "add":
from plone.memoize.instance import memoize from senaite.patient import check_installed from senaite.patient import messageFactory as _ from senaite.app.listing.interfaces import IListingView from senaite.app.listing.interfaces import IListingViewAdapter from senaite.app.listing.utils import add_review_state from senaite.app.listing.utils import add_column from zope.component import adapts from zope.component import getMultiAdapter from zope.interface import implements # Statuses to add. List of dicts ADD_STATUSES = [ { "id": "temp_mrn", "title": _("Temporary MRN"), "contentFilter": { "is_temporary_mrn": True, "sort_on": "created", "sort_order": "descending", }, "before": "to_be_verified", "transitions": [], "custom_transitions": [], }, ] # Columns to add ADD_COLUMNS = [ ("MRN", { "title": _("MRN"),
class PatientControlPanelForm(RegistryEditForm): schema = IPatientControlPanel schema_prefix = "senaite.patient" label = _("SENAITE Patient Settings")
class IPatientSchema(model.Schema): """Patient Content """ directives.omitted("title") title = schema.TextLine(title=u"Title", required=False) directives.omitted("description") description = schema.Text(title=u"Description", required=False) # contact fieldset fieldset("contact", label=u"Contact", fields=["email", "phone", "mobile"]) # address fieldset fieldset("address", label=u"Address", fields=["city", "zipcode", "address", "country"]) # Default mrn = schema.TextLine( title=_(u"label_patient_mrn", default=u"Medical Record #"), description=_(u"Patient Medical Record Number"), required=True, ) patient_id = schema.TextLine( title=_(u"label_patient_id", default=u"ID"), description=_(u"Unique Patient ID"), required=False, ) firstname = schema.TextLine( title=_(u"label_patient_firstname", default=u"Firstname"), description=_(u"Patient firstname"), required=False, ) lastname = schema.TextLine( title=_(u"label_patient_lastname", default=u"Lastname"), description=_(u"Patient lastname"), required=False, ) gender = schema.Choice( title=_(u"label_patient_gender", default=u"Gender"), description=_(u"Patient gender"), source="senaite.patient.vocabularies.gender", default="", required=True, ) # Contact email = schema.TextLine( title=_(u"label_patient_email", default=u"Email"), description=_(u"Patient email address"), required=False, ) phone = schema.TextLine( title=_(u"label_patient_phone", default=u"Phone"), description=_(u"Patient phone number"), required=False, ) mobile = schema.TextLine( title=_(u"label_patient_mobile", default=u"Mobile"), description=_(u"Patient mobile phone number"), required=False, ) # Address address = schema.Text( title=_(u"label_patient_address", default=u"Address"), description=_(u"Patient address"), required=False, ) city = schema.TextLine( title=_(u"label_patient_city", default=u"City"), description=_(u"Patient city"), required=False, ) zipcode = schema.TextLine( title=_(u"label_patient_zipcode", default=u"ZIP"), description=_(u"Patient ZIP Code"), required=False, ) country = schema.Choice( title=_(u"label_patient_country", default=u"Country"), description=_(u"Patient country"), source="senaite.patient.vocabularies.country", required=False, ) directives.widget("birthdate", DatetimeWidget, datepicker_nofuture=True, show_time=False) birthdate = DatetimeField( title=_(u"label_patient_birthdate", default=u"Birthdate"), description=_(u"Patient birthdate"), required=False, ) @invariant def validate_mrn(data): """Checks if the patient MRN # is unique """ # https://community.plone.org/t/dexterity-unique-field-validation context = getattr(data, "__context__", None) if context is not None: if context.mrn == data.mrn: # nothing changed return patient = patient_api.get_patient_by_mrn(data.mrn, full_object=False, include_inactive=True) if patient: raise Invalid(_("Patient Medical Record # must be unique")) @invariant def validate_patient_id(data): """Checks if the patient ID is unique """ pid = data.patient_id # field is not required if not pid: return # https://community.plone.org/t/dexterity-unique-field-validation context = getattr(data, "__context__", None) if context is not None: if context.patient_id == pid: # nothing changed return query = { "portal_type": "Patient", "patient_id": pid, "is_active": True, } patient = patient_api.patient_search(query) if patient: raise Invalid(_("Patient ID must be unique")) @invariant def validate_email(data): """Checks if the email is correct """ if not data.email: return if not is_valid_email_address(data.email): raise Invalid(_("Patient email is invalid"))