# coronasafe.network

Design Document

## Design Document

Coronasafe Care is a free and open-source disaster management system that is used by the National Health Mission, the Government of India, and various state governments for reimaging digital war rooms. The solution that students got an opportunity to intern with has supported 3.34\*Lac patient management and 1.29\* Lac ambulance shiftings and is approved by the United Nations as a[ Digital Public Good.](https://digitalpublicgoods.net/)

### Tech Stack

Backend API - Django\
Frontend - React Typescript\
Database - Postgres - RDS with read replica\
Hosting Backend - EKS  with amazon ACM cert\
Hosting Frontend - EC2 - Nginx with Cloudflare origin cert and  proxy\
Version control - Github\
Communication - Slack\
Ci/CD - Circle Ci

### **Production**

Care is deployed in production at different states in India. The production instance for Kerala/Ernakulam is deployed at

Frontend:  [care.coronasafe.network](http://care.coronasafe.network/)\
Backend API:  <http://careapi.coronasafe.network/><br>

### **Staging**

Frontend:  [care.coronasafe.in](http://care.coronasafe.network/)\
Backend API: [careapi.coronasafe.in/](https://careapi.coronasafe.in/)<br>

### Testing

Ci/CD: <https://circleci.com/gh/coronasafe><br>

### API Documentation

[https://careapi.coronasafe.in/swagger](https://api.care.coronasafe.network/swagger)\
[https://careapi.coronasafe.in/redoc](https://api.care.coronasafe.network/redoc)

### ER Diagram

{% content-ref url="/pages/ByR1NDqp8MtF5ERVnEeA" %}
[Mar 1, 2021](/schema/mar-1-2021)
{% endcontent-ref %}

### Data Visualization

{% embed url="<https://data.coronasafe.network>" %}

### **Task Manager and Issue Tracker**

{% embed url="<https://github.com/orgs/coronasafe/projects/4/views/1>" %}

### Status Monitor

New Relic APM

### Repository

Backend: <https://github.com/coronasafe/care>\
Frontend: <https://github.com/coronasafe/care_fe><br>

### Related Applications

* Telemedicine (WIP)
* Ambulance and Food Delivery Network ([https://logistics.coronasafe.network](https://logistics.coronasafe.network/))

## **Features**

Facility Management&#x20;

Realtime Capacity Analysis&#x20;

Patient Management&#x20;

Sample Management&#x20;

Patient Record Management&#x20;

Inventory Management

Central Dashboard for GOV&#x20;

Central Dashbaord for all facilities&#x20;


# State Dashboard

* Number of beds avilable
* Number of patients admitted
* Nubmer of COVID postive patients
* Number of people under observation
* Number of cases reported today
* Number of COVID postive reported today<br>

![State Wide Capacity Map](/files/-MABj2ayJQptIui-IBhM)

![Hotspot map with capacity overlay](/files/-MABkVzj79hGYcXhfMUh)

## District wise stats

* Number of beds avilable
* Number of patients admitted
* Nubmer of COVID postive patients
* Number of people under observation
* Number of cases reported today
* Number of COVID postive reported today<br>

![Sample Dashboard Ernakulam](/files/-MABisbKwVKl72_r3pZI)


# District Dashboard

* number of facilities
* facility stats
* totoal number of patients admited
* total number of patients positive
* Number of ICU beds free
* show where the ICU beds are avilable
* Number of people under observation&#x20;

![](/files/-MABlM9odWQLTfolEp9B)

## Facility stats

* Number of beds
* Number of ICU beds
* Number of Paitens
* Number COVID positive Patients
* Stock (Inventory along with count)


# Facility Dashboard

* Number of beds
* Number of ICU beds
* Number of Paitens
* Number COVID positive Patients
* Stock (Inventory along with count)&#x20;


# Patient Registration

* Unique Patient Registration
* Capture basic medical data&#x20;
* Capture consulation details
* Capture daily rounds

![](/files/-MABoON5vinAfLH38D5Q)

Tables

{% content-ref url="/pages/-M2KEc9UBN7VOrGuLm\_O" %}
[Broken mention](broken://pages/-M2KEc9UBN7VOrGuLm_O)
{% endcontent-ref %}

{% content-ref url="/pages/-M2KEt7W2NKzPnLRwP00" %}
[Medical Records](/medical-records/medical-history)
{% endcontent-ref %}


# Triage Summary Collection

Capture daily triage details from each hospital

![](/files/-MABoh-ww-6qnEGMhVoT)


# Sample Management

Generate ICMR form the user data <br>

![Sample Request Form](/files/-MABousYWngkj4cWwWOw)

![Printable  CMR Referal Form Generated from the system](/files/-MABpuQaA3QJuC158HG5)


# Patient Record

Patient Consulation details\
Daily Rounds for each consultation\
Option to tranfer a medical records from one hospital to another.

![Patient Transfer Form](/files/-MABqiSLwWS6Lmpv78PX)


# Telemedicine

Build telemedicine.coronasafe.network inside care

This will allow all facilities in the care system to operate their own telemedicine unit seamlessly.<br>

![Summary stats from telemedicine](/files/-MBVjLoX2XmXJVqynRa8)

## Requirments

1. staff profile with limited data access should be able to log calls
2. doctor linked to the facility should be able to see the pending calls and associated patent record
3. The doctor should be able to add consultation
4. The doctor should be able to schedule a reminder for follow-up.&#x20;
5. pending calls, upcoming followups and missed followups should be listed on an index page
6. The docotor should be able to add a prescription for the patient which can be shared with the patient via SMS.&#x20;
7. The pharmacy unit of the facility should be able to mark the status of each prescription given to the patient.
8. Doctor could be a tele-caller for multiple facilities.&#x20;
9. A facility admin should be able to assign calls to a doctor

## Changes required in Care

* [ ] \[Evaluate and add chnages required]

## After Merge

* [ ] Migrate data from telemed to care


# State

```
 id: AutoField
 name: CharField 
```


# District

```
 id: AutoField
 state: ForeignKey (id)
 name: CharField 
```


# LocalBody

```
 id AutoField
 district ForeignKey (id)
 body_type IntegerField
 localbody_code CharField
 name CharField 
```


# User

The platform identifies every one as a user, Basic information that we should collect from everyone

```
 id: AutoField
 district: ForeignKey (id)
 local_body: ForeignKey (id)
 skill: ForeignKey (id)
 state: ForeignKey (id)
 age: IntegerField
 date_joined: DateTimeField
 deleted: BooleanField
 email: EmailField
 first_name: CharField
 gender: IntegerField
 is_active: BooleanField
 is_staff: BooleanField
 is_superuser: BooleanField
 last_login: DateTimeField
 last_name: CharField
 password: CharField
 phone_number: CharField
 user_type: IntegerField
 username: CharField
 verified: BooleanField 
```

## Roles&#x20;

| User Type      | Privilege                                |
| -------------- | ---------------------------------------- |
| Super Admin    | Admin for the entire platform            |
| State Admin    | Admin with state level data scope        |
| District Admin | User with district level data scope      |
| Facility Admin | User with facility level data scope      |
| Doctor         | User with limited data permissions       |
| Patient        | User with acess to his/her personal data |
| Staff          | User with limited data permissions       |


# Medical History

PatientRegistration

```
 id AutoField
 created_by ForeignKey (id)
 district ForeignKey (id)
 facility ForeignKey (id)
 local_body ForeignKey (id)
 meta_info OneToOneField (id)
 nearest_facility ForeignKey (id)
 state ForeignKey (id)
 aadhar_no CharField
 address EncryptedTextField
 age PositiveIntegerField
 blood_group CharField
 contact_with_confirmed_carrier BooleanField
 contact_with_suspected_carrier BooleanField
 countries_travelled JSONField
 countries_travelled_old TextField
 created_date DateTimeField
 date_of_birth DateField
 date_of_receipt_of_information DateTimeField
 date_of_return DateTimeField
 deleted BooleanField
 disease_status IntegerField
 estimated_contact_date DateTimeField
 external_id UUIDField
 gender IntegerField
 has_SARI BooleanField
 is_active BooleanField
 is_medical_worker BooleanField
 modified_date DateTimeField
 name EncryptedCharField
 nationality CharField
 number_of_aged_dependents IntegerField
 number_of_chronic_diseased_dependents IntegerField
 ongoing_medication TextField
 passport_no CharField
 past_travel BooleanField
 patient_search_id EncryptedIntegerField
 phone_number EncryptedCharField
 present_health TextField
 source IntegerField
 year_of_birth IntegerField 
```


# Consultation History

```
 id AutoField
 facility ForeignKey (id)
 patient ForeignKey (id)
 referred_to ForeignKey (id)
 admission_date DateTimeField
 admitted BooleanField
 admitted_to IntegerField
 bed_number CharField
 category CharField
 created_date DateTimeField
 deleted BooleanField
 discharge_date DateTimeField
 examination_details TextField
 existing_medication TextField
 external_id UUIDField
 modified_date DateTimeField
 other_symptoms TextField
 prescribed_medication TextField
 suggestion CharField
 symptoms MultiSelectField
 symptoms_onset_date DateTimeField 
```


# Sample History

```
 id AutoField
 consultation ForeignKey (id)
 patient ForeignKey (id)
 atypical_presentation TextField
 created_date DateTimeField
 date_of_result DateTimeField
 date_of_sample DateTimeField
 deleted BooleanField
 diagnosis TextField
 diff_diagnosis TextField
 doctor_name CharField
 etiology_identified TextField
 external_id UUIDField
 fast_track TextField
 has_ari BooleanField
 has_sari BooleanField
 icmr_category IntegerField
 is_atypical_presentation BooleanField
 is_unusual_course BooleanField
 modified_date DateTimeField
 result IntegerField
 sample_type IntegerField
 sample_type_other TextField
 status IntegerField 
```


# Daily Rounds

```
 id AutoField
 consultation ForeignKey (id)
 additional_symptoms MultiSelectField
 current_health IntegerField
 other_details TextField
 other_symptoms TextField
 patient_category CharField
 physical_examination_info TextField
 recommend_discharge BooleanField
 temperature DecimalField
 temperature_measured_at DateTimeField 
```


# Facility

```
 id AutoField
 created_by ForeignKey (id)
 district ForeignKey (id)
 local_body ForeignKey (id)
 state ForeignKey (id)
 address TextField
 corona_testing BooleanField
 created_date DateTimeField
 deleted BooleanField
 external_id UUIDField
 facility_type IntegerField
 is_active BooleanField
 location LocationField
 modified_date DateTimeField
 name CharField
 oxygen_capacity IntegerField
 phone_number CharField
 pincode IntegerField
 verified BooleanField 
```


# Building

Details of buildings a facility has

```
 id AutoField
 facility ForeignKey (id)
 created_date DateTimeField
 deleted BooleanField
 external_id UUIDField
 modified_date DateTimeField
 name CharField
 num_buildings IntegerField
 num_floors IntegerField
 num_rooms IntegerField
```


# Room

```
 id AutoField
 building ForeignKey (id)
 beds_capacity IntegerField
 created_date DateTimeField
 deleted BooleanField
 external_id UUIDField
 floor IntegerField
 modified_date DateTimeField
 num CharField
 occupied_beds IntegerField
 room_type IntegerField 
```


# Beds

```
room_id: Room.id
icu_bed: bool
```


# InventoryItem

Common table for inventory

```
 id AutoField
 facility ForeignKey (id)
 item ForeignKey (id)
 created_date DateTimeField
 deleted BooleanField
 external_id UUIDField
 modified_date DateTimeField
 quantitiy IntegerField 
```

`minimum_stock` will vary for each inventory item. It should be captured so that, we could trigger alerts


# Facility Inventory

Join table for facilty and inventory

```
 id AutoField
 created_date DateTimeField
 deleted BooleanField
 description TextField
 external_id UUIDField
 minimum_stock IntegerField
 modified_date DateTimeField
 name CharField
 unit CharField 
```


# June 15, 2020

{% file src="/files/-M9tiiLYRbotiDzRAcl7" %}
Data Schema as on June 15 2020
{% endfile %}


# Mar 1, 2021

{% file src="/files/SPt5ZMpMKfNVC532S4dl" %}
CARE Schema
{% endfile %}


# Data Security

**For the network security of the application we have enforced the following standards.**&#x20;

1. Web Application Firewall (WAF) Configured at Domain level to prevent access to coronasafe.network from countries like US, China,  Hongkong, Pakistan , Russian Federation Etc
2. Open Web Application Security Project (OWASP)  core rule set based WAF rules implemented to provide protection against common attack categories, including Structured Query Language (SQL) Injection and Cross-Site Scripting.
3. Customised WAF rules created to prevent common attacks and Bot Access
4. Autonomous system number (ASN) based lockdown in WAF against common threat matrix.
5. Sanity Check Based Block and Rate Limiting Enabled
6. Network level Port Blocking allowing only port 80 and  443 from internet in the entire network
7. IP blacklist and lockdown based on Threat Score ( Score Greater than 8 is blocked) based on IP reputation.
8. Customised Content Security policy (CSP) Header implemented to prevent common Clickjacking and other attacks .
9. HTTP Strict Transport Security (HSTS) preloaded domain wide to enforce Hypertext Transfer Protocol Secure (HTTPS) only traffic with a Max Age of 1 year
10. Origin to domain, domain to domain, and domain to User traffic encrypted via Transport Layer Security 1.2 (tls1.2) and above
11. Content Security Policy (CSP) and Certificate Transparency CT violations monitoring done to update threat matrix
12. The Domain Name System Security Extensions (DNSSEC) enabled to prevent domain takeovers .(DNSSEC protects against forged domain name system (DNS) answers. DNSSEC protected zones are cryptographically signed to ensure the DNS records received are identical to the DNS records published by the domain owner.)
13. Speed up of page load speed by the Implementation of Brotli Compression
14. HTTP/2 and HTTP/3(Quick User Datagram Protocol Internet Connections)  enabled for faster network speeds
15. Automatic Branch based Continuous integration (CI) and continuous delivery (CD) to prevent unauthorised access.
16. New pods are created before old pods with old code is terminated.&#x20;
17. Database backups (Snapshots) are created daily at scheduled intervals and stored with Key Management Service (KMS) keys securely inside Cloud Infrastructure without external Access.
18. All server nodes and Volumes and database Instances are Encrypted with KMS based Cryptographic Keys.
19. Database Connectivity allowed only using internal Private Network and allowed for the backend host only.
20. Virtual Private Network(VPN) + Jump Host( Bastion Host) Based Server Maintenance (Cluster Management Shell ) to enhance security.

Reverse Proxying all network traffic to mask origin IP to enhance security.\
\
Apart from the above rules, additional measures could be added to enforce maximum security of data


# Privacy and Data Protection (PDP)

Details to be Added


# Cyber Security Audit

## 1. CERT Certification                  &#x20;

Care has been Security Audited & Assessed as per CERT-IN Guideline & OWASP Standard. The Site & Web Application is fit and safe for hosting under continuous monitoring and observation by Authorized Authorities. The Application/Site has fulfilled the criteria as per CERT-IN Security norms.

The full certification details can be found here:

{% embed url="<https://drive.google.com/file/d/1UQBDH_LGJ7ciCR2_QL5yE9CvpA9P3sIQ/view>" %}

## **2. Vulnerability Assessment Report by Lucideus**

{% embed url="<https://drive.google.com/file/d/1XxH4Gc2g6pyNz4xZekKGtS_SEpJDn4mQ/view>" %}

![](/files/-MAC1oBwSbTl_kQg1A-a)

## 2. **Security Assessment Report by Mozilla Observatory**

**Report:** [**Link**<br>](https://drive.google.com/file/d/1Z71P9b7lx3jAy6pWvxlnDmX7HsoijmmD/view?usp=sharing)**Password: hawk** <br>

![](/files/-MAC24XLjw5w-lFlgA-B)

## **3. SSL Security Test by ImmuniWeb**

**Report:** [**Link**](https://drive.google.com/file/d/1arfacBKTCc2vS4RAf73RjJT2PDTJg8Gz/view?usp=sharing)

![](/files/-MAC2O8acK2JVSzF4X0Y)


# Notifications

{% embed url="<https://github.com/coronasafe/care/blob/master/care/facility/models/notification.py>" %}

| Key                                    | Code | Content                    |
| -------------------------------------- | ---- | -------------------------- |
| PATIENT\_CREATED                       | 20   | Patient Created            |
| PATIENT\_UPDATED                       | 30   | Patient Updated            |
| PATIENT\_DELETED                       | 40   | Patient Deleted            |
| PATIENT\_CONSULTATION\_CREATED         | 50   | Consultation Created       |
| PATIENT\_CONSULTATION\_UPDATED         | 60   | Consultation Updated       |
| PATIENT\_CONSULTATION\_DELETED         | 70   | Consultation Deleted       |
| INVESTIGATION\_SESSION\_CREATED        | 80   | Investigation Created      |
| INVESTIGATION\_UPDATED                 | 90   | Investigation Updated      |
| PATIENT\_FILE\_UPLOAD\_CREATED         | 100  | Patient File Uploaded      |
| CONSULTATION\_FILE\_UPLOAD\_CREATED    | 110  | Consultation File Uploaded |
| PATIENT\_CONSULTATION\_UPDATE\_CREATED | 120  | Daily Round Created        |
| PATIENT\_CONSULTATION\_UPDATE\_UPDATED | 130  | Daily Round Updated        |
| PATIENT\_CONSULTATION\_ASSIGNMENT      | 140  | Patient Doctor Assigned    |
| SHIFTING\_UPDATED                      | 200  | Shifting Request Updated   |


