I can guarantee you that if this were to be attempted in SF, they would have to have the drugs administered by medical staff. They couldn't just hand heroin and crack to the patients. Pimps and dealers would send in mules to get drugs that could be resold for cash. That would also probably cause human trafficking to surge.
Portugal's efforts to reduce addiction and homelessness sound great too, but those won't work here either. We need to find solutions that are workable for our culture... or wait for our culture to change.