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

The Equipment Class #1098

Merged
merged 125 commits into from
May 15, 2024
Merged

The Equipment Class #1098

merged 125 commits into from
May 15, 2024

Conversation

EvaJanouskova
Copy link
Collaborator

@EvaJanouskova EvaJanouskova commented Sep 6, 2023

main changes:

  • modified healthsystem module to allow tracking and logging of equipment used

minor changes:

  • added some TODOs (hoping at least some of them will be resolved before this PR closes)

TODO

  • decide on empty declaration appearance
  • logging of equipment counts of use by HSI event & facility level
  • script to catalogue equipment associated with each HSI event & catalogue equipment by treatment id and facility levels
  • add item codes to RF
  • log item codes instead of names
  • add possibility of adding equipment packages (not just items)
  • make possible equipment pkgs to be set as essential equipment
  • test essential equipment set for all HSI events
    if essential equipment setting is missing, set it to empty set and add HSI event name to warning
  • test essential equipment is in RF_Equipment
    test equipment potentially used is in RF_Equipment (if possible)
    if any equipment item or pkg name provided in the code is not included in RF_Equipment, ignore the item(s) and
    add the item/pkg name to warning
  • stop HSI events from running if essential equipment not available
  • add possibility to check equip availability within an hsi event
  • add switcher: no X all X default equipment available
  • equip availability columns by facility levels in RF_Equipment with dummy values (True for all)
  • availability of items based on RF_Equipment (now, all available except a few item codes)
  • tests
  • add instructions for equipment integration to the wiki
  • make the script code_to_items_list to be a function in the utils module

before merge:

  • rm the dummy examples before merge
  • what equip availability default values for the merge?

move to next PR:

Copy link
Collaborator

@tbhallett tbhallett left a comment

Choose a reason for hiding this comment

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

Great start on this Eva. Only minor comments.

Do we have an idea about how to provide people with a catalogue of equipment they can choose from when making these declarations?

src/scripts/healthsystem/equipment/equipment_catalogue.py Outdated Show resolved Hide resolved
src/tlo/analysis/utils.py Outdated Show resolved Hide resolved
src/tlo/methods/breast_cancer.py Outdated Show resolved Hide resolved
@@ -646,6 +647,7 @@ def __init__(self, module, person_id):
self.TREATMENT_ID = "BreastCancer_Investigation"
self.EXPECTED_APPT_FOOTPRINT = self.make_appt_footprint({"Over5OPD": 1, "Mammography": 1})
self.ACCEPTED_FACILITY_LEVEL = '3' # Mammography only available at level 3 and above.
# TODO: what this means, should be the mammography done within this event, or the biopsy, or both?
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure about this. Better ask Andrew.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@andrew-phillips-1, Would you know what is done within this HSI? Biopsy, mammography, or both?

The guideline you sent me, says in 10.3.3 'Breast Cancer':
"Diagnosis -> Definitive diagnosis is through histology. This is more superior than cytology which should be understood as a preliminary diagnostic test."

However, in the beginning of 10.1 'Cancer Diagnosis and Registration' Section they mention Mammography as a radiological test for breast cancer.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@EvaJanouskova I don't know for sure but I think we should consider this as just biopsy. As you saw in the guidelines, population screening for mammography is not done. So I think the mammography can be removed here.

Copy link
Collaborator Author

@EvaJanouskova EvaJanouskova Sep 18, 2023

Choose a reason for hiding this comment

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

@andrew-phillips-1, I've update the comment from # Mammography only available at level 3 and above. to # Biopsy only available at level 3 and above., is that correct?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@EvaJanouskova I'm not sure what levels biopsy will be done at but that sounds right and yes I agree about removing any mention of mammography

src/tlo/methods/breast_cancer.py Outdated Show resolved Hide resolved
src/tlo/methods/newborn_outcomes.py Outdated Show resolved Hide resolved
src/tlo/methods/contraception.py Outdated Show resolved Hide resolved
src/tlo/methods/contraception.py Outdated Show resolved Hide resolved
src/tlo/methods/contraception.py Outdated Show resolved Hide resolved
src/tlo/methods/healthsystem.py Outdated Show resolved Hide resolved
@EvaJanouskova EvaJanouskova force-pushed the EvaJ/equipment/structure_ToRunSim branch 2 times, most recently from 238459b to c1373e7 Compare September 12, 2023 18:44
@andrew-phillips-1
Copy link
Collaborator

Hi @EvaJanouskova (and @tbhallett) It's been a while since I worked on the module so I have forgotten all the reading I did at the time. I'm fairly sure that for some of your questions I didn't know the answer to even at that time. When I return I can try to spend some time over the next few weeks trying to read up about it again if that seems something worth me prioritising at this time.

@tbhallett
Copy link
Collaborator

Hi @EvaJanouskova (and @tbhallett) It's been a while since I worked on the module so I have forgotten all the reading I did at the time. I'm fairly sure that for some of your questions I didn't know the answer to even at that time. When I return I can try to spend some time over the next few weeks trying to read up about it again if that seems something worth me prioritising at this time.

Thanks @andrew-phillips-1. I don't think a wholesale update or anything like that is needed at the moment (although we have something along these lines slated for version 2, when we have someone available to support). For now, we just need to know the equipment that (implicitly) is being used. In the coming weeks, Eva will gather a catalogue of items and ask all disease module leads to identify the ones used in each HSI. This is needed for the costing model and to allow us to look at some analyses that MOH/CHAI are asking about.

@andrew-phillips-1
Copy link
Collaborator

Thanks @tbhallett - that seems good and I'm happy to try to do that for the modules I developed. @EvaJanouskova Do you know how other module leads are going about checking on equipment use for their modules ? There are the 2015 clinical guidelines, and I guess the service assessment survey is of some use, but do you know of other sources, that I have perhaps paid insufficient attention to ?

src/tlo/methods/breast_cancer.py Outdated Show resolved Hide resolved
src/tlo/methods/breast_cancer.py Outdated Show resolved Hide resolved
@EvaJanouskova
Copy link
Collaborator Author

EvaJanouskova commented Sep 18, 2023

Great start on this Eva. Only minor comments.

Do we have an idea about how to provide people with a catalogue of equipment they can choose from when making these declarations?

@tbhallett, It depends on the purpose and scope of the catalogue. Are we looking for a simple list for users to reference, where they manually copy equipment names as needed? Should it include only equipment currently modelled, meaning that when a new piece of equipment is added to the model, it must also be added to the catalogue?

What functionalities or requirements on the catalogue did you have in mind?

@EvaJanouskova EvaJanouskova changed the title equipment use equipment use infrastructure Sep 19, 2023
@EvaJanouskova EvaJanouskova changed the title equipment use infrastructure hs: equipment use structure Sep 19, 2023
@EvaJanouskova
Copy link
Collaborator Author

Thanks @tbhallett - that seems good and I'm happy to try to do that for the modules I developed. @EvaJanouskova Do you know how other module leads are going about checking on equipment use for their modules ? There are the 2015 clinical guidelines, and I guess the service assessment survey is of some use, but do you know of other sources, that I have perhaps paid insufficient attention to ?

Hi @andrew-phillips-1, I've just received a draft of the new 2023 version of the Malawi standard treatment guidelines. I will make these guidelines and the survey easily available to everyone. Additionally, we will create an equipment catalogue, allowing everyone to find the equipment needed for their module(s) and ensuring consistency by using the same names if used by multiple leaders.

@andrew-phillips-1
Copy link
Collaborator

Sounds good @EvaJanouskova

@EvaJanouskova EvaJanouskova force-pushed the EvaJ/equipment/structure_ToRunSim branch 3 times, most recently from ed64e6a to ebe0b6a Compare September 29, 2023 10:09
@EvaJanouskova EvaJanouskova force-pushed the EvaJ/equipment/structure_ToRunSim branch from 76b9bd6 to f1aa86c Compare October 24, 2023 22:03
tbhallett added a commit that referenced this pull request Nov 3, 2023
* utils: typo

* healthsystem: typo

* co: comments about consumable items

* healthsyst: comment moved to where it belongs

* minor typos

* healthsystem: correct argument name arg_service_availability

* brc: changes in comments based on discussion with Andrew in #1098

* hs: typos/minor corrections

* formatting_demog_data: minor changes is comments

* ac: minor comment updates

---------

Co-authored-by: Tim Hallett <[email protected]>
@EvaJanouskova EvaJanouskova force-pushed the EvaJ/equipment/structure_ToRunSim branch from f1aa86c to 9de2730 Compare November 15, 2023 00:26
@EvaJanouskova

This comment was marked as outdated.

@EvaJanouskova EvaJanouskova force-pushed the EvaJ/equipment/structure_ToRunSim branch from 522c135 to a30017a Compare November 15, 2023 19:01
@EvaJanouskova

This comment was marked as outdated.

@EvaJanouskova EvaJanouskova force-pushed the EvaJ/equipment/structure_ToRunSim branch 2 times, most recently from 5e29244 to 193a81e Compare November 19, 2023 18:23
Copy link
Collaborator

@matt-graham matt-graham left a comment

Choose a reason for hiding this comment

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

Interface generally looks good to me. I've added some further suggested changes and comments below, but the only one I think is vital is around changing HSI_Event._EQUIPMENT from being a class attribute to an instance attribute unless the former was specifically intended.

src/tlo/methods/healthsystem.py Show resolved Hide resolved
Comment on lines 89 to 94
_EQUIPMENT: Set[int] = set() # The set of equipment that is used in the HSI. If any items in this set are not
# available at the point when the HSI will be run, then the HSI is not run, and the
# `never_ran` method is called instead. This is a declaration of resource needs, but
# is private because users are expected to use `add_equipment` to declare equipment
# needs.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it would be better to initialise self._EQUIPMENT in the initialiser __init__ method, as setting the value here makes it an attribute of the class rather than a specific instance. That means all instances of the class will share the same _EQUIPMENT set and so equipment added / removed from one instance will affect all other instances. It's possible I'm misunderstanding and that is the desired behaviour though!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks. We absolutely don't want that behaviour. I'm making the change and will also add a test to check that the equipment list for each HSI_Event is kept separate.

src/tlo/methods/hsi_event.py Outdated Show resolved Hide resolved
src/tlo/methods/hsi_event.py Outdated Show resolved Hide resolved
src/tlo/methods/hsi_event.py Outdated Show resolved Hide resolved
src/tlo/methods/hsi_event.py Outdated Show resolved Hide resolved
src/tlo/methods/hsi_event.py Outdated Show resolved Hide resolved
Comment on lines 68 to 71
# - using single string for one item descriptor
assert eq_default.parse_items('ItemOne')
# - using list of strings for item descriptors
assert eq_default.parse_items(['ItemOne', 'ItemTwo'])
Copy link
Collaborator

Choose a reason for hiding this comment

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

The assertions here seem to be just that the values returned by parse_items are not 'Falsey' (for example not an empty set). Could we not instead check that we get the expected set of item codes (that is I think {1} and {1, 2} respectively if I'm understanding how parse_items works correctly)?

Copy link
Collaborator

Choose a reason for hiding this comment

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

That's exactly right. I didn't update this from an earlier version of the test file. Next commit will make these tests check for more than 'lack of error and falsiness'

tests/test_equipment.py Show resolved Hide resolved
@tbhallett
Copy link
Collaborator

tbhallett commented May 15, 2024

bahhhh-- checks failing due to ruff pylint errors on file I haven't touched in this PR.... 🤪

@matt-graham
Copy link
Collaborator

bahhhh-- checks failing due to ruff errors on file I haven't touched in this PR.... 🤪

I'll take a look - if specific rules are causing false positives I can set them to be ignored.

@matt-graham
Copy link
Collaborator

bahhhh-- checks failing due to ruff errors on file I haven't touched in this PR.... 🤪

I'll take a look - if specific rules are causing false positives I can set them to be ignored.

Looks like this is due a new pylint release yesterday (version 3.2.0) which added a new possibly-used-before-assignment check as the scheduled checks workflow on master also failed overnight. I'll check whether any of the occurences flagged are actually a problem and either fix or disable the rule.

@tbhallett
Copy link
Collaborator

bahhhh-- checks failing due to ruff errors on file I haven't touched in this PR.... 🤪

I'll take a look - if specific rules are causing false positives I can set them to be ignored.

Looks like this is due a new pylint release yesterday (version 3.2.0) which added a new possibly-used-before-assignment check as the scheduled checks workflow on master also failed overnight. I'll check whether any of the occurences flagged are actually a problem and either fix or disable the rule.

That makes sense -- thanks very much for this.

@matt-graham
Copy link
Collaborator

@tbhallett #1349 should fix the pylint errors when running checks on both master and here

Copy link
Collaborator

@matt-graham matt-graham left a comment

Choose a reason for hiding this comment

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

Given the failing checks here are not to do with anything in this PR as they are also failing on master and should be fixed by #1349, I would say this is good to go in now.

Edit: A but we won't be able to do without disabling the status check, so maybe we do need to merge in #1349 first.

@tbhallett
Copy link
Collaborator

tbhallett commented May 15, 2024 via email

@tbhallett tbhallett merged commit 8b0698d into master May 15, 2024
57 checks passed
@giordano giordano deleted the EvaJ/equipment/structure_ToRunSim branch May 16, 2024 11:50
@EvaJanouskova
Copy link
Collaborator Author

Thank you all for your amazing work! This looks so much better than it ever did. I love it!

Thank you.

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

Successfully merging this pull request may close these issues.

6 participants