Search in sources :

Example 11 with Organization

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

the class MedicationRequestResourceProvider method getDispenseRequestComponent.

private MedicationRequestDispenseRequestComponent getDispenseRequestComponent(MedicationRequestDetail requestDetail) {
    MedicationRequestDispenseRequestComponent dispenseRequest = new MedicationRequestDispenseRequestComponent();
    Period period = new Period().setStart(requestDetail.getDispenseRequestStartDate());
    if (requestDetail.getDispenseRequestEndDate() != null) {
        period.setEnd(requestDetail.getDispenseRequestEndDate());
    }
    dispenseRequest.setValidityPeriod(period);
    setDispenseQuantity(dispenseRequest, requestDetail);
    Duration duration = new Duration();
    duration.setSystem(SystemURL.CS_UNITS_OF_MEASURE);
    duration.setCode("d");
    duration.setValue(requestDetail.getExpectedSupplyDuration());
    duration.setUnit("day");
    // TODO - spec needs to clarify whether this should be populated or not
    dispenseRequest.setExpectedSupplyDuration(duration);
    dispenseRequest.setPerformer(new Reference(new IdType("Organization", requestDetail.getDispenseRequestOrganizationId())));
    return dispenseRequest;
}
Also used : MedicationRequestDispenseRequestComponent(org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestDispenseRequestComponent)

Example 12 with Organization

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

the class MedicationRequestResourceProvider method getRequesterComponent.

// TODO - spec needs to clarify whether this should be populated or not
private MedicationRequestRequesterComponent getRequesterComponent(MedicationRequestDetail requestDetail) {
    MedicationRequestRequesterComponent requesterComponent = new MedicationRequestRequesterComponent();
    switch(requestDetail.getRequesterUrl()) {
        case (SystemURL.SD_GPC_PATIENT):
            requesterComponent.setAgent(new Reference(new IdType("Patient", requestDetail.getRequesterId())));
            break;
        case (SystemURL.SD_GPC_PRACTITIONER):
            requesterComponent.setAgent(new Reference(new IdType("Practitioner", requestDetail.getRequesterId())));
            break;
        case (SystemURL.SD_GPC_ORGANIZATION):
            requesterComponent.setAgent(new Reference(new IdType("Organization", requestDetail.getRequesterId())));
            break;
        default:
            break;
    }
    requesterComponent.setOnBehalfOf(new Reference(new IdType("Organization", requestDetail.getDispenseRequestOrganizationId())));
    return requesterComponent;
}
Also used : MedicationRequestRequesterComponent(org.hl7.fhir.dstu3.model.MedicationRequest.MedicationRequestRequesterComponent)

Example 13 with Organization

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

the class OrganizationResourceProvider method convertOrganizationDetailsToOrganization.

public Organization convertOrganizationDetailsToOrganization(OrganizationDetails organizationDetails) {
    String mapKey = String.format("%s", organizationDetails.getOrgCode());
    Identifier identifier = new Identifier().setSystem(SystemURL.ID_ODS_ORGANIZATION_CODE).setValue(organizationDetails.getOrgCode());
    Organization organization = new Organization().setName(organizationDetails.getOrgName()).addIdentifier(identifier);
    String resourceId = String.valueOf(organizationDetails.getId());
    String versionId = String.valueOf(organizationDetails.getLastUpdated().getTime());
    String resourceType = organization.getResourceType().toString();
    IdType id = new IdType(resourceType, resourceId, versionId);
    organization.setId(id);
    organization.getMeta().setVersionId(versionId);
    organization.getMeta().setLastUpdated(organizationDetails.getLastUpdated());
    organization.getMeta().addProfile(SystemURL.SD_GPC_ORGANIZATION);
    organization = addAdditionalProperties(organization);
    return organization;
}
Also used : Identifier(org.hl7.fhir.dstu3.model.Identifier) Organization(org.hl7.fhir.dstu3.model.Organization) IdType(org.hl7.fhir.dstu3.model.IdType)

Example 14 with Organization

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

the class OrganizationResourceProvider method addAdditionalProperties.

// Adding in additional properties manually for now so we can test in the
// Test Suite
private Organization addAdditionalProperties(Organization organization) {
    Coding orgTypeCode = new Coding();
    orgTypeCode.setCode("dept");
    orgTypeCode.setDisplay("Hospital Department");
    orgTypeCode.setSystem(SystemURL.VS_CC_ORGANISATION_TYPE);
    organization.addTelecom(getValidTelecom());
    organization.addAddress(getValidAddress());
    // organization.addContact(getValidContact());
    CodeableConcept orgType = new CodeableConcept();
    orgType.addCoding(orgTypeCode);
    organization.addType(orgType);
    organization.addExtension().setUrl(SystemURL.SD_EXTENSION_CC_MAIN_LOCATION);
    return organization;
}
Also used : Coding(org.hl7.fhir.dstu3.model.Coding) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Example 15 with Organization

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

the class OrganizationResourceProvider method convertOrganizaitonDetailsListToOrganizationList.

private List<Organization> convertOrganizaitonDetailsListToOrganizationList(List<OrganizationDetails> organizationDetails) {
    Map<String, Organization> map = new HashMap<>();
    for (OrganizationDetails organizationDetail : organizationDetails) {
        String mapKey = String.format("%s", organizationDetail.getOrgCode());
        if (map.containsKey(mapKey)) {
            continue;
        }
        Identifier identifier = new Identifier().setSystem(SystemURL.ID_ODS_ORGANIZATION_CODE).setValue(organizationDetail.getOrgCode());
        Organization organization = new Organization().setName(organizationDetail.getOrgName()).addIdentifier(identifier);
        String resourceId = String.valueOf(organizationDetail.getId());
        String versionId = String.valueOf(organizationDetail.getLastUpdated().getTime());
        String resourceType = organization.getResourceType().toString();
        IdType id = new IdType(resourceType, resourceId, versionId);
        organization.setId(id);
        organization.getMeta().setVersionId(versionId);
        organization.getMeta().setLastUpdated(organizationDetail.getLastUpdated());
        organization.getMeta().addProfile(SystemURL.SD_GPC_ORGANIZATION);
        organization = addAdditionalProperties(organization);
        map.put(mapKey, organization);
    }
    return new ArrayList<>(map.values());
}
Also used : Organization(org.hl7.fhir.dstu3.model.Organization) Identifier(org.hl7.fhir.dstu3.model.Identifier) HashMap(java.util.HashMap) OrganizationDetails(uk.gov.hscic.model.organization.OrganizationDetails) ArrayList(java.util.ArrayList) IdType(org.hl7.fhir.dstu3.model.IdType)

Aggregations

Organization (org.hl7.fhir.dstu3.model.Organization)6 IdType (org.hl7.fhir.dstu3.model.IdType)5 OrganizationDetails (uk.gov.hscic.model.organization.OrganizationDetails)5 Identifier (org.hl7.fhir.dstu3.model.Identifier)4 HashMap (java.util.HashMap)3 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)3 Coding (org.hl7.fhir.dstu3.model.Coding)3 Reference (org.hl7.fhir.dstu3.model.Reference)3 ResourceNotFoundException (ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException)2 ArrayList (java.util.ArrayList)2 BundleEntryComponent (org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent)2 Location (org.hl7.fhir.dstu3.model.Location)2 BookingOrgDetail (uk.gov.hscic.model.appointment.BookingOrgDetail)2 SlotDetail (uk.gov.hscic.model.appointment.SlotDetail)2 LocationDetails (uk.gov.hscic.model.location.LocationDetails)2 DateTimeDt (ca.uhn.fhir.model.primitive.DateTimeDt)1 Search (ca.uhn.fhir.rest.annotation.Search)1 ForbiddenOperationException (ca.uhn.fhir.rest.server.exceptions.ForbiddenOperationException)1 InvalidRequestException (ca.uhn.fhir.rest.server.exceptions.InvalidRequestException)1 UnprocessableEntityException (ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException)1