Hepatitis B infection in pregnancy can be dangerous because the virus can be transmitted to the baby.
Hepatitis B infection can be diagnosed from a blood test. Different tests are available. The antigen test checks for the presence of the virus and the antibody test checks for the body's immune response to the virus.
The first test done by obstetricians is to test for the hepatitis B surface antigen. After an infection, most adults will clear the virus from the body usually after several months to a year. If the hepatitis B virus is not cleared from the body (i.e. in carriers), the surface antigen remains positive for life. Hepatitis B surface antigen is present in the blood of people who are acutely or chronically infected with hepatitis B virus. People with a positive Hepatitis B surface antigen are infectious and can transmit the virus.
Hepatitis B core antibody is present in the blood of people who have been infected with hepatitis B in the past. It is present in carriers of hepatitis B, but also in people who have cleared the virus from their body. If the core antibody is positive and the Hepatitis B surface antigen is negative, then there is immunity to hepatitis B. These people are not carriers and there is no risk of transmitting the virus to others or developing hepatitis B-related liver complications later.
Hepatitis B surface antibody is positive in people who have been exposed to hepatitis B previously but have cleared the virus from their body. It is also usually positive in people who have been vaccinated against hepatitis B. People who test positive for surface antibody are immune to hepatitis B or are vaccinated; they are not carriers.
The CDC website has a table to compare different results of Hepatitis B testing.