Skip to content

Adds lab set feature for external labs#6204

Open
szaccagni wants to merge 1 commit intodevelopfrom
szaccagni/otr-1534-add-ability-to-select-from-lab-sets
Open

Adds lab set feature for external labs#6204
szaccagni wants to merge 1 commit intodevelopfrom
szaccagni/otr-1534-add-ability-to-select-from-lab-sets

Conversation

@szaccagni
Copy link
Contributor

I'm going to create another PR pointing at this branch for inhouse, but wanted to break it up a little to make it easier to review, i'll include the tf config file there.

https://linear.app/zapehr/issue/OTR-1534/add-ability-to-select-from-lab-sets

onChange={(_, selectedLab: any) => {
const alreadySelected = selectedLabs.find((tempLab) => {
const tempLabCode = `${tempLab.item.itemCode}${tempLab.lab.labGuid}`;
const selectedLabCode = `${selectedLab.item.itemCode}${selectedLab.lab.labGuid}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be sufficient to use the lab.item.uniqueName as the comparison here rather than itemCode + labGuid? I see that uniqueName is used as the getOptionKey so it would at least be consistent. And if the answer is that uniqueName wouldn't be unique enough for this comparison, then I wonder if uniqueName should be replaced as the getOptionKey

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that sounds good to me.

setSelectedLabs((prev) =>
prev.filter((tempLab) => {
const tempLabCode = `${tempLab.item.itemCode}${tempLab.lab.labGuid}`;
const labCode = `${lab.item.itemCode}${lab.lab.labGuid}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thought here about this vs uniqueName

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah lets use uniqueName

Comment on lines +43 to +44
const errorMessage = [sdkError.message];
setError(errorMessage);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could consolidate these lines

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

</DialogTitle>

<DialogContent dividers>
{labSets.map((set, idx) => (
Copy link
Contributor

@abraun-ml abraun-ml Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the state of the UI when labSets.length === 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i send undefined from backend when labsets len is 0 so that should never happen

Comment on lines +25 to +26
labs: {
display: string; // list of names of the tests contained in this list formatted list {lab name / filler lab name}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

love the comment but I wonder if

// list of names of the tests contained in this list

should live above line 25 and the rest stay where it is, e.g.

Suggested change
labs: {
display: string; // list of names of the tests contained in this list formatted list {lab name / filler lab name}
// list of names of the tests contained in this list
labs: {
display: string; // formatted 'test name / filler lab name'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the object isn't just a list of names, its a list of display, itemCode and labGuid

Copy link
Contributor

@abraun-ml abraun-ml Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, what about this? My primary reason for changing this is rn it makes it seem like "display" is a list of something when it isn't

Suggested change
labs: {
display: string; // list of names of the tests contained in this list formatted list {lab name / filler lab name}
// tests contained in this list
labs: {
display: string; // formatted list {test name / filler lab name}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay, that makes sense, will update

dx,
encounter,
orderableItem,
encounter, // why do we send the whole encounter? can probably just do the id and grab the resource later
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the very least to check encounter.account no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dunno it feels weird to send the whole object and then use that data from the front end rather than fetching the resource from the back end. I have no intention of changing this now, just more of a note to someone in the future if they are doing work here thats less disruptive, i think it would be good to change.


validateLabOrgAndOrderingLocationAndGetAccountNumber(labOrganization, orderingLocation);
// create lab order requests will come in for the same patient, encounter, psc flag, location
// the only thing that is potentially different is the lab the test will be run by
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"run by"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lol "is the lab the test will be run by" - i can see how thats not super clear, will update to "the only potential difference is the lab that will perform the test"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooooohhhhhh

clinicalInfoNoteByUser,
} = resources;
console.log(
`Formatting fhir batch input requests. Requisition: ${requisitionNumber} Test: ${orderableItem.item.itemName} ${orderableItem.item.itemCode}`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To help disambiguate, would be nice to include the labGuid in this log too please

const formattedListDTOs: LabListsDTO[] = [];
labLists.forEach((list) => {
const formatted: LabListsDTO = {
listId: list.id ?? 'missing',
Copy link
Contributor

@abraun-ml abraun-ml Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since listId gets used as a FE component key, might as well stick an idx in here as well to keep listId unique so the FE isn't mad. But also I know this is a type thing not something that actually happens

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay

Comment on lines +68 to +74
if (selectedLabSet) {
console.log('searching orderable items for the lab set', selectedLabSet.listName);
const labRequests = selectedLabSet.labs.map((lab) => {
return getLabs([lab.labGuid], { itemCodes: [lab.itemCode] }, m2mToken);
});
const allLabsResults = await Promise.all(labRequests);
labs = allLabsResults.flat();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depending on your answer here maybe this could go away?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see how we can get away without doing this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I forgot we stick basically all of orderable item info on the ServiceRequest so when I saw it earlier I thought we were just using the test name and lab guid. But you're right that this would be tough to get around

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

Successfully merging this pull request may close these issues.

2 participants