This repository has been archived by the owner on Jan 9, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(patients): add very simple create patient page
- Loading branch information
1 parent
c220b96
commit bb94ef0
Showing
5 changed files
with
93 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,70 @@ | ||
import React, { Component } from 'react'; | ||
import { withRouter, RouteComponentProps } from 'react-router-dom'; | ||
import { TextInput, Button } from '@hospitalrun/components'; | ||
import * as patientsDb from '../clients/db/patients-db'; | ||
|
||
interface Props extends RouteComponentProps { | ||
|
||
} | ||
|
||
interface State { | ||
firstName: string | ||
lastName: string | ||
} | ||
|
||
|
||
class NewPatient extends Component<Props, State> { | ||
|
||
constructor(props: Props) { | ||
super(props); | ||
this.onFirstNameChange = this.onFirstNameChange.bind(this) | ||
this.onLastNameChange = this.onLastNameChange.bind(this); | ||
this.onSaveButtonClick = this.onSaveButtonClick.bind(this); | ||
|
||
this.state = { | ||
firstName: '', | ||
lastName: '', | ||
}; | ||
} | ||
|
||
|
||
onFirstNameChange(event: any) { | ||
this.setState({ | ||
firstName: event.target.value, | ||
}) | ||
} | ||
|
||
onLastNameChange(event: any) { | ||
this.setState({ | ||
lastName: event.target.value, | ||
}) | ||
} | ||
|
||
async onSaveButtonClick() { | ||
const newPatient = (await patientsDb.save(this.state)) as any | ||
this.props.history.push(`/patients/${newPatient.id}`); | ||
} | ||
|
||
class NewPatient extends Component { | ||
render() { | ||
return ( | ||
<h1>New Patient</h1> | ||
<div> | ||
<h1>New Patient</h1> | ||
<div className="container"> | ||
<form> | ||
<div className="row"> | ||
<h3>First Name:</h3> | ||
<TextInput onChange={this.onFirstNameChange}/> | ||
</div> | ||
<div className="row"> | ||
<h3>Last Name:</h3> | ||
<TextInput onChange={this.onLastNameChange}/> | ||
</div> | ||
<Button onClick={this.onSaveButtonClick}>Save</Button> | ||
</form> | ||
</div> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default NewPatient; | ||
export default withRouter(NewPatient); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import PouchDB from 'pouchdb'; | ||
|
||
export const patients = new PouchDB('patients'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters