Skip to content

Commit

Permalink
use ".update()" instead of .create() for storing foreign resources th…
Browse files Browse the repository at this point in the history
…at already have identifiers
  • Loading branch information
timcoffman committed Jul 12, 2024
1 parent 7fa8ac0 commit eb0819f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions src/test/java/edu/ohsu/cmp/ecp/sds/ForeignPartitionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import ca.uhn.fhir.rest.api.MethodOutcome;
import ca.uhn.fhir.rest.client.api.IGenericClient;
import ca.uhn.fhir.util.BundleBuilder;

Expand Down Expand Up @@ -88,10 +89,11 @@ void canStoreAndRetrieveConditionResourceInForeignPartition() {
IGenericClient client = clientTargetingPartition( FOREIGN_PARTITION_NAME );

Patient pat = initPatient( "0123456789" ) ;
IIdType patId = client.update().resource(pat).execute().getId();
client.update().resource(pat).execute();

Condition condition = initCondition( patId, "0123456789-001" ) ;
IIdType conditionId = client.create().resource(condition).execute().getId();
Condition condition = initCondition( pat.getIdElement(), "0123456789-001" ) ;
condition.setId( new IdType( "Condition", createTestSpecificId() ) ) ;
IIdType conditionId = client.update().resource(condition).execute().getId();

Condition readCondition = client.read().resource(Condition.class).withId(conditionId).execute();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ void canStorePatientWithoutAdditionalSetup() {

private Condition createHealthConcern( Reference subjectRef, String codeAsPlainText ) {
Condition condition = new Condition() ;
condition.setId( new IdType("Condition", createTestSpecificId()) ) ;

condition.setSubject( subjectRef ) ;

CodeableConcept healthConcernCategory = new CodeableConcept();
Expand All @@ -110,11 +112,11 @@ void canStoreConditionWhereSubjectIsClaimedPatientWithoutAdditionalSetup() {
Patient subjectPatient = new Patient() ;
subjectPatient.setId( new IdType( "Patient", subjectPatientId ) ) ;

IIdType claimedPatientId = patientAppClient.update().resource(subjectPatient).execute().getId();
patientAppClient.update().resource(subjectPatient).execute();

Condition condition = createHealthConcern( new Reference(claimedPatientId), "my health concern" ) ;
Condition condition = createHealthConcern( new Reference( subjectPatient.getIdElement() ), "my health concern" ) ;

IIdType conditionId = patientAppClient.create().resource(condition).execute().getId();
IIdType conditionId = patientAppClient.update().resource(condition).execute().getId();

Condition readQuestResp = patientAppClient.read().resource(Condition.class).withId(conditionId).execute();

Expand Down

0 comments on commit eb0819f

Please sign in to comment.