ca.uhn.fhir.rest.api.server.RequestDetails Java Examples

The following examples show how to use ca.uhn.fhir.rest.api.server.RequestDetails. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LibraryOperationsProvider.java    From cqf-ruler with Apache License 2.0 8 votes vote down vote up
@Operation(name = "$refresh-generated-content", type = Library.class)
public MethodOutcome refreshGeneratedContent(HttpServletRequest theRequest, RequestDetails theRequestDetails,
        @IdParam IdType theId) {
    Library theResource = this.libraryResourceProvider.getDao().read(theId);
    //this.formatCql(theResource);

    ModelManager modelManager = this.getModelManager();
    LibraryManager libraryManager = this.getLibraryManager(modelManager);

    CqlTranslator translator = this.dataRequirementsProvider.getTranslator(theResource, libraryManager, modelManager);
    if (translator.getErrors().size() > 0) {
        throw new RuntimeException("Errors during library compilation.");
    }
    
    this.dataRequirementsProvider.ensureElm(theResource, translator);
    this.dataRequirementsProvider.ensureRelatedArtifacts(theResource, translator, this);
    this.dataRequirementsProvider.ensureDataRequirements(theResource, translator);

    Narrative n = this.narrativeProvider.getNarrative(this.libraryResourceProvider.getContext(), theResource);
    theResource.setText(n);

    return this.libraryResourceProvider.update(theRequest, theResource, theId,
            theRequestDetails.getConditionalUrl(RestOperationTypeEnum.UPDATE), theRequestDetails);
}
 
Example #2
Source File: TerminologyLoaderTestIT.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Test
public void testLoadLoinc() throws Exception {
    ourLog.info("TEST = testLoadLoinc()");
    ByteArrayOutputStream bos1 = new ByteArrayOutputStream();
    ZipOutputStream zos1 = new ZipOutputStream(bos1);
    addEntry(zos1, "/loinc/", "loinc.csv");
    zos1.close();
    ourLog.info("ZIP file has {} bytes", bos1.toByteArray().length);

    ByteArrayOutputStream bos2 = new ByteArrayOutputStream();
    ZipOutputStream zos2 = new ZipOutputStream(bos2);
    addEntry(zos2, "/loinc/", "LOINC_2.54_MULTI-AXIAL_HIERARCHY.CSV");
    zos2.close();
    ourLog.info("ZIP file has {} bytes", bos2.toByteArray().length);

    RequestDetails details = mock(RequestDetails.class);
    when(codeSvc.findBySystem("http://loinc.org")).thenReturn(new CodeSystemEntity());
    mySvc.loadLoinc(list(bos1.toByteArray(), bos2.toByteArray()), details);

    verify(codeSvc).storeNewCodeSystemVersion( myCsvCaptor.capture(), any(RequestDetails.class));

    CodeSystemEntity ver = myCsvCaptor.getValue();
    ConceptEntity code = ver.getConcepts().iterator().next();
    assertEquals("10013-1", code.getCode());

}
 
Example #3
Source File: EndpointProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Update
public MethodOutcome updateEndpoint(HttpServletRequest theRequest, @ResourceParam Endpoint endpoint, @IdParam IdType theId, @ConditionalUrlParam String theConditional, RequestDetails theRequestDetails) {

	resourcePermissionProvider.checkPermission("update");
    MethodOutcome method = new MethodOutcome();
    method.setCreated(true);
    OperationOutcome opOutcome = new OperationOutcome();

    method.setOperationOutcome(opOutcome);

try {
    Endpoint newEndpoint = endpointDao.create(ctx, endpoint, theId, theConditional);
    method.setId(newEndpoint.getIdElement());
    method.setResource(newEndpoint);

} catch (Exception ex) {

    ProviderResponseLibrary.handleException(method,ex);
}


    return method;
}
 
Example #4
Source File: DocumentReferenceProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Update
public MethodOutcome update(HttpServletRequest theRequest, @ResourceParam DocumentReference documentReference, @IdParam IdType theId, @ConditionalUrlParam String theConditional, RequestDetails theRequestDetails) {
	resourcePermissionProvider.checkPermission("update");
    MethodOutcome method = new MethodOutcome();
    method.setCreated(true);
    OperationOutcome opOutcome = new OperationOutcome();
    method.setOperationOutcome(opOutcome);
    try {
    DocumentReference newDocumentReference = documentReferenceDao.create(ctx,documentReference, theId, theConditional);
    method.setId(newDocumentReference.getIdElement());
    method.setResource(newDocumentReference);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }


    return method;
}
 
Example #5
Source File: MedicationStatementProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Update
public MethodOutcome update(HttpServletRequest theRequest, @ResourceParam MedicationStatement statement, @IdParam IdType theId, @ConditionalUrlParam String theConditional, RequestDetails theRequestDetails) {

	resourcePermissionProvider.checkPermission("update");
    MethodOutcome method = new MethodOutcome();
    method.setCreated(true);
    OperationOutcome opOutcome = new OperationOutcome();

    method.setOperationOutcome(opOutcome);

    try {
    MedicationStatement newMedicationStatement = statementDao.create(ctx,statement, theId, theConditional);
    method.setId(newMedicationStatement.getIdElement());
    method.setResource(newMedicationStatement);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }



    return method;
}
 
Example #6
Source File: ScheduleProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Update
public MethodOutcome updateSchedule(HttpServletRequest theRequest, @ResourceParam Schedule schedule, @IdParam IdType theId, @ConditionalUrlParam String theConditional, RequestDetails theRequestDetails) {

	resourcePermissionProvider.checkPermission("update");
    MethodOutcome method = new MethodOutcome();
    method.setCreated(true);
    OperationOutcome opOutcome = new OperationOutcome();

    method.setOperationOutcome(opOutcome);

    try {
        Schedule existingSchedule = scheduleDao.create(ctx, schedule, theId, theConditional);
        method.setId(existingSchedule.getIdElement());
        method.setResource(existingSchedule);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }


    return method;
}
 
Example #7
Source File: ListProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Update
public MethodOutcome updateList(HttpServletRequest theRequest, @ResourceParam ListResource list, @IdParam IdType theId, @ConditionalUrlParam String theConditional, RequestDetails theRequestDetails) {

	resourcePermissionProvider.checkPermission("update");
    MethodOutcome method = new MethodOutcome();
    method.setCreated(true);
    OperationOutcome opOutcome = new OperationOutcome();

    method.setOperationOutcome(opOutcome);

try {
    log.info(theId.getId());
    ListResource newList = listDao.create(ctx, list, theId, theConditional);
    method.setId(newList.getIdElement());
    method.setResource(newList);

} catch (Exception ex) {

    ProviderResponseLibrary.handleException(method,ex);
}


    return method;
}
 
Example #8
Source File: OrganizationProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Update
public MethodOutcome updateOrganization(HttpServletRequest theRequest,@ResourceParam Organization organization, @IdParam IdType theId, @ConditionalUrlParam String theConditional, RequestDetails theRequestDetails) {

	resourcePermissionProvider.checkPermission("update");
    MethodOutcome method = new MethodOutcome();
    method.setCreated(true);
    OperationOutcome opOutcome = new OperationOutcome();

    method.setOperationOutcome(opOutcome);

    try {
            Organization newOrganization = organisationDao.create(ctx, organization, theId, theConditional);
            method.setId(newOrganization.getIdElement());
            method.setResource(newOrganization);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }



    return method;
}
 
Example #9
Source File: ServerInterceptor.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Override
public boolean incomingRequestPostProcessed(RequestDetails theRequestDetails, HttpServletRequest theRequest, HttpServletResponse theResponse) throws AuthenticationException {
    log.trace("incomingRequestPostProcessed "+theRequest.getMethod());
    Enumeration<String> headers = theRequest.getHeaderNames();
    while (headers.hasMoreElements()) {
        String header = headers.nextElement();
        log.debug("Header  = "+ header + "="+ theRequest.getHeader(header));
    }
    // Perform any string substitutions from the message format
    StrLookup<?> lookup = new MyLookup(theRequest, theRequestDetails);
    StrSubstitutor subs = new StrSubstitutor(lookup, "${", "}", '\\');

    // Actually log the line
    String myMessageFormat = "httpVerb[${requestVerb}] Source[${remoteAddr}] Operation[${operationType} ${idOrResourceName}] UA[${requestHeader.user-agent}] Params[${requestParameters}] RequestId[${requestHeader.x-request-id}] ForwardedFor[${requestHeader.x-forwarded-for}] ForwardedHost[${requestHeader.x-forwarded-host}] CorrelationId[] ProcessingTime[]  ResponseCode[]";

    String line = subs.replace(myMessageFormat);
    log.info(line);

    return true;
}
 
Example #10
Source File: AppointmentProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Update
public MethodOutcome updateAppointment(HttpServletRequest theRequest, @ResourceParam Appointment appointment, @IdParam IdType theId, @ConditionalUrlParam String theConditional, RequestDetails theRequestDetails) {

	resourcePermissionProvider.checkPermission("update");
	
    MethodOutcome method = new MethodOutcome();
    method.setCreated(true);
    OperationOutcome opOutcome = new OperationOutcome();

    method.setOperationOutcome(opOutcome);

    try {
        Appointment newAppointment = appointmentDao.create(ctx, appointment, theId, theConditional);
        method.setId(newAppointment.getIdElement());
        method.setResource(newAppointment);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }


    return method;
}
 
Example #11
Source File: MedicationDispenseProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Update
public MethodOutcome update(HttpServletRequest theRequest, @ResourceParam MedicationDispense dispense, @IdParam IdType theId, @ConditionalUrlParam String theConditional, RequestDetails theRequestDetails) {

	resourcePermissionProvider.checkPermission("update");
    MethodOutcome method = new MethodOutcome();
    method.setCreated(true);
    OperationOutcome opOutcome = new OperationOutcome();

    method.setOperationOutcome(opOutcome);

    try {
    MedicationDispense newMedicationDispense = dispenseDao.create(ctx,dispense, theId, theConditional);
    method.setId(newMedicationDispense.getIdElement());
    method.setResource(newMedicationDispense);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }



    return method;
}
 
Example #12
Source File: MedicationAdministrationProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Update
public MethodOutcome update(HttpServletRequest theRequest, @ResourceParam MedicationAdministration administration, @IdParam IdType theId, @ConditionalUrlParam String theConditional, RequestDetails theRequestDetails) {

	resourcePermissionProvider.checkPermission("update");
    MethodOutcome method = new MethodOutcome();
    method.setCreated(true);
    OperationOutcome opOutcome = new OperationOutcome();

    method.setOperationOutcome(opOutcome);

    try {
    MedicationAdministration newMedicationAdministration = administrationDao.create(ctx,administration, theId, theConditional);
    method.setId(newMedicationAdministration.getIdElement());
    method.setResource(newMedicationAdministration);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }



    return method;
}
 
Example #13
Source File: PatientProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Update
public MethodOutcome update(HttpServletRequest theRequest, @ResourceParam Patient patient, @IdParam IdType theId,@ConditionalUrlParam String theConditional, RequestDetails theRequestDetails) {

    log.debug("Update Patient Provider called");
    
    resourcePermissionProvider.checkPermission("update");

    MethodOutcome method = new MethodOutcome();
    method.setCreated(true);
    OperationOutcome opOutcome = new OperationOutcome();

    method.setOperationOutcome(opOutcome);
    Patient newPatient = null;
    try {
        newPatient = patientDao.update(ctx, patient, theId, theConditional);
    } catch (OperationOutcomeException ex) {
        ProviderResponseLibrary.handleException(method,ex);
    }
    method.setId(newPatient.getIdElement());
    method.setResource(newPatient);


    log.debug("called update Patient method");

    return method;
}
 
Example #14
Source File: ConditionProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Update
public MethodOutcome update(HttpServletRequest theRequest, @ResourceParam Condition condition, @IdParam IdType theId, @ConditionalUrlParam String theConditional, RequestDetails theRequestDetails) {
	resourcePermissionProvider.checkPermission("update");

    MethodOutcome method = new MethodOutcome();
    method.setCreated(true);
    OperationOutcome opOutcome = new OperationOutcome();

    method.setOperationOutcome(opOutcome);

    try {
        Condition newCondition = conditionDao.create(ctx, condition, theId, theConditional);
        method.setId(newCondition.getIdElement());
        method.setResource(newCondition);
    } catch (BaseServerResponseException srv) {
        // HAPI Exceptions pass through
        throw srv;
    } catch(Exception ex) {
        ProviderResponseLibrary.handleException(method,ex);
    }


    return method;
}
 
Example #15
Source File: LocationProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Update
public MethodOutcome updateLocation(HttpServletRequest theRequest, @ResourceParam Location location, @IdParam IdType theId, @ConditionalUrlParam String theConditional, RequestDetails theRequestDetails) {

	resourcePermissionProvider.checkPermission("update");
    MethodOutcome method = new MethodOutcome();
    method.setCreated(true);
    OperationOutcome opOutcome = new OperationOutcome();

    method.setOperationOutcome(opOutcome);

try {
    Location newLocation = locationDao.create(ctx, location, theId, theConditional);
    method.setId(newLocation.getIdElement());
    method.setResource(newLocation);

} catch (Exception ex) {

    ProviderResponseLibrary.handleException(method,ex);
}


    return method;
}
 
Example #16
Source File: EncounterProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Update
public MethodOutcome update(HttpServletRequest theRequest, @ResourceParam Encounter encounter, @IdParam IdType theId, @ConditionalUrlParam String theConditional, RequestDetails theRequestDetails) {

	resourcePermissionProvider.checkPermission("update");
    MethodOutcome method = new MethodOutcome();
    method.setCreated(true);
    OperationOutcome opOutcome = new OperationOutcome();

    method.setOperationOutcome(opOutcome);

    try {
        Encounter newEncounter = encounterDao.create(ctx, encounter, theId, theConditional);
        method.setId(newEncounter.getIdElement());
        method.setResource(newEncounter);
    } catch (Exception ex) {
        ProviderResponseLibrary.handleException(method,ex);
    }


    return method;
}
 
Example #17
Source File: CompositionProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Update
public MethodOutcome update(HttpServletRequest theRequest, @ResourceParam Composition composition, @IdParam IdType theId, @ConditionalUrlParam String theConditional, RequestDetails theRequestDetails) {
	resourcePermissionProvider.checkPermission("update");
	
    MethodOutcome method = new MethodOutcome();
    method.setCreated(true);
    OperationOutcome opOutcome = new OperationOutcome();
    method.setOperationOutcome(opOutcome);
    try {
        Composition newComposition = compositionDao.create(ctx,composition, theId, theConditional);
        method.setId(newComposition.getIdElement());
        method.setResource(newComposition);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }


    return method;
}
 
Example #18
Source File: ImmunizationProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Update
public MethodOutcome update(HttpServletRequest theRequest, @ResourceParam Immunization immunisation, @IdParam IdType theId, @ConditionalUrlParam String theConditional, RequestDetails theRequestDetails) {
	resourcePermissionProvider.checkPermission("update");
    MethodOutcome method = new MethodOutcome();
    method.setCreated(true);
    OperationOutcome opOutcome = new OperationOutcome();
    method.setOperationOutcome(opOutcome);
    try {
        Immunization newImmunisation = immunisationDao.create(ctx,immunisation, theId, theConditional);
        method.setId(newImmunisation.getIdElement());
        method.setResource(newImmunisation);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }


    return method;
}
 
Example #19
Source File: MedicationRequestProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Update
public MethodOutcome update(HttpServletRequest theRequest, @ResourceParam MedicationRequest prescription, @IdParam IdType theId, @ConditionalUrlParam String theConditional, RequestDetails theRequestDetails) {

	resourcePermissionProvider.checkPermission("update");
    MethodOutcome method = new MethodOutcome();
    method.setCreated(true);
    OperationOutcome opOutcome = new OperationOutcome();

    method.setOperationOutcome(opOutcome);

    try {
    MedicationRequest newMedicationRequest = prescriptionDao.create(ctx,prescription, theId, theConditional);
    method.setId(newMedicationRequest.getIdElement());
    method.setResource(newMedicationRequest);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }



    return method;
}
 
Example #20
Source File: TerminologyLoaderTest.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Test
public void testLoadSnomedCtBadInput() throws Exception {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ZipOutputStream zos = new ZipOutputStream(bos);
    addEntry(zos, "/sct/", "sct2_StatedRelationship_Full_INT_20160131.txt");
    zos.close();

    ourLog.info("ZIP file has {} bytes", bos.toByteArray().length);
    //when(mySvc.newTx()).thenReturn(mock(EntityTransaction.class));

    RequestDetails details = mock(RequestDetails.class);
    try {
        mySvc.loadSnomedCt(Collections.singletonList(bos.toByteArray()), details);
        fail();
    } catch (InvalidRequestException e) {
        assertEquals("Invalid input zip file, expected zip to contain the following name fragments: [codeSystem/sct2_Description_Full-en, codeSystem/sct2_Relationship_Full, codeSystem/sct2_Concept_Full_] but found: []", e.getMessage());
    }
}
 
Example #21
Source File: ReferralRequestProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Update
public MethodOutcome updateReferralRequest(HttpServletRequest theRequest, @ResourceParam ReferralRequest referral, @IdParam IdType theId, @ConditionalUrlParam String theConditional, RequestDetails theRequestDetails) {

	resourcePermissionProvider.checkPermission("update");
    MethodOutcome method = new MethodOutcome();
    method.setCreated(true);
    OperationOutcome opOutcome = new OperationOutcome();

    method.setOperationOutcome(opOutcome);

    try {
        ReferralRequest newReferralRequest = referralDao.create(ctx, referral, theId, theConditional);
        method.setId(newReferralRequest.getIdElement());
        method.setResource(newReferralRequest);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }

    return method;
}
 
Example #22
Source File: ObservationProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Update
public MethodOutcome update(HttpServletRequest theRequest, @ResourceParam Observation observation, @IdParam IdType theId,@ConditionalUrlParam String theConditional, RequestDetails theRequestDetails) {
	resourcePermissionProvider.checkPermission("update");
    MethodOutcome method = new MethodOutcome();
    method.setCreated(true);
    OperationOutcome opOutcome = new OperationOutcome();
    	
    method.setOperationOutcome(opOutcome);
    try {

        Observation newObservation = observationDao.save(ctx,observation,theId,theConditional);
        method.setId(newObservation.getIdElement());
        method.setResource(newObservation);
    } catch (BaseServerResponseException srv) {
        // HAPI Exceptions pass through
        throw srv;
    } catch(Exception ex) {
        ProviderResponseLibrary.handleException(method,ex);
    }

    return method;
}
 
Example #23
Source File: TaskProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Update
public MethodOutcome update(HttpServletRequest theRequest, @ResourceParam Task task, @IdParam IdType theId, @ConditionalUrlParam String theConditional, RequestDetails theRequestDetails) {
	
	resourcePermissionProvider.checkPermission("update");
	
    MethodOutcome method = new MethodOutcome();
    method.setCreated(true);
    OperationOutcome opOutcome = new OperationOutcome();

    method.setOperationOutcome(opOutcome);

    try {
        Task newTask = taskDao.create(ctx,task, theId, theConditional);
        method.setId(newTask.getIdElement());
        method.setResource(newTask);
    } catch (BaseServerResponseException srv) {
        // HAPI Exceptions pass through
        throw srv;
    } catch(Exception ex) {
        ProviderResponseLibrary.handleException(method,ex);
    }

    return method;
}
 
Example #24
Source File: PractitionerProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Update
public MethodOutcome updatePractitioner(HttpServletRequest theRequest, @ResourceParam Practitioner practitioner, @IdParam IdType theId, @ConditionalUrlParam String theConditional, RequestDetails theRequestDetails) {

	resourcePermissionProvider.checkPermission("update");
    MethodOutcome method = new MethodOutcome();
    method.setCreated(true);
    OperationOutcome opOutcome = new OperationOutcome();

    method.setOperationOutcome(opOutcome);
    try {
    Practitioner newPractitioner = practitionerDao.create(ctx,practitioner, theId, theConditional);
    method.setId(newPractitioner.getIdElement());
    method.setResource(newPractitioner);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }



    return method;
}
 
Example #25
Source File: HealthcareServiceProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Update
public MethodOutcome updateHealthcareService(HttpServletRequest theRequest, @ResourceParam HealthcareService service, @IdParam IdType theId, @ConditionalUrlParam String theConditional, RequestDetails theRequestDetails) {

	resourcePermissionProvider.checkPermission("update");
    MethodOutcome method = new MethodOutcome();
    method.setCreated(true);
    OperationOutcome opOutcome = new OperationOutcome();

    method.setOperationOutcome(opOutcome);

    try {
        HealthcareService newHealthcareService = serviceDao.create(ctx, service, theId, theConditional);
        method.setId(newHealthcareService.getIdElement());
        method.setResource(newHealthcareService);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }


    return method;
}
 
Example #26
Source File: RelatedPersonProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Update
public MethodOutcome updateRelatedPerson(HttpServletRequest theRequest, @ResourceParam RelatedPerson person, @IdParam IdType theId, @ConditionalUrlParam String theConditional, RequestDetails theRequestDetails) {

	resourcePermissionProvider.checkPermission("update");
    MethodOutcome method = new MethodOutcome();
    method.setCreated(true);
    OperationOutcome opOutcome = new OperationOutcome();

    method.setOperationOutcome(opOutcome);

try {
    RelatedPerson newRelatedPerson = personDao.update(ctx, person, theId, theConditional);
    method.setId(newRelatedPerson.getIdElement());
    method.setResource(newRelatedPerson);

} catch (Exception ex) {

    ProviderResponseLibrary.handleException(method,ex);
}


    return method;
}
 
Example #27
Source File: MedicationProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Update
public MethodOutcome update(HttpServletRequest theRequest, @ResourceParam Medication medication, @IdParam IdType theId, @ConditionalUrlParam String theConditional, RequestDetails theRequestDetails) {

	resourcePermissionProvider.checkPermission("update");
    MethodOutcome method = new MethodOutcome();
    method.setCreated(true);
    OperationOutcome opOutcome = new OperationOutcome();

    method.setOperationOutcome(opOutcome);

    try {
        Medication newMedication = medicationDao.create(ctx,medication, theId, theConditional);
        method.setId(newMedication.getIdElement());
        method.setResource(newMedication);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }



    return method;
}
 
Example #28
Source File: TerminologyLoaderTest.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Test
public void testLoadLoinc() throws Exception {
    ourLog.info("TEST = testLoadLoinc()");
    ByteArrayOutputStream bos1 = new ByteArrayOutputStream();
    ZipOutputStream zos1 = new ZipOutputStream(bos1);
    addEntry(zos1, "/loinc/", "loinc.csv");
    zos1.close();
    ourLog.info("ZIP file has {} bytes", bos1.toByteArray().length);

    ByteArrayOutputStream bos2 = new ByteArrayOutputStream();
    ZipOutputStream zos2 = new ZipOutputStream(bos2);
    addEntry(zos2, "/loinc/", "LOINC_2.54_MULTI-AXIAL_HIERARCHY.CSV");
    zos2.close();
    ourLog.info("ZIP file has {} bytes", bos2.toByteArray().length);

    RequestDetails details = mock(RequestDetails.class);
    when(codeSvc.findBySystem("http://loinc.org")).thenReturn(new CodeSystemEntity());
    mySvc.loadLoinc(list(bos1.toByteArray(), bos2.toByteArray()), details);

    verify(codeSvc).storeNewCodeSystemVersion( myCsvCaptor.capture(), any(RequestDetails.class));

    CodeSystemEntity ver = myCsvCaptor.getValue();
    ConceptEntity code = ver.getConcepts().iterator().next();
    assertEquals("10013-1", code.getCode());

}
 
Example #29
Source File: DiagnosticReportProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Update
public MethodOutcome update(HttpServletRequest theRequest, @ResourceParam DiagnosticReport diagnosticReport, @IdParam IdType theId, @ConditionalUrlParam String theConditional, RequestDetails theRequestDetails) {

	resourcePermissionProvider.checkPermission("update");
    MethodOutcome method = new MethodOutcome();
    method.setCreated(true);
    OperationOutcome opOutcome = new OperationOutcome();
    method.setOperationOutcome(opOutcome);

    try {
    DiagnosticReport newDiagnosticReport = diagnosticReportDao.create(ctx,diagnosticReport, theId, theConditional);
    method.setId(newDiagnosticReport.getIdElement());
    method.setResource(newDiagnosticReport);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }


    return method;
}
 
Example #30
Source File: SlotProvider.java    From careconnect-reference-implementation with Apache License 2.0 6 votes vote down vote up
@Update
public MethodOutcome updateSlot(HttpServletRequest theRequest, @ResourceParam Slot slot, @IdParam IdType theId, @ConditionalUrlParam String theConditional, RequestDetails theRequestDetails) {

	resourcePermissionProvider.checkPermission("update");
    MethodOutcome method = new MethodOutcome();
    method.setCreated(true);
    OperationOutcome opOutcome = new OperationOutcome();

    method.setOperationOutcome(opOutcome);

    try {
        Slot existingSlot = slotDao.create(ctx, slot, theId, theConditional);
        method.setId(existingSlot.getIdElement());
        method.setResource(existingSlot);
    } catch (Exception ex) {

        ProviderResponseLibrary.handleException(method,ex);
    }


    return method;
}