NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

pragma solidity ^0.4.6;
contract insurance{

address admin;
uint public hospitalCount;
uint public patientCount;
mapping(address => uint[3][5]) private offers;
mapping(address => uint) private hospitals;
address[] hospitalAddresses;
address[] patientAddresses;
mapping(address => uint[]) private usages;
mapping(address => uint) private reimbursements;
mapping(address => uint) private enddates;
uint[5] public examinationCounts;
uint[5] lastYearsExaminationCounts;
uint startPeriod;
uint endPeriod;
uint periodNumber;
address selectedHospital;
address lastYearsSelectedHospital;
uint[3][5] lastYearsSelectedOffer;
uint[3][5] selectedOffer;
uint[4] packetPrices;


function insurance() public{
admin = msg.sender;
hospitalCount = 0;
patientCount = 0;

}

function getAdmin() constant public returns(address){
return admin;
}

function getUsages() constant public returns(uint[]){
return usages[msg.sender];
}

function getSelectedHospital() constant public returns(address){
return selectedHospital;
}

function getPatients() constant public returns(address[]){
return patientAddresses;
}

function addHospital(address hospitalAddress) public{
if(msg.sender != admin){
throw;
}
hospitalCount=hospitalCount + 1;
hospitals[hospitalAddress] = hospitalCount;
hospitalAddresses.push(hospitalAddress);
}

function calculatePrice(){
packetPrices[0] = 130*selectedOffer[0][2]/100 + 130*selectedOffer[1][2]/100;
packetPrices[1] = (packetPrices[0] + 130*selectedOffer[2][2]/100)*90/100;
packetPrices[2] = (packetPrices[1] + 130*selectedOffer[3][2]/100)*90/100;
packetPrices[3] = (packetPrices[2] + 130*selectedOffer[4][2]/100)*90/100;
}

function viewPackets() constant public returns(uint[3][5], uint[4]){
return (selectedOffer, packetPrices);
}

function selectPacket(uint packetType, bytes32 name, bytes32 surname) public payable returns(uint patientNum){
uint price = packetPrices[packetType-1];
patientCount = patientCount + 1;
for(uint i=0; i<packetType+1; i++){
usages[msg.sender].push(selectedOffer[i][1]);
}
reimbursements[msg.sender] = msg.value-price;
enddates[msg.sender] = block.timestamp + 365 days;
return patientCount-1;
}

function giveOffer(uint[3][5] offer) public{
if(hospitals[msg.sender]>0){
offers[msg.sender] = offer;
}
}

function reimburseme() public{
uint amnt = reimbursements[msg.sender];
if(amnt>0){
reimbursements[msg.sender]=0;
if(!msg.sender.send(amnt)){
reimbursements[msg.sender]=amnt;
}
}
}

function getExamined(uint serviceType, address patientAddress) public{
if(msg.sender != selectedHospital){
throw;
}
if(block.timestamp>enddates[patientAddress]){
throw;
}
if(usages[patientAddress][serviceType-1] == 0){
throw;
}
usages[patientAddress][serviceType-1] = usages[patientAddress][serviceType-1] - 1;
examinationCounts[serviceType] += 1;
}

function getHospitalNumber() constant public returns(uint){
if(msg.sender != admin){
throw;
}
return hospitalCount;
}

function getHospitals() constant public returns(address[]){
if(msg.sender != admin){
throw;
}
return hospitalAddresses;
}

function getOffer(address hospitalAddress) constant public returns(uint[3][5]){
if(msg.sender != admin){
throw;
}
return offers[hospitalAddress];
}

function decideHospital(address hospitalAddress) public{
if(msg.sender != admin){
throw;
}
if(endPeriod > 0 && endPeriod < block.timestamp){
throw;
}
if(lastYearsSelectedHospital != address(0)){
reimbursements[lastYearsSelectedHospital] = getHospitalAmount();
}
if(selectedHospital != address(0)){
lastYearsSelectedHospital = selectedHospital;
lastYearsSelectedOffer = selectedOffer;
lastYearsExaminationCounts = examinationCounts;
}
selectedHospital = hospitalAddress;
selectedOffer = offers[hospitalAddress];
calculatePrice();
examinationCounts = [0,0,0,0,0];
startPeriod = block.timestamp;
endPeriod = startPeriod + 365 days;
periodNumber++;
}

function getHospitalAmount() returns(uint){
uint amnt = 0;
for(uint i=0; i<5; i++){
amnt += lastYearsExaminationCounts[i] * lastYearsSelectedOffer[i][2];
}
return amnt;
}

}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.