<commit_before>/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * Copyright 2010(Year date of delivery) United States Government, as represented by the Secretary of Health and Human Services.  All rights reserved.
 *
 */
package gov.hhs.fha.nhinc.util.format;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author webbn
 */
public class PatientIdFomatUtilTest {

    @Test
    public void testPatientIdParse()
    {
        try
        {
            String toParse = "1234";
            String expected = "1234";

            String parsed = PatientIdFormatUtil.parsePatientId(toParse);
            assertNotNull("Parsed - no HL7 was null", parsed);
            assertEquals("Parsed - no HL7  was incorrect", expected, parsed);

            toParse = "4567^^^&2.16.840.1.113883.192.168.127.12&ISO";
            expected = "4567";

            parsed = PatientIdFormatUtil.parsePatientId(toParse);
            assertNotNull("Parsed - HL7 was null", parsed);
            assertEquals("Parsed - HL7  was incorrect", expected, parsed);
        }
        catch(Throwable t)
        {
            t.printStackTrace();
            fail("Failed to parse patient id: " + t.getMessage());
        }
    }

    @Test
    public void testCommunityIdParse()
    {
        try
        {
            String toParse = "4567^^^&2.16.840.1.113883.192.168.127.12&ISO";
            String expectedHomeCommunity = "2.16.840.1.113883.192.168.127.12";

            String parsedHomeCommunity = PatientIdFormatUtil.parseCommunityId(toParse);
            assertNotNull("Parsed home community was null", parsedHomeCommunity);
            assertEquals("Parsed home community  was incorrect", expectedHomeCommunity, parsedHomeCommunity);

            toParse = "4567^^^";
            parsedHomeCommunity = PatientIdFormatUtil.parseCommunityId(toParse);
            assertNull("Parsed home community was not null when invalid", parsedHomeCommunity);

            toParse = "4567";
            parsedHomeCommunity = PatientIdFormatUtil.parseCommunityId(toParse);
            assertNull("Parsed home community was not null when not HL7 formatted", parsedHomeCommunity);

            toParse = null;
            parsedHomeCommunity = PatientIdFormatUtil.parseCommunityId(toParse);
            assertNull("Parsed home community was not null when id was null", parsedHomeCommunity);

        }
        catch(Throwable t)
        {
            t.printStackTrace();
            fail("Failed to parse community id: " + t.getMessage());
        }
    }

   /* @Test
    public void testPatientIdFormat()
    {
        try
        {
            String patientId = "1234";
            String homeCommunityId = "2.16.840.1.113883.192.168.127.12";
            String expected = "'1234^^^&2.16.840.1.113883.192.168.127.12&ISO'";

            String formatted = PatientIdFormatUtil.hl7EncodePatientId(patientId, homeCommunityId);
            assertNotNull("Formatted - id was null", formatted);
            assertEquals("Formatted - id was incorrect", expected, formatted);

        }
        catch(Throwable t)
        {
            t.printStackTrace();
            fail("Failed to parse patient id: " + t.getMessage());
        }
    }
*/
}<commit_msg>Removed single quotes from PatientID in hl7EncodePatientId that was apparently copied from old HITSP doc. It was probably just a typo - even then. It should be noted that other places in the code are defensively looking for these quotes created from legacy code.<commit_after>/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * Copyright 2010(Year date of delivery) United States Government, as represented by the Secretary of Health and Human Services.  All rights reserved.
 *
 */
package gov.hhs.fha.nhinc.util.format;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author webbn
 */
public class PatientIdFomatUtilTest {

    @Test
    public void testPatientIdParse()
    {
        try
        {
            String toParse = "1234";
            String expected = "1234";

            String parsed = PatientIdFormatUtil.parsePatientId(toParse);
            assertNotNull("Parsed - no HL7 was null", parsed);
            assertEquals("Parsed - no HL7  was incorrect", expected, parsed);

            toParse = "4567^^^&2.16.840.1.113883.192.168.127.12&ISO";
            expected = "4567";

            parsed = PatientIdFormatUtil.parsePatientId(toParse);
            assertNotNull("Parsed - HL7 was null", parsed);
            assertEquals("Parsed - HL7  was incorrect", expected, parsed);
        }
        catch(Throwable t)
        {
            t.printStackTrace();
            fail("Failed to parse patient id: " + t.getMessage());
        }
    }

    @Test
    public void testCommunityIdParse()
    {
        try
        {
            String toParse = "4567^^^&2.16.840.1.113883.192.168.127.12&ISO";
            String expectedHomeCommunity = "2.16.840.1.113883.192.168.127.12";

            String parsedHomeCommunity = PatientIdFormatUtil.parseCommunityId(toParse);
            assertNotNull("Parsed home community was null", parsedHomeCommunity);
            assertEquals("Parsed home community  was incorrect", expectedHomeCommunity, parsedHomeCommunity);

            toParse = "4567^^^";
            parsedHomeCommunity = PatientIdFormatUtil.parseCommunityId(toParse);
            assertNull("Parsed home community was not null when invalid", parsedHomeCommunity);

            toParse = "4567";
            parsedHomeCommunity = PatientIdFormatUtil.parseCommunityId(toParse);
            assertNull("Parsed home community was not null when not HL7 formatted", parsedHomeCommunity);

            toParse = null;
            parsedHomeCommunity = PatientIdFormatUtil.parseCommunityId(toParse);
            assertNull("Parsed home community was not null when id was null", parsedHomeCommunity);

        }
        catch(Throwable t)
        {
            t.printStackTrace();
            fail("Failed to parse community id: " + t.getMessage());
        }
    }

    @Test
    public void testPatientIdFormat()
    {
        try
        {
            String patientId = "1234";
            String homeCommunityId = "2.16.840.1.113883.192.168.127.12";
            String expected = "1234^^^&2.16.840.1.113883.192.168.127.12&ISO";

            String formatted = PatientIdFormatUtil.hl7EncodePatientId(patientId, homeCommunityId);
            assertNotNull("Formatted - id was null", formatted);
            assertEquals("Formatted - id was incorrect", expected, formatted);

        }
        catch(Throwable t)
        {
            t.printStackTrace();
            fail("Failed to parse patient id: " + t.getMessage());
        }
    }

}
{'fraction_non_alphanumeric': 0.09995628733789888, 'fraction_numerical': 0.04852105493224537, 'mean_word_length': 2.3191489361702127, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 10, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4160172', 'n_tokens_mistral': 2098, 'n_tokens_neox': 1816, 'n_words': 478}