Generate valid Australian Medicare card numbers for testing purposes
Disclaimer: These are randomly generated valid Medicare numbers for testing purposes only. Do not use for any official or fraudulent purposes. These numbers are not associated with real individuals.
Maximum 100 numbers per generation
Medicare number generator creates valid test Medicare card numbers for Australian healthcare system testing. Medicare numbers use a specific format with check digit validation. For software testing only - not for actual healthcare use.
Generate 8-digit base number plus check digit using weighted sum algorithm. Medicare format: 10 digits displayed as XXXX XXXXX X. IRN (Individual Reference Number) 1-9 appended for family members.
Medicare format: 10 digits (8 base + 1 check + 1 IRN). Check digit: weighted sum with weights [1,3,7,9,1,3,7,9], mod 10. IRN: 1-9 for card members. Cards valid 1-5 years. Green (resident), Blue (interim), Yellow (reciprocal).
Test patient management systems.
Verify Medicare input validation.
Test Medicare claiming integrations.
Seed test databases with valid numbers.
// Medicare check digit weights
const MEDICARE_WEIGHTS = [1, 3, 7, 9, 1, 3, 7, 9];
// Calculate Medicare check digit
function calculateMedicareCheckDigit(digits) {
if (digits.length !== 8) throw new Error('Need 8 digits');
const sum = digits.reduce((acc, digit, i) => {
return acc + (digit * MEDICARE_WEIGHTS[i]);
}, 0);
return sum % 10;
}
// Validate Medicare number
function validateMedicare(medicare) {
const digits = String(medicare).replace(/\s/g, '').split('').map(Number);
if (digits.length !== 10 || digits.some(isNaN)) {
return false;
}
// Check digit is position 9 (index 8)
const baseDigits = digits.slice(0, 8);
const checkDigit = calculateMedicareCheckDigit(baseDigits);
const irn = digits[9];
return checkDigit === digits[8] && irn >= 1 && irn <= 9;
}
// Generate valid Medicare number
function generateMedicare(irn = 1) {
if (irn < 1 || irn > 9) irn = 1;
// Generate 8 random digits (first digit 2-6 typically)
const digits = [
2 + Math.floor(Math.random() * 5), // 2-6
...Array(7).fill(0).map(() => Math.floor(Math.random() * 10))
];
// Calculate check digit
const checkDigit = calculateMedicareCheckDigit(digits);
digits.push(checkDigit);
digits.push(irn);
return digits.join('');
}
// Format Medicare number
function formatMedicare(medicare) {
const clean = String(medicare).replace(/\D/g, '');
return clean.replace(/(\d{4})(\d{5})(\d{1})/, '$1 $2 $3');
}
// Generate with expiry
function generateMedicareCard(irn = 1) {
const number = generateMedicare(irn);
const now = new Date();
const expiry = new Date(now.getFullYear() + Math.floor(Math.random() * 5) + 1, Math.floor(Math.random() * 12), 1);
return {
number: formatMedicare(number),
irn: irn,
expiry: `${String(expiry.getMonth() + 1).padStart(2, '0')}/${expiry.getFullYear()}`
};
}
// Examples
console.log(generateMedicareCard(1));
// { number: "2345 67890 1", irn: 1, expiry: "06/2027" }
console.log(validateMedicare('2345 67890 1')); // Depends on check digitComplete Medicare number generation with check digit validation and formatting.
Use for testing Australian healthcare software, patient management systems, or Medicare claiming integrations. Never use generated numbers for actual healthcare services.
No. Generated numbers aren't linked to real people. Medicare fraud is a criminal offense. Use only for software testing.