Search in sources :

Example 86 with Organization

use of org.hl7.fhir.r4.model.Organization in project nia-patient-switching-standard-adaptor by NHSDigital.

the class AgentDirectoryMapperTest method mapAgentDirectoryOnlyAgentOrganizationWithValidIdentifier.

@Test
public void mapAgentDirectoryOnlyAgentOrganizationWithValidIdentifier() {
    var agentDirectory = unmarshallAgentDirectoryElement("agent_org_valid_identifier_example.xml");
    List mappedAgents = agentDirectoryMapper.mapAgentDirectory(agentDirectory);
    assertThat(mappedAgents.size()).isEqualTo(1);
    var organization = (Organization) mappedAgents.get(0);
    assertThat(organization.getId()).isEqualTo("1D9BDC28-50AB-440D-B421-0E5E049526FA");
    assertThat(organization.getMeta().getProfile().get(0).getValue()).isEqualTo(ORG_META_PROFILE);
    assertThat(organization.getName()).isEqualTo("The Health Centre");
    assertThat(organization.getIdentifierFirstRep().getSystem()).isEqualTo(ORG_IDENTIFIER_SYSTEM);
    assertThat(organization.getIdentifierFirstRep().getValue()).isEqualTo("A81001");
    assertThat(organization.getTelecom().size()).isEqualTo(0);
    assertThat(organization.getAddress().size()).isEqualTo(0);
}
Also used : Organization(org.hl7.fhir.dstu3.model.Organization) List(java.util.List) Test(org.junit.jupiter.api.Test)

Example 87 with Organization

use of org.hl7.fhir.r4.model.Organization in project nia-patient-switching-standard-adaptor by NHSDigital.

the class AgentDirectoryMapperTest method mapAgentDirectoryOnlyAgentOrganizationNoOptionalFields.

@Test
public void mapAgentDirectoryOnlyAgentOrganizationNoOptionalFields() {
    var agentDirectory = unmarshallAgentDirectoryElement("agent_org_only_example.xml");
    List mappedAgents = agentDirectoryMapper.mapAgentDirectory(agentDirectory);
    assertThat(mappedAgents.size()).isEqualTo(1);
    var organization = (Organization) mappedAgents.get(0);
    assertThat(organization.getId()).isEqualTo("1D9BDC28-50AB-440D-B421-0E5E049526FA");
    assertThat(organization.getMeta().getProfile().get(0).getValue()).isEqualTo(ORG_META_PROFILE);
    assertThat(organization.getName()).isEqualTo("The Health Centre");
    assertThat(organization.getIdentifier().size()).isEqualTo(0);
    assertThat(organization.getTelecom().size()).isEqualTo(0);
    assertThat(organization.getAddress().size()).isEqualTo(0);
}
Also used : Organization(org.hl7.fhir.dstu3.model.Organization) List(java.util.List) Test(org.junit.jupiter.api.Test)

Example 88 with Organization

use of org.hl7.fhir.r4.model.Organization in project nia-patient-switching-standard-adaptor by NHSDigital.

the class AgentDirectoryMapperTest method mapAgentDirectoryOnlyAgentOrganizationWithWPAddress.

@Test
public void mapAgentDirectoryOnlyAgentOrganizationWithWPAddress() {
    var agentDirectory = unmarshallAgentDirectoryElement("agent_org_wp_address_example.xml");
    List mappedAgents = agentDirectoryMapper.mapAgentDirectory(agentDirectory);
    assertThat(mappedAgents.size()).isEqualTo(1);
    var organization = (Organization) mappedAgents.get(0);
    assertThat(organization.getId()).isEqualTo("1D9BDC28-50AB-440D-B421-0E5E049526FA");
    assertThat(organization.getMeta().getProfile().get(0).getValue()).isEqualTo(ORG_META_PROFILE);
    assertThat(organization.getName()).isEqualTo("The Health Centre");
    assertThat(organization.getIdentifier().size()).isEqualTo(0);
    assertThat(organization.getTelecom().size()).isEqualTo(0);
    assertAddress(organization.getAddressFirstRep());
}
Also used : Organization(org.hl7.fhir.dstu3.model.Organization) List(java.util.List) Test(org.junit.jupiter.api.Test)

Example 89 with Organization

use of org.hl7.fhir.r4.model.Organization in project gpconnect-demonstrator by nhsconnect.

the class OrganizationResourceProvider method getOrganizationsByODSCode.

@Search
public List<Organization> getOrganizationsByODSCode(@RequiredParam(name = Organization.SP_IDENTIFIER) TokenParam tokenParam, @Sort SortSpec sort, @Count Integer count) {
    if (StringUtils.isBlank(tokenParam.getSystem()) || StringUtils.isBlank(tokenParam.getValue())) {
        throw OperationOutcomeFactory.buildOperationOutcomeException(new InvalidRequestException("Missing identifier token"), SystemCode.INVALID_PARAMETER, IssueType.INVALID);
    }
    if (tokenParam.getSystem().equals(SystemURL.ID_ODS_ORGANIZATION_CODE) || tokenParam.getSystem().equals(SystemURL.ID_ODS_OLD_ORGANIZATION_CODE)) {
        List<Organization> organizationDetails = convertOrganizaitonDetailsListToOrganizationList(organizationSearch.findOrganizationDetailsByOrgODSCode(tokenParam.getValue()));
        if (organizationDetails.isEmpty()) {
            return null;
        }
        if (sort != null && sort.getParamName().equalsIgnoreCase(Location.SP_STATUS)) {
            Collections.sort(organizationDetails, (Organization a, Organization b) -> {
                String aStatus = a.getName();
                String bStatus = b.getName();
                if (aStatus == null && bStatus == null) {
                    return 0;
                }
                if (aStatus == null && bStatus != null) {
                    return -1;
                }
                if (aStatus != null && bStatus == null) {
                    return 1;
                }
                return aStatus.compareToIgnoreCase(bStatus);
            });
        }
        // Update startIndex if we do paging
        return count != null ? organizationDetails.subList(0, count) : organizationDetails;
    } else {
        throw OperationOutcomeFactory.buildOperationOutcomeException(new InvalidRequestException("Invalid system code"), SystemCode.INVALID_PARAMETER, IssueType.INVALID);
    }
}
Also used : Organization(org.hl7.fhir.dstu3.model.Organization) InvalidRequestException(ca.uhn.fhir.rest.server.exceptions.InvalidRequestException) Search(ca.uhn.fhir.rest.annotation.Search)

Example 90 with Organization

use of org.hl7.fhir.r4.model.Organization in project gpconnect-demonstrator by nhsconnect.

the class PatientResourceProvider method setStaticPatientData.

private Patient setStaticPatientData(Patient patient) {
    patient.setLanguage(("en-GB"));
    patient.addExtension(createCodingExtension("CG", "Greek Cypriot", SystemURL.CS_CC_ETHNIC_CATEGORY, SystemURL.SD_CC_EXT_ETHNIC_CATEGORY));
    patient.addExtension(createCodingExtension("SomeSnomedCode", "Some Snomed Code", SystemURL.CS_CC_RELIGIOUS_AFFILI, SystemURL.SD_CC_EXT_RELIGIOUS_AFFILI));
    patient.addExtension(new Extension(SystemURL.SD_PATIENT_CADAVERIC_DON, new BooleanType(false)));
    patient.addExtension(createCodingExtension("H", "UK Resident", SystemURL.CS_CC_RESIDENTIAL_STATUS, SystemURL.SD_CC_EXT_RESIDENTIAL_STATUS));
    patient.addExtension(createCodingExtension("3", "To pay hotel fees only", SystemURL.CS_CC_TREATMENT_CAT, SystemURL.SD_CC_EXT_TREATMENT_CAT));
    Extension nhsCommExtension = new Extension();
    nhsCommExtension.setUrl(SystemURL.SD_CC_EXT_NHS_COMMUNICATION);
    nhsCommExtension.addExtension(createCodingExtension("en", "English", SystemURL.CS_CC_HUMAN_LANG, SystemURL.SD_CC_EXT_COMM_LANGUAGE));
    nhsCommExtension.addExtension(new Extension(SystemURL.SD_CC_COMM_PREFERRED, new BooleanType(false)));
    nhsCommExtension.addExtension(createCodingExtension("RWR", "Received written", SystemURL.CS_CC_LANG_ABILITY_MODE, SystemURL.SD_CC_MODE_OF_COMM));
    nhsCommExtension.addExtension(createCodingExtension("E", "Excellent", SystemURL.CS_CC_LANG_ABILITY_PROFI, SystemURL.SD_CC_COMM_PROFICIENCY));
    nhsCommExtension.addExtension(new Extension(SystemURL.SD_CC_INTERPRETER_REQUIRED, new BooleanType(false)));
    patient.addExtension(nhsCommExtension);
    Identifier localIdentifier = new Identifier();
    localIdentifier.setUse(IdentifierUse.USUAL);
    localIdentifier.setSystem(SystemURL.ID_LOCAL_PATIENT_IDENTIFIER);
    localIdentifier.setValue("123456");
    CodeableConcept liType = new CodeableConcept();
    Coding liTypeCoding = new Coding();
    liTypeCoding.setCode("EN");
    liTypeCoding.setDisplay("Employer number");
    liTypeCoding.setSystem(SystemURL.VS_IDENTIFIER_TYPE);
    liType.addCoding(liTypeCoding);
    localIdentifier.setType(liType);
    localIdentifier.setAssigner(new Reference("Organization/1"));
    patient.addIdentifier(localIdentifier);
    Calendar calendar = Calendar.getInstance();
    calendar.set(2017, 1, 1);
    DateTimeDt endDate = new DateTimeDt(calendar.getTime());
    calendar.set(2016, 1, 1);
    DateTimeDt startDate = new DateTimeDt(calendar.getTime());
    Period pastPeriod = new Period().setStart(calendar.getTime()).setEnd(calendar.getTime());
    patient.addName().setFamily("AnotherOfficialFamilyName").addGiven("AnotherOfficialGivenName").setUse(NameUse.OFFICIAL).setPeriod(pastPeriod);
    patient.addName().setFamily("AdditionalFamily").addGiven("AdditionalGiven").setUse(NameUse.TEMP);
    patient.addTelecom(staticElHelper.getValidTelecom());
    patient.addAddress(staticElHelper.getValidAddress());
    return patient;
}
Also used : Extension(org.hl7.fhir.dstu3.model.Extension) Identifier(org.hl7.fhir.dstu3.model.Identifier) DateTimeDt(ca.uhn.fhir.model.primitive.DateTimeDt) Coding(org.hl7.fhir.dstu3.model.Coding) Reference(org.hl7.fhir.dstu3.model.Reference) Calendar(java.util.Calendar) BooleanType(org.hl7.fhir.dstu3.model.BooleanType) Period(org.hl7.fhir.dstu3.model.Period) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Aggregations

Test (org.junit.jupiter.api.Test)101 Organization (org.hl7.fhir.dstu3.model.Organization)90 Organization (org.hl7.fhir.r4.model.Organization)69 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)41 Resource (org.hl7.fhir.r4.model.Resource)38 ArrayList (java.util.ArrayList)34 List (java.util.List)33 Reference (org.hl7.fhir.r4.model.Reference)33 Identifier (org.hl7.fhir.r4.model.Identifier)30 Bundle (org.hl7.fhir.dstu3.model.Bundle)27 UUID (java.util.UUID)26 IGenericClient (ca.uhn.fhir.rest.client.api.IGenericClient)25 Patient (org.hl7.fhir.r4.model.Patient)25 IdType (org.hl7.fhir.dstu3.model.IdType)24 Bundle (org.hl7.fhir.r4.model.Bundle)24 Coding (org.hl7.fhir.r4.model.Coding)24 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)19 ContactPoint (org.hl7.fhir.r4.model.ContactPoint)17 Reference (org.hl7.fhir.dstu3.model.Reference)16 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)16