Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instruct command picks the wrong concept #363

Open
dbajet opened this issue Jan 24, 2025 · 1 comment
Open

Instruct command picks the wrong concept #363

dbajet opened this issue Jan 24, 2025 · 1 comment

Comments

@dbajet
Copy link

dbajet commented Jan 24, 2025

When creating an Instruct command, the interpreter on the home-app side takes the first result from science for the provided instruction, following this code:

        first_result = (
            next(iter(search_for_instructions(instruction)), None) if instruction else None
        )

The consequence is that if there are two instructions, one containing the same characters than the other with a few additional ones and having a better score, it is always chosen.

So, when trying to create an Instruct command for the instruction Advice to return, it always ends up with the instruction Advice to return to work based on this request:

Image

Here is some plugin code to reproduce the issue:

from canvas_sdk.commands.commands.instruct import InstructCommand
from canvas_sdk.effects import Effect
from canvas_sdk.events import EventType
from canvas_sdk.protocols import BaseProtocol
from canvas_sdk.v1.data.note import Note
from logger import log


class Commander(BaseProtocol):
    RESPONDS_TO = [
        EventType.Name(EventType.PATIENT_PROFILE__SECTION_CONFIGURATION),
    ]

    def compute(self) -> list[Effect]:
        patient_uuid = self.target
        note = Note.objects.filter(patient__id=patient_uuid).order_by('-dbid').first()
        note_uuid = str(note.id)

        commands = [
            InstructCommand(
                instruction="Advice to return",
                comment='Follow up and come back to the clinic in two weeks.',
                note_uuid=note_uuid,
            )
        ]
        log.info('--------------------')
        log.info(f"event {self.event.name}")
        log.info(f"patient_uuid {patient_uuid}")
        log.info(f"note_uuid {note_uuid}")
        log.info(f"commands {len(commands)}")
        log.info('--------------------')
        return [command.originate() for command in commands]

@andhines
Copy link
Member

Another approach, which doesn't solve the specific problem with search result selection, would be to allow specification of SNOMED code itself in the Instruct class constructor so there is direct control. Right now, there is no direct control over the SNOMED code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants