1.0.2 • Published 5 years ago

pk-sp13w-check v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

Praktice-Navigator React-webSDK

NPM NPM NPM NPM

Table of contents

Minimum required version of react 16.3.x

To use navigator SDK you must have ClientID.

In case you do not have a client ID, please write to contact@praktice.ai

Importing SDK and rendering host component

import { NavigatorSDK } from 'praktice-navigator-react-web-sdk'
export default class App extends React.Component {
  render() {
    return (
		<NavigatorSDK
			clientId = 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
		/>
	)}
}

This will load SDK with all default UI Component, but can also pass your own component to SDK and render it.

Getting started with $Generator

$Generator is required for accessing the dynamic data and methods of SDK, and it can be imported like

import ${Generator} from 'praktice-navigator-react-native-sdk'

every time you invoke $Generator you have to pass request object to generate data from it

Format of requestObject

{
	type: "categoryTitle" 
 	component: Button 
    componentProps: [ 
    	{style: {fontWeight: "bold"}}, //React native style only
        "fullWidth"	//Custom props
    ]
}
keydata typedescription
typestring, requiredUnique for every component, see in component section
componentclass, optionalData will be wrapped in this component, if it is null then data will be render in it's native component
componentPropsarray, optionalProps to the above component, array can only contain either string or object
payloadstring/int/array/objectPayload to dynamic method. Please check component documentation for detail.

Example of genrating Symptoms list

var requestObject =  {
     type: "categoryList",
     component:Button,
     componentProps: [
       {style: {fontWeight: "bold"}},
       "fullWidth",
       "bordered"
     ]
 }
 
const ListData = $Generator(requestObject) // return the UI element List

Available props to Navigator

Passing Custom component to NavigatorSDK component

  • List of Component can be passed to NavigatorSDK
    Component (type)StatusDescription
    searchComponentworkingRepalces the search component
    categoryComponentworkingcomponent in which all symptoms are render
    errorMessageComponentworkingThis component get render when thier is an error on backend side
    showDocBtnworkingIn this you can call $Generator to obatin the result.
    patientInfoQueryComponentworkingComponent which collect user data, like age and gender
    loaderworkingCustom loader inside the sdk
    Category Component -
<NavigatorSDK
    clientId = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
    categoryComponent={CustomCategoryComponent}
    patientInfoQueryComponent={CustomPacientInfoQueryComponent}
    showDocBtn={CustomShowDocComponent}
    errorMessageComponent={CustomErrorComponent}
    loader={CustomLoaderComponent}
/>

Import Autocomplete

Autocomplete can be imported and rendered by the $Generator

const AutoComplete = $Generator({type:"autoComplete"})

<AutoComplete
    query={this.state.inputvalue}
	  onSelect={(e) => {this.setState({inputvalue: e})}}
    containerStyle={...}
    listStyle={...}
/>
propstypedescription
querystring, requiredvalue of input
onSelectfunc, requiredthis callback function will fire when the user will select any suggestion from autocomplete, developer are advised to use this callback to set the value of input
containerStyleObject, optionalThese styles will be applied to the container which surrounds the autocomplete component.
listStyleObject, optionalThese style will be applied to the result list.

Custom Styling of SDK Component

Currently four component support custom styling to the SDK component, but before you proceed to this step, developer's are advised to see the component layout.

See Component Layout

ComponentProp nameAvailable keys for style object, all keys are optional
SDK ContainersdkContainerStylewrapperwrapper_msectAsectA_msectA_containersectA_container_mselectedselected_msectBsectB_msearch_button_wrappersearch_button_wrapper_msearch_buttonsearch_button_mselectedSymptoms
Category ComponentcategoryComponentStylecategory_wrappercategory_wrapper_mtitleCategorytitleCategory_msymptoms_wrappersymptoms_wrapper_msymptomssymptoms_msymptoms_selectedsymptoms_selected_m
Selected SymptomsComponentselectedSymptomsStyleFlat style object (no keys, just react style)
selectedSymptomsCrossStyleselectedSymptomsCrossStyleFlat style object
Input Component StyleinputComponentStyleFlat style Object
AutoComplete Component StyleautoCompleteComponentStylecontainerStylelistStyle
<NavigatorSDK
	clientId = ""
    errorComponent={ErrorComponent}
    patientInfoQueryComponent={PacientInfoQuery}
    showDocBtn={CustomShowDocBtn}
    loader={CustomLoaderComponent}
    // Custom Style Object to tune the native component style.
    sdkContainerStyle = {customContainerStyle}
    categoryComponentStyle={customCategoryStyle}
    inputComponentStyle={cusotmInputComponentStyle}
/>


const customCategoryStyle = {
  symptoms_selected_m: {
    color: "white",
    fontSize: "0.8rem",
    fontWeight: "600",
    fontFamily: "sans-serif",
    cursor: "pointer"
  },
  symptoms_selected: {
    color: "white",
    fontSize: "0.8rem",
    fontWeight: "600",
    background: "red"
  }
};
const customContainerStyle = {
  sectA: {
    background: "red",
    display: "flex",
    height: "-webkit-fill-available",
    padding: "1rem",
    maxWidth: "300px"
  }
};

// Flat style object
const customInputComponentStyle = {
  margin: "5px",
  border: "4px solid #efefef"
}
  

Your style object must comply with the rules of react style object

Utility Props

Props Keydata typedescription
patientGenderstring female or maleIf this prop is passed to navigator SDK then, SDK will never ask for the patient gender from the user, it will use the provided value when needed.
patientAgeintIf this prop is passed to navigator SDK then, SDK will never ask for the patient age from the user, it will use the provided value when needed.
maximumNumberOfCategoriesintThis limits the number of Category to be render.
maximumTermsPerCategoriesintThis is limit the numbder of terms/symptoms in one category.
permitEmptySelectionbooleanIf set true, then SDK will not disable the SEARCH DOCTORS Button when there is no symptoms selected. and if user clicks without selecting any symptoms SDK will respond with General Physician

Custom Listner for Seacrh Doctors

In some cases, where the related symptoms won't exist (example - treatment like a Muscle Biopsy or condition like Non Hodgkin's Lympoma, SDK would directly invoke the listener if the listner is passed as a prop. Otherwise, in such cases, where no related symptoms exist, SDK would not render any medical terms in the category component.

<NavigatorSDK
  clientId = 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
  searchDoctorlistner={this.customListner}
>

customListner(resultData){
  console.log("Hmm... no more option ..time to navigate to", resultData)
}

Rendering Custom components in SDK

  • Search Component

    	This component does not require any dynamic data to render but require only two method from SDK, one to submit the patient query back to SDK and other to render `autocomplete`
     $Generator({type:"inputSearch",payload: "I have a leg pain"})
    	For __AutComplete__ 
    const AutoComplete = $Generator({type:"autoComplete"})
    <AutoComplete
      query={this.state.inputvalue}
      onSelect={(e) => {this.setState({inputvalue: e})}}
      containerStyle={...}
      listStyle={...}
    		/>
    		```
    
    |props|type|description|
    |-|-|-|
    |query|string, required| value of input|
    |onSelect| func, required| this callback function will fire when the user will select any suggestion from autocomplete, developer are advised to use this callback to set the value of input|
    |containerStyle|Object, optional| These styles will be applied to the container which surrounds the autocomplete component.|
    |listStyle|Object, optional|These style will be applied to the result list.
  • Category Component

    Component Layout

    Dynamic data available for this component
    | Data |type|return type | provides | | ----- |--| ---------- | ---------| |Category Title| categoryTitle | single UI element | Category Title, example: Comman Health Prombelm, Bone & Joint problems | |Symptoms List| categoryList | List of UI Element | Symptoms List, example: Leg pain, Stress |

    Getting Dynamic data

    const CategoryTitle = $Generator({
       type: "categoryTitle",
       component: Text,
       componentProps: [{ style: { fontWeight: "bold" } }]
     });
    const SymptomsList = $Generator({
        type: "categoryList",
        component:Button,
         componentProps: [
              {style: {fontWeight: "bold"}},
              "fullWidth",
              "bordered"
            ]
        })
    
    //Rendering the data
    //below whole class component is repetitive section as represented in image
    export class CategoryComponent extends React.Component{
       render(){
       return(
           <View>
              <CategoryTitle/>
               <SymptomsList/>
           </View>
         )}
      }
  • Patient Info Component

    	This component does not require any dynamic data to render but require only one method from SDK to submit the patient data
     $Generator({type:"submitPatientInfo",debug:true})(true, "female", "26")
  • Show Doc Button

    	This component will replace the native button of __Show Doctor__ in SDK, this component does not require any dynamic data to be render but has one method to obtain the result in json format from SDK.

    Developer is responsible to navigate further on the basis of result. SDK will not navigate further, and spinner will continue.

    $Generator({type:"showSpeciality"})
  • Error Component

    	This component does not require any dynamic data or method from SDK, it will render on screen if any error logs up either on front-end side or on the back-end side

    currently there is no provision of detecting the error type, but in future it will have an error code and error message for developer

  • Loader Component

    	This Component does not require any dynamic data or method from SDK, it will replace the native loader of SDK.