Is it possible to change Sample Type?

Hi everyone,

Is it possible to change Sample Type?

Any usergroups cant change.

Thanks.

Hi,
I think it canā€™t be changed, as the sampleID is related to sampletype(prefix).
But why you want to change it?
You can have other alternative way. Ex.
-ā€œCopy to newā€ to register a new sample with the right sampletype, most of field contents are automatically pre-filled.
-then ā€œCancelā€ the sample with ā€œwrongā€ sampletype.

Deng

Hi,
@fengyun.deng is right. Sample Type is one of the few attributes that can never be changed after creation.

So creating new samples by copying is the easiest way.

Unluckily sometimes we notice a wrong sample type after all work was done.
So hereā€™s another workaround keeping the original SampleID:

  • create a new partition for that sample
  • assign new sample type for that partition
  • assign existing analysis service, if possible and needed
  • after creation there is a new sub-sample with the original id and a suffix ā€˜-P01ā€™!
  • complete missing sample metadata e.g. profile, template, specsā€¦
  • detach this sub-sample from the original sample, so it becomes distinct
  • cancel or reject the original sample

HTH

1 Like

Hi everyone,

@grulisco 's suggestion was exactly what we needed. Indeed, sometimes we realize the wrong sample type after tests have progressed and been concluded, and we want to preserve those protocols. We have lists and records kept within the laboratory according to those protocol numbers. gruliscoā€™s workaround was helpful for us.

Thank you everyone for your messages.

Actually, there is another similar situation: changing the client. Have you encountered a situation where you needed to change the client? What would you do in that case?

Thanks in advance for your help.

Changing Client?
Worse Situationā€¦ Thereā€™s No Trick for this, iā€™m afraid.
Best solution: Copying Samples, Change Client, but getting new IDs.

I want to thank the community and @grulisco for the response. Since the majority of our sample registration and acceptance is done within our own laboratory, we very rarely make incorrect client entries, but we do notice it during reporting. As you mentioned, we apply the suggested method.

Wishing everyone all the best.

Do you know if this constraint automatically disappear after removing the Sample Type from the ID Server?

We can alter our Sample Type after creation:

But we also removed SampleType from the ID Server formula:

I havenā€™t tested to see if that automatically flags the configuration, but it appears that way :thinking:.

1 Like

Hi @faytrow

we removed {SampleType} in our ID server, too - with no effect.

So Iā€™m really surprised, that you can alter the sample type afterwards.

I havenā€™t enough knowledge about the coding, but I would like to have this ability for myself.

1 Like

Ah, I found where it was added in.

You can a modify the widget using an adapter on the AnalysisRequest to make that field editable (in addition to removing it from the ID Server).

If you have your own custom Plone add-on for Senaite, you can put this in an adapter with your specified lims layer:

from archetypes.schemaextender.interfaces import ISchemaModifier
from bika.lims.interfaces import IAnalysisRequest
from your.lims.interfaces import IYourLimsLayer #This is for your add-on
from Products.CMFCore.permissions import View #Consider a different permission

class AnalysisRequestSchemaModifier(object):
    adapts(IAnalysisRequest)
    implements(ISchemaModifier)
    layer = IYourLimsLayer

    def __init__(self, context):
        self.context = context

    def fiddle(self, schema):
        schema['SampleType'].widget.visible={
            'edit':'visible',
            'view':'visible',
            'add':'edit',
            'header_table':'visible',
        }
        schema['SampleType'].write_permission = View #This lets ANYONE edit it
        return schema

Also make sure the register the adapter in a .zcml file that is part of your GenericSetup:

    <!-- Schema extender for ARs -->
    <adapter
      name="your.lims.analysisrequest.schemaextender"
      factory=".your_module.AnalysisRequestSchemaExtender"
      provides="archetypes.schemaextender.interfaces.ISchemaExtender"
      />

Note: This will be obsolete once Archetypes are no longer used for AnalysisRequests.

1 Like