In order to answer the above question, it is necessary to determine whether a given person is covered by the Act on assistance to Ukrainian citizens or under temporary protection. For this purpose, see points 1 and 13 of our guide The Law on Assistance to Ukrainian Citizens: https://ukraina.interwencjaprawna.pl/the-act-on-assistance-for-ukrainian-citizens/
If you are a citizen of Ukraine covered by the Act on assistance, citizens of Ukraine are entitled to healthcare on the same terms as Polish citizens.
If you are not covered by this act, but you are covered by temporary protection, then you are also entitled to health care, but to a more limited extent. The Head of the Office for Foreigners is responsible for ensuring it.
If you are not covered by any of the above forms of regulation, e.g. you are a citizen of a third country, and you only had a temporary stay in Ukraine, then you are not entitled to free medical care in Poland.
In case of emergency, you can receive basic medical care right after your arrival in reception point for refugees.