How can I auto fill the before medications to the new one?

How can I automatically fill the previous medication data to the new prescription in Patient Encounter doctype?

For ex,.
Already I raised a Encounter for the patient and doctor prescribed some medications on there First Encounter, then on the second time patient come to visit the doctor means, at that time the before encounter medications will automatically shows what they raised before encounter while clicking the default “Fill From” button on the Patient Encounter doctor…

Please some guide me to acheive this…