In this paper, we develop a model for bed allocation problems under Indonesia's National Health Insurance Scheme (Jaminan Kesehatan Nasional - JKN) managed by the Social Security Organizing Body (Badan Penyelenggara Jaminan Sosial - BPJS). This scheme categorizes patients and beds into three insurance classes. However, patients often face bed shortages in their designated classes. To address these bed shortages and the consequences of patients residing in beds other than those of their designated classes, we propose a bed allocation model using an overflow queueing model with repacking: when a patient arrives and finds all beds in its treatment class occupied, according to the BPJS-JKN the patient will be put in the first higher class bed and transferred immediately to its original class as soon as a bed is available in that class. We obtain a product form expression for the stationary distribution of bed occupancy, allowing explicit evaluation of various performance measures, including the blocking probabilities. Furthermore, we maximize the expected profit from the inpatient care under the BPJS-JKN health insurance scheme. Using the model, we develop a capacity planning tool to maximize the total revenue. To illustrate our model, we apply our model to our partnering hospital in Yogyakarta, Indonesia.