@Create public MethodOutcome createPatient(@ResourceParam Patient patient) { patient.setId(createId(counter, 1L)); patients.put(String.valueOf(counter), patient); return new MethodOutcome(patient.getIdElement()); }
private static Patient createPatient(final String name) { final Patient patient = new Patient(); patient.getName().add(new HumanName().setFamily(name)); patient.setId(createId(counter, 1L)); counter++; return patient; }
@History() public List<Patient> getPatientHistory( @IdParam IdType theId, @Since InstantType theSince, @At DateRangeParam theAt ) { List<Patient> retVal = new ArrayList<Patient>(); Patient patient = new Patient(); patient.addName().setFamily("Smith"); // Set the ID and version patient.setId(theId.withVersion("1")); // ...populate the rest... return retVal; } //END SNIPPET: history
patient.setId(new IdType("Patient", logicalId, versionId));
@Read() public Patient getResourceById(@IdParam IdType theId) { Patient retVal = new Patient(); // ...populate... retVal.addIdentifier().setSystem("urn:mrns").setValue("12345"); retVal.addName().setFamily("Smith").addGiven("Tester").addGiven("Q"); // ...etc... // if you know the version ID of the resource, you should set it and HAPI will // include it in a Content-Location header retVal.setId(new IdType("Patient", "123", "2")); return retVal; } //END SNIPPET: read
@Update public MethodOutcome updatePatientPrefer( @ResourceParam Patient thePatient, @IdParam IdType theId) { // Save the patient to the database // Update the version and last updated time on the resource IdType updatedId = theId.withVersion("123"); thePatient.setId(updatedId); InstantType lastUpdated = InstantType.withCurrentTime(); thePatient.getMeta().setLastUpdatedElement(lastUpdated); // Add the resource to the outcome, so that it can be returned by the server // if the client requests it MethodOutcome outcome = new MethodOutcome(); outcome.setId(updatedId); outcome.setResource(thePatient); return outcome; } //END SNIPPET: updatePrefer
@Before public void setup() { requestConsumer = EasyMock.createMock(RequestConsumer.class); response = new ArrayList<>(); for (int i = 0; i < MAX_SIZE; i++) { response.add(new Patient().setId(Integer.toString(i))); } Object payload = new Object(); Map<String, Object> headers = new HashMap<>(); bundleProvider = new LazyBundleProvider(requestConsumer, true, payload, headers); }
@Before public void setup() { requestConsumer = EasyMock.createMock(RequestConsumer.class); response = new ArrayList<>(); for (int i = 0; i < MAX_SIZE; i++) { response.add(new Patient().setId(Integer.toString(i))); } Object payload = new Object(); Map<String, Object> headers = new HashMap<>(); bundleProvider = new EagerBundleProvider(requestConsumer, payload, headers); }
/** * @param jCas ye olde ... */ public FhirNoteSpecs( final JCas jCas ) { _noteSpecs = new NoteSpecs( jCas ); final String noteDateText = _noteSpecs.getNoteTime(); _clinicalNoteId = FhirElementFactory.createId( jCas, ID_NAME_CLINICAL_NOTE, noteDateText ); final Date noteDate = _noteSpecs.getNoteDate(); final long noteDateMillis = noteDate.getTime(); _period = FhirElementFactory.createPeriod( noteDateMillis, noteDateMillis + 1000 ); final Patient mainPatient = new Patient(); final String patientName = _noteSpecs.getPatientName(); mainPatient.addName( createHumanName( patientName ) ); mainPatient.setId( FhirElementFactory.createId( jCas, patientName, patientName.hashCode() ) ); _mainPatientRef = new Reference( mainPatient ); _subjectRefs = createSubjects( jCas ); final SourceData sourceData = SourceMetadataUtil.getSourceData( jCas ); final Encounter encounter = createEncounter( jCas, sourceData, noteDateText ); _encounterReference = new Reference( encounter ); }
changeUserContext(); Patient patient1 = new Patient(); patient1.setId("321"); patient1.getName().add(hnp.fromString(null, "Smith, Joe")); Identifier ssn = new Identifier(); patient1.setBirthDate(DateUtil.parseDate("1958-07-27")); Patient patient2 = new Patient(); patient2.setId("123"); patient2.getName().add(hnp.fromString(null, "Doe, Jane")); Identifier ssn2 = new Identifier();