本文整理汇总了Java中ca.uhn.fhir.context.FhirContext.newRestfulGenericClient方法的典型用法代码示例。如果您正苦于以下问题:Java FhirContext.newRestfulGenericClient方法的具体用法?Java FhirContext.newRestfulGenericClient怎么用?Java FhirContext.newRestfulGenericClient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ca.uhn.fhir.context.FhirContext
的用法示例。
在下文中一共展示了FhirContext.newRestfulGenericClient方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteBundle
import ca.uhn.fhir.context.FhirContext; //导入方法依赖的package包/类
public static void deleteBundle(FhirContext oContext, IdDt idBundle, String serverUrl, String logFileName)
{
try
{
IGenericClient client=oContext.newRestfulGenericClient(serverUrl);
IBaseOperationOutcome resp=client.delete().resourceById(idBundle)
.execute();
if(resp!=null)
{
OperationOutcome outcome = (OperationOutcome) resp;
System.out.println(outcome.getIssueFirstRep().getDetailsElement().getValue());
}
}
catch (Exception exc)
{
FhirMediatorUtilities.writeInLogFile(logFileName,
exc.getMessage(),"Error");
}
}
示例2: deleteDiagnosticOrderBySpecimen
import ca.uhn.fhir.context.FhirContext; //导入方法依赖的package包/类
public static void deleteDiagnosticOrderBySpecimen(FhirContext oContext,List<String> listIdSpecimenToDelete, String serverUrl, String logFileName)
{
try
{
IGenericClient client=oContext.newRestfulGenericClient(serverUrl);
IBaseOperationOutcome resp=client.delete()
.resourceConditionalByType("DiagnosticOrder")
//.where(DiagnosticReport.SPECIMEN.hasId(idSpecimenToDelete))
.where(DiagnosticOrder.SPECIMEN.hasAnyOfIds(listIdSpecimenToDelete))
.execute();
if(resp!=null)
{
OperationOutcome outcome = (OperationOutcome) resp;
System.out.println(outcome.getIssueFirstRep().getDetailsElement().getValue());
}
}
catch (Exception exc)
{
FhirMediatorUtilities.writeInLogFile(logFileName,
exc.getMessage(),"Error");
}
}
示例3: deletePractitioner
import ca.uhn.fhir.context.FhirContext; //导入方法依赖的package包/类
public static void deletePractitioner(FhirContext oContext,List<IdDt> listIdsPractitioner, String serverUrl, String logFileName)
{
try
{
IGenericClient client=oContext.newRestfulGenericClient(serverUrl);
for(IdDt idToDelete:listIdsPractitioner)
{
IBaseOperationOutcome resp=client.delete()
.resourceById(idToDelete)
.execute();
if(resp!=null)
{
OperationOutcome outcome = (OperationOutcome) resp;
System.out.println(outcome.getIssueFirstRep().getDetailsElement().getValue());
}
}
}
catch (Exception exc)
{
FhirMediatorUtilities.writeInLogFile(logFileName,
exc.getMessage(),"Error");
}
}
示例4: loadHapiTestData
import ca.uhn.fhir.context.FhirContext; //导入方法依赖的package包/类
/**
* Load test data files onto HAPI test server using FileBasedFhirDstu2Provider
* Assumes each resource has an identifier with system http://mcm.usciitg-prep.org
* and value equal to json file resource Id
*
* @throws JAXBException
*/
@BeforeClass
public static void loadHapiTestData() throws JAXBException {
FhirContext fhirContext = FhirContext.forDstu2Hl7Org();
FileBasedFhirDstu2Provider provider = new FileBasedFhirDstu2Provider(System.getProperty("user.dir") + "/src/test/resources/org/partners/usciitg_prep/fhir/cql/data", null);
provider.setFhirContext(fhirContext);
provider.setPackageName("org.hl7.fhir.instance.model");
UsciitgLibraryManager libraryManager = new UsciitgLibraryManager(
new ModelManager(),
System.getProperty("user.dir") + "/src/test/resources/org/partners/usciitg_prep/fhir/cql");
LibraryLoader libraryLoader = new LibraryLoaderImpl(libraryManager);
VersionedIdentifier libraryIdentifier = new VersionedIdentifier()
.withId("usciitg_flu_study");
Context context = new Context(libraryLoader.load(libraryIdentifier));
TerminologyProvider terminologyProvider = new TestTerminologyProvider();
provider.setTerminologyProvider(terminologyProvider);
context.registerDataProvider("http://hl7.org/fhir", provider);
context.registerTerminologyProvider(terminologyProvider);
context.setContextValue("Patient", "fhirTest");
IGenericClient client = fhirContext.newRestfulGenericClient("http://fhirtest.uhn.ca/baseDstu2");
Iterable<Object> resources = provider.retrieve("Patient", "fhirTest", "Patient", null, null, null, null, null, null, null, null);
createServerResources(client, resources, "Patient");
resources = provider.retrieve("Patient", "fhirTest", "Observation", null, null, null, null, null, null, null, null);
deleteServerResources(client, resources, "Observation");
createServerResources(client, resources, "Observation");
resources = provider.retrieve("Patient", "fhirTest", "MedicationOrder", null, null, null, null, null, null, null, null);
deleteServerResources(client, resources, "MedicationOrder");
createServerResources(client, resources, "MedicationOrder");
resources = provider.retrieve("Patient", "fhirTest", "Immunization", null, null, null, null, null, null, null, null);
deleteServerResources(client, resources, "Immunization");
createServerResources(client, resources, "Immunization");
}
开发者ID:Discovery-Research-Network-SCCM,项目名称:FHIR-CQL-ODM-service,代码行数:45,代码来源:UsciitgFhirDataProviderHL7IT.java
示例5: createDiagnosticOrderInTransaction
import ca.uhn.fhir.context.FhirContext; //导入方法依赖的package包/类
public static String createDiagnosticOrderInTransaction(FhirContext oContext,List<DiagnosticOrder> _listOfDiagnosticOrder,String serverUrl) throws Exception
{
Bundle respOutcome=null;
String stringTransactionResult="{TransactionResultStatus:no}";
try
{
Bundle resourceBundle=new Bundle();
resourceBundle.setType(BundleTypeEnum.TRANSACTION);
int compter=0;
for(DiagnosticOrder oDiagnosticOrder: _listOfDiagnosticOrder)
{
String searchPattern="DiagnosticOrder?";
searchPattern+="_id="+oDiagnosticOrder.getId().getValueAsString();
Entry oBundleEntry= new Entry().setResource(oDiagnosticOrder);
oBundleEntry.setElementSpecificId(oDiagnosticOrder.getId().getValueAsString());
oBundleEntry.setFullUrl(oDiagnosticOrder.getId());
oBundleEntry.getRequest().setUrl(searchPattern).setMethod(HTTPVerbEnum.PUT);
resourceBundle.addEntry(oBundleEntry);
compter++;
//if(compter==5) break;
}
//String filePath1="/home/server-hit/Desktop/"+"Bundle.json";
//ManageJsonFile.saveResourceInJSONFile(resourceBundle,oContext,filePath1);
IGenericClient client=oContext.newRestfulGenericClient(serverUrl);
String resJSONFormat=oContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(resourceBundle);
respOutcome=client.transaction().withBundle(resourceBundle).execute();
//System.out.print(oContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respOutcome));
if(respOutcome!=null)
{
stringTransactionResult=FhirResourceProcessor.extractResponseStaticsFromBundleTransactionRespons(respOutcome,1);
}
}
catch (Exception exc)
{
throw new Exception(exc.getMessage());
}
return stringTransactionResult;
}
示例6: createPractitioner
import ca.uhn.fhir.context.FhirContext; //导入方法依赖的package包/类
public static String createPractitioner(FhirContext oContext,List<Practitioner> listOfPractitioners,String serverUrl) throws Exception
{
MethodOutcome respOutcome=null;
String stringTransactionResult="{TransactionResultStatus:no}";
try
{
IGenericClient client=oContext.newRestfulGenericClient(serverUrl);
int compter=0;
int nbreResourceCreated=0;
int total=listOfPractitioners.size();
for(Practitioner oPractitioner: listOfPractitioners)
{
//oPractitioner.getPractitionerRole().get(0).getManagingOrganization().se
respOutcome=client.update()
.resource(oPractitioner)
.prettyPrint()
.encodedJson()
.execute();
if(respOutcome.getCreated())
{
nbreResourceCreated++;
}
}
int succes=nbreResourceCreated;
int failed=total-succes;
stringTransactionResult="total:"+total+"," +
"succes:"+succes+"," +
"failed:"+failed+"}";
}
catch (Exception exc)
{
throw new Exception(exc.getMessage());
}
return stringTransactionResult;
}
示例7: createOrganization
import ca.uhn.fhir.context.FhirContext; //导入方法依赖的package包/类
public static String createOrganization(FhirContext oContext,List<Organization> listOfOrganization,String serverUrl) throws Exception
{
MethodOutcome respOutcome=null;
String stringTransactionResult="{TransactionResultStatus:no}";
try
{
IGenericClient client=oContext.newRestfulGenericClient(serverUrl);
int compter=0;
int nbreResourceCreated=0;
int total=listOfOrganization.size();
for(Organization oOrganization: listOfOrganization)
{
respOutcome=client.update()
.resource(oOrganization)
.prettyPrint()
.encodedJson()
.execute();
if(respOutcome.getCreated())
{
nbreResourceCreated++;
}
}
int success=nbreResourceCreated;
int failed=total-success;
stringTransactionResult="total:"+total+"," +
"succes:"+success+"," +
"failed:"+failed+"}";
}
catch (Exception exc)
{
throw new Exception(exc.getMessage());
}
return stringTransactionResult;
}
示例8: createBundle
import ca.uhn.fhir.context.FhirContext; //导入方法依赖的package包/类
public static String createBundle(FhirContext oContext,List<Bundle> listOfBundles,String serverUrl) throws Exception
{
MethodOutcome respOutcome=null;
String stringTransactionResult="{TransactionResultStatus:no}";
try
{
IGenericClient client=oContext.newRestfulGenericClient(serverUrl);
int compter=0;
int nbreResourceCreated=0;
int total=listOfBundles.size();
for(Bundle oBundle: listOfBundles )
{
respOutcome=client.update()
.resource(oBundle)
.prettyPrint()
.encodedJson()
.execute();
if(respOutcome.getCreated())
{
nbreResourceCreated++;
}
}
int success=nbreResourceCreated;
int failed=total-success;
stringTransactionResult="total:"+total+"," +
"succes:"+success+"," +
"failed:"+failed+"}";
}
catch (Exception exc)
{
throw new Exception(exc.getMessage());
}
return stringTransactionResult;
}
示例9: createObservation
import ca.uhn.fhir.context.FhirContext; //导入方法依赖的package包/类
public static String createObservation(FhirContext oContext,List<Observation> listOfObservation,String serverUrl
, String logFileName) throws Exception
{
MethodOutcome respOutcome=null;
String stringTransactionResult="{TransactionResultStatus:no}";
IGenericClient client=oContext.newRestfulGenericClient(serverUrl);
int compter=0;
int nbreResourceCreated=0;
int total=listOfObservation.size();
for(Observation oObservation: listOfObservation)
{
try
{
respOutcome=client.update()
.resource(oObservation)
.prettyPrint()
.encodedJson()
.execute();
if(respOutcome.getCreated())
{
nbreResourceCreated++;
}
}
catch (Exception exc)
{
FhirMediatorUtilities.writeInLogFile(logFileName,
oObservation.toString()+" Creation resource operation failed! "+exc.getMessage(),"Error");
continue;
}
}
int success=nbreResourceCreated;
int failed=total-success;
stringTransactionResult="total:"+total+"," +
"succes:"+success+"," +
"failed:"+failed+"}";
return stringTransactionResult;
}
示例10: deleteListResourceSpecimen
import ca.uhn.fhir.context.FhirContext; //导入方法依赖的package包/类
public static void deleteListResourceSpecimen(FhirContext oContext,List<String> listIdsSpecimen, String serverUrl, String logFileName)
{
try
{
IGenericClient client=oContext.newRestfulGenericClient(serverUrl);
for(String idToDelete:listIdsSpecimen)
{
//First search for List resource that refers to the specimen
ca.uhn.fhir.model.api.Bundle oBundle = client.search().forResource(ListResource.class)
.where(new StringClientParam("item").matches().value(idToDelete))
.execute();
List<ListResource> listExtractedResource= FhirResourceValidator.extractListResourceFromApiBundleObject(oBundle,oContext,serverUrl);
for(ListResource oListResource:listExtractedResource)
{
IBaseOperationOutcome resp=client.delete()
.resourceById(oListResource.getId())
.execute();
if(resp!=null)
{
OperationOutcome outcome = (OperationOutcome) resp;
System.out.println(outcome.getIssueFirstRep().getDetailsElement().getValue());
}
}
}
}
catch (Exception exc)
{
FhirMediatorUtilities.writeInLogFile(logFileName,
exc.getMessage(),"Error");
}
}
示例11: getPatient
import ca.uhn.fhir.context.FhirContext; //导入方法依赖的package包/类
public PatientInformation getPatient(String endpoint, String PatientId) throws UnsupportedEncodingException {
FhirContext ctx = FhirContext.forDstu2Hl7Org();// ca.uhn.fhir.model.dstu2.resource.Patient
IGenericClient client = ctx.newRestfulGenericClient(endpoint);
org.hl7.fhir.instance.model.Bundle bundleResult = client.search()
.byUrl("/Patient?_id=" + URLEncoder.encode(PatientId, "UTF-8"))
.returnBundle(org.hl7.fhir.instance.model.Bundle.class)
.execute();
if (bundleResult != null && bundleResult.hasEntry()) {
for (Bundle.BundleEntryComponent bundleEntryComponent : bundleResult
.getEntry()) {
if (bundleEntryComponent.getResource().getResourceType() == ResourceType.Patient) {
Patient patient = (Patient) bundleEntryComponent
.getResource();
String resultName = "";
if (patient.getName() != null
&& patient.getName().size() > 0) {
if (patient.getName().get(0).getFamily() != null
&& patient.getName().get(0).getFamily()
.size() > 0) {
resultName = patient.getName().get(0)
.getFamily().get(0).getValueNotNull();
}
if (patient.getName().get(0).getGiven() != null
&& patient.getName().get(0).getGiven()
.size() > 0) {
if (!resultName.isEmpty()) {
resultName += ", ";
}
resultName += patient.getName().get(0)
.getGiven().get(0).getValueNotNull();
}
}
PatientInformation patientInformation = new PatientInformation();
patientInformation.setName(resultName);
patientInformation.setId(patient.getId());
if (patient.getBirthDate() == null) {
patientInformation.setDoB(null);
} else {
patientInformation.setDoB(patient.getBirthDate()
.toString());
}
return patientInformation;
}
}
}
return null;
}
示例12: updateObservationInTransaction
import ca.uhn.fhir.context.FhirContext; //导入方法依赖的package包/类
public static String updateObservationInTransaction(FhirContext oContext,List<Observation> listOfObservation, String serverUrl) throws Exception
{
Bundle respOutcome=null;
String stringTransactionResult="{TransactionResultStatus:no}";
try
{
Bundle resourceBundle=new Bundle();
resourceBundle.setType(BundleTypeEnum.TRANSACTION);
int compter=0;
for (Observation oObservation:listOfObservation)
{
String searchPattern="Observation?";
String key=null;
//getKey
searchPattern+="_id="+oObservation.getId().getValueAsString();
Entry oBundleEntry= new Entry().setResource(oObservation);
oBundleEntry.setFullUrl(oObservation.getId());
oBundleEntry.getRequest().setUrl(searchPattern).setMethod(HTTPVerbEnum.PUT);
resourceBundle.addEntry(oBundleEntry);
}
//ManageJsonFile.saveResourceInJSONFile(resourceBundle,oContext,filePath1);
IGenericClient client=oContext.newRestfulGenericClient(serverUrl);
//System.out.print(oContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(resourceBundle));
respOutcome=client.transaction().withBundle(resourceBundle).execute();
System.out.print(oContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respOutcome));
if(respOutcome!=null)
{
stringTransactionResult=FhirResourceProcessor.extractResponseStaticsFromBundleTransactionRespons(respOutcome,2);
}
//respOutcome.gere
}
catch (Exception exc)
{
throw new Exception(exc.getMessage());
}
return stringTransactionResult;
}
示例13: updateDiagnosticReportInTransaction
import ca.uhn.fhir.context.FhirContext; //导入方法依赖的package包/类
public static String updateDiagnosticReportInTransaction(FhirContext oContext,List<DiagnosticReport> listOfDiagnosticReport, String serverUrl) throws Exception
{
Bundle respOutcome=null;
String stringTransactionResult="{TransactionResultStatus:no}";
try
{
Bundle resourceBundle=new Bundle();
resourceBundle.setType(BundleTypeEnum.TRANSACTION);
int compter=0;
for (DiagnosticReport oDiagnosticReport:listOfDiagnosticReport)
{
String searchPattern="DiagnosticReport?";
String key=null;
//getKey
searchPattern+="_id="+oDiagnosticReport.getId().getValueAsString();
Entry oBundleEntry= new Entry().setResource(oDiagnosticReport);
oBundleEntry.setFullUrl(oDiagnosticReport.getId());
oBundleEntry.getRequest().setUrl(searchPattern).setMethod(HTTPVerbEnum.PUT);
resourceBundle.addEntry(oBundleEntry);
}
//ManageJsonFile.saveResourceInJSONFile(resourceBundle,oContext,filePath1);
IGenericClient client=oContext.newRestfulGenericClient(serverUrl);
//System.out.print(oContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(resourceBundle));
respOutcome=client.transaction().withBundle(resourceBundle).execute();
System.out.print(oContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respOutcome));
if(respOutcome!=null)
{
stringTransactionResult=FhirResourceProcessor.extractResponseStaticsFromBundleTransactionRespons(respOutcome,2);
}
//respOutcome.gere
}
catch (Exception exc)
{
throw new Exception(exc.getMessage());
}
return stringTransactionResult;
}
示例14: updateBasicInTransaction
import ca.uhn.fhir.context.FhirContext; //导入方法依赖的package包/类
public static String updateBasicInTransaction(FhirContext oContext,List<Basic> listOfBasic, String serverUrl) throws Exception
{
Bundle respOutcome=null;
String stringTransactionResult="{TransactionResultStatus:no}";
try
{
Bundle resourceBundle=new Bundle();
resourceBundle.setType(BundleTypeEnum.TRANSACTION);
int compter=0;
for (Basic oBasic:listOfBasic)
{
String searchPattern="Basic?";
String key=null;
//getKey
searchPattern+="_id="+oBasic.getId().getValueAsString();
Entry oBundleEntry= new Entry().setResource(oBasic);
oBundleEntry.setFullUrl(oBasic.getId());
oBundleEntry.getRequest().setUrl(searchPattern).setMethod(HTTPVerbEnum.PUT);
resourceBundle.addEntry(oBundleEntry);
}
//ManageJsonFile.saveResourceInJSONFile(resourceBundle,oContext,filePath1);
IGenericClient client=oContext.newRestfulGenericClient(serverUrl);
//System.out.print(oContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(resourceBundle));
respOutcome=client.transaction().withBundle(resourceBundle).execute();
System.out.print(oContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respOutcome));
if(respOutcome!=null)
{
stringTransactionResult=FhirResourceProcessor.extractResponseStaticsFromBundleTransactionRespons(respOutcome,2);
}
//respOutcome.gere
}
catch (Exception exc)
{
throw new Exception(exc.getMessage());
}
return stringTransactionResult;
}
示例15: updatePatientInTransaction
import ca.uhn.fhir.context.FhirContext; //导入方法依赖的package包/类
public static String updatePatientInTransaction(FhirContext oContext,List<Patient> listOfPatient, String serverUrl) throws Exception
{
Bundle respOutcome=null;
String stringTransactionResult="{TransactionResultStatus:no}";
try
{
Bundle resourceBundle=new Bundle();
resourceBundle.setType(BundleTypeEnum.TRANSACTION);
int compter=0;
for (Patient oPatient:listOfPatient)
{
String searchPattern="Patient?";
String key=null;
//getKey
searchPattern+="_id="+oPatient.getId().getValueAsString();
Entry oBundleEntry= new Entry().setResource(oPatient);
oBundleEntry.setFullUrl(oPatient.getId());
oBundleEntry.getRequest().setUrl(searchPattern).setMethod(HTTPVerbEnum.PUT);
resourceBundle.addEntry(oBundleEntry);
}
//ManageJsonFile.saveResourceInJSONFile(resourceBundle,oContext,filePath1);
IGenericClient client=oContext.newRestfulGenericClient(serverUrl);
//System.out.print(oContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(resourceBundle));
respOutcome=client.transaction().withBundle(resourceBundle).execute();
System.out.print(oContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(respOutcome));
if(respOutcome!=null)
{
stringTransactionResult=FhirResourceProcessor.extractResponseStaticsFromBundleTransactionRespons(respOutcome,2);
}
//respOutcome.gere
}
catch (Exception exc)
{
throw new Exception(exc.getMessage());
}
return stringTransactionResult;
}